Sha256: 31841655299ab2564fe00ceab7ac9d45aef9b004e8a7454b10e55ff5035c3957
Contents?: true
Size: 620 Bytes
Versions: 1
Compression:
Stored size: 620 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
geo_redirect-0.3 | lib/tasks/geo_redirect.rake |