maxminddb 0.1.10 → 0.1.11

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: 8637e3f4ecc8e4f58d5c8af760d7e2a2ead66a03
4
- data.tar.gz: ef77114d3b291de887419089610ae7dcba866661
3
+ metadata.gz: 060a8073660803af80c0e767c46b8e0206ec20b9
4
+ data.tar.gz: 6360690707519d82e97f0b6b79d81ca189d05b51
5
5
  SHA512:
6
- metadata.gz: b05b703f559465f178bcfa6d5ad37a6a5a2a166cfbfcebb79380e95d52f974a9793fa4957a3c238780823816b15d45ab46b548de6c97904df9b9f220ba0a771f
7
- data.tar.gz: 505663ceb677df3deb1702f8984ac01c35b17a25c6f42eda0dcdde4eb3c4254f14ba1a1ec8d61681bba0cf7328bbad58ef86712879044d8106ec671e70bbb24f
6
+ metadata.gz: 51a624b1d899191fbc61bfb76bb75e5d26fb421320bf37a12396661ae85208b33c16be00090228eb7a6d96daf7a5baf59bf81ce2ca4fd3d294d2422a6fc4ff9a
7
+ data.tar.gz: 3de3d8614f824ea706a459163fce9019b90d10fbdf825a5a39178c6c91ea2b54034a3e96beaebdfa20b3ccbd81ab392363235d7f823e8f238bf9dccc0eceac9e
@@ -23,6 +23,7 @@ module MaxMindDB
23
23
  pos += METADATA_BEGIN_MARKER.size
24
24
  metadata = decode(pos, 0)[1]
25
25
 
26
+ @ip_version = metadata['ip_version']
26
27
  @node_count = metadata['node_count']
27
28
  @node_byte_size = metadata['record_size'] * 2 / 8
28
29
  @search_tree_size = @node_count * @node_byte_size
@@ -35,7 +36,8 @@ module MaxMindDB
35
36
  def lookup(ip)
36
37
  node_no = 0
37
38
  addr = addr_from_ip(ip)
38
- for i in 0 ... 128
39
+ start_idx = @ip_version == 4 ? 96 : 0
40
+ for i in start_idx ... 128
39
41
  flag = (addr >> (127 - i)) & 1
40
42
  next_node_no = read_record(node_no, flag)
41
43
  if next_node_no == 0
@@ -1,3 +1,3 @@
1
1
  module MaxMindDB
2
- VERSION = "0.1.10"
2
+ VERSION = "0.1.11"
3
3
  end
@@ -3,6 +3,7 @@ require 'maxminddb'
3
3
  describe MaxMindDB do
4
4
  let(:city_db) { MaxMindDB.new('spec/cache/GeoLite2-City.mmdb') }
5
5
  let(:country_db) { MaxMindDB.new('spec/cache/GeoLite2-Country.mmdb') }
6
+ let(:rec32_db) { MaxMindDB.new('spec/data/32bit_record_data.mmdb') }
6
7
 
7
8
  context 'for the ip 74.125.225.224' do
8
9
  let(:ip) { '74.125.225.224' }
@@ -84,6 +85,14 @@ describe MaxMindDB do
84
85
  end
85
86
  end
86
87
 
88
+ context 'for 32bit record data' do
89
+ let(:ip) { '1.0.16.1' }
90
+
91
+ it 'finds data' do
92
+ expect(rec32_db.lookup(ip)).to be_found
93
+ end
94
+ end
95
+
87
96
  context 'test ips' do
88
97
  [
89
98
  ['185.23.124.1', 'SA'],
metadata CHANGED
@@ -1,69 +1,69 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: maxminddb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.10
4
+ version: 0.1.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - yhirose
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-25 00:00:00.000000000 Z
11
+ date: 2016-03-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.5'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.5'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rspec-its
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  description: Pure Ruby MaxMind DB (GeoIP2) binary file reader.
@@ -73,9 +73,9 @@ executables: []
73
73
  extensions: []
74
74
  extra_rdoc_files: []
75
75
  files:
76
- - .gitignore
77
- - .rspec
78
- - .travis.yml
76
+ - ".gitignore"
77
+ - ".rspec"
78
+ - ".travis.yml"
79
79
  - Gemfile
80
80
  - LICENSE.txt
81
81
  - README.md
@@ -89,6 +89,7 @@ files:
89
89
  - lib/maxminddb/version.rb
90
90
  - maxminddb.gemspec
91
91
  - spec/cache/.gitkeep
92
+ - spec/data/32bit_record_data.mmdb
92
93
  - spec/maxminddb/result/location_spec.rb
93
94
  - spec/maxminddb/result/named_location_spec.rb
94
95
  - spec/maxminddb/result/postal_spec.rb
@@ -105,22 +106,23 @@ require_paths:
105
106
  - lib
106
107
  required_ruby_version: !ruby/object:Gem::Requirement
107
108
  requirements:
108
- - - '>='
109
+ - - ">="
109
110
  - !ruby/object:Gem::Version
110
111
  version: '0'
111
112
  required_rubygems_version: !ruby/object:Gem::Requirement
112
113
  requirements:
113
- - - '>='
114
+ - - ">="
114
115
  - !ruby/object:Gem::Version
115
116
  version: '0'
116
117
  requirements: []
117
118
  rubyforge_project:
118
- rubygems_version: 2.0.14
119
+ rubygems_version: 2.5.1
119
120
  signing_key:
120
121
  specification_version: 4
121
122
  summary: MaxMind DB binary file reader.
122
123
  test_files:
123
124
  - spec/cache/.gitkeep
125
+ - spec/data/32bit_record_data.mmdb
124
126
  - spec/maxminddb/result/location_spec.rb
125
127
  - spec/maxminddb/result/named_location_spec.rb
126
128
  - spec/maxminddb/result/postal_spec.rb