Skip to content

Commit

Permalink
Updated due to GeoLite2 downlaod policy change
Browse files Browse the repository at this point in the history
  • Loading branch information
yhirose committed Jan 12, 2020
1 parent 8643e0d commit 8f06524
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 22 deletions.
23 changes: 9 additions & 14 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
language: ruby
rvm:
- 1.9.3
- 2.0
- 2.1
- 2.2
- 2.3
- 2.4.5
- 2.5.3
- 2.6.0
- jruby-19mode

- 2.4
- 2.5
- 2.6
- 2.7
script: bundle exec rake

before_install:
- gem update bundler

- gem update bundler
cache:
directories:
- spec/cache
- spec/cache
env:
global:
secure: VCgYOWeLKAAiXnLw3vWLs8PRbSg4pPLeLZPbBCIRUQKqttzL6pEL28lkB/05YVbu1v9wQxogtk0zv+ZacJK0SbIL96BHVrCaRebWik5A8UOoOGTanTQj0SRCCmacrOm3EhWF9t262uv31byAdw73S08jCPIYd2JqA5IOrcJYJ0Y=
22 changes: 18 additions & 4 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,27 @@ RSpec::Core::RakeTask.new(:spec)
desc "Downloads maxmind free DBs if required"
task :ensure_maxmind_files do
unless File.exist?('spec/cache/GeoLite2-City.mmdb')
sh 'curl http://geolite.maxmind.com/download/geoip/database/GeoLite2-City.mmdb.gz -o spec/cache/GeoLite2-City.mmdb.gz'
sh 'gunzip spec/cache/GeoLite2-City.mmdb.gz'
sh "curl 'https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-City&suffix=tar.gz&license_key=#{ENV['API_KEY']}' -o spec/cache/GeoLite2-City.mmdb.tar.gz"
sh 'tar zxvf spec/cache/GeoLite2-City.mmdb.tar.gz *.mmdb'
src = %x{tar ztf spec/cache/GeoLite2-City.mmdb.tar.gz *.mmdb}.strip
dir = %x{dirname `tar ztf spec/cache/GeoLite2-City.mmdb.tar.gz *.mmdb`}
fname = %x{basename `tar ztf spec/cache/GeoLite2-City.mmdb.tar.gz *.mmdb`}
dst = ('spec/cache/' + fname).strip
sh "mv #{src} #{dst}"
sh "rmdir #{dir}"
sh 'rm spec/cache/GeoLite2-City.mmdb.tar.gz'
end

unless File.exist?('spec/cache/GeoLite2-Country.mmdb')
sh 'curl http://geolite.maxmind.com/download/geoip/database/GeoLite2-Country.mmdb.gz -o spec/cache/GeoLite2-Country.mmdb.gz'
sh 'gunzip spec/cache/GeoLite2-Country.mmdb.gz'
sh "curl 'https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-Country&suffix=tar.gz&license_key=#{ENV['API_KEY']}' -o spec/cache/GeoLite2-Country.mmdb.tar.gz"
sh 'tar zxvf spec/cache/GeoLite2-Country.mmdb.tar.gz *.mmdb'
src = %x{tar ztf spec/cache/GeoLite2-Country.mmdb.tar.gz *.mmdb}.strip
dir = %x{dirname `tar ztf spec/cache/GeoLite2-Country.mmdb.tar.gz *.mmdb`}
fname = %x{basename `tar ztf spec/cache/GeoLite2-Country.mmdb.tar.gz *.mmdb`}
dst = ('spec/cache/' + fname).strip
sh "mv #{src} #{dst}"
sh "rmdir #{dir}"
sh 'rm spec/cache/GeoLite2-Country.mmdb.tar.gz'
end
end

Expand Down
8 changes: 4 additions & 4 deletions spec/maxminddb_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
expect(city_db.lookup(ip).city.name).to eq('Mountain View')
end

it 'returns -122.0775 as the longitude' do
expect(city_db.lookup(ip).location.longitude).to eq(-122.0775)
it 'returns -122.0748 as the longitude' do
expect(city_db.lookup(ip).location.longitude).to eq(-122.0748)
end

it 'returns nil for is_anonymous_proxy' do
Expand Down Expand Up @@ -160,8 +160,8 @@
expect(city_db.lookup(ip).city.name).to eq('Mountain View')
end

it 'returns -122.0775 as the longitude' do
expect(city_db.lookup(ip).location.longitude).to eq(-122.0775)
it 'returns -122.0748 as the longitude' do
expect(city_db.lookup(ip).location.longitude).to eq(-122.0748)
end

it 'returns nil for is_anonymous_proxy' do
Expand Down

0 comments on commit 8f06524

Please sign in to comment.