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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: de3d917a3dc6c98952db3093c0b757f0118e214f
4
- data.tar.gz: 825e4a603556972cb5455530b8961bdf55a3d9fe
3
+ metadata.gz: 640d5200605128fcd33cb0e4c5ce00239f2c89e0
4
+ data.tar.gz: cb17775a082a4e53a6035821fe66a506b1d19720
5
5
  SHA512:
6
- metadata.gz: aa879149d7c2a6ed871bcf35a460b02267147a00a64f1c9c3facc5f8b1876aedeccb5cb1ab186e20c220906a051678736c1a5c429048b49fe907c4dfb07f8666
7
- data.tar.gz: 3a7b04887875dad51eda9a3f1e670df59de0fe6d55a1bb823011214a4e098e7225c84726068e785dbb208e3defcff911418463de0f93cc3901844f3be5e331f2
6
+ metadata.gz: 3c1c713de0019cf7aaa1cb9c5421e0ae014ee3b7b2a411f87da91122288fd4ef765377463dd564c363df0b1e13a3b79777f1861d63416f2505afa1f7622905d4
7
+ data.tar.gz: 5211dd0f86395311a9ff137e0315ac95a5c169272551013215e2d5dcf9b1a3f308bb55937170ae92876c3d479071d2dcd0fb3c67ba71ccbae9f258e1e658f3a2
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ### 0.1.17 (June 9, 2018)
4
+
5
+ - Allow the database file reader to be overridden.
6
+ - increase coverage for IPv6 and EU tests
7
+
3
8
  ### 0.1.16 (May 22, 2018)
4
9
 
5
10
  - Adds is_in_european_union feature
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
- def self.new(path)
8
- Client.new(path)
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 = File.binread(path)
23
+ @data = file_reader.call(path)
22
24
 
23
25
  pos = @data.rindex(METADATA_BEGIN_MARKER)
24
26
  raise 'invalid file format' unless pos
@@ -1,3 +1,3 @@
1
1
  module MaxMindDB
2
- VERSION = "0.1.16"
2
+ VERSION = "0.1.17"
3
3
  end
@@ -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 false for the is_in_european_union' do
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.16
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-05-23 00:00:00.000000000 Z
11
+ date: 2018-06-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler