geocoder 1.6.2 → 1.6.3

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: 90c4756998f02d1ff8f3f8ca4323d47e3d726547f8ce42c79fc21beeecd88b90
4
- data.tar.gz: f2dc1c26391cd757001f2e973f4136e97c52da6f2153e9f3db29cae336555bdd
3
+ metadata.gz: b8ab5b6c482a72aa85d0594577eb88c912ae9304254f006b9f7a37818318c94b
4
+ data.tar.gz: d2a71cc1cd294237c006ade75db89a99a2a01e31515eefc825aa833cb136acaa
5
5
  SHA512:
6
- metadata.gz: 43144700ad9a0a7fcec1dd0f363348b049984bda7fbefd57285c86a03ae7a16afc1302fd9dea656bc7b65142248d6cec06446f98dee80f9b5577b7ba4ee1b175
7
- data.tar.gz: d4fcd8d3a6ed87234cdb9f411d7f58fd92d126f7ff23fef0c53e470ed78a76003f095a7b291c33748dd3e8282b2f237cf5c73e155863bb1d34b7e5f148e32677
6
+ metadata.gz: 1badbbf1f2633044d3f9a3ce56cf89f1573538795128c945102c02141f76304dc6c3ef98fef8befe0b9865871beec1cd98109290f05c28cbc042162d084af3a9
7
+ data.tar.gz: 3edf26f306e5a72a764a0def55a74eeff0652e90956b3cba26d44e7c51a5746df01a6ae09639ea61773768b0ffd58be888bca687a3427f2e1e5cec202c12aa02
@@ -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.6.3 (2020 Apr 30)
7
+ -------------------
8
+ * Update URL for :telize lookup (thanks github.com/alexwalling).
9
+ * Fix bug parsing IPv6 with port (thanks github.com/gdomingu).
10
+
6
11
  1.6.2 (2020 Mar 16)
7
12
  -------------------
8
13
  * Add support for :nationaal_georegister_nl lookup (thanks github.com/opensourceame).
@@ -3,5 +3,11 @@
3
3
  require 'bundler/setup'
4
4
  require 'geocoder'
5
5
 
6
+ if File.exist?("api_keys.yml")
7
+ require 'yaml'
8
+ @api_keys = YAML.load(File.read("api_keys.yml"), symbolize_names: true)
9
+ Geocoder.configure(@api_keys)
10
+ end
11
+
6
12
  require 'irb'
7
13
  IRB.start
@@ -20,7 +20,8 @@ module Geocoder
20
20
  end
21
21
 
22
22
  def valid?
23
- !!((self =~ Resolv::IPv4::Regex) || (self =~ Resolv::IPv6::Regex))
23
+ ip = self[/(?<=\[)(.*?)(?=\])/] || self
24
+ !!((ip =~ Resolv::IPv4::Regex) || (ip =~ Resolv::IPv6::Regex))
24
25
  end
25
26
  end
26
27
  end
@@ -47,6 +47,8 @@ module Geocoder::Lookup
47
47
  params[:forStorage] = for_storage_value
48
48
  end
49
49
  params[:sourceCountry] = configuration[:source_country] if configuration[:source_country]
50
+ params[:preferredLabelValues] = configuration[:preferred_label_values] if configuration[:preferred_label_values]
51
+
50
52
  params.merge(super)
51
53
  end
52
54
 
@@ -25,8 +25,7 @@ module Geocoder::Lookup
25
25
  # The API returned a 404 response, which indicates no results found
26
26
  elsif doc['error']['type'] == 'api_error'
27
27
  []
28
- elsif
29
- doc['error']['type'] == 'authentication_error'
28
+ elsif doc['error']['type'] == 'authentication_error'
30
29
  raise_error(Geocoder::InvalidApiKey) ||
31
30
  Geocoder.log(:warn, "LatLon.io service error: invalid API key.")
32
31
  else
@@ -57,7 +57,12 @@ module Geocoder::Lookup
57
57
  end
58
58
 
59
59
  def results(query)
60
- fetch_data(query) || []
60
+ doc = fetch_data(query) || []
61
+ if doc.is_a?(Hash) and doc.key?('status') # implies there's an error
62
+ return []
63
+ else
64
+ return doc
65
+ end
61
66
  end
62
67
  end
63
68
  end
@@ -16,7 +16,7 @@ module Geocoder::Lookup
16
16
  if configuration[:host]
17
17
  "#{protocol}://#{configuration[:host]}/location/#{query.sanitized_text}"
18
18
  else
19
- "#{protocol}://telize-v1.p.mashape.com/location/#{query.sanitized_text}?mashape-key=#{api_key}"
19
+ "#{protocol}://telize-v1.p.rapidapi.com/location/#{query.sanitized_text}?rapidapi-key=#{api_key}"
20
20
  end
21
21
  end
22
22
 
@@ -33,8 +33,7 @@ module Geocoder::Lookup
33
33
  return []
34
34
  end
35
35
  if doc = doc['response']['GeoObjectCollection']
36
- meta = doc['metaDataProperty']['GeocoderResponseMetaData']
37
- return meta['found'].to_i > 0 ? doc['featureMember'] : []
36
+ return doc['featureMember'].to_a
38
37
  else
39
38
  Geocoder.log(:warn, "Yandex Geocoding API error: unexpected response format.")
40
39
  return []
@@ -1,3 +1,3 @@
1
1
  module Geocoder
2
- VERSION = "1.6.2"
2
+ VERSION = "1.6.3"
3
3
  end
metadata CHANGED
@@ -1,19 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: geocoder
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.2
4
+ version: 1.6.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Reisner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-16 00:00:00.000000000 Z
11
+ date: 2020-04-30 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: Provides object geocoding (by street or IP address), reverse geocoding
14
- (coordinates to street address), distance queries for ActiveRecord and Mongoid,
15
- result caching, and more. Designed for Rails but works with Sinatra and other Rack
16
- frameworks too.
13
+ description: Object geocoding (by street or IP address), reverse geocoding (coordinates
14
+ to street address), distance queries for ActiveRecord and Mongoid, result caching,
15
+ and more. Designed for Rails but works with Sinatra and other Rack frameworks too.
17
16
  email:
18
17
  - alex@alexreisner.com
19
18
  executables:
@@ -186,7 +185,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
186
185
  - !ruby/object:Gem::Version
187
186
  version: '0'
188
187
  requirements: []
189
- rubygems_version: 3.0.1
188
+ rubygems_version: 3.1.2
190
189
  signing_key:
191
190
  specification_version: 4
192
191
  summary: Complete geocoding solution for Ruby.