dbip_util 0.1.0.2025.07 → 0.1.2.2025.08
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 +4 -4
- data/README.md +2 -2
- data/bin/dbiputil-provision +33 -0
- data/lib/dbip_util/db/dbip-asn-lite.mmdb +0 -0
- data/lib/dbip_util/db/dbip-city-lite.mmdb +0 -0
- data/lib/dbip_util/db/dbip-country-lite.mmdb +0 -0
- data/lib/dbip_util/version.rb +2 -2
- data/lib/dbip_util.rb +2 -2
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cfcca5e602eb73f00205b7b47fec56075811dcf5257b327eb928cc688ac3da47
|
4
|
+
data.tar.gz: a76cd7b5f220551fb180b33cb2c760c2b19e7f41a1aaaf2438fc8d95acc5d397
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9f936121b637f8110c6cf235d1cb03ef02354f8eefbdb6dce312bd5e248b4c385f9665280a58f6c88d3767938388a4c08cd3ec27d431df72c13ad7dbd74e6571
|
7
|
+
data.tar.gz: 23b4c9fac25697bfac8fb773992e9bd5ca6f737469483950cebcb861f18bb129df2343f324eadaa6ef74f35729867f275ab3f2acda8afb35a976291e941ee384
|
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:
|
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
|
Binary file
|
data/lib/dbip_util/version.rb
CHANGED
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-
|
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.
|
4
|
+
version: 0.1.2.2025.08
|
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.
|
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
|