maxminddb 0.1.12 → 0.1.13

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: 5a6f5ba73422ebfe6973bc700356c193e38c0c9b
4
- data.tar.gz: 45c7e665af9e5dadf354bb073ae603aa37603252
3
+ metadata.gz: 8baf986bd6ee8827d5dec1075ab871ed940a7450
4
+ data.tar.gz: d6c493bf9a2c759deaf221c7adde7092faf1ac02
5
5
  SHA512:
6
- metadata.gz: d61c9dee82554e8b3e5e5c6a373110a46e195c833b523b4d17ddf2bdc66f056b7bc446c8bd3b38fc8296e8ff7d3e429db22873ceee361df6a3a2de007d3a8704
7
- data.tar.gz: 22d61b2d469069f52dfa11b0dc8e90a13f95f4c9668f06fbcd3df5fa4fc072bef872741480f359037eac98b6a19891c97199aa383ff0cb460dcbd79d94788289
6
+ metadata.gz: d5f7b6bc12aad94797fccd16c77a1b383e4c9b0502134e74429b2fafa1ea55db633d00ce7787f6c6f2039b845431f81e7c8441d22f3cb993e2291c63ff42bf6b
7
+ data.tar.gz: 88f840828b38a877fd346057f847e38bc04d6ad9977e61cd829f56cce781b40d4a05d0a3cded7451a27c45f38afd005c763887f2e4d3f7305e1f27039947dbbb
@@ -5,9 +5,8 @@ rvm:
5
5
  - 2.1
6
6
  - 2.2
7
7
  - 2.3
8
- - 2.4
8
+ - 2.4.0
9
9
  - jruby-19mode
10
- - rbx
11
10
 
12
11
  script: bundle exec rake
13
12
 
@@ -0,0 +1,23 @@
1
+ # Changelog
2
+
3
+ ### 0.1.13 (June 13, 2017)
4
+
5
+ - Expose database metadata #27
6
+
7
+ ### 0.1.12 (January 11, 2017)
8
+
9
+ - Removed Fixnum and Bignum deprecation warnings (in ruby 2.4)
10
+ - Update Travis
11
+ - Fix failing test
12
+
13
+ ### 0.1.11 (March 7, 2016)
14
+
15
+ - Fixed problem with 32bit record data
16
+
17
+ ### 0.1.10 (February 25, 2016)
18
+
19
+ - Performance tweaks
20
+
21
+ ***
22
+
23
+ *For older releases, see commit log.*
data/README.md CHANGED
@@ -53,6 +53,14 @@ ret.country.name # => nil
53
53
  ret.to_hash # => {}
54
54
  ```
55
55
 
56
+ It's also possible to access the database metadata.
57
+
58
+ ```ruby
59
+ db = MaxMindDB.new('./GeoLite2-City.mmdb')
60
+ db.metadata['build_epoch'] # => 1493762948
61
+ db.metadata # => {"binary_format_major_version"=>2, "binary_format_minor_version"=>0, "build_epoch"=>1493762948, "database_type"=>"GeoLite2-City", "description"=>{"en"=>"GeoLite2 City database"}, "ip_version"=>6, "languages"=>["de", "en", "es", "fr", "ja", "pt-BR", "ru", "zh-CN"], "node_count"=>3678850, "record_size"=>28}
62
+ ```
63
+
56
64
 
57
65
  ## Contributing
58
66
 
@@ -14,6 +14,8 @@ module MaxMindDB
14
14
  SIZE_BASE_VALUES = [0, 29, 285, 65821]
15
15
  POINTER_BASE_VALUES = [0, 0, 2048, 526336]
16
16
 
17
+ attr_reader :metadata
18
+
17
19
  def initialize(path)
18
20
  @path = path
19
21
  @data = File.binread(path)
@@ -21,11 +23,11 @@ module MaxMindDB
21
23
  pos = @data.rindex(METADATA_BEGIN_MARKER)
22
24
  raise 'invalid file format' unless pos
23
25
  pos += METADATA_BEGIN_MARKER.size
24
- metadata = decode(pos, 0)[1]
26
+ @metadata = decode(pos, 0)[1]
25
27
 
26
- @ip_version = metadata['ip_version']
27
- @node_count = metadata['node_count']
28
- @node_byte_size = metadata['record_size'] * 2 / 8
28
+ @ip_version = @metadata['ip_version']
29
+ @node_count = @metadata['node_count']
30
+ @node_byte_size = @metadata['record_size'] * 2 / 8
29
31
  @search_tree_size = @node_count * @node_byte_size
30
32
  end
31
33
 
@@ -1,3 +1,3 @@
1
1
  module MaxMindDB
2
- VERSION = "0.1.12"
2
+ VERSION = "0.1.13"
3
3
  end
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.12
4
+ version: 0.1.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - yhirose
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-11 00:00:00.000000000 Z
11
+ date: 2017-06-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -76,6 +76,7 @@ files:
76
76
  - ".gitignore"
77
77
  - ".rspec"
78
78
  - ".travis.yml"
79
+ - CHANGELOG.md
79
80
  - Gemfile
80
81
  - LICENSE.txt
81
82
  - README.md