dbip_util 0.1.2.2025.07 → 0.1.2.2025.09

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 825f0a122cb51b2586e2656da0e816197a1ce687f2d1c130d1d9835d111d5dc1
4
- data.tar.gz: 010712567ead33d8670a63a9f2458967374c7025b6d99ef098fafc2e8def3c92
3
+ metadata.gz: cc1ed66811626db083793b7804ffc903a5ebfdeb7f8fbd467f589c3218b0ae6b
4
+ data.tar.gz: b51336041baacc83958550b06915ff155f702c3ba34e6152423740d0153841cd
5
5
  SHA512:
6
- metadata.gz: 8d14f077e7ed32f57c2d19ff6bfe62f2560d58205da23eccbba543642e731d0f00603f7cbce0cabdf4f914729e06161c0408786521441097966a228eb540098a
7
- data.tar.gz: 1ccde884f78d13b70d463da545ebe0a367cb37457ac9c6605d3cafa4a1236a4187bc91ad09d2cb2e6b05a6deb9e19ba12f89d76d14d7efd4d5b8e125b751d07f
6
+ metadata.gz: 79caca50719bb7b389d3fff5f686892a9ecbcc176167b152fb089f08562a71365abbe4fad2ce9e65891a26cda8a3a5f80362614c8300880100f8b52d62d0c325
7
+ data.tar.gz: d1b35d15bdf3a02d6733469e5b20fd4189447b664493e7b29fb8f8fc8ce30b022acdb226172ec0c7e3484dcbdee88c5fe71e569efbf9cef455bd4a57e3be7a58
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  DbipUtil includes DB-IP Lite databases and a simple interface to them, based on `maxmind-db` gem.
4
4
 
5
- The included databases are refreshed automatically. A GitHub Actions workflow runs `bin/dbiputil-refresh` and then `rake release` at **00:45 GMT+1 on the 15th of every month** to publish a new gem version. Ensure to comply with the database licensing terms below in this document.
5
+ The included databases are refreshed automatically. A GitHub Actions workflow runs `bin/dbiputil-refresh` and then `rake release` at **00:00 GMT on the 2nd of every month** to publish a new gem version. Ensure to comply with the database licensing terms below in this document.
6
6
 
7
7
  ## Installation
8
8
 
@@ -42,7 +42,7 @@ The databases are documented here:
42
42
 
43
43
  ## Development
44
44
 
45
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
45
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment. If you only need the databases without downloading them from DB-IP directly, run `ruby bin/dbiputil-provision` which extracts them from the latest released gem on RubyGems.
46
46
 
47
47
  To install this gem onto your local machine, run `bundle exec rake install`. If you need to trigger a release manually, run `bin/dbiputil-refresh` and then `bundle exec rake release`. This will create a git tag for the version, push commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
48
48
 
@@ -0,0 +1,33 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "json"
5
+ require "net/http"
6
+ require "uri"
7
+ require "rubygems/package"
8
+ require "fileutils"
9
+ require "tmpdir"
10
+
11
+ GEM_NAME = "dbip_util"
12
+
13
+ def latest_version
14
+ uri = URI("https://rubygems.org/api/v1/gems/#{GEM_NAME}.json")
15
+ JSON.parse(Net::HTTP.get(uri))["version"]
16
+ end
17
+
18
+ version = latest_version
19
+
20
+ base_dir = File.expand_path(File.join(__dir__, "..", "lib", "dbip_util"))
21
+ Dir.chdir(base_dir) do
22
+ Dir.mktmpdir do |tmp|
23
+ gem_path = File.join(tmp, "#{GEM_NAME}-#{version}.gem")
24
+ File.binwrite(gem_path, Net::HTTP.get(URI("https://rubygems.org/downloads/#{GEM_NAME}-#{version}.gem")))
25
+ extract_dir = File.join(tmp, "pkg")
26
+ Gem::Package.new(gem_path).extract_files(extract_dir)
27
+ %w[country city asn].each do |type|
28
+ FileUtils.mkdir_p("db")
29
+ src = File.join(extract_dir, "lib", "dbip_util", "db", "dbip-#{type}-lite.mmdb")
30
+ FileUtils.cp(src, File.join("db", "dbip-#{type}-lite.mmdb"))
31
+ end
32
+ end
33
+ end
Binary file
Binary file
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DbipUtil
4
- DB_VERSION = "2025.07"
4
+ DB_VERSION = "2025.09"
5
5
  VERSION = "0.1.2.#{DB_VERSION}".freeze
6
6
  end
data/lib/dbip_util.rb CHANGED
@@ -35,8 +35,8 @@ module DbipUtil
35
35
  end
36
36
 
37
37
  def ensure_provisioned!
38
- # Check for a sample database. If not present, provision it.
39
- system "#{__dir__}/../bin/dbiputil-refresh" unless File.exist?(db_path(:country))
38
+ # Check for a sample database. If not present, provision it from Rubygems.
39
+ system "#{__dir__}/../bin/dbiputil-provision" unless File.exist?(db_path(:country))
40
40
  rescue StandardError
41
41
  warn "Couldn't provision a database! Use a `dbip_util` gem from Rubygems, as it includes a database."
42
42
  raise
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dbip_util
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2.2025.07
4
+ version: 0.1.2.2025.09
5
5
  platform: ruby
6
6
  authors:
7
7
  - hmdne
@@ -36,6 +36,7 @@ files:
36
36
  - README.md
37
37
  - Rakefile
38
38
  - bin/console
39
+ - bin/dbiputil-provision
39
40
  - bin/dbiputil-refresh
40
41
  - bin/setup
41
42
  - lib/dbip_util.rb
@@ -67,7 +68,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
67
68
  - !ruby/object:Gem::Version
68
69
  version: '0'
69
70
  requirements: []
70
- rubygems_version: 3.6.7
71
+ rubygems_version: 3.6.9
71
72
  specification_version: 4
72
73
  summary: DbipUtil includes DB-IP Lite databases and a simple interface to them, based
73
74
  on `maxmind-db` gem