geocoder 1.3.3 → 1.3.4
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 +5 -0
- data/README.md +16 -7
- data/lib/geocoder/lookup.rb +2 -1
- data/lib/geocoder/lookups/freegeoip.rb +1 -1
- data/lib/geocoder/lookups/ipapi_com.rb +64 -0
- data/lib/geocoder/results/freegeoip.rb +1 -1
- data/lib/geocoder/results/ipapi_com.rb +53 -0
- data/lib/geocoder/results/ipinfo_io.rb +2 -2
- data/lib/geocoder/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d790b89d4257ea08df5cc44f42b141e528ab807b
|
4
|
+
data.tar.gz: d9b4a0cbe6b3f4c709040e9b784cb8e605e5b9ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ecfc4e757b64650f23cb1cbba2aa7294395c5cb1deff2e30f52639951c7392104c4cca299655062558540147ffab088a4d66de5da37cde17e2c0de7cfc60ab61
|
7
|
+
data.tar.gz: 6e60f809ce62c62bbe05522ceb1adeb5f8e6fbbff9e6eea61d934d1362afdc8123525ca30674c000f92b440182a3e6b038b0389a37128dd5a9d5e5bfb715c33b
|
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.3.4 (2016 Apr 14)
|
7
|
+
-------------------
|
8
|
+
* Update :freegeoip host (old one is down).
|
9
|
+
* Add ip-api.com IP address lookup (thanks github.com/piotrgorecki).
|
10
|
+
|
6
11
|
1.3.3 (2016 Apr 4)
|
7
12
|
------------------
|
8
13
|
* Fix incorrect gem version number.
|
data/README.md
CHANGED
@@ -567,28 +567,27 @@ The [Google Places Details API](https://developers.google.com/places/documentati
|
|
567
567
|
|
568
568
|
#### Mapzen (`:mapzen`)
|
569
569
|
|
570
|
-
* **About**: Mapzen is the primary author of pelias and offers Pelias-as-a-service in free and paid versions https://mapzen.com/pelias.
|
571
570
|
* **API key**: required
|
572
571
|
* **Quota**: 6/sec, up to 30k per day, paid plan info at https://mapzen.com/documentation/search/api-keys-rate-limits/#rate-limits
|
573
|
-
* **Region**:
|
572
|
+
* **Region**: world
|
574
573
|
* **SSL support**: yes
|
575
574
|
* **Languages**: en
|
576
575
|
* **Documentation**: https://mapzen.com/documentation/search/search/
|
577
576
|
* **Terms of Service**: http://mapzen.com/terms
|
578
|
-
* **Limitations**:
|
577
|
+
* **Limitations**: ?
|
578
|
+
* **Notes**: Mapzen is the primary author of Pelias and offers Pelias-as-a-service in free and paid versions https://mapzen.com/pelias.
|
579
579
|
|
580
580
|
#### Pelias (`:pelias`)
|
581
581
|
|
582
|
-
* **About**: Pelias is a modular open-source geocoder using ElasticSearch for fast geocoding https://github.com/pelias/pelias.
|
583
582
|
* **API key**: required
|
584
|
-
* **Quota**:
|
585
|
-
* **Region**:
|
583
|
+
* **Quota**: none (self-hosted service)
|
584
|
+
* **Region**: world
|
586
585
|
* **SSL support**: yes
|
587
586
|
* **Languages**: en
|
588
587
|
* **Documentation**: https://mapzen.com/documentation/search/search/
|
589
588
|
* **Terms of Service**: http://mapzen.com/terms
|
590
589
|
* **Limitations**: See terms
|
591
|
-
* **Notes**: Configure your self-hosted pelias with the `endpoint` option: `Geocoder.configure(:lookup => :pelias, :api_key => 'your_api_key', :pelias => {:endpoint => 'self.hosted/pelias'})`.
|
590
|
+
* **Notes**: Configure your self-hosted pelias with the `endpoint` option: `Geocoder.configure(:lookup => :pelias, :api_key => 'your_api_key', :pelias => {:endpoint => 'self.hosted/pelias'})`. Defaults to `localhost`.
|
592
591
|
|
593
592
|
#### Data Science Toolkit (`:dstk`)
|
594
593
|
|
@@ -771,6 +770,16 @@ This uses the PostcodeAnywhere UK Geocode service, this will geocode any string
|
|
771
770
|
* **Documentation**: http://ipinfo.io/developers
|
772
771
|
* **Terms of Service**: http://ipinfo.io/developers
|
773
772
|
|
773
|
+
#### IP-API.com (`:ipapi_com`)
|
774
|
+
|
775
|
+
* **API key**: optional - see http://ip-api.com/docs/#usage_limits
|
776
|
+
* **Quota**: 150/minute - unlimited with api key
|
777
|
+
* **Region**: world
|
778
|
+
* **SSL support**: no (not without access key - see https://signup.ip-api.com/)
|
779
|
+
* **Languages**: English
|
780
|
+
* **Documentation**: http://ip-api.com/docs/
|
781
|
+
* **Terms of Service**: https://signup.ip-api.com/terms
|
782
|
+
|
774
783
|
### IP Address Local Database Services
|
775
784
|
|
776
785
|
#### MaxMind Local (`:maxmind_local`) - EXPERIMENTAL
|
data/lib/geocoder/lookup.rb
CHANGED
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'geocoder/lookups/base'
|
2
|
+
require 'geocoder/results/ipapi_com'
|
3
|
+
|
4
|
+
module Geocoder::Lookup
|
5
|
+
class IpapiCom < Base
|
6
|
+
|
7
|
+
def name
|
8
|
+
"ip-api.com"
|
9
|
+
end
|
10
|
+
|
11
|
+
def query_url(query)
|
12
|
+
url_ = "#{protocol}://ip-api.com/json/#{query.sanitized_text}"
|
13
|
+
|
14
|
+
if (params = url_query_string(query)) && !params.empty?
|
15
|
+
url_ + "?" + params
|
16
|
+
else
|
17
|
+
url_
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def supported_protocols
|
22
|
+
if configuration.api_key
|
23
|
+
[:http, :https]
|
24
|
+
else
|
25
|
+
[:http]
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def results(query)
|
33
|
+
return [reserved_result(query.text)] if query.loopback_ip_address?
|
34
|
+
|
35
|
+
(doc = fetch_data(query)) ? [doc] : []
|
36
|
+
end
|
37
|
+
|
38
|
+
def reserved_result(query)
|
39
|
+
{
|
40
|
+
"message" => "reserved range",
|
41
|
+
"query" => query,
|
42
|
+
"status" => fail,
|
43
|
+
"ip" => query,
|
44
|
+
"city" => "",
|
45
|
+
"region_code" => "",
|
46
|
+
"region_name" => "",
|
47
|
+
"metrocode" => "",
|
48
|
+
"zipcode" => "",
|
49
|
+
"latitude" => "0",
|
50
|
+
"longitude" => "0",
|
51
|
+
"country_name" => "Reserved",
|
52
|
+
"country_code" => "RD"
|
53
|
+
}
|
54
|
+
end
|
55
|
+
|
56
|
+
def query_url_params(query)
|
57
|
+
params = {}
|
58
|
+
params.merge!(fields: configuration[:fields]) if configuration.has_key?(:fields)
|
59
|
+
params.merge!(key: configuration.api_key) if configuration.api_key
|
60
|
+
params.merge(super)
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'geocoder/results/base'
|
2
|
+
|
3
|
+
module Geocoder::Result
|
4
|
+
class IpapiCom < Base
|
5
|
+
|
6
|
+
def latitude
|
7
|
+
lat
|
8
|
+
end
|
9
|
+
|
10
|
+
def longitude
|
11
|
+
lon
|
12
|
+
end
|
13
|
+
|
14
|
+
def coordinates
|
15
|
+
[lat, lon]
|
16
|
+
end
|
17
|
+
|
18
|
+
def address
|
19
|
+
"#{city}, #{state_code} #{postal_code}, #{country}".sub(/^[ ,]*/, "")
|
20
|
+
end
|
21
|
+
|
22
|
+
def state
|
23
|
+
region_name
|
24
|
+
end
|
25
|
+
|
26
|
+
def state_code
|
27
|
+
region
|
28
|
+
end
|
29
|
+
|
30
|
+
def postal_code
|
31
|
+
zip
|
32
|
+
end
|
33
|
+
|
34
|
+
def country_code
|
35
|
+
@data['countryCode']
|
36
|
+
end
|
37
|
+
|
38
|
+
def region_name
|
39
|
+
@data['regionName']
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.response_attributes
|
43
|
+
%w[country region city zip timezone isp org as reverse query status message mobile proxy lat lon]
|
44
|
+
end
|
45
|
+
|
46
|
+
response_attributes.each do |attribute|
|
47
|
+
define_method attribute do
|
48
|
+
@data[attribute]
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
end
|
@@ -16,7 +16,7 @@ module Geocoder::Result
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def coordinates
|
19
|
-
[
|
19
|
+
[latitude, longitude]
|
20
20
|
end
|
21
21
|
|
22
22
|
def city
|
@@ -44,7 +44,7 @@ module Geocoder::Result
|
|
44
44
|
end
|
45
45
|
|
46
46
|
def self.response_attributes
|
47
|
-
%w['ip', '
|
47
|
+
%w['ip', 'region', 'postal']
|
48
48
|
end
|
49
49
|
|
50
50
|
response_attributes.each do |a|
|
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.3.
|
4
|
+
version: 1.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Reisner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-04-
|
11
|
+
date: 2016-04-14 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,
|
@@ -62,6 +62,7 @@ files:
|
|
62
62
|
- lib/geocoder/lookups/google_places_details.rb
|
63
63
|
- lib/geocoder/lookups/google_premier.rb
|
64
64
|
- lib/geocoder/lookups/here.rb
|
65
|
+
- lib/geocoder/lookups/ipapi_com.rb
|
65
66
|
- lib/geocoder/lookups/ipinfo_io.rb
|
66
67
|
- lib/geocoder/lookups/latlon.rb
|
67
68
|
- lib/geocoder/lookups/mapbox.rb
|
@@ -105,6 +106,7 @@ files:
|
|
105
106
|
- lib/geocoder/results/google_places_details.rb
|
106
107
|
- lib/geocoder/results/google_premier.rb
|
107
108
|
- lib/geocoder/results/here.rb
|
109
|
+
- lib/geocoder/results/ipapi_com.rb
|
108
110
|
- lib/geocoder/results/ipinfo_io.rb
|
109
111
|
- lib/geocoder/results/latlon.rb
|
110
112
|
- lib/geocoder/results/mapbox.rb
|