maxmind-db 1.0.0.beta → 1.0.0

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
  SHA256:
3
- metadata.gz: '0783d0fa6b13e4fa43dd70dd24c876452e1d5911a8de8296669bd4f806e38ec9'
4
- data.tar.gz: 22720864310267dc946e90f1b6b7fb12ee506e2959414b7214539479401a24a6
3
+ metadata.gz: 604697b9d2de00a32fec3ee2b84c53703f532ecf708ca6cfcd4898fa934d830e
4
+ data.tar.gz: cdaeb5d99ca07f8c9f6af0354dc23fb3f8678a40e0ea67fe74b7b7dcaabc7ec5
5
5
  SHA512:
6
- metadata.gz: 2705b919ec933748987b7495ce750361eb62643e8f5cf8ef142215af61c4f6f6b539cdec47976b58346cad0748241d362aee16f054a14a9986cdcee8c7c534ff
7
- data.tar.gz: a7f994be60c64df42176ef98131433812a739eef6533fafde8a867eeb8e097b18127e276cb49eaf42d5d93f84ef807958b4f4cf84d5c6276b49fc56b0decd298
6
+ metadata.gz: 3939f3025d4a715537d6284ac49cfa691bf733711afd6143ec73e586aec96cbcf717115c340214903fd4a8bcc1c4b8c4973d0fa9517491b2c48c5d710cdc9e87
7
+ data.tar.gz: 54dbe0bebe152e151234b0b0026492d38a80858174c3342d12ff665026d858295b29434d3ea7c8ea56b3b7c669b0d2f921c018b7dba9c16aad996143f9c66ede
@@ -1,4 +1,9 @@
1
1
  # Changelog
2
2
 
3
- ## 0.0.1.pre - 2018-12-24
3
+ ## 1.0.0 - 2019-01-04
4
+ * We no longer include the database's buffer in inspect output. This avoids
5
+ showing excessive output when creating a memory reader in irb. Reported
6
+ by Wojciech Wnętrzak. GitHub #6.
7
+
8
+ ## 1.0.0.beta - 2018-12-24
4
9
  * Initial implementation.
@@ -2,12 +2,15 @@
2
2
  * Update changelog and set release date
3
3
  * Bump version in `maxmind-db.gemspec`
4
4
  * Commit: `git commit -m v1.0.0`
5
- * Push: `git push`
6
5
  * Tag: `git tag -a v1.0.0 -m v1.0.0`
7
- * Push tag: `git push --tags`
8
- * Create `.gem` file: `gem build maxmind-db.spec`
6
+ * Clean up to be sure nothing stray gets into gem: `git clean -dxff`
7
+ * Create `.gem` file: `gem build maxmind-db.gemspec`
9
8
  * Complete prerequisites (see below)
10
- * Upload to rubygems.org: `gem push <.gem>`
9
+ * Upload to rubygems.org: `gem push maxmind-db-1.0.0.gem`
10
+ * Push: `git push`
11
+ * Push tag: `git push --tags`
12
+ * Double check it looks okay at https://rubygems.org/gems/maxmind-db and
13
+ https://www.rubydoc.info/gems/maxmind-db
11
14
 
12
15
 
13
16
  # Prerequisites
data/README.md CHANGED
@@ -6,6 +6,20 @@ This is the Ruby API for reading [MaxMind
6
6
  DB](https://maxmind.github.io/MaxMind-DB/) files. MaxMind DB is a binary
7
7
  file format that stores data indexed by IP address subnets (IPv4 or IPv6).
8
8
 
9
+
10
+ ## Installation
11
+
12
+ ```
13
+ gem install maxmind-db
14
+ ```
15
+
16
+ Or from source:
17
+
18
+ ```
19
+ gem build maxmind-db.spec
20
+ gem install ./maxmind-db-xxx.gem
21
+ ```
22
+
9
23
  ## Usage
10
24
 
11
25
  ```ruby
@@ -24,6 +38,9 @@ end
24
38
  reader.close
25
39
  ```
26
40
 
41
+ For more information see the
42
+ [documentation](https://www.rubydoc.info/gems/maxmind-db).
43
+
27
44
  ## Requirements
28
45
 
29
46
  This code requires Ruby version 2.3 or higher. Older versions may work, but
@@ -48,7 +65,7 @@ This library uses [Semantic Versioning](https://semver.org/).
48
65
 
49
66
  ## Copyright and License
50
67
 
51
- This software is Copyright (c) 2018 by MaxMind, Inc.
68
+ This software is Copyright (c) 2018 - 2019 by MaxMind, Inc.
52
69
 
53
70
  This is free software, licensed under the [Apache License, Version
54
71
  2.0](LICENSE-APACHE) or the [MIT License](LICENSE-MIT), at your option.
@@ -22,7 +22,7 @@ def parse_args
22
22
 
23
23
  {
24
24
  database: database,
25
- ip_file: ip_file,
25
+ ip_file: ip_file,
26
26
  }
27
27
  end
28
28
 
@@ -167,6 +167,7 @@ module MaxMind # :nodoc:
167
167
  node_count = @node_count
168
168
  bit_count.times do |i|
169
169
  break if node >= node_count
170
+
170
171
  c = packed[i >> 3].ord
171
172
  bit = 1 & (c >> 7 - (i % 8))
172
173
  node = read_node(node, bit)
@@ -187,6 +188,7 @@ module MaxMind # :nodoc:
187
188
  node = 0
188
189
  96.times do
189
190
  break if node >= @metadata.node_count
191
+
190
192
  node = read_node(node, 0)
191
193
  end
192
194
 
@@ -250,6 +252,7 @@ module MaxMind # :nodoc:
250
252
  index = @size - METADATA_START_MARKER_LENGTH
251
253
  while index >= stop_index
252
254
  return index + METADATA_START_MARKER_LENGTH if at_metadata?(index)
255
+
253
256
  index -= 1
254
257
  end
255
258
 
@@ -58,6 +58,7 @@ module MaxMind # :nodoc:
58
58
 
59
59
  def verify_size(expected, actual)
60
60
  return if expected == actual
61
+
61
62
  raise InvalidDatabaseError,
62
63
  'The MaxMind DB file\'s data section contains bad data (unknown data type or corrupt data)'.freeze
63
64
  end
@@ -152,15 +153,15 @@ module MaxMind # :nodoc:
152
153
  end
153
154
 
154
155
  TYPE_DECODER = {
155
- 1 => :decode_pointer,
156
- 2 => :decode_utf8_string,
157
- 3 => :decode_double,
158
- 4 => :decode_bytes,
159
- 5 => :decode_uint16,
160
- 6 => :decode_uint32,
161
- 7 => :decode_map,
162
- 8 => :decode_int32,
163
- 9 => :decode_uint64,
156
+ 1 => :decode_pointer,
157
+ 2 => :decode_utf8_string,
158
+ 3 => :decode_double,
159
+ 4 => :decode_bytes,
160
+ 5 => :decode_uint16,
161
+ 6 => :decode_uint32,
162
+ 7 => :decode_map,
163
+ 8 => :decode_int32,
164
+ 9 => :decode_uint64,
164
165
  10 => :decode_uint128,
165
166
  11 => :decode_array,
166
167
  14 => :decode_boolean,
@@ -14,6 +14,12 @@ module MaxMind # :nodoc:
14
14
 
15
15
  attr_reader :size
16
16
 
17
+ # Override to not show @buf in inspect to avoid showing it in irb.
18
+ def inspect
19
+ s = "#<#{self.class.name}:0x#{self.class.object_id.to_s(16)} "
20
+ s << '@size=' << @size.inspect << '>'
21
+ end
22
+
17
23
  def close; end
18
24
 
19
25
  def read(offset, size)
@@ -3,17 +3,17 @@ Gem::Specification.new do |s|
3
3
  s.files = Dir['**/*']
4
4
  s.name = 'maxmind-db'
5
5
  s.summary = 'A gem for reading MaxMind DB files.'
6
- s.version = '1.0.0.beta'
6
+ s.version = '1.0.0'
7
7
 
8
8
  s.description = 'A gem for reading MaxMind DB files. MaxMind DB is a binary file format that stores data indexed by IP address subnets (IPv4 or IPv6).'
9
9
  s.email = 'wstorey@maxmind.com'
10
10
  s.homepage = 'https://github.com/maxmind/MaxMind-DB-Reader-ruby'
11
11
  s.licenses = ['Apache-2.0', 'MIT']
12
12
  s.metadata = {
13
- 'bug_tracker_uri' => 'https://github.com/maxmind/MaxMind-DB-Reader-ruby/issues',
14
- 'changelog_uri' => 'https://github.com/maxmind/MaxMind-DB-Reader-ruby/blob/master/CHANGELOG.md',
13
+ 'bug_tracker_uri' => 'https://github.com/maxmind/MaxMind-DB-Reader-ruby/issues',
14
+ 'changelog_uri' => 'https://github.com/maxmind/MaxMind-DB-Reader-ruby/blob/master/CHANGELOG.md',
15
15
  'documentation_uri' => 'https://github.com/maxmind/MaxMind-DB-Reader-ruby',
16
- 'homepage_uri' => 'https://github.com/maxmind/MaxMind-DB-Reader-ruby',
17
- 'source_code_uri' => 'https://github.com/maxmind/MaxMind-DB-Reader-ruby',
16
+ 'homepage_uri' => 'https://github.com/maxmind/MaxMind-DB-Reader-ruby',
17
+ 'source_code_uri' => 'https://github.com/maxmind/MaxMind-DB-Reader-ruby',
18
18
  }
19
19
  end
@@ -96,15 +96,15 @@ class DecoderTest < Minitest::Test # :nodoc:
96
96
  'languages' => %w[en zh]
97
97
  },
98
98
  MMDBUtil.make_metadata_map(28) => {
99
- 'node_count' => 0,
100
- 'record_size' => 28,
101
- 'ip_version' => 4,
102
- 'database_type' => 'test',
103
- 'languages' => ['en'],
99
+ 'node_count' => 0,
100
+ 'record_size' => 28,
101
+ 'ip_version' => 4,
102
+ 'database_type' => 'test',
103
+ 'languages' => ['en'],
104
104
  'binary_format_major_version' => 2,
105
105
  'binary_format_minor_version' => 0,
106
- 'build_epoch' => 0,
107
- 'description' => 'hi',
106
+ 'build_epoch' => 0,
107
+ 'description' => 'hi',
108
108
  },
109
109
  }
110
110
  validate_type_decoding('maps', maps)
@@ -41,7 +41,7 @@ class ReaderTest < Minitest::Test # :nodoc:
41
41
  assert_equal(
42
42
  {
43
43
  'mapX' => {
44
- 'arrayX' => [7, 8, 9],
44
+ 'arrayX' => [7, 8, 9],
45
45
  'utf8_stringX' => 'hello',
46
46
  },
47
47
  },
@@ -111,7 +111,7 @@ class ReaderTest < Minitest::Test # :nodoc:
111
111
  e = assert_raises ArgumentError do
112
112
  reader.get('not_ip')
113
113
  end
114
- assert_equal('invalid address', e.message)
114
+ assert(e.message.match(/invalid address/))
115
115
  reader.close
116
116
  end
117
117
 
@@ -270,28 +270,28 @@ class ReaderTest < Minitest::Test # :nodoc:
270
270
  {
271
271
  record_size: 24,
272
272
  # Left record + right record
273
- node_bytes: "\xab\xcd\xef".b + "\xbc\xfe\xfa".b,
274
- left: 11_259_375,
275
- right: 12_386_042,
276
- check_left: "\x00\xab\xcd\xef".b.unpack('N')[0],
273
+ node_bytes: "\xab\xcd\xef".b + "\xbc\xfe\xfa".b,
274
+ left: 11_259_375,
275
+ right: 12_386_042,
276
+ check_left: "\x00\xab\xcd\xef".b.unpack('N')[0],
277
277
  check_right: "\x00\xbc\xfe\xfa".b.unpack('N')[0],
278
278
  },
279
279
  {
280
280
  record_size: 28,
281
281
  # Left record (part) + middle byte + right record (part)
282
- node_bytes: "\xab\xcd\xef".b + "\x12".b + "\xfd\xdc\xfa".b,
283
- left: 28_036_591,
284
- right: 50_191_610,
285
- check_left: "\x01\xab\xcd\xef".b.unpack('N')[0],
282
+ node_bytes: "\xab\xcd\xef".b + "\x12".b + "\xfd\xdc\xfa".b,
283
+ left: 28_036_591,
284
+ right: 50_191_610,
285
+ check_left: "\x01\xab\xcd\xef".b.unpack('N')[0],
286
286
  check_right: "\x02\xfd\xdc\xfa".b.unpack('N')[0],
287
287
  },
288
288
  {
289
289
  record_size: 32,
290
290
  # Left record + right record
291
- node_bytes: "\xab\xcd\xef\x12".b + "\xfd\xdc\xfa\x15".b,
292
- left: 2_882_400_018,
293
- right: 4_259_117_589,
294
- check_left: "\xab\xcd\xef\x12".b.unpack('N')[0],
291
+ node_bytes: "\xab\xcd\xef\x12".b + "\xfd\xdc\xfa\x15".b,
292
+ left: 2_882_400_018,
293
+ right: 4_259_117_589,
294
+ check_left: "\xab\xcd\xef\x12".b.unpack('N')[0],
295
295
  check_right: "\xfd\xdc\xfa\x15".b.unpack('N')[0],
296
296
  },
297
297
  ]
@@ -350,10 +350,10 @@ class ReaderTest < Minitest::Test # :nodoc:
350
350
  end
351
351
 
352
352
  pairs = {
353
- '1.1.1.3' => '1.1.1.2',
354
- '1.1.1.5' => '1.1.1.4',
355
- '1.1.1.7' => '1.1.1.4',
356
- '1.1.1.9' => '1.1.1.8',
353
+ '1.1.1.3' => '1.1.1.2',
354
+ '1.1.1.5' => '1.1.1.4',
355
+ '1.1.1.7' => '1.1.1.4',
356
+ '1.1.1.9' => '1.1.1.8',
357
357
  '1.1.1.15' => '1.1.1.8',
358
358
  '1.1.1.17' => '1.1.1.16',
359
359
  '1.1.1.31' => '1.1.1.16',
@@ -388,7 +388,7 @@ class ReaderTest < Minitest::Test # :nodoc:
388
388
  end
389
389
 
390
390
  pairs = {
391
- '::2:0:1' => '::2:0:0',
391
+ '::2:0:1' => '::2:0:0',
392
392
  '::2:0:33' => '::2:0:0',
393
393
  '::2:0:39' => '::2:0:0',
394
394
  '::2:0:41' => '::2:0:40',
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: maxmind-db
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.beta
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - William Storey
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-12-24 00:00:00.000000000 Z
11
+ date: 2019-01-05 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A gem for reading MaxMind DB files. MaxMind DB is a binary file format
14
14
  that stores data indexed by IP address subnets (IPv4 or IPv6).
@@ -114,9 +114,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
114
114
  version: '0'
115
115
  required_rubygems_version: !ruby/object:Gem::Requirement
116
116
  requirements:
117
- - - ">"
117
+ - - ">="
118
118
  - !ruby/object:Gem::Version
119
- version: 1.3.1
119
+ version: '0'
120
120
  requirements: []
121
121
  rubyforge_project:
122
122
  rubygems_version: 2.7.6