geocoder 1.8.5 → 1.8.6

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: fdb45130990fbb878a93ceb3e68729abce378f50a6bc5ebda0b77cbaae60156c
4
- data.tar.gz: 1d65925f76418f4023db18f3422450b831f4501715e0ff8c645dba67820766dc
3
+ metadata.gz: 0b8e84b8e86854f7aadc62c7b2a5258af91c7a24e80e99755e3f96629bb501f3
4
+ data.tar.gz: 5f2ddd4bb79edb7a05539f8bd58108a5b84359a46f6fea711770b575428c628f
5
5
  SHA512:
6
- metadata.gz: 974c3eb6c880fdcdf316e1fb93dae18f5d6bf486f0a6ae3a7cba5629404e69cba64a5005bd0a7d86682be5d535fa4d772a7fab7a69b5e975bf9679c7d682a5aa
7
- data.tar.gz: 80e8c1de0e969b7c8353bfb760cc807ec3469529e36bd388873d84f3d8a53c5a74e58bcbb9da07f1f014538c284fe012c36d6ada9930170d7d987a656dd95f3d
6
+ metadata.gz: a42721f88ac240ccf70e58d3ff9556e413727ce385c28b40aef5a9a43819468b91a58c8543d3f267452fd1f5560dfd7cbf7d6e01f77d0d8d7cef23dbc1d5bf81
7
+ data.tar.gz: eb50fe5f2852c809778ff329a11d189a6ac226d6b2c99404b530c75bae316211cf79cbc3d2d2ef391b73a1dd0dbba57fb6b9bfc8ec597a63e7027929bd0ad0e6
data/CHANGELOG.md CHANGED
@@ -3,6 +3,11 @@ Changelog
3
3
 
4
4
  Major changes to Geocoder for each release. Please see the Git log for complete list of changes.
5
5
 
6
+ 1.8.6 (2025 Sep 21)
7
+ -------------------
8
+ * Add support for IPInfo Lite lookup (thanks github.com/iltempo).
9
+ * Various minor fixes and improvements.
10
+
6
11
  1.8.5 (2024 Dec 18)
7
12
  -------------------
8
13
  * Fix bug when working with IPAddr objects (thanks github.com/ledermann and github.com/mattlemx).
@@ -87,6 +87,7 @@ module Geocoder
87
87
  :pointpin,
88
88
  :maxmind_geoip2,
89
89
  :ipinfo_io,
90
+ :ipinfo_io_lite,
90
91
  :ipregistry,
91
92
  :ipapi_com,
92
93
  :ipdata_co,
@@ -18,7 +18,7 @@ module Geocoder::Lookup
18
18
 
19
19
  def base_query_url(query)
20
20
  method = query.reverse_geocode? ? "reverse" : "search"
21
- "#{protocol}://api-adresse.data.gouv.fr/#{method}/?"
21
+ "#{protocol}://data.geopf.fr/geocodage/#{method}/?"
22
22
  end
23
23
 
24
24
  def any_result?(doc)
@@ -48,8 +48,8 @@ module Geocoder::Lookup
48
48
  "country_name" => "-",
49
49
  "region_name" => "-",
50
50
  "city_name" => "-",
51
- "latitude" => null,
52
- "longitude" => null,
51
+ "latitude" => nil,
52
+ "longitude" => nil,
53
53
  "zip_code" => "-",
54
54
  "time_zone" => "-",
55
55
  "asn" => "-",
@@ -0,0 +1,42 @@
1
+ require 'geocoder/lookups/base'
2
+ require 'geocoder/results/ipinfo_io_lite'
3
+
4
+ module Geocoder::Lookup
5
+ class IpinfoIoLite < Base
6
+ def name
7
+ 'Ipinfo.io Lite'
8
+ end
9
+
10
+ private # ---------------------------------------------------------------
11
+
12
+ def base_query_url(query)
13
+ url = "#{protocol}://api.ipinfo.io/lite/#{query.sanitized_text}"
14
+ url << '?' if configuration.api_key
15
+ url
16
+ end
17
+
18
+ def results(query)
19
+ # don't look up a loopback or private address, just return the stored result
20
+ return [reserved_result(query.text)] if query.internal_ip_address?
21
+
22
+ if !(doc = fetch_data(query)).is_a?(Hash) or doc['error']
23
+ []
24
+ else
25
+ [doc]
26
+ end
27
+ end
28
+
29
+ def reserved_result(ip)
30
+ {
31
+ 'ip' => ip,
32
+ 'bogon' => true
33
+ }
34
+ end
35
+
36
+ def query_url_params(query)
37
+ {
38
+ token: configuration.api_key
39
+ }.merge(super)
40
+ end
41
+ end
42
+ end
@@ -20,6 +20,7 @@ module Geocoder::Lookup
20
20
  sort_relevant_feature(data['features'])
21
21
  elsif data['message'] =~ /Invalid\sToken/
22
22
  raise_error(Geocoder::InvalidApiKey, data['message'])
23
+ []
23
24
  else
24
25
  []
25
26
  end
@@ -10,10 +10,12 @@ module Geocoder::Lookup
10
10
  # AF: Africa
11
11
  # AS: Asia
12
12
  # EU: Europe
13
+ # ME: Middle East
14
+ # MX: Mexico
13
15
  # NA: North America
14
16
  # OC: Oceania
15
17
  # SA: South America
16
- %w[AF AS EU NA OC SA]
18
+ %w[AF AS EU ME MX NA OC SA]
17
19
  end
18
20
 
19
21
  def name
@@ -0,0 +1,16 @@
1
+ require 'geocoder/results/base'
2
+
3
+ module Geocoder::Result
4
+ class IpinfoIoLite < Base
5
+
6
+ def self.response_attributes
7
+ %w(ip asn as_name as_domain country country_code continent continent_code)
8
+ end
9
+
10
+ response_attributes.each do |a|
11
+ define_method a do
12
+ @data[a]
13
+ end
14
+ end
15
+ end
16
+ end
@@ -8,7 +8,7 @@ module Geocoder::Result
8
8
  end
9
9
 
10
10
  def place_name
11
- data['text']
11
+ data['place_name']
12
12
  end
13
13
 
14
14
  def street
@@ -78,4 +78,3 @@ module Geocoder::Result
78
78
  end
79
79
  end
80
80
  end
81
-
@@ -132,7 +132,8 @@ module Geocoder::Store
132
132
  # If radius is a DB column name, bounding box should include
133
133
  # all rows within the maximum radius appearing in that column.
134
134
  # Note: performance is dependent on variability of radii.
135
- bb_radius = radius.is_a?(Symbol) ? maximum(radius) : radius
135
+ radius_is_column = radius.is_a?(Symbol) || (defined?(Arel::Nodes::SqlLiteral) && radius.is_a?(Arel::Nodes::SqlLiteral))
136
+ bb_radius = radius_is_column ? maximum(radius) : radius
136
137
  b = Geocoder::Calculations.bounding_box([latitude, longitude], bb_radius, options)
137
138
  args = b + [
138
139
  full_column_name(latitude_attribute),
@@ -146,7 +147,7 @@ module Geocoder::Store
146
147
  min_radius = options.fetch(:min_radius, 0).to_f
147
148
  # if radius is a DB column name,
148
149
  # find rows between min_radius and value in column
149
- if radius.is_a?(Symbol)
150
+ if radius_is_column
150
151
  c = "BETWEEN ? AND #{radius}"
151
152
  a = [min_radius]
152
153
  else
@@ -1,3 +1,3 @@
1
1
  module Geocoder
2
- VERSION = "1.8.5"
2
+ VERSION = "1.8.6"
3
3
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: geocoder
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.5
4
+ version: 1.8.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Reisner
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2024-12-18 00:00:00.000000000 Z
10
+ date: 2025-09-21 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: base64
@@ -109,6 +108,7 @@ files:
109
108
  - lib/geocoder/lookups/ipdata_co.rb
110
109
  - lib/geocoder/lookups/ipgeolocation.rb
111
110
  - lib/geocoder/lookups/ipinfo_io.rb
111
+ - lib/geocoder/lookups/ipinfo_io_lite.rb
112
112
  - lib/geocoder/lookups/ipqualityscore.rb
113
113
  - lib/geocoder/lookups/ipregistry.rb
114
114
  - lib/geocoder/lookups/ipstack.rb
@@ -177,6 +177,7 @@ files:
177
177
  - lib/geocoder/results/ipdata_co.rb
178
178
  - lib/geocoder/results/ipgeolocation.rb
179
179
  - lib/geocoder/results/ipinfo_io.rb
180
+ - lib/geocoder/results/ipinfo_io_lite.rb
180
181
  - lib/geocoder/results/ipqualityscore.rb
181
182
  - lib/geocoder/results/ipregistry.rb
182
183
  - lib/geocoder/results/ipstack.rb
@@ -224,7 +225,6 @@ licenses:
224
225
  metadata:
225
226
  source_code_uri: https://github.com/alexreisner/geocoder
226
227
  changelog_uri: https://github.com/alexreisner/geocoder/blob/master/CHANGELOG.md
227
- post_install_message:
228
228
  rdoc_options: []
229
229
  require_paths:
230
230
  - lib
@@ -239,8 +239,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
239
239
  - !ruby/object:Gem::Version
240
240
  version: '0'
241
241
  requirements: []
242
- rubygems_version: 3.3.26
243
- signing_key:
242
+ rubygems_version: 3.6.3
244
243
  specification_version: 4
245
244
  summary: Complete geocoding solution for Ruby.
246
245
  test_files: []