Sha256: 80feb2ec0ceff67cc00c4fb561718d7d33383d60172fd98c65c0ac17c4c7537b
Contents?: true
Size: 625 Bytes
Versions: 2
Compression:
Stored size: 625 Bytes
Contents
require 'geo_redirect' require 'open-uri' require 'zlib' namespace :geo_redirect do DB_URI = 'http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz'.freeze desc 'Fetches an updated copy of the GeoIP countries DB from MaxMind' task :fetch_db, :db_path do |_t, args| args.with_defaults(db_path: GeoRedirect::DEFAULT_DB_PATH) # Fetches DB copy and gunzips it # Thx http://stackoverflow.com/a/2014317/107085 source = open(DB_URI) gz = Zlib::GzipReader.new(source) result = gz.read # Write to file File.open(args[:db_path], 'w') { |f| f.write(result) } end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
geo_redirect-0.8 | lib/tasks/geo_redirect.rake |
geo_redirect-0.7 | lib/tasks/geo_redirect.rake |