Sha256: cee116528e1fb16d1d03f072d9e79cd752b93545c3c2dd63feecdf2cc5096682
Contents?: true
Size: 618 Bytes
Versions: 4
Compression:
Stored size: 618 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' 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
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
geo_redirect-0.6 | lib/tasks/geo_redirect.rake |
geo_redirect-0.5.1 | lib/tasks/geo_redirect.rake |
geo_redirect-0.5 | lib/tasks/geo_redirect.rake |
geo_redirect-0.4 | lib/tasks/geo_redirect.rake |