geocoder 1.4.7 → 1.4.8
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of geocoder might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +22 -10
- data/examples/autoexpire_cache_redis.rb +3 -3
- data/lib/generators/geocoder/config/templates/initializer.rb +1 -1
- data/lib/geocoder/cache.rb +1 -1
- data/lib/geocoder/configuration.rb +1 -1
- data/lib/geocoder/lookup.rb +2 -1
- data/lib/geocoder/lookups/geocodio.rb +1 -1
- data/lib/geocoder/lookups/ipstack.rb +64 -0
- data/lib/geocoder/lookups/telize.rb +3 -3
- data/lib/geocoder/results/geoip2.rb +0 -4
- data/lib/geocoder/results/ipstack.rb +60 -0
- data/lib/geocoder/stores/base.rb +1 -1
- data/lib/geocoder/version.rb +1 -1
- metadata +9 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 854db8cc60efe7a71d336d5001d509a69e1abd13
|
4
|
+
data.tar.gz: e75d9237cd4fc8399b19308434bca339e2a538c1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b10a62001c292e4829aa71e44846c8d2a3272095de360ba09b8cb1469692158bd4a8b0745053433b316e60edf6c7720487c45f9cea303067d44c8d2883b65f6d
|
7
|
+
data.tar.gz: 0b6f87527cf3fa4034b080423a3c195a56c34de80cc3069b103710a14af562e46e446da2e65fbb2f7df62e424be9e6623924f4087b343767617ebb0bfa091be3
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,12 @@ 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.4.8 (2018 May 21)
|
7
|
+
-------------------
|
8
|
+
* Change default IP address lookup from :freegeoip to :ipinfo_io.
|
9
|
+
* Add support for :ipstack lookup (thanks github.com/Heath101).
|
10
|
+
* Fix incompatibility with redis-rb gem v4.0.
|
11
|
+
|
6
12
|
1.4.7 (2018 Mar 13)
|
7
13
|
-------------------
|
8
14
|
* Allow HTTP protocol for Nominatim.
|
data/README.md
CHANGED
@@ -327,7 +327,7 @@ If you're familiar with the results returned by the geocoding service you're usi
|
|
327
327
|
Geocoding Service ("Lookup") Configuration
|
328
328
|
------------------------------------------
|
329
329
|
|
330
|
-
Geocoder supports a variety of street and IP address geocoding services. The default lookups are `:google` for street addresses and `:
|
330
|
+
Geocoder supports a variety of street and IP address geocoding services. The default lookups are `:google` for street addresses and `:ipinfo_io` for IP addresses. Please see the listing and comparison below for details on specific geocoding services (not all settings are supported by all services).
|
331
331
|
|
332
332
|
To create a Rails initializer with an example configuration:
|
333
333
|
|
@@ -477,7 +477,7 @@ The [Google Places Search API](https://developers.google.com/places/web-service/
|
|
477
477
|
* **API key**: none
|
478
478
|
* **Quota**: 1 request/second
|
479
479
|
* **Region**: world
|
480
|
-
* **SSL support**:
|
480
|
+
* **SSL support**: yes
|
481
481
|
* **Languages**: ?
|
482
482
|
* **Documentation**: http://wiki.openstreetmap.org/wiki/Nominatim
|
483
483
|
* **Terms of Service**: http://wiki.openstreetmap.org/wiki/Nominatim_usage_policy
|
@@ -753,7 +753,17 @@ This uses the PostcodeAnywhere UK Geocode service, this will geocode any string
|
|
753
753
|
|
754
754
|
### IP Address Services
|
755
755
|
|
756
|
-
####
|
756
|
+
#### IPInfo.io (`:ipinfo_io`)
|
757
|
+
|
758
|
+
* **API key**: optional - see http://ipinfo.io/pricing
|
759
|
+
* **Quota**: 1,000/day - more with api key
|
760
|
+
* **Region**: world
|
761
|
+
* **SSL support**: no (not without access key - see http://ipinfo.io/pricing)
|
762
|
+
* **Languages**: English
|
763
|
+
* **Documentation**: http://ipinfo.io/developers
|
764
|
+
* **Terms of Service**: http://ipinfo.io/developers
|
765
|
+
|
766
|
+
#### FreeGeoIP (`:freegeoip`) - [DISCONTINUED](https://github.com/alexreisner/geocoder/wiki/Freegeoip-Discontinuation)
|
757
767
|
|
758
768
|
* **API key**: none
|
759
769
|
* **Quota**: 15,000 requests per hour. After reaching the hourly quota, all of your requests will result in HTTP 403 (Forbidden) until it clears up on the next roll over.
|
@@ -826,15 +836,17 @@ This uses the PostcodeAnywhere UK Geocode service, this will geocode any string
|
|
826
836
|
* **Limitations**: ?
|
827
837
|
* **Notes**: You must specify which MaxMind service you are using in your configuration, and also basic authentication. For example: `Geocoder.configure(:maxmind_geoip2 => {:service => :country, :basic_auth => {:user => '', :password => ''}})`.
|
828
838
|
|
829
|
-
####
|
839
|
+
#### Ipstack (`:ipstack`)
|
830
840
|
|
831
|
-
* **API key**:
|
832
|
-
* **Quota**:
|
841
|
+
* **API key**: required (see https://ipstack.com/product)
|
842
|
+
* **Quota**: 10,000 requests per month (with free API Key, 50,000/day and up for paid plans)
|
833
843
|
* **Region**: world
|
834
|
-
* **SSL support**:
|
835
|
-
* **Languages**: English
|
836
|
-
* **Documentation**:
|
837
|
-
* **Terms of Service**:
|
844
|
+
* **SSL support**: yes ( only with paid plan )
|
845
|
+
* **Languages**: English, German, Spanish, French, Japanese, Portugues (Brazil), Russian, Chinese
|
846
|
+
* **Documentation**: https://ipstack.com/documentation
|
847
|
+
* **Terms of Service**: ?
|
848
|
+
* **Limitations**: ?
|
849
|
+
* **Notes**: To use Ipstack set `Geocoder.configure(:ip_lookup => :ipstack, :api_key => "your_ipstack_api_key")`. Supports the optional params: `:hostname`, `:security`, `:fields`, `:language` (see API documentation for details).
|
838
850
|
|
839
851
|
#### IP-API.com (`:ipapi_com`)
|
840
852
|
|
@@ -8,11 +8,11 @@ class AutoexpireCacheRedis
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def [](url)
|
11
|
-
@store.
|
11
|
+
@store.get(url)
|
12
12
|
end
|
13
13
|
|
14
14
|
def []=(url, value)
|
15
|
-
@store.
|
15
|
+
@store.set(url, value)
|
16
16
|
@store.expire(url, @ttl)
|
17
17
|
end
|
18
18
|
|
@@ -25,4 +25,4 @@ class AutoexpireCacheRedis
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
-
Geocoder.configure(:cache => AutoexpireCacheRedis.new(Redis.new))
|
28
|
+
Geocoder.configure(:cache => AutoexpireCacheRedis.new(Redis.new))
|
@@ -2,7 +2,7 @@ Geocoder.configure(
|
|
2
2
|
# Geocoding options
|
3
3
|
# timeout: 3, # geocoding service timeout (secs)
|
4
4
|
# lookup: :google, # name of geocoding service (symbol)
|
5
|
-
# ip_lookup: :
|
5
|
+
# ip_lookup: :ipinfo_io, # name of IP address geocoding service (symbol)
|
6
6
|
# language: :en, # ISO-639 language code
|
7
7
|
# use_https: false, # use HTTPS for lookup requests? (if supported)
|
8
8
|
# http_proxy: nil, # HTTP proxy server (user:pass@host:port)
|
data/lib/geocoder/cache.rb
CHANGED
@@ -98,7 +98,7 @@ module Geocoder
|
|
98
98
|
# geocoding options
|
99
99
|
@data[:timeout] = 3 # geocoding service timeout (secs)
|
100
100
|
@data[:lookup] = :google # name of street address geocoding service (symbol)
|
101
|
-
@data[:ip_lookup] = :
|
101
|
+
@data[:ip_lookup] = :ipinfo_io # name of IP address geocoding service (symbol)
|
102
102
|
@data[:language] = :en # ISO-639 language code
|
103
103
|
@data[:http_headers] = {} # HTTP headers for lookup
|
104
104
|
@data[:use_https] = false # use HTTPS for lookup requests? (if supported)
|
data/lib/geocoder/lookup.rb
CHANGED
@@ -10,7 +10,7 @@ module Geocoder::Lookup
|
|
10
10
|
|
11
11
|
def query_url(query)
|
12
12
|
path = query.reverse_geocode? ? "reverse" : "geocode"
|
13
|
-
"#{protocol}://api.geocod.io/v1.
|
13
|
+
"#{protocol}://api.geocod.io/v1.3/#{path}?#{url_query_string(query)}"
|
14
14
|
end
|
15
15
|
|
16
16
|
def results(query)
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'geocoder/lookups/base'
|
2
|
+
require 'geocoder/results/ipstack'
|
3
|
+
|
4
|
+
module Geocoder::Lookup
|
5
|
+
class Ipstack < Base
|
6
|
+
|
7
|
+
ERROR_CODES = {
|
8
|
+
404 => Geocoder::InvalidRequest,
|
9
|
+
101 => Geocoder::InvalidApiKey,
|
10
|
+
102 => Geocoder::Error,
|
11
|
+
103 => Geocoder::InvalidRequest,
|
12
|
+
104 => Geocoder::OverQueryLimitError,
|
13
|
+
105 => Geocoder::RequestDenied,
|
14
|
+
301 => Geocoder::InvalidRequest,
|
15
|
+
302 => Geocoder::InvalidRequest,
|
16
|
+
303 => Geocoder::RequestDenied,
|
17
|
+
}
|
18
|
+
ERROR_CODES.default = Geocoder::Error
|
19
|
+
|
20
|
+
def name
|
21
|
+
"Ipstack"
|
22
|
+
end
|
23
|
+
|
24
|
+
def query_url(query)
|
25
|
+
extra_params = url_query_string(query)
|
26
|
+
url = "#{protocol}://#{host}/#{query.sanitized_text}?access_key=#{api_key}"
|
27
|
+
url << "&#{extra_params}" unless extra_params.empty?
|
28
|
+
url
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def results(query)
|
34
|
+
# don't look up a loopback address, just return the stored result
|
35
|
+
return [reserved_result(query.text)] if query.loopback_ip_address?
|
36
|
+
|
37
|
+
return [] unless doc = fetch_data(query)
|
38
|
+
|
39
|
+
if error = doc['error']
|
40
|
+
code = error['code']
|
41
|
+
msg = error['info']
|
42
|
+
raise_error(ERROR_CODES[code], msg ) || Geocoder.log(:warn, "Ipstack Geocoding API error: #{msg}")
|
43
|
+
return []
|
44
|
+
end
|
45
|
+
[doc]
|
46
|
+
end
|
47
|
+
|
48
|
+
def reserved_result(ip)
|
49
|
+
{
|
50
|
+
"ip" => ip,
|
51
|
+
"country_name" => "Reserved",
|
52
|
+
"country_code" => "RD"
|
53
|
+
}
|
54
|
+
end
|
55
|
+
|
56
|
+
def host
|
57
|
+
configuration[:host] || "api.ipstack.com"
|
58
|
+
end
|
59
|
+
|
60
|
+
def api_key
|
61
|
+
configuration.api_key
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -14,9 +14,9 @@ module Geocoder::Lookup
|
|
14
14
|
|
15
15
|
def query_url(query)
|
16
16
|
if configuration[:host]
|
17
|
-
"#{protocol}://#{configuration[:host]}/
|
17
|
+
"#{protocol}://#{configuration[:host]}/location/#{query.sanitized_text}"
|
18
18
|
else
|
19
|
-
"#{protocol}://telize-v1.p.mashape.com/
|
19
|
+
"#{protocol}://telize-v1.p.mashape.com/location/#{query.sanitized_text}?mashape-key=#{api_key}"
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
@@ -50,6 +50,6 @@ module Geocoder::Lookup
|
|
50
50
|
def api_key
|
51
51
|
configuration.api_key
|
52
52
|
end
|
53
|
-
|
53
|
+
|
54
54
|
end
|
55
55
|
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'geocoder/results/base'
|
2
|
+
|
3
|
+
module Geocoder::Result
|
4
|
+
class Ipstack < Base
|
5
|
+
|
6
|
+
def address(format = :full)
|
7
|
+
s = region_code.empty? ? "" : ", #{region_code}"
|
8
|
+
"#{city}#{s} #{zip}, #{country_name}".sub(/^[ ,]*/, "")
|
9
|
+
end
|
10
|
+
|
11
|
+
def state
|
12
|
+
@data['region_name']
|
13
|
+
end
|
14
|
+
|
15
|
+
def state_code
|
16
|
+
@data['region_code']
|
17
|
+
end
|
18
|
+
|
19
|
+
def country
|
20
|
+
@data['country_name']
|
21
|
+
end
|
22
|
+
|
23
|
+
def postal_code
|
24
|
+
@data['zip'] || @data['zipcode'] || @data['zip_code']
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.response_attributes
|
28
|
+
[
|
29
|
+
['ip', ''],
|
30
|
+
['hostname', ''],
|
31
|
+
['continent_code', ''],
|
32
|
+
['continent_name', ''],
|
33
|
+
['country_code', ''],
|
34
|
+
['country_name', ''],
|
35
|
+
['region_code', ''],
|
36
|
+
['region_name', ''],
|
37
|
+
['city', ''],
|
38
|
+
['zip', ''],
|
39
|
+
['latitude', 0],
|
40
|
+
['longitude', 0],
|
41
|
+
['location', {}],
|
42
|
+
['time_zone', {}],
|
43
|
+
['currency', {}],
|
44
|
+
['connection', {}],
|
45
|
+
['security', {}],
|
46
|
+
]
|
47
|
+
end
|
48
|
+
|
49
|
+
response_attributes.each do |attr, default|
|
50
|
+
define_method attr do
|
51
|
+
@data[attr] || default
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def metro_code
|
56
|
+
Geocoder.log(:warn, "Ipstack does not implement `metro_code` in api results. Please discontinue use.")
|
57
|
+
0 # no longer implemented by ipstack
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
data/lib/geocoder/stores/base.rb
CHANGED
@@ -90,7 +90,7 @@ module Geocoder
|
|
90
90
|
return
|
91
91
|
end
|
92
92
|
|
93
|
-
query_options = [:lookup, :ip_lookup, :language].inject({}) do |hash, key|
|
93
|
+
query_options = [:lookup, :ip_lookup, :language, :params].inject({}) do |hash, key|
|
94
94
|
if options.has_key?(key)
|
95
95
|
val = options[key]
|
96
96
|
hash[key] = val.respond_to?(:call) ? val.call(self) : val
|
data/lib/geocoder/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: geocoder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Reisner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-05-21 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Provides object geocoding (by street or IP address), reverse geocoding
|
14
14
|
(coordinates to street address), distance queries for ActiveRecord and Mongoid,
|
@@ -71,6 +71,7 @@ files:
|
|
71
71
|
- lib/geocoder/lookups/ipapi_com.rb
|
72
72
|
- lib/geocoder/lookups/ipdata_co.rb
|
73
73
|
- lib/geocoder/lookups/ipinfo_io.rb
|
74
|
+
- lib/geocoder/lookups/ipstack.rb
|
74
75
|
- lib/geocoder/lookups/latlon.rb
|
75
76
|
- lib/geocoder/lookups/location_iq.rb
|
76
77
|
- lib/geocoder/lookups/mapbox.rb
|
@@ -122,6 +123,7 @@ files:
|
|
122
123
|
- lib/geocoder/results/ipapi_com.rb
|
123
124
|
- lib/geocoder/results/ipdata_co.rb
|
124
125
|
- lib/geocoder/results/ipinfo_io.rb
|
126
|
+
- lib/geocoder/results/ipstack.rb
|
125
127
|
- lib/geocoder/results/latlon.rb
|
126
128
|
- lib/geocoder/results/location_iq.rb
|
127
129
|
- lib/geocoder/results/mapbox.rb
|
@@ -159,7 +161,11 @@ licenses:
|
|
159
161
|
metadata:
|
160
162
|
source_code_uri: https://github.com/alexreisner/geocoder
|
161
163
|
changelog_uri: https://github.com/alexreisner/geocoder/blob/master/CHANGELOG.md
|
162
|
-
post_install_message:
|
164
|
+
post_install_message: |2+
|
165
|
+
|
166
|
+
|
167
|
+
NOTE: Geocoder's default IP address lookup has changed from FreeGeoIP.net to IPInfo.io. If you explicitly specify :freegeoip in your configuration you must choose a different IP lookup before FreeGeoIP is discontinued on July 1, 2018. If you do not explicitly specify :freegeoip you do not need to change anything.
|
168
|
+
|
163
169
|
rdoc_options: []
|
164
170
|
require_paths:
|
165
171
|
- lib
|