maxminddb 0.1.16 → 0.1.17
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +4 -0
- data/lib/maxminddb.rb +6 -4
- data/lib/maxminddb/version.rb +1 -1
- data/spec/maxminddb_spec.rb +32 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 640d5200605128fcd33cb0e4c5ce00239f2c89e0
|
4
|
+
data.tar.gz: cb17775a082a4e53a6035821fe66a506b1d19720
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c1c713de0019cf7aaa1cb9c5421e0ae014ee3b7b2a411f87da91122288fd4ef765377463dd564c363df0b1e13a3b79777f1861d63416f2505afa1f7622905d4
|
7
|
+
data.tar.gz: 5211dd0f86395311a9ff137e0315ac95a5c169272551013215e2d5dcf9b1a3f308bb55937170ae92876c3d479071d2dcd0fb3c67ba71ccbae9f258e1e658f3a2
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -66,6 +66,10 @@ db.metadata # => {"binary_format_major_version"=>2, "binary_format_minor_version
|
|
66
66
|
|
67
67
|
A MaxMindDB instance doesn't do any write operation after it is created. So we can consider it as an immutable object which is 'thread-safe'.
|
68
68
|
|
69
|
+
### JSON web server on Docker
|
70
|
+
|
71
|
+
maxminddb-docker: https://github.com/samnissen/maxminddb-docker
|
72
|
+
|
69
73
|
## Contributing
|
70
74
|
|
71
75
|
1. Fork it ( http://github.com/yhirose/maxminddb/fork )
|
data/lib/maxminddb.rb
CHANGED
@@ -4,8 +4,10 @@ require 'ipaddr'
|
|
4
4
|
|
5
5
|
module MaxMindDB
|
6
6
|
|
7
|
-
|
8
|
-
|
7
|
+
DEFAULT_FILE_READER = proc { |path| File.binread(path) }
|
8
|
+
|
9
|
+
def self.new(path, file_reader=DEFAULT_FILE_READER)
|
10
|
+
Client.new(path, file_reader)
|
9
11
|
end
|
10
12
|
|
11
13
|
class Client
|
@@ -16,9 +18,9 @@ module MaxMindDB
|
|
16
18
|
|
17
19
|
attr_reader :metadata
|
18
20
|
|
19
|
-
def initialize(path)
|
21
|
+
def initialize(path, file_reader)
|
20
22
|
@path = path
|
21
|
-
@data =
|
23
|
+
@data = file_reader.call(path)
|
22
24
|
|
23
25
|
pos = @data.rindex(METADATA_BEGIN_MARKER)
|
24
26
|
raise 'invalid file format' unless pos
|
data/lib/maxminddb/version.rb
CHANGED
data/spec/maxminddb_spec.rb
CHANGED
@@ -64,7 +64,7 @@ describe MaxMindDB do
|
|
64
64
|
expect(city_db.lookup(ip)).to be_found
|
65
65
|
end
|
66
66
|
|
67
|
-
it 'returns
|
67
|
+
it 'returns true for the is_in_european_union' do
|
68
68
|
expect(country_db.lookup(ip).country.is_in_european_union).to eq(true)
|
69
69
|
end
|
70
70
|
|
@@ -81,6 +81,37 @@ describe MaxMindDB do
|
|
81
81
|
end
|
82
82
|
end
|
83
83
|
|
84
|
+
context 'for a Canadian ipv6' do
|
85
|
+
let(:ip) { '2607:5300:60:72ba::' }
|
86
|
+
it 'finds data' do
|
87
|
+
expect(city_db.lookup(ip)).to be_found
|
88
|
+
end
|
89
|
+
|
90
|
+
it 'returns true for the is_in_european_union' do
|
91
|
+
expect(country_db.lookup(ip).country.is_in_european_union).to be_falsey
|
92
|
+
end
|
93
|
+
|
94
|
+
it 'returns CA as the country iso code' do
|
95
|
+
expect(country_db.lookup(ip).country.iso_code).to eq('CA')
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
context 'for a German IPv6' do
|
100
|
+
let(:ip) { '2a01:488:66:1000:2ea3:495e::1' }
|
101
|
+
|
102
|
+
it 'finds data' do
|
103
|
+
expect(city_db.lookup(ip)).to be_found
|
104
|
+
end
|
105
|
+
|
106
|
+
it 'returns false for the is_in_european_union' do
|
107
|
+
expect(country_db.lookup(ip).country.is_in_european_union).to eq(true)
|
108
|
+
end
|
109
|
+
|
110
|
+
it 'returns DE as the country iso code' do
|
111
|
+
expect(country_db.lookup(ip).country.iso_code).to eq('DE')
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
84
115
|
context 'for the ip 127.0.0.1' do
|
85
116
|
let(:ip) { '127.0.0.1' }
|
86
117
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: maxminddb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.17
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- yhirose
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-06-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|