geoip2_c 0.4.1 → 0.5.0

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: 25a17a86c77f7e092f8f24a224cd8a57d6bba8595f51d0e052e3a846a3fd67e8
4
- data.tar.gz: 1bb129e6fba2ff42f583dff127ba4168d958c12af6a7c1521d23a07fbf59dab8
3
+ metadata.gz: a7471c1c8b9c5960c8b10f11701a6b23cedce5cbf49356c1a06a4fed3896ffc4
4
+ data.tar.gz: 5bc5a25d99d5b6dd98c06be377d85d9097cd2ceeaad5d8fcbf9e116c3ea628f6
5
5
  SHA512:
6
- metadata.gz: 22d90d27edebbf88c8d0a9ec2edc304fc0265b1f6814012ca47e4cd5b9ef5f8422fe3b92a63ed90bbba1f3a2eb874c98d1f52f9d28d246f8df83f5d19e3a4819
7
- data.tar.gz: 4ba29b9f46963e6be9c298c686885b6224e4b7346069da485972d48ac91f0baf025fa882461df943461a0798102a3429cd165d7c13340c7c1aecae576e0fbf97
6
+ metadata.gz: 16607879122d4480d57abe51b8b5cf312ce4122de4d531bb11089e48b6993541d52f52d495c99196bc657be8c45bafff325558168ed062ac163bffb19916a017
7
+ data.tar.gz: 81b34e63a9e5aef8585ad6a2a0318a70893963b37b26c0286fb07aba1f12d872873ae1fd3e4345dbd31de6e869414a09f4fb35c74822e8339968e80064431b3a
@@ -13,7 +13,7 @@ jobs:
13
13
  uses: ruby/actions/.github/workflows/ruby_versions.yml@master
14
14
  with:
15
15
  engine: cruby
16
- min_version: 3.0
16
+ min_version: 3.2
17
17
  build:
18
18
  needs: ruby-versions
19
19
  runs-on: ubuntu-latest
@@ -23,11 +23,11 @@ jobs:
23
23
  exclude:
24
24
  - ruby: head
25
25
  steps:
26
- - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
26
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
27
27
  with:
28
28
  submodules: true
29
29
  - name: Setup ruby
30
- uses: ruby/setup-ruby@0dafeac902942906541bc140009cdbf32665b601 # v1.315.0
30
+ uses: ruby/setup-ruby@7f797815d8adceb1c412e7abefdd1ab4abc47a5f # v1.335.0
31
31
  with:
32
32
  ruby-version: ${{ matrix.ruby }}
33
33
  bundler: latest
@@ -33,15 +33,11 @@ jobs:
33
33
  # * https://github.com/oneclick/rubyinstaller2/blob/8225034c22152d8195bc0aabc42a956c79d6c712/lib/ruby_installer/build/dll_directory.rb
34
34
  ruby-lib-opt: RUBYLIB=%RUNNER_TOOL_CACHE%/Ruby/3.0.3/x64/lib/ruby/gems/3.0.0/gems/fiddle-1.1.0/lib
35
35
  steps:
36
- - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
36
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
37
37
  with:
38
38
  submodules: true
39
- - name: Install dependencies
40
- run: |
41
- ridk enable
42
- pacman -Sy --noconfirm mingw-w64-x86_64-libmaxminddb
43
39
  - name: Setup ruby
44
- uses: ruby/setup-ruby@0dafeac902942906541bc140009cdbf32665b601 # v1.315.0
40
+ uses: ruby/setup-ruby@7f797815d8adceb1c412e7abefdd1ab4abc47a5f # v1.335.0
45
41
  with:
46
42
  ruby-version: ${{ matrix.ruby }}
47
43
  bundler: latest
data/README.md CHANGED
@@ -16,7 +16,7 @@ Need ruby.h to build this extension, so you must install it before build this ex
16
16
  Debian GNU Linux / Ubuntu:
17
17
 
18
18
  ```
19
- $ sudo apt install -y build-essential automake autoconf libtool
19
+ $ sudo apt install -y build-essential automake autoconf libtool pkgconf
20
20
  ```
21
21
 
22
22
  CentOS:
@@ -25,7 +25,7 @@ CentOS:
25
25
  $ sudo yum groupinstall -y "Development Tools"
26
26
  ```
27
27
 
28
- **NOTE**: If you want to use libmaxminddb provided as a deb/rpm package, you can install libmaxminddb-dev or libmaxminddb-devel at your own risk.
28
+ By default, the build downloads the libmaxminddb source from GitHub, so it needs network access. To build without network access, use [libmaxminddb installed on the system](#using-libmaxminddb-installed-on-the-system).
29
29
 
30
30
  ## Installation
31
31
 
@@ -43,6 +43,19 @@ Or install it yourself as:
43
43
 
44
44
  $ gem install geoip2_c
45
45
 
46
+ ### Using libmaxminddb installed on the system
47
+
48
+ By default, the installation downloads the source of libmaxminddb from GitHub and builds it. To link libmaxminddb installed on the system instead, for example where the build cannot access github.com, install its development package and pass `--use-system-libraries`:
49
+
50
+ $ sudo apt install -y libmaxminddb-dev # or: sudo yum install -y libmaxminddb-devel
51
+ $ gem install geoip2_c -- --use-system-libraries
52
+
53
+ Setting the environment variable `GEOIP2_C_USE_SYSTEM_LIBRARIES` has the same effect, which helps when geoip2_c is installed as a dependency of another gem. Any value enables it, even `0` or an empty value:
54
+
55
+ $ GEOIP2_C_USE_SYSTEM_LIBRARIES=1 gem install fluent-plugin-geoip
56
+
57
+ In both ways, the extension is linked to the shared library of libmaxminddb. Keep the runtime package (`libmaxminddb0` on Debian and Ubuntu, `libmaxminddb` on RHEL) installed wherever geoip2_c is used.
58
+
46
59
  ## Usage
47
60
 
48
61
  ```ruby
@@ -1,17 +1,49 @@
1
1
  require "mkmf"
2
- require "mini_portile2"
3
2
 
4
- maxminddb_version = "1.13.3"
3
+ # By default, this downloads libmaxminddb and builds it. To link the
4
+ # libmaxminddb installed on the system instead, for example where the build
5
+ # cannot access github.com, pass --use-system-libraries
6
+ # (gem install geoip2_c -- --use-system-libraries) or set
7
+ # GEOIP2_C_USE_SYSTEM_LIBRARIES.
8
+ if arg_config("--use-system-libraries", ENV.key?("GEOIP2_C_USE_SYSTEM_LIBRARIES"))
9
+ pkg_config("libmaxminddb")
10
+ unless have_header("maxminddb.h") && have_library("maxminddb", "MMDB_open")
11
+ abort "libmaxminddb is not found. Install libmaxminddb-dev (Debian, Ubuntu) " \
12
+ "or libmaxminddb-devel (RHEL), or build without --use-system-libraries " \
13
+ "and without GEOIP2_C_USE_SYSTEM_LIBRARIES."
14
+ end
15
+ $CFLAGS << " -std=c99 -fPIC -fms-extensions"
16
+ else
17
+ require "mini_portile2"
5
18
 
6
- recipe = MiniPortile.new("libmaxminddb", maxminddb_version)
7
- recipe.files = ["https://github.com/maxmind/libmaxminddb/releases/download/#{maxminddb_version}/libmaxminddb-#{maxminddb_version}.tar.gz"]
8
- recipe.cook
9
- recipe.activate
19
+ maxminddb_version = "1.14.1"
20
+ maxminddb_sha256 = "ca5c87d41339f8bc4daabb53e8a9356b3c995f2d2419b85d7bff823b2ecc252d"
21
+ maxminddb_url = "https://github.com/maxmind/libmaxminddb/releases/download/#{maxminddb_version}/libmaxminddb-#{maxminddb_version}.tar.gz"
10
22
 
11
- $INCFLAGS = "-I#{File.join(recipe.path, 'include')} " + $INCFLAGS
12
- $LDFLAGS << " -L#{File.join(recipe.path, 'lib')} -lmaxminddb"
13
- $CFLAGS << " -std=c99 -fPIC -fms-extensions -I#{File.join(recipe.path, 'include')}"
23
+ recipe = MiniPortile.new("libmaxminddb", maxminddb_version)
24
+ recipe.files = [{
25
+ url: maxminddb_url,
26
+ sha256: maxminddb_sha256
27
+ }]
28
+ recipe.configure_options += ["--with-pic"]
29
+ begin
30
+ recipe.download
31
+ rescue
32
+ raise if recipe.downloaded?
33
+ abort <<~MESSAGE
34
+ Failed to download #{maxminddb_url}.
35
+ If the build accesses github.com through a proxy, set https_proxy.
36
+ To link libmaxminddb installed on the system instead, install libmaxminddb-dev (Debian, Ubuntu)
37
+ or libmaxminddb-devel (RHEL), and pass --use-system-libraries
38
+ (gem install geoip2_c -- --use-system-libraries) or set GEOIP2_C_USE_SYSTEM_LIBRARIES.
39
+ MESSAGE
40
+ end
41
+ recipe.cook
42
+ recipe.activate
14
43
 
15
- have_func("rb_sym2str", "ruby.h")
44
+ $INCFLAGS = "-I#{File.join(recipe.path, 'include')} " + $INCFLAGS
45
+ $LOCAL_LIBS << " #{File.join(recipe.path, 'lib', 'libmaxminddb.a')}"
46
+ $CFLAGS << " -std=c99 -fPIC -fms-extensions -I#{File.join(recipe.path, 'include')}"
47
+ end
16
48
 
17
49
  create_makefile("geoip2/geoip2")
data/ext/geoip2/geoip2.c CHANGED
@@ -1,7 +1,7 @@
1
+ #include <stdbool.h>
1
2
  #include <ruby.h>
2
3
  #include <ruby/encoding.h>
3
4
  #include <maxminddb.h>
4
- #include "rb_compat.h"
5
5
 
6
6
  VALUE rb_mGeoIP2;
7
7
  VALUE rb_cGeoIP2Database;
data/geoip2_c.gemspec CHANGED
@@ -8,10 +8,14 @@ Gem::Specification.new do |spec|
8
8
  spec.authors = ["okkez"]
9
9
  spec.email = ["okkez000@gmail.com"]
10
10
 
11
- spec.summary = %q{Write a short summary, because Rubygems requires one.}
12
- spec.description = %q{Write a longer description or delete this line.}
13
- spec.homepage = ""
11
+ spec.summary = %q{Ruby binding for libmaxminddb}
12
+ spec.description = %q{geoip2_c is a Ruby binding for libmaxminddb to read MaxMind DB files such as GeoIP2. It does not traverse all elements in a lookup result by default, so you can get the element you want fast.}
13
+ spec.homepage = "https://github.com/fluent-plugins-nursery/geoip2_c"
14
14
  spec.license = "Apache-2.0"
15
+ spec.metadata = {
16
+ "source_code_uri" => "https://github.com/fluent-plugins-nursery/geoip2_c",
17
+ "bug_tracker_uri" => "https://github.com/fluent-plugins-nursery/geoip2_c/issues",
18
+ }
15
19
 
16
20
  spec.files = `git ls-files -z --recurse-submodules`.split("\x0").reject do |f|
17
21
  f.match(%r{^(test|spec|features|benchmark)/})
@@ -20,6 +24,7 @@ Gem::Specification.new do |spec|
20
24
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
21
25
  spec.require_paths = ["lib"]
22
26
  spec.extensions = ["ext/geoip2/extconf.rb"]
27
+ spec.required_ruby_version = ">= 2.3.0"
23
28
 
24
29
  spec.add_dependency('mini_portile2', '~> 2.8')
25
30
  spec.add_development_dependency "appraisal"
@@ -1,3 +1,3 @@
1
1
  module GeoIP2
2
- VERSION = "0.4.1"
2
+ VERSION = "0.5.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: geoip2_c
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - okkez
@@ -93,7 +93,9 @@ dependencies:
93
93
  - - "~>"
94
94
  - !ruby/object:Gem::Version
95
95
  version: '3.2'
96
- description: Write a longer description or delete this line.
96
+ description: geoip2_c is a Ruby binding for libmaxminddb to read MaxMind DB files
97
+ such as GeoIP2. It does not traverse all elements in a lookup result by default,
98
+ so you can get the element you want fast.
97
99
  email:
98
100
  - okkez000@gmail.com
99
101
  executables: []
@@ -118,16 +120,17 @@ files:
118
120
  - dockerfiles/Dockerfile-ruby2.7
119
121
  - ext/geoip2/extconf.rb
120
122
  - ext/geoip2/geoip2.c
121
- - ext/geoip2/rb_compat.h
122
123
  - geoip2_c.gemspec
123
124
  - lib/geoip2.rb
124
125
  - lib/geoip2/database.rb
125
126
  - lib/geoip2/lookup_result.rb
126
127
  - lib/geoip2/version.rb
127
- homepage: ''
128
+ homepage: https://github.com/fluent-plugins-nursery/geoip2_c
128
129
  licenses:
129
130
  - Apache-2.0
130
- metadata: {}
131
+ metadata:
132
+ source_code_uri: https://github.com/fluent-plugins-nursery/geoip2_c
133
+ bug_tracker_uri: https://github.com/fluent-plugins-nursery/geoip2_c/issues
131
134
  rdoc_options: []
132
135
  require_paths:
133
136
  - lib
@@ -135,14 +138,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
135
138
  requirements:
136
139
  - - ">="
137
140
  - !ruby/object:Gem::Version
138
- version: '0'
141
+ version: 2.3.0
139
142
  required_rubygems_version: !ruby/object:Gem::Requirement
140
143
  requirements:
141
144
  - - ">="
142
145
  - !ruby/object:Gem::Version
143
146
  version: '0'
144
147
  requirements: []
145
- rubygems_version: 4.0.15
148
+ rubygems_version: 4.0.20
146
149
  specification_version: 4
147
- summary: Write a short summary, because Rubygems requires one.
150
+ summary: Ruby binding for libmaxminddb
148
151
  test_files: []
@@ -1,10 +0,0 @@
1
- #ifndef __RB_COMPAT_H__
2
- #define __RB_COMPAT_H__
3
-
4
- #include <ruby.h>
5
-
6
- #ifndef HAVE_RB_SYM2STR
7
- # define rb_sym2str(name) (rb_id2str(SYM2ID(name)))
8
- #endif
9
-
10
- #endif