geonames_api 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.travis.yml +0 -1
- data/lib/geonames_api/base.rb +3 -1
- data/lib/geonames_api/error.rb +8 -4
- data/lib/geonames_api/nearest_intersection.rb +9 -0
- data/lib/geonames_api/version.rb +1 -1
- data/spec/geonames_api/nearest_intersection_spec.rb +22 -0
- data/spec/geonames_api/retry_spec.rb +2 -2
- data/spec/spec_helper.rb +1 -1
- metadata +22 -32
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b50c12c8caf88cb16c72e51b02e0899f9f6f76df
|
4
|
+
data.tar.gz: 31bf711659f22e768a31827e15d1577e1d138362
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b09f7294b7b01b99732866b17fb59ae7b96a3065ed06c344a5219cd2737e2f1a6b133ca07d792c05b2b05fcafe63a56d2065bc97697a7df4246b5db7c63f463e
|
7
|
+
data.tar.gz: c6bc4c9b9326f9837f473231280a2f59a57169a46f453d4c21eee6c39d2635daccc15013746f7a777a63789f5d8c68a047c13d28f3d0ff963af9a22b98aee79c
|
data/.travis.yml
CHANGED
data/lib/geonames_api/base.rb
CHANGED
@@ -28,7 +28,9 @@ module GeoNamesAPI
|
|
28
28
|
rescue Timeout => e
|
29
29
|
if retries_remaining > 0
|
30
30
|
retries_remaining -= 1
|
31
|
-
|
31
|
+
sleep_time = rand * GeoNamesAPI.max_sleep_time_between_retries
|
32
|
+
GeoNamesAPI.logger.info("GEONAMES RETRIABLE ERROR: #{e}. Retrying in #{sleep_time}s.") if GeoNamesAPI.logger
|
33
|
+
sleep sleep_time
|
32
34
|
retry
|
33
35
|
else
|
34
36
|
raise e
|
data/lib/geonames_api/error.rb
CHANGED
@@ -23,7 +23,8 @@ module GeoNamesAPI
|
|
23
23
|
ERROR_CODES = [11]
|
24
24
|
end
|
25
25
|
class Timeout < Error
|
26
|
-
|
26
|
+
# 12 is "other error", but is normally "Cannot get a connection, pool error Timeout waiting for idle object"
|
27
|
+
ERROR_CODES = [12, 13, 22]
|
27
28
|
end
|
28
29
|
class InvalidParameter < Error
|
29
30
|
ERROR_CODES = [14]
|
@@ -37,13 +38,16 @@ module GeoNamesAPI
|
|
37
38
|
class PostalCodeNotFound < Error
|
38
39
|
ERROR_CODES = [17]
|
39
40
|
end
|
40
|
-
class
|
41
|
+
class LimitExceeded < Error
|
42
|
+
ERROR_CODES = []
|
43
|
+
end
|
44
|
+
class DailyLimitExceeded < LimitExceeded
|
41
45
|
ERROR_CODES = [18]
|
42
46
|
end
|
43
|
-
class HourlyLimitExceeded <
|
47
|
+
class HourlyLimitExceeded < LimitExceeded
|
44
48
|
ERROR_CODES = [19]
|
45
49
|
end
|
46
|
-
class WeeklyLimitExceeded <
|
50
|
+
class WeeklyLimitExceeded < LimitExceeded
|
47
51
|
ERROR_CODES = [20]
|
48
52
|
end
|
49
53
|
class ServiceNotImplemented < Error
|
data/lib/geonames_api/version.rb
CHANGED
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe GeoNamesAPI::NearestIntersection do
|
4
|
+
|
5
|
+
describe '::find' do
|
6
|
+
|
7
|
+
context 'given the latitude and longitude for a point inside the United States' do
|
8
|
+
|
9
|
+
# Manhattan, Kansas, USA
|
10
|
+
let(:latitude) { 39.191253 }
|
11
|
+
let(:longitude) { -96.573737 }
|
12
|
+
|
13
|
+
it 'returns the two street names of the nearest intersection' do
|
14
|
+
response = described_class.find(latitude,longitude)
|
15
|
+
|
16
|
+
response.intersection["street1"].should eq('Bertrand St')
|
17
|
+
response.intersection["street2"].should eq('N 11th St')
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe GeoNamesAPI::Base do
|
4
4
|
describe "retries" do
|
5
5
|
before :each do
|
6
|
-
GeoNamesAPI.max_sleep_time_between_retries
|
6
|
+
GeoNamesAPI.stub(:max_sleep_time_between_retries).and_return(0)
|
7
7
|
@timeout = JSON.load <<-JSON
|
8
8
|
{
|
9
9
|
"status": {
|
@@ -28,7 +28,7 @@ describe GeoNamesAPI::Base do
|
|
28
28
|
|
29
29
|
it "fails when geonames returns timeout errors too many times" do
|
30
30
|
GeoNamesAPI::Hierarchy.stub(:make_request).and_return(@timeout, @timeout, @response)
|
31
|
-
GeoNamesAPI.retries
|
31
|
+
GeoNamesAPI.stub(:retries).and_return(1)
|
32
32
|
proc { GeoNamesAPI::Hierarchy.find(6295630) }.should raise_error GeoNamesAPI::Timeout
|
33
33
|
end
|
34
34
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -11,7 +11,7 @@ RSpec.configure do |config|
|
|
11
11
|
name = $stdin.gets.chomp
|
12
12
|
GeoNamesAPI.username = name if name.present?
|
13
13
|
end
|
14
|
-
GeoNamesAPI.logger = Logger.new("test.log")
|
14
|
+
GeoNamesAPI.logger = ENV['CI'] ? Logger.new(STDERR) : Logger.new("test.log")
|
15
15
|
GeoNamesAPI.retries = 10
|
16
16
|
GeoNamesAPI.max_sleep_time_between_retries = 60
|
17
17
|
end
|
metadata
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: geonames_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
5
|
-
prerelease:
|
4
|
+
version: 0.1.3
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Sean Devine
|
@@ -10,86 +9,76 @@ authors:
|
|
10
9
|
autorequire:
|
11
10
|
bindir: bin
|
12
11
|
cert_chain: []
|
13
|
-
date: 2014-
|
12
|
+
date: 2014-03-19 00:00:00.000000000 Z
|
14
13
|
dependencies:
|
15
14
|
- !ruby/object:Gem::Dependency
|
16
15
|
name: activesupport
|
17
16
|
requirement: !ruby/object:Gem::Requirement
|
18
|
-
none: false
|
19
17
|
requirements:
|
20
|
-
- -
|
18
|
+
- - ">="
|
21
19
|
- !ruby/object:Gem::Version
|
22
20
|
version: '0'
|
23
21
|
type: :runtime
|
24
22
|
prerelease: false
|
25
23
|
version_requirements: !ruby/object:Gem::Requirement
|
26
|
-
none: false
|
27
24
|
requirements:
|
28
|
-
- -
|
25
|
+
- - ">="
|
29
26
|
- !ruby/object:Gem::Version
|
30
27
|
version: '0'
|
31
28
|
- !ruby/object:Gem::Dependency
|
32
29
|
name: tzinfo
|
33
30
|
requirement: !ruby/object:Gem::Requirement
|
34
|
-
none: false
|
35
31
|
requirements:
|
36
|
-
- -
|
32
|
+
- - ">="
|
37
33
|
- !ruby/object:Gem::Version
|
38
34
|
version: '0'
|
39
35
|
type: :runtime
|
40
36
|
prerelease: false
|
41
37
|
version_requirements: !ruby/object:Gem::Requirement
|
42
|
-
none: false
|
43
38
|
requirements:
|
44
|
-
- -
|
39
|
+
- - ">="
|
45
40
|
- !ruby/object:Gem::Version
|
46
41
|
version: '0'
|
47
42
|
- !ruby/object:Gem::Dependency
|
48
43
|
name: rubyzip
|
49
44
|
requirement: !ruby/object:Gem::Requirement
|
50
|
-
none: false
|
51
45
|
requirements:
|
52
|
-
- -
|
46
|
+
- - ">="
|
53
47
|
- !ruby/object:Gem::Version
|
54
48
|
version: '0'
|
55
49
|
type: :runtime
|
56
50
|
prerelease: false
|
57
51
|
version_requirements: !ruby/object:Gem::Requirement
|
58
|
-
none: false
|
59
52
|
requirements:
|
60
|
-
- -
|
53
|
+
- - ">="
|
61
54
|
- !ruby/object:Gem::Version
|
62
55
|
version: '0'
|
63
56
|
- !ruby/object:Gem::Dependency
|
64
57
|
name: rake
|
65
58
|
requirement: !ruby/object:Gem::Requirement
|
66
|
-
none: false
|
67
59
|
requirements:
|
68
|
-
- -
|
60
|
+
- - ">="
|
69
61
|
- !ruby/object:Gem::Version
|
70
62
|
version: '0'
|
71
63
|
type: :development
|
72
64
|
prerelease: false
|
73
65
|
version_requirements: !ruby/object:Gem::Requirement
|
74
|
-
none: false
|
75
66
|
requirements:
|
76
|
-
- -
|
67
|
+
- - ">="
|
77
68
|
- !ruby/object:Gem::Version
|
78
69
|
version: '0'
|
79
70
|
- !ruby/object:Gem::Dependency
|
80
71
|
name: rspec
|
81
72
|
requirement: !ruby/object:Gem::Requirement
|
82
|
-
none: false
|
83
73
|
requirements:
|
84
|
-
- -
|
74
|
+
- - ">="
|
85
75
|
- !ruby/object:Gem::Version
|
86
76
|
version: '0'
|
87
77
|
type: :development
|
88
78
|
prerelease: false
|
89
79
|
version_requirements: !ruby/object:Gem::Requirement
|
90
|
-
none: false
|
91
80
|
requirements:
|
92
|
-
- -
|
81
|
+
- - ">="
|
93
82
|
- !ruby/object:Gem::Version
|
94
83
|
version: '0'
|
95
84
|
description: Simple ruby client for the GeoNames API to get free and easy geographic
|
@@ -101,8 +90,8 @@ executables: []
|
|
101
90
|
extensions: []
|
102
91
|
extra_rdoc_files: []
|
103
92
|
files:
|
104
|
-
- .gitignore
|
105
|
-
- .travis.yml
|
93
|
+
- ".gitignore"
|
94
|
+
- ".travis.yml"
|
106
95
|
- CHANGELOG.md
|
107
96
|
- Gemfile
|
108
97
|
- LICENSE.txt
|
@@ -125,6 +114,7 @@ files:
|
|
125
114
|
- lib/geonames_api/hierarchy.rb
|
126
115
|
- lib/geonames_api/list_endpoint.rb
|
127
116
|
- lib/geonames_api/nearby_postal_code.rb
|
117
|
+
- lib/geonames_api/nearest_intersection.rb
|
128
118
|
- lib/geonames_api/neighbourhood.rb
|
129
119
|
- lib/geonames_api/place.rb
|
130
120
|
- lib/geonames_api/place_name.rb
|
@@ -140,6 +130,7 @@ files:
|
|
140
130
|
- spec/geonames_api/country_spec.rb
|
141
131
|
- spec/geonames_api/country_subdivision_spec.rb
|
142
132
|
- spec/geonames_api/hierarchy_spec.rb
|
133
|
+
- spec/geonames_api/nearest_intersection_spec.rb
|
143
134
|
- spec/geonames_api/neighbourhood_spec.rb
|
144
135
|
- spec/geonames_api/place_name_spec.rb
|
145
136
|
- spec/geonames_api/place_search_spec.rb
|
@@ -150,27 +141,26 @@ files:
|
|
150
141
|
- spec/spec_helper.rb
|
151
142
|
homepage: https://github.com/buytruckload/geonames_api
|
152
143
|
licenses: []
|
144
|
+
metadata: {}
|
153
145
|
post_install_message:
|
154
146
|
rdoc_options: []
|
155
147
|
require_paths:
|
156
148
|
- lib
|
157
149
|
required_ruby_version: !ruby/object:Gem::Requirement
|
158
|
-
none: false
|
159
150
|
requirements:
|
160
|
-
- -
|
151
|
+
- - ">="
|
161
152
|
- !ruby/object:Gem::Version
|
162
153
|
version: '0'
|
163
154
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
164
|
-
none: false
|
165
155
|
requirements:
|
166
|
-
- -
|
156
|
+
- - ">="
|
167
157
|
- !ruby/object:Gem::Version
|
168
158
|
version: '0'
|
169
159
|
requirements: []
|
170
160
|
rubyforge_project:
|
171
|
-
rubygems_version:
|
161
|
+
rubygems_version: 2.2.2
|
172
162
|
signing_key:
|
173
|
-
specification_version:
|
163
|
+
specification_version: 4
|
174
164
|
summary: This is a lightweight client for the GeoNames API. Huge thanks to them for
|
175
165
|
such a great service! There are many GeoNames API clients. BUT, most are rewritten
|
176
166
|
versions of a Java API whose interface is a little funny =| This is a simplified
|
@@ -180,6 +170,7 @@ test_files:
|
|
180
170
|
- spec/geonames_api/country_spec.rb
|
181
171
|
- spec/geonames_api/country_subdivision_spec.rb
|
182
172
|
- spec/geonames_api/hierarchy_spec.rb
|
173
|
+
- spec/geonames_api/nearest_intersection_spec.rb
|
183
174
|
- spec/geonames_api/neighbourhood_spec.rb
|
184
175
|
- spec/geonames_api/place_name_spec.rb
|
185
176
|
- spec/geonames_api/place_search_spec.rb
|
@@ -188,4 +179,3 @@ test_files:
|
|
188
179
|
- spec/geonames_api/street_spec.rb
|
189
180
|
- spec/geonames_api/weather_icao_spec.rb
|
190
181
|
- spec/spec_helper.rb
|
191
|
-
has_rdoc:
|