geocoder 1.2.2 → 1.2.3
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/.travis.yml +2 -2
- data/CHANGELOG.md +5 -0
- data/README.md +24 -7
- data/lib/geocoder/lookup.rb +2 -1
- data/lib/geocoder/lookups/bing.rb +10 -5
- data/lib/geocoder/lookups/telize.rb +36 -0
- data/lib/geocoder/results/telize.rb +45 -0
- data/lib/geocoder/version.rb +1 -1
- data/test/fixtures/telize_10_10_10_10 +1 -0
- data/test/fixtures/telize_555_555_555_555 +4 -0
- data/test/fixtures/telize_74_200_247_59 +1 -0
- data/test/fixtures/telize_no_results +1 -0
- data/test/test_helper.rb +7 -0
- data/test/unit/lookup_test.rb +1 -1
- data/test/unit/lookups/bing_test.rb +1 -1
- data/test/unit/lookups/telize_test.rb +30 -0
- metadata +9 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 29ab290c8d6f4d7604e92add7c07f37b47b9f7c1
|
4
|
+
data.tar.gz: 6cbd84ac0eac3f768f68e69024232c3ab489ee48
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 29cebb43ee5215ccf28154c5e8f41985f5079cc6f765fedfae222e17379ecad604977ec5fc92f1f5ba9dd17c7d26f60c96df9a6b8372eced7d5a7814dc4b1c0b
|
7
|
+
data.tar.gz: 07e490262d72393456d1915dfb054b16448e454a6f14f1e910a21758547b73c6e03abd2dfa66a7b8966ec6758e91bd0ea3d1d00ee1a077b0202071ed59155acb
|
data/.travis.yml
CHANGED
@@ -2,7 +2,7 @@ rvm:
|
|
2
2
|
- 1.9.2
|
3
3
|
- 1.9.3
|
4
4
|
- 2.0.0
|
5
|
-
- 2.1.
|
5
|
+
- 2.1.2
|
6
6
|
- jruby-19mode
|
7
7
|
- rbx-2
|
8
8
|
gemfile:
|
@@ -20,7 +20,7 @@ matrix:
|
|
20
20
|
- rvm: 2.0.0
|
21
21
|
gemfile: gemfiles/Gemfile.mongoid-2.4.x
|
22
22
|
env: SSL_CERT_DIR=/etc/ssl/certs
|
23
|
-
- rvm: 2.1.
|
23
|
+
- rvm: 2.1.2
|
24
24
|
gemfile: gemfiles/Gemfile.mongoid-2.4.x
|
25
25
|
env: SSL_CERT_DIR=/etc/ssl/certs
|
26
26
|
- rvm: jruby-19mode
|
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.2.3 (2014 June 11)
|
7
|
+
|
8
|
+
* Add Telize IP address lookup (thanks github.com/lukeroberts1990).
|
9
|
+
* Fix bug in Bing reverse geocoding (thanks github.com/nickelser).
|
10
|
+
|
6
11
|
1.2.2 (2014 Jun 12)
|
7
12
|
|
8
13
|
* Add ability to specify language per query (thanks github.com/mkristian).
|
data/README.md
CHANGED
@@ -306,7 +306,13 @@ If you're familiar with the results returned by the geocoding service you're usi
|
|
306
306
|
Geocoding Service ("Lookup") Configuration
|
307
307
|
------------------------------------------
|
308
308
|
|
309
|
-
Geocoder supports a variety of street and IP address geocoding services. The default lookups are `:google` for street addresses and `:freegeoip` for IP addresses. Please see the listing and comparison below for details on specific geocoding services (not all settings are supported by all services).
|
309
|
+
Geocoder supports a variety of street and IP address geocoding services. The default lookups are `:google` for street addresses and `:freegeoip` for IP addresses. Please see the listing and comparison below for details on specific geocoding services (not all settings are supported by all services).
|
310
|
+
|
311
|
+
To create a Rails initializer with an example configuration:
|
312
|
+
|
313
|
+
rails generate geocoder:config
|
314
|
+
|
315
|
+
Some common configuration options are:
|
310
316
|
|
311
317
|
# config/initializers/geocoder.rb
|
312
318
|
Geocoder.configure(
|
@@ -576,7 +582,18 @@ Data Science Toolkit provides an API whose reponse format is like Google's but w
|
|
576
582
|
* **Documentation**: http://github.com/fiorix/freegeoip/blob/master/README.md
|
577
583
|
* **Terms of Service**: ?
|
578
584
|
* **Limitations**: ?
|
579
|
-
* **Notes**: If you are running your own local instance of the FreeGeoIP service you can configure the host like this: `Geocoder.configure(freegeoip: {host: "..."})`.
|
585
|
+
* **Notes**: If you are [running your own local instance of the FreeGeoIP service](https://github.com/fiorix/freegeoip) you can configure the host like this: `Geocoder.configure(freegeoip: {host: "..."})`.
|
586
|
+
|
587
|
+
#### Telize (`:telize`)
|
588
|
+
|
589
|
+
* **API key**: none
|
590
|
+
* **Quota**: none
|
591
|
+
* **Region**: world
|
592
|
+
* **SSL support**: no
|
593
|
+
* **Languages**: English
|
594
|
+
* **Documentation**: http://www.telize.com/
|
595
|
+
* **Terms of Service**: ?
|
596
|
+
* **Limitations**: ?
|
580
597
|
|
581
598
|
#### MaxMind Web Services (`:maxmind`)
|
582
599
|
|
@@ -614,12 +631,12 @@ This lookup provides methods for geocoding IP addresses without making a call to
|
|
614
631
|
|
615
632
|
You can generate ActiveRecord migrations and download and import data via provided rake tasks:
|
616
633
|
|
617
|
-
rails generate geocoder:maxmind:
|
634
|
+
rails generate geocoder:maxmind:geolite PACKAGE=city
|
618
635
|
|
619
|
-
rake geocoder:maxmind:
|
620
|
-
rake geocoder:maxmind:
|
621
|
-
rake geocoder:maxmind:
|
622
|
-
rake geocoder:maxmind:
|
636
|
+
rake geocoder:maxmind:geolite:download PACKAGE=city
|
637
|
+
rake geocoder:maxmind:geolite:extract PACKAGE=city
|
638
|
+
rake geocoder:maxmind:geolite:insert PACKAGE=city
|
639
|
+
rake geocoder:maxmind:geolite:load PACKAGE=city # runs the above three in sequence
|
623
640
|
|
624
641
|
You can replace `city` with `country` in any of the above tasks, generators, and configurations.
|
625
642
|
|
data/lib/geocoder/lookup.rb
CHANGED
@@ -24,12 +24,17 @@ module Geocoder::Lookup
|
|
24
24
|
|
25
25
|
def base_url(query)
|
26
26
|
url = "#{protocol}://dev.virtualearth.net/REST/v1/Locations"
|
27
|
-
|
28
|
-
|
27
|
+
|
28
|
+
if !query.reverse_geocode?
|
29
|
+
if r = query.options[:region]
|
30
|
+
url << "/#{r}"
|
31
|
+
end
|
32
|
+
# use the more forgiving 'unstructured' query format to allow special
|
33
|
+
# chars, newlines, brackets, typos.
|
34
|
+
url + "?q=" + URI.escape(query.sanitized_text.strip) + "&"
|
35
|
+
else
|
36
|
+
url + "/#{URI.escape(query.sanitized_text.strip)}?"
|
29
37
|
end
|
30
|
-
# use the more forgiving 'unstructured' query format to allow special
|
31
|
-
# chars, newlines, brackets, typos.
|
32
|
-
url + "?q=" + URI.escape(query.sanitized_text.strip) + "&"
|
33
38
|
end
|
34
39
|
|
35
40
|
def results(query)
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'geocoder/lookups/base'
|
2
|
+
require 'geocoder/results/telize'
|
3
|
+
|
4
|
+
module Geocoder::Lookup
|
5
|
+
class Telize < Base
|
6
|
+
|
7
|
+
def name
|
8
|
+
"Telize"
|
9
|
+
end
|
10
|
+
|
11
|
+
def query_url(query)
|
12
|
+
#currently doesn't support HTTPS
|
13
|
+
"http://www.telize.com/geoip/#{query.sanitized_text}"
|
14
|
+
end
|
15
|
+
|
16
|
+
private # ---------------------------------------------------------------
|
17
|
+
|
18
|
+
def results(query)
|
19
|
+
# don't look up a loopback address, just return the stored result
|
20
|
+
return [reserved_result(query.text)] if query.loopback_ip_address?
|
21
|
+
if (doc = fetch_data(query)).nil? or doc['code'] == 401 or empty_result?(doc)
|
22
|
+
[]
|
23
|
+
else
|
24
|
+
[doc]
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def empty_result?(doc)
|
29
|
+
!doc.is_a?(Hash) or doc.keys == ["ip"]
|
30
|
+
end
|
31
|
+
|
32
|
+
def reserved_result(ip)
|
33
|
+
{"message" => "Input string is not a valid IP address", "code" => 401}
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'geocoder/results/base'
|
2
|
+
|
3
|
+
module Geocoder::Result
|
4
|
+
class Telize < Base
|
5
|
+
|
6
|
+
def address(format = :full)
|
7
|
+
s = state_code.to_s == "" ? "" : ", #{state_code}"
|
8
|
+
"#{city}#{s} #{postal_code}, #{country}".sub(/^[ ,]*/, "")
|
9
|
+
end
|
10
|
+
|
11
|
+
def city
|
12
|
+
@data['city']
|
13
|
+
end
|
14
|
+
|
15
|
+
def state
|
16
|
+
@data['region']
|
17
|
+
end
|
18
|
+
|
19
|
+
def state_code
|
20
|
+
@data['region_code']
|
21
|
+
end
|
22
|
+
|
23
|
+
def country
|
24
|
+
@data['country']
|
25
|
+
end
|
26
|
+
|
27
|
+
def country_code
|
28
|
+
@data['country_code']
|
29
|
+
end
|
30
|
+
|
31
|
+
def postal_code
|
32
|
+
@data['postal_code']
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.response_attributes
|
36
|
+
%w[timezone isp dma_code area_code ip asn continent_code country_code3]
|
37
|
+
end
|
38
|
+
|
39
|
+
response_attributes.each do |a|
|
40
|
+
define_method a do
|
41
|
+
@data[a]
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
data/lib/geocoder/version.rb
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
{"ip":"10.10.10.10"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"timezone":"America\/Chicago","isp":"Layered Technologies, Inc.","region_code":"TX","country":"United States","dma_code":"0","area_code":"0","region":"Texas","ip":"74.200.247.59","asn":"AS22576","continent_code":"NA","city":"Plano","postal_code":"75093","longitude":-96.8134,"latitude":33.0347,"country_code":"US","country_code3":"USA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"ip":"10.10.10.10"}
|
data/test/test_helper.rb
CHANGED
data/test/unit/lookup_test.rb
CHANGED
@@ -23,7 +23,7 @@ class LookupTest < GeocoderTestCase
|
|
23
23
|
|
24
24
|
def test_query_url_contains_values_in_params_hash
|
25
25
|
Geocoder::Lookup.all_services_except_test.each do |l|
|
26
|
-
next if
|
26
|
+
next if [:freegeoip, :maxmind_local, :telize].include? l # does not use query string
|
27
27
|
set_api_key!(l)
|
28
28
|
url = Geocoder::Lookup.get(l).query_url(Geocoder::Query.new(
|
29
29
|
"test", :params => {:one_in_the_hand => "two in the bush"}
|
@@ -12,7 +12,7 @@ class BingTest < GeocoderTestCase
|
|
12
12
|
def test_query_for_reverse_geocode
|
13
13
|
lookup = Geocoder::Lookup::Bing.new
|
14
14
|
url = lookup.query_url(Geocoder::Query.new([45.423733, -75.676333]))
|
15
|
-
assert_match(/Locations
|
15
|
+
assert_match(/Locations\/45.423733/, url)
|
16
16
|
end
|
17
17
|
|
18
18
|
def test_result_components
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
$: << File.join(File.dirname(__FILE__), "..", "..")
|
3
|
+
require 'test_helper'
|
4
|
+
|
5
|
+
class TelizeTest < GeocoderTestCase
|
6
|
+
|
7
|
+
def setup
|
8
|
+
Geocoder.configure(ip_lookup: :telize)
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_result_on_ip_address_search
|
12
|
+
result = Geocoder.search("74.200.247.59").first
|
13
|
+
assert result.is_a?(Geocoder::Result::Telize)
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_result_components
|
17
|
+
result = Geocoder.search("74.200.247.59").first
|
18
|
+
assert_equal "Plano, TX 75093, United States", result.address
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_no_results
|
22
|
+
results = Geocoder.search("10.10.10.10")
|
23
|
+
assert_equal 0, results.length
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_invalid_address
|
27
|
+
results = Geocoder.search("555.555.555.555")
|
28
|
+
assert_equal 0, results.length
|
29
|
+
end
|
30
|
+
end
|
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.2.
|
4
|
+
version: 1.2.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: 2014-
|
11
|
+
date: 2014-07-11 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,
|
@@ -67,6 +67,7 @@ files:
|
|
67
67
|
- lib/geocoder/lookups/nominatim.rb
|
68
68
|
- lib/geocoder/lookups/ovi.rb
|
69
69
|
- lib/geocoder/lookups/smarty_streets.rb
|
70
|
+
- lib/geocoder/lookups/telize.rb
|
70
71
|
- lib/geocoder/lookups/test.rb
|
71
72
|
- lib/geocoder/lookups/yahoo.rb
|
72
73
|
- lib/geocoder/lookups/yandex.rb
|
@@ -98,6 +99,7 @@ files:
|
|
98
99
|
- lib/geocoder/results/nominatim.rb
|
99
100
|
- lib/geocoder/results/ovi.rb
|
100
101
|
- lib/geocoder/results/smarty_streets.rb
|
102
|
+
- lib/geocoder/results/telize.rb
|
101
103
|
- lib/geocoder/results/test.rb
|
102
104
|
- lib/geocoder/results/yahoo.rb
|
103
105
|
- lib/geocoder/results/yandex.rb
|
@@ -170,6 +172,10 @@ files:
|
|
170
172
|
- test/fixtures/smarty_streets_11211
|
171
173
|
- test/fixtures/smarty_streets_madison_square_garden
|
172
174
|
- test/fixtures/smarty_streets_no_results
|
175
|
+
- test/fixtures/telize_10_10_10_10
|
176
|
+
- test/fixtures/telize_555_555_555_555
|
177
|
+
- test/fixtures/telize_74_200_247_59
|
178
|
+
- test/fixtures/telize_no_results
|
173
179
|
- test/fixtures/yahoo_error
|
174
180
|
- test/fixtures/yahoo_invalid_key
|
175
181
|
- test/fixtures/yahoo_madison_square_garden
|
@@ -206,6 +212,7 @@ files:
|
|
206
212
|
- test/unit/lookups/maxmind_test.rb
|
207
213
|
- test/unit/lookups/nominatim_test.rb
|
208
214
|
- test/unit/lookups/smarty_streets_test.rb
|
215
|
+
- test/unit/lookups/telize_test.rb
|
209
216
|
- test/unit/lookups/yahoo_test.rb
|
210
217
|
- test/unit/method_aliases_test.rb
|
211
218
|
- test/unit/model_test.rb
|