maxminddb-geolite2-city 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/CHANGELOG.md +7 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +48 -0
- data/Rakefile +119 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/maxminddb/geolite2/city.rb +11 -0
- data/lib/maxminddb/geolite2/city/version.rb +7 -0
- data/lib/maxminddb/geolite2/db/GeoLite2-City.mmdb +0 -0
- data/maxminddb-geolite2-city.gemspec +29 -0
- metadata +127 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ac634ad881ccdb30f91b6478998bf3c4a8201152
|
4
|
+
data.tar.gz: 0420e6d9623e201f1844b690b47f842d5098cf91
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 433f9db5a292a0cbba9b5b7d999e3c73c4eadc6332c2898550001297f316dd023518a8a8fbc1de1f00acbbd4ccbc2a8b092a0e1c27f7629eac292539c7d64b22
|
7
|
+
data.tar.gz: 974dda709fd965c66939d5418cf0894a86afacc05ade700db35de06b24947751841325a841725ad0b98691cce34403e7c0294e586cc193c953210ab557d094c5
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Eurico Doirado
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
# Maxminddb::Geolite2::City
|
2
|
+
|
3
|
+
This gem bundles the GeoLite2-City.mmdb database along with the [MaxMinDB gem](https://github.com/yhirose/maxminddb).
|
4
|
+
This way you don't need to manage the DB version yourself.
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
gem 'maxminddb-geolite2-city'
|
12
|
+
```
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
|
16
|
+
$ bundle
|
17
|
+
|
18
|
+
Or install it yourself as:
|
19
|
+
|
20
|
+
$ gem install maxminddb-geolite2-city
|
21
|
+
|
22
|
+
## Usage
|
23
|
+
|
24
|
+
```ruby
|
25
|
+
require 'maxminddb/geolite2/city'
|
26
|
+
|
27
|
+
MaxMindDB.default_city_db.lookup('8.8.8.8').city.name
|
28
|
+
# => "Mountain View"
|
29
|
+
```
|
30
|
+
|
31
|
+
## Development
|
32
|
+
|
33
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
34
|
+
|
35
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
36
|
+
|
37
|
+
Update to the latest DB:
|
38
|
+
|
39
|
+
$ rake update_db
|
40
|
+
|
41
|
+
## Contributing
|
42
|
+
|
43
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/Phybbit/maxminddb-geolite2-city.git.
|
44
|
+
|
45
|
+
## License
|
46
|
+
|
47
|
+
This product includes GeoLite2 data created by MaxMind, available from
|
48
|
+
<a href="http://www.maxmind.com">http://www.maxmind.com</a>.
|
data/Rakefile
ADDED
@@ -0,0 +1,119 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'rspec/core/rake_task'
|
3
|
+
require 'digest/md5'
|
4
|
+
require 'highline'
|
5
|
+
|
6
|
+
RSpec::Core::RakeTask.new(:spec)
|
7
|
+
|
8
|
+
task :default => :spec
|
9
|
+
|
10
|
+
|
11
|
+
task :update_db do
|
12
|
+
cli = HighLine.new
|
13
|
+
if is_same_db?
|
14
|
+
cli.say "The current DB is already up-to-date."
|
15
|
+
next
|
16
|
+
end
|
17
|
+
|
18
|
+
db_filepath = download_db
|
19
|
+
unless db_checksum_valid?(db_filepath)
|
20
|
+
cli.say "ERROR: md5 checksum failed. Please try again"
|
21
|
+
return
|
22
|
+
end
|
23
|
+
|
24
|
+
move_db_to_lib
|
25
|
+
run_tests!
|
26
|
+
|
27
|
+
new_version = bump_version
|
28
|
+
update_changelog(new_version)
|
29
|
+
|
30
|
+
can_commit_and_push = cli.agree "Do you want to commit and push (y/n)?"
|
31
|
+
next unless can_commit_and_push
|
32
|
+
|
33
|
+
commit_and_push(new_version)
|
34
|
+
|
35
|
+
can_release_to_rubygems = cli.agree "Do you want to release the gem (rubygems.org) (y/n)?"
|
36
|
+
next unless can_release_to_rubygems
|
37
|
+
|
38
|
+
release_to_rubygems
|
39
|
+
end
|
40
|
+
|
41
|
+
def is_same_db?
|
42
|
+
checksum = `md5sum -b ./lib/maxminddb/geolite2/db/GeoLite2-City.mmdb`.split(' ')[0]
|
43
|
+
fetch_db_md5_checksum == checksum
|
44
|
+
end
|
45
|
+
|
46
|
+
def fetch_db_md5_checksum
|
47
|
+
@db_md5_checksum ||= `curl http://geolite.maxmind.com/download/geoip/database/GeoLite2-City.md5`
|
48
|
+
end
|
49
|
+
|
50
|
+
def download_db
|
51
|
+
`wget http://geolite.maxmind.com/download/geoip/database/GeoLite2-City.mmdb.gz -O GeoLite2-City.mmdb.gz`
|
52
|
+
`gunzip -f GeoLite2-City.mmdb.gz`
|
53
|
+
|
54
|
+
'./GeoLite2-City.mmdb'
|
55
|
+
end
|
56
|
+
|
57
|
+
def db_checksum_valid?(db_path)
|
58
|
+
checksum = `md5sum -b #{db_path}`.split(' ')[0]
|
59
|
+
fetch_db_md5_checksum == checksum
|
60
|
+
end
|
61
|
+
|
62
|
+
def move_db_to_lib
|
63
|
+
`mv GeoLite2-City.mmdb ./lib/maxminddb/geolite2/db/`
|
64
|
+
end
|
65
|
+
|
66
|
+
def run_tests!
|
67
|
+
# this will trigger a SystemExit error if the tests fail
|
68
|
+
Rake::Task['spec'].invoke
|
69
|
+
end
|
70
|
+
|
71
|
+
def bump_version
|
72
|
+
current_version = MaxMindDB::Geolite2::City::VERSION
|
73
|
+
minor_version = current_version.split('.')[1].to_i
|
74
|
+
generate_new_version(minor_version + 1)
|
75
|
+
end
|
76
|
+
|
77
|
+
def generate_new_version(minor_version)
|
78
|
+
new_version = "1.#{minor_version}.0"
|
79
|
+
|
80
|
+
content = <<VERSION_CONTENT
|
81
|
+
module MaxMindDB
|
82
|
+
module Geolite2
|
83
|
+
module City
|
84
|
+
VERSION = "#{new_version}"
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
VERSION_CONTENT
|
89
|
+
|
90
|
+
File.write('./lib/maxminddb/geolite2/city/version.rb', content)
|
91
|
+
new_version
|
92
|
+
end
|
93
|
+
|
94
|
+
def update_changelog(new_version)
|
95
|
+
update_content = <<NEW_UPDATE
|
96
|
+
Release #{new_version}
|
97
|
+
- Bundled the #{Date.today.strftime("%B %Y")} geolite2-city db
|
98
|
+
|
99
|
+
NEW_UPDATE
|
100
|
+
|
101
|
+
changelog_content = File.read('CHANGELOG.md')
|
102
|
+
# Split on updates
|
103
|
+
updates = changelog_content.split('####')
|
104
|
+
# the first element is the changelog's title/basic info,
|
105
|
+
# so insert after that
|
106
|
+
updates.insert(1, update_content)
|
107
|
+
|
108
|
+
File.write('CHANGELOG.md', updates.join('####'))
|
109
|
+
end
|
110
|
+
|
111
|
+
def commit_and_push(version)
|
112
|
+
date_str = Date.today.strftime("%B %Y")
|
113
|
+
`git commit -a -m 'Update DB to #{date_str}. Bumped to #{version}.'`
|
114
|
+
`git push`
|
115
|
+
end
|
116
|
+
|
117
|
+
def release_to_rubygems
|
118
|
+
Rake::Task['release'].invoke
|
119
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "maxminddb/geolite2/city"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'maxminddb/geolite2/city/version'
|
2
|
+
require 'maxminddb'
|
3
|
+
|
4
|
+
module MaxMindDB
|
5
|
+
def MaxMindDB.default_city_db
|
6
|
+
return @default_city_db if @default_city_db
|
7
|
+
|
8
|
+
default_db_path = File.join(File.dirname(__FILE__), 'db', 'GeoLite2-City.mmdb')
|
9
|
+
@default_city_db = MaxMindDB.new(default_db_path)
|
10
|
+
end
|
11
|
+
end
|
Binary file
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'maxminddb/geolite2/city/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "maxminddb-geolite2-city"
|
8
|
+
spec.version = MaxMindDB::Geolite2::City::VERSION
|
9
|
+
spec.authors = ["okoriko"]
|
10
|
+
spec.email = ["eurico@phybbit.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Bundles the GeoLite2-City.mmdb database}
|
13
|
+
spec.description = %q{Bundles the GeoLite2-City.mmdb database}
|
14
|
+
spec.homepage = "https://github.com/Phybbit/maxminddb-geolite2-city"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
17
|
+
f.match(%r{^(test|spec|features)/})
|
18
|
+
end
|
19
|
+
spec.bindir = "exe"
|
20
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
|
+
spec.require_paths = ["lib"]
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.13"
|
24
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
25
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
26
|
+
spec.add_development_dependency "highline", "~> 1.7"
|
27
|
+
|
28
|
+
spec.add_dependency "maxminddb", ">= 0.1.11"
|
29
|
+
end
|
metadata
ADDED
@@ -0,0 +1,127 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: maxminddb-geolite2-city
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- okoriko
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-11-24 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.13'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.13'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: highline
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.7'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.7'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: maxminddb
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.1.11
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.1.11
|
83
|
+
description: Bundles the GeoLite2-City.mmdb database
|
84
|
+
email:
|
85
|
+
- eurico@phybbit.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- ".gitignore"
|
91
|
+
- ".rspec"
|
92
|
+
- ".travis.yml"
|
93
|
+
- CHANGELOG.md
|
94
|
+
- Gemfile
|
95
|
+
- LICENSE.txt
|
96
|
+
- README.md
|
97
|
+
- Rakefile
|
98
|
+
- bin/console
|
99
|
+
- bin/setup
|
100
|
+
- lib/maxminddb/geolite2/city.rb
|
101
|
+
- lib/maxminddb/geolite2/city/version.rb
|
102
|
+
- lib/maxminddb/geolite2/db/GeoLite2-City.mmdb
|
103
|
+
- maxminddb-geolite2-city.gemspec
|
104
|
+
homepage: https://github.com/Phybbit/maxminddb-geolite2-city
|
105
|
+
licenses: []
|
106
|
+
metadata: {}
|
107
|
+
post_install_message:
|
108
|
+
rdoc_options: []
|
109
|
+
require_paths:
|
110
|
+
- lib
|
111
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
112
|
+
requirements:
|
113
|
+
- - ">="
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: '0'
|
116
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
117
|
+
requirements:
|
118
|
+
- - ">="
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '0'
|
121
|
+
requirements: []
|
122
|
+
rubyforge_project:
|
123
|
+
rubygems_version: 2.5.2
|
124
|
+
signing_key:
|
125
|
+
specification_version: 4
|
126
|
+
summary: Bundles the GeoLite2-City.mmdb database
|
127
|
+
test_files: []
|