geokit 1.7.0 → 1.7.1
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 +8 -8
- data/CHANGELOG.md +4 -0
- data/README.markdown +1 -1
- data/lib/geokit.rb +0 -3
- data/lib/geokit/geocoders.rb +4 -4
- data/lib/geokit/services/fcc.rb +1 -1
- data/lib/geokit/services/geonames.rb +2 -2
- data/lib/geokit/services/maxmind.rb +0 -2
- data/lib/geokit/services/us_geocoder.rb +2 -2
- data/lib/geokit/version.rb +1 -1
- data/test/test_geoplugin_geocoder.rb +5 -5
- data/test/test_inflector.rb +1 -1
- data/test/test_ipgeocoder.rb +14 -14
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MWVmODZiMjVhMTFlZjYwNGViY2EzYTBjNWQwMjMyNmE0MWRkMTMwZA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YTc2ZmM1N2FkOGM0OTM3ODU1ZWE5ZjQ0NjAxMjdhMDRiM2NkZGY3NA==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
Njg0YTQwYzRmMTIxZDhiYWVjMDJhZDI0M2UxNjYyNGNjZDc0NzI0NzNhMjcx
|
10
|
+
MTJkYjlhMmEyMzc3MDQwODIyZTIxOGE3NTkwOWVkOTgzMmU0YzgzYmU2ZDhi
|
11
|
+
Y2UwNDhhODM0NjkyODhjOGFjMTcwMTEyOTgxZDg1YjM4ZGYzN2Y=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
OWYwOGNjZTRmYjJhODg0NzMxMWQ2MDg2Y2UyMGUxMGNlYzU2YmU0YzJjNTk3
|
14
|
+
YzdhM2JmMjYwMWIzZGU0ZWE3NDU0YWEyMWI3ZTQ2M2U4ZjRlNGE5NzEzY2M0
|
15
|
+
N2Y1NDNiMzA2NjZlOGM3MTg0ZDk5YTM3ZWI0YTQwZjQ4NjFlY2E=
|
data/CHANGELOG.md
CHANGED
data/README.markdown
CHANGED
@@ -11,7 +11,7 @@ Geokit
|
|
11
11
|
|
12
12
|
The Geokit gem provides:
|
13
13
|
|
14
|
-
* Distance calculations between two points on the earth. Calculate the distance in miles, kilometers, or nautical miles, with all the trigonometry abstracted away by
|
14
|
+
* Distance calculations between two points on the earth. Calculate the distance in miles, kilometers, or nautical miles, with all the trigonometry abstracted away by Geokit.
|
15
15
|
* Geocoding from multiple providers. It supports Google, Yahoo, Geocoder.us, and Geocoder.ca geocoders, and others. It provides a uniform response structure from all of them.
|
16
16
|
It also provides a fail-over mechanism, in case your input fails to geocode in one service.
|
17
17
|
* Rectangular bounds calculations: is a point within a given rectangular bounds?
|
data/lib/geokit.rb
CHANGED
data/lib/geokit/geocoders.rb
CHANGED
@@ -136,10 +136,10 @@ module Geokit
|
|
136
136
|
req = Net::HTTP::Get.new(url)
|
137
137
|
req.basic_auth(uri.user, uri.password) if uri.userinfo
|
138
138
|
res = Net::HTTP::new(uri.host, uri.port,
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
139
|
+
Geokit::Geocoders::proxy_addr,
|
140
|
+
Geokit::Geocoders::proxy_port,
|
141
|
+
Geokit::Geocoders::proxy_user,
|
142
|
+
Geokit::Geocoders::proxy_pass).start { |http| http.request(req) }
|
143
143
|
return res
|
144
144
|
end
|
145
145
|
|
data/lib/geokit/services/fcc.rb
CHANGED
@@ -13,8 +13,8 @@ module Geokit
|
|
13
13
|
address_str.gsub!(/,/, " ")
|
14
14
|
params = "/postalCodeSearch?placename=#{Geokit::Inflector::url_escape(address_str)}&maxRows=10"
|
15
15
|
|
16
|
-
if(
|
17
|
-
url = "http://ws.geonames.net#{params}&username=#{
|
16
|
+
if(Geokit::Geocoders::geonames)
|
17
|
+
url = "http://ws.geonames.net#{params}&username=#{Geokit::Geocoders::geonames}"
|
18
18
|
else
|
19
19
|
url = "http://ws.geonames.org#{params}"
|
20
20
|
end
|
@@ -10,8 +10,8 @@ module Geokit
|
|
10
10
|
address_str = address.is_a?(GeoLoc) ? address.to_geocodeable_s : address
|
11
11
|
|
12
12
|
query = (address_str =~ /^\d{5}(?:-\d{4})?$/ ? "zip" : "address") + "=#{Geokit::Inflector::url_escape(address_str)}"
|
13
|
-
url = if
|
14
|
-
"http://#{
|
13
|
+
url = if Geokit::Geocoders::geocoder_us
|
14
|
+
"http://#{Geokit::Geocoders::geocoder_us}@geocoder.us/member/service/csv/geocode"
|
15
15
|
else
|
16
16
|
"http://geocoder.us/service/csv/geocode"
|
17
17
|
end
|
data/lib/geokit/version.rb
CHANGED
@@ -29,8 +29,8 @@ class IpGeocoderTest < BaseGeocoderTest #:nodoc: all
|
|
29
29
|
success = MockSuccess.new
|
30
30
|
success.expects(:body).returns(IP_SUCCESS)
|
31
31
|
url = 'http://www.geoplugin.net/xml.gp?ip=200.150.38.66'
|
32
|
-
|
33
|
-
location =
|
32
|
+
Geokit::Geocoders::GeoPluginGeocoder.expects(:call_geocoder_service).with(url).returns(success)
|
33
|
+
location = Geokit::Geocoders::GeoPluginGeocoder.geocode('200.150.38.66')
|
34
34
|
assert_not_nil location
|
35
35
|
assert_equal(-19.916700, location.lat)
|
36
36
|
assert_equal(-43.933300, location.lng)
|
@@ -42,7 +42,7 @@ class IpGeocoderTest < BaseGeocoderTest #:nodoc: all
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def test_invalid_ip
|
45
|
-
location =
|
45
|
+
location = Geokit::Geocoders::GeoPluginGeocoder.geocode("pixrum")
|
46
46
|
assert_not_nil location
|
47
47
|
assert !location.success?
|
48
48
|
end
|
@@ -50,8 +50,8 @@ class IpGeocoderTest < BaseGeocoderTest #:nodoc: all
|
|
50
50
|
def test_service_unavailable
|
51
51
|
failure = MockFailure.new
|
52
52
|
url = 'http://www.geoplugin.net/xml.gp?ip=10.10.10.10'
|
53
|
-
|
54
|
-
location =
|
53
|
+
Geokit::Geocoders::GeoPluginGeocoder.expects(:call_geocoder_service).with(url).returns(failure)
|
54
|
+
location = Geokit::Geocoders::GeoPluginGeocoder.geocode("10.10.10.10")
|
55
55
|
assert_not_nil location
|
56
56
|
assert !location.success?
|
57
57
|
end
|
data/test/test_inflector.rb
CHANGED
@@ -20,7 +20,7 @@ class InflectorTest < Test::Unit::TestCase #:nodoc: all
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def test_url_escape
|
23
|
-
assert_equal '%E4%B8%8A%E6%B5%B7%E5%B8%82%E5%BE%90%E6%B1%87%E5%8C%BA%E6%BC%95%E6%BA%AA%E5%8C%97%E8%B7%AF1111%E5%8F%B7',
|
23
|
+
assert_equal '%E4%B8%8A%E6%B5%B7%E5%B8%82%E5%BE%90%E6%B1%87%E5%8C%BA%E6%BC%95%E6%BA%AA%E5%8C%97%E8%B7%AF1111%E5%8F%B7', Geokit::Inflector.url_escape('上海市徐汇区漕溪北路1111号')
|
24
24
|
assert_equal '%C3%BC%C3%B6%C3%A4', Geokit::Inflector.url_escape('üöä')
|
25
25
|
end
|
26
26
|
end
|
data/test/test_ipgeocoder.rb
CHANGED
@@ -52,8 +52,8 @@ class IpGeocoderTest < BaseGeocoderTest #:nodoc: all
|
|
52
52
|
success = MockSuccess.new
|
53
53
|
success.expects(:body).returns(IP_SUCCESS)
|
54
54
|
url = 'http://api.hostip.info/get_html.php?ip=12.215.42.19&position=true'
|
55
|
-
|
56
|
-
location =
|
55
|
+
Geokit::Geocoders::IpGeocoder.expects(:call_geocoder_service).with(url).returns(success)
|
56
|
+
location = Geokit::Geocoders::IpGeocoder.geocode('12.215.42.19')
|
57
57
|
assert_not_nil location
|
58
58
|
assert_equal 41.7696, location.lat
|
59
59
|
assert_equal(-88.4588, location.lng)
|
@@ -68,8 +68,8 @@ class IpGeocoderTest < BaseGeocoderTest #:nodoc: all
|
|
68
68
|
success = MockSuccess.new
|
69
69
|
success.expects(:body).returns(IP_UNICODED)
|
70
70
|
url = 'http://api.hostip.info/get_html.php?ip=12.215.42.19&position=true'
|
71
|
-
|
72
|
-
location =
|
71
|
+
Geokit::Geocoders::IpGeocoder.expects(:call_geocoder_service).with(url).returns(success)
|
72
|
+
location = Geokit::Geocoders::IpGeocoder.geocode('12.215.42.19')
|
73
73
|
assert_not_nil location
|
74
74
|
assert_equal 57.7167, location.lat
|
75
75
|
assert_equal 12.9167, location.lng
|
@@ -85,8 +85,8 @@ class IpGeocoderTest < BaseGeocoderTest #:nodoc: all
|
|
85
85
|
success.stubs(:body).returns(IP_LATIN)
|
86
86
|
success.stubs(:[]).with('content-type').returns('text/plain; charset=iso-8859-1')
|
87
87
|
url = 'http://api.hostip.info/get_html.php?ip=201.23.177.144&position=true'
|
88
|
-
|
89
|
-
location =
|
88
|
+
Geokit::Geocoders::IpGeocoder.expects(:call_geocoder_service).with(url).returns(success)
|
89
|
+
location = Geokit::Geocoders::IpGeocoder.geocode('201.23.177.144')
|
90
90
|
assert_not_nil location
|
91
91
|
assert_equal -20.8, location.lat
|
92
92
|
assert_equal -49.3833, location.lng
|
@@ -101,24 +101,24 @@ class IpGeocoderTest < BaseGeocoderTest #:nodoc: all
|
|
101
101
|
failure = MockSuccess.new
|
102
102
|
failure.expects(:body).returns(IP_FAILURE)
|
103
103
|
url = 'http://api.hostip.info/get_html.php?ip=128.178.0.0&position=true'
|
104
|
-
|
105
|
-
location =
|
104
|
+
Geokit::Geocoders::IpGeocoder.expects(:call_geocoder_service).with(url).returns(failure)
|
105
|
+
location = Geokit::Geocoders::IpGeocoder.geocode("128.178.0.0")
|
106
106
|
assert_not_nil location
|
107
107
|
assert !location.success?
|
108
108
|
end
|
109
109
|
|
110
110
|
def test_private_ips
|
111
|
-
|
111
|
+
Geokit::Geocoders::IpGeocoder.expects(:call_geocoder_service).never
|
112
112
|
PRIVATE_IPS_TO_TEST.each do |ip|
|
113
|
-
location =
|
113
|
+
location = Geokit::Geocoders::IpGeocoder.geocode(ip)
|
114
114
|
assert_not_nil location
|
115
115
|
assert !location.success?
|
116
116
|
end
|
117
117
|
end
|
118
118
|
|
119
119
|
def test_invalid_ip
|
120
|
-
|
121
|
-
location =
|
120
|
+
Geokit::Geocoders::IpGeocoder.expects(:call_geocoder_service).never
|
121
|
+
location = Geokit::Geocoders::IpGeocoder.geocode("blah")
|
122
122
|
assert_not_nil location
|
123
123
|
assert !location.success?
|
124
124
|
end
|
@@ -126,8 +126,8 @@ class IpGeocoderTest < BaseGeocoderTest #:nodoc: all
|
|
126
126
|
def test_service_unavailable
|
127
127
|
failure = MockFailure.new
|
128
128
|
url = 'http://api.hostip.info/get_html.php?ip=12.215.42.19&position=true'
|
129
|
-
|
130
|
-
location =
|
129
|
+
Geokit::Geocoders::IpGeocoder.expects(:call_geocoder_service).with(url).returns(failure)
|
130
|
+
location = Geokit::Geocoders::IpGeocoder.geocode("12.215.42.19")
|
131
131
|
assert_not_nil location
|
132
132
|
assert !location.success?
|
133
133
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: geokit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.7.
|
4
|
+
version: 1.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Noack, James Cox, Andre Lewis & Bill Eisenhauer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-11-
|
11
|
+
date: 2013-11-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: multi_json
|