File: voight_kampff.rake

package info (click to toggle)
ruby-voight-kampff 1.1.3-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 340 kB
  • sloc: ruby: 240; makefile: 4
file content (18 lines) | stat: -rw-r--r-- 594 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
namespace :voight_kampff do
  desc 'Import a new crawler-user-agents.json file'
  task :import_user_agents, :url do |t, args|
    args.with_defaults url: 'https://raw.githubusercontent.com/monperrus/crawler-user-agents/master/crawler-user-agents.json'

    require 'net/http'

    uri = URI(args[:url])
    contents = Net::HTTP.get(uri)

    if contents.present?
      file = File.open('./config/crawler-user-agents.json', 'w')
      file.write(contents.force_encoding(Encoding::UTF_8))
    else
      puts "voight_kampff:import_user_agents - empty file received from #{uri}"
    end
  end
end