geokit 1.10.0 → 1.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -0
  3. data/.hound.yml +2 -0
  4. data/.rubocop.yml +358 -0
  5. data/.travis.yml +4 -4
  6. data/CHANGELOG.md +16 -0
  7. data/Gemfile +3 -3
  8. data/README.markdown +19 -4
  9. data/Rakefile +11 -16
  10. data/fixtures/keys.yml +9 -0
  11. data/fixtures/vcr_cassettes/google_postal_town.yml +117 -0
  12. data/fixtures/vcr_cassettes/mapbox_forward_geocode.yml +30 -30
  13. data/fixtures/vcr_cassettes/mapbox_forward_geocode_city_only.yml +25 -25
  14. data/fixtures/vcr_cassettes/mapbox_forward_geocode_state_only.yml +71 -0
  15. data/fixtures/vcr_cassettes/mapbox_reverse_geocode.yml +25 -25
  16. data/fixtures/vcr_cassettes/test_component_filtering_off.yml +390 -0
  17. data/fixtures/vcr_cassettes/test_component_filtering_on.yml +164 -0
  18. data/fixtures/vcr_cassettes/test_component_filtering_on_without_filter.yml +404 -0
  19. data/geokit.gemspec +24 -23
  20. data/lib/geokit.rb +7 -7
  21. data/lib/geokit/core_ext.rb +1 -1
  22. data/lib/geokit/geo_loc.rb +25 -19
  23. data/lib/geokit/geocoders.rb +21 -30
  24. data/lib/geokit/geocoders/bing.rb +5 -4
  25. data/lib/geokit/geocoders/ca_geocoder.rb +10 -11
  26. data/lib/geokit/geocoders/fcc.rb +9 -9
  27. data/lib/geokit/geocoders/free_geo_ip.rb +8 -8
  28. data/lib/geokit/geocoders/geo_plugin.rb +7 -7
  29. data/lib/geokit/geocoders/geobytes.rb +10 -10
  30. data/lib/geokit/geocoders/geocodio.rb +14 -14
  31. data/lib/geokit/geocoders/geonames.rb +12 -12
  32. data/lib/geokit/geocoders/google.rb +89 -61
  33. data/lib/geokit/geocoders/ip.rb +9 -14
  34. data/lib/geokit/geocoders/mapbox.rb +30 -30
  35. data/lib/geokit/geocoders/mapquest.rb +12 -12
  36. data/lib/geokit/geocoders/maxmind.rb +1 -1
  37. data/lib/geokit/geocoders/opencage.rb +19 -19
  38. data/lib/geokit/geocoders/openstreetmap.rb +21 -19
  39. data/lib/geokit/geocoders/ripe.rb +7 -7
  40. data/lib/geokit/geocoders/us_geocoder.rb +5 -5
  41. data/lib/geokit/geocoders/yahoo.rb +46 -46
  42. data/lib/geokit/geocoders/yandex.rb +18 -17
  43. data/lib/geokit/inflectors.rb +5 -5
  44. data/lib/geokit/lat_lng.rb +5 -4
  45. data/lib/geokit/multi_geocoder.rb +4 -2
  46. data/lib/geokit/net_adapter/net_http.rb +3 -2
  47. data/lib/geokit/net_adapter/typhoeus.rb +2 -1
  48. data/lib/geokit/version.rb +1 -1
  49. data/test/coverage_loader.rb +25 -0
  50. data/test/helper.rb +18 -87
  51. data/test/test_base_geocoder.rb +44 -11
  52. data/test/test_bing_geocoder.rb +40 -48
  53. data/test/test_bounds.rb +1 -1
  54. data/test/test_ca_geocoder.rb +15 -15
  55. data/test/test_fcc_geocoder.rb +8 -9
  56. data/test/test_free_geo_ip_geocoder.rb +8 -10
  57. data/test/test_geo_plugin_geocoder.rb +21 -22
  58. data/test/test_geobytes_geocoder.rb +9 -11
  59. data/test/test_geocodio_geocoder.rb +12 -14
  60. data/test/test_geoloc.rb +48 -49
  61. data/test/test_geonames_geocoder.rb +19 -23
  62. data/test/test_google_geocoder.rb +197 -189
  63. data/test/test_inflector.rb +7 -7
  64. data/test/test_ipgeocoder.rb +32 -31
  65. data/test/test_latlng.rb +28 -28
  66. data/test/test_map_quest.rb +23 -27
  67. data/test/test_mapbox_geocoder.rb +38 -28
  68. data/test/test_mappable.rb +2 -2
  69. data/test/test_maxmind_geocoder.rb +16 -16
  70. data/test/test_multi_geocoder.rb +5 -5
  71. data/test/test_multi_ip_geocoder.rb +3 -3
  72. data/test/test_net_adapter.rb +4 -4
  73. data/test/test_opencage_geocoder.rb +58 -67
  74. data/test/test_openstreetmap_geocoder.rb +67 -65
  75. data/test/test_polygon.rb +4 -22
  76. data/test/test_ripe_geocoder.rb +21 -26
  77. data/test/test_us_geocoder.rb +21 -21
  78. data/test/test_useragent.rb +46 -0
  79. data/test/test_yahoo_geocoder.rb +35 -47
  80. data/test/test_yandex_geocoder.rb +29 -27
  81. data/test/vcr_loader.rb +18 -0
  82. metadata +20 -6
@@ -0,0 +1,404 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://maps.google.com/maps/api/geocode/json?address=austin&sensor=false
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - "*/*"
14
+ User-Agent:
15
+ - Ruby
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ Content-Type:
22
+ - application/json; charset=UTF-8
23
+ Date:
24
+ - Fri, 24 Jun 2016 17:36:56 GMT
25
+ Expires:
26
+ - Sat, 25 Jun 2016 17:36:56 GMT
27
+ Cache-Control:
28
+ - public, max-age=86400
29
+ Vary:
30
+ - Accept-Language
31
+ Access-Control-Allow-Origin:
32
+ - "*"
33
+ Server:
34
+ - mafe
35
+ Content-Length:
36
+ - '1170'
37
+ X-Xss-Protection:
38
+ - 1; mode=block
39
+ X-Frame-Options:
40
+ - SAMEORIGIN
41
+ Alternate-Protocol:
42
+ - 443:quic
43
+ Alt-Svc:
44
+ - quic=":443"; ma=2592000; v="34,33,32,31,30,29,28,27,26,25"
45
+ body:
46
+ encoding: UTF-8
47
+ string: |
48
+ {
49
+ "results" : [
50
+ {
51
+ "address_components" : [
52
+ {
53
+ "long_name" : "Austin",
54
+ "short_name" : "Austin",
55
+ "types" : [ "locality", "political" ]
56
+ },
57
+ {
58
+ "long_name" : "Travis County",
59
+ "short_name" : "Travis County",
60
+ "types" : [ "administrative_area_level_2", "political" ]
61
+ },
62
+ {
63
+ "long_name" : "Texas",
64
+ "short_name" : "TX",
65
+ "types" : [ "administrative_area_level_1", "political" ]
66
+ },
67
+ {
68
+ "long_name" : "United States",
69
+ "short_name" : "US",
70
+ "types" : [ "country", "political" ]
71
+ }
72
+ ],
73
+ "formatted_address" : "Austin, TX, USA",
74
+ "geometry" : {
75
+ "bounds" : {
76
+ "northeast" : {
77
+ "lat" : 30.516863,
78
+ "lng" : -97.56841989999999
79
+ },
80
+ "southwest" : {
81
+ "lat" : 30.0986589,
82
+ "lng" : -97.938383
83
+ }
84
+ },
85
+ "location" : {
86
+ "lat" : 30.267153,
87
+ "lng" : -97.74306079999999
88
+ },
89
+ "location_type" : "APPROXIMATE",
90
+ "viewport" : {
91
+ "northeast" : {
92
+ "lat" : 30.516863,
93
+ "lng" : -97.56841989999999
94
+ },
95
+ "southwest" : {
96
+ "lat" : 30.0986589,
97
+ "lng" : -97.938383
98
+ }
99
+ }
100
+ },
101
+ "place_id" : "ChIJLwPMoJm1RIYRetVp1EtGm10",
102
+ "types" : [ "locality", "political" ]
103
+ },
104
+ {
105
+ "address_components" : [
106
+ {
107
+ "long_name" : "Austin",
108
+ "short_name" : "Austin",
109
+ "types" : [ "locality", "political" ]
110
+ },
111
+ {
112
+ "long_name" : "Jennings Township",
113
+ "short_name" : "Jennings Township",
114
+ "types" : [ "administrative_area_level_3", "political" ]
115
+ },
116
+ {
117
+ "long_name" : "Scott County",
118
+ "short_name" : "Scott County",
119
+ "types" : [ "administrative_area_level_2", "political" ]
120
+ },
121
+ {
122
+ "long_name" : "Indiana",
123
+ "short_name" : "IN",
124
+ "types" : [ "administrative_area_level_1", "political" ]
125
+ },
126
+ {
127
+ "long_name" : "United States",
128
+ "short_name" : "US",
129
+ "types" : [ "country", "political" ]
130
+ },
131
+ {
132
+ "long_name" : "47102",
133
+ "short_name" : "47102",
134
+ "types" : [ "postal_code" ]
135
+ }
136
+ ],
137
+ "formatted_address" : "Austin, IN 47102, USA",
138
+ "geometry" : {
139
+ "bounds" : {
140
+ "northeast" : {
141
+ "lat" : 38.761413,
142
+ "lng" : -85.7941829
143
+ },
144
+ "southwest" : {
145
+ "lat" : 38.725949,
146
+ "lng" : -85.83327109999999
147
+ }
148
+ },
149
+ "location" : {
150
+ "lat" : 38.7415038,
151
+ "lng" : -85.80595819999999
152
+ },
153
+ "location_type" : "APPROXIMATE",
154
+ "viewport" : {
155
+ "northeast" : {
156
+ "lat" : 38.761413,
157
+ "lng" : -85.7941829
158
+ },
159
+ "southwest" : {
160
+ "lat" : 38.725949,
161
+ "lng" : -85.83327109999999
162
+ }
163
+ }
164
+ },
165
+ "place_id" : "ChIJEwoB_irba4gRCuPOsftKQUY",
166
+ "types" : [ "locality", "political" ]
167
+ },
168
+ {
169
+ "address_components" : [
170
+ {
171
+ "long_name" : "Austin",
172
+ "short_name" : "Austin",
173
+ "types" : [ "locality", "political" ]
174
+ },
175
+ {
176
+ "long_name" : "Mower County",
177
+ "short_name" : "Mower County",
178
+ "types" : [ "administrative_area_level_2", "political" ]
179
+ },
180
+ {
181
+ "long_name" : "Minnesota",
182
+ "short_name" : "MN",
183
+ "types" : [ "administrative_area_level_1", "political" ]
184
+ },
185
+ {
186
+ "long_name" : "United States",
187
+ "short_name" : "US",
188
+ "types" : [ "country", "political" ]
189
+ },
190
+ {
191
+ "long_name" : "55912",
192
+ "short_name" : "55912",
193
+ "types" : [ "postal_code" ]
194
+ }
195
+ ],
196
+ "formatted_address" : "Austin, MN 55912, USA",
197
+ "geometry" : {
198
+ "bounds" : {
199
+ "northeast" : {
200
+ "lat" : 43.70683289999999,
201
+ "lng" : -92.91887509999999
202
+ },
203
+ "southwest" : {
204
+ "lat" : 43.64136,
205
+ "lng" : -93.0286019
206
+ }
207
+ },
208
+ "location" : {
209
+ "lat" : 43.6666296,
210
+ "lng" : -92.97463669999999
211
+ },
212
+ "location_type" : "APPROXIMATE",
213
+ "viewport" : {
214
+ "northeast" : {
215
+ "lat" : 43.70683289999999,
216
+ "lng" : -92.91887509999999
217
+ },
218
+ "southwest" : {
219
+ "lat" : 43.64136,
220
+ "lng" : -93.0286019
221
+ }
222
+ }
223
+ },
224
+ "place_id" : "ChIJffSKNVXF8IcR7z58vRXIRcM",
225
+ "types" : [ "locality", "political" ]
226
+ },
227
+ {
228
+ "address_components" : [
229
+ {
230
+ "long_name" : "Austin",
231
+ "short_name" : "Austin",
232
+ "types" : [ "locality", "political" ]
233
+ },
234
+ {
235
+ "long_name" : "Lander County",
236
+ "short_name" : "Lander County",
237
+ "types" : [ "administrative_area_level_2", "political" ]
238
+ },
239
+ {
240
+ "long_name" : "Nevada",
241
+ "short_name" : "NV",
242
+ "types" : [ "administrative_area_level_1", "political" ]
243
+ },
244
+ {
245
+ "long_name" : "United States",
246
+ "short_name" : "US",
247
+ "types" : [ "country", "political" ]
248
+ },
249
+ {
250
+ "long_name" : "89310",
251
+ "short_name" : "89310",
252
+ "types" : [ "postal_code" ]
253
+ }
254
+ ],
255
+ "formatted_address" : "Austin, NV 89310, USA",
256
+ "geometry" : {
257
+ "bounds" : {
258
+ "northeast" : {
259
+ "lat" : 39.49897989999999,
260
+ "lng" : -117.0559103
261
+ },
262
+ "southwest" : {
263
+ "lat" : 39.4850673,
264
+ "lng" : -117.0767529
265
+ }
266
+ },
267
+ "location" : {
268
+ "lat" : 39.49257009999999,
269
+ "lng" : -117.0672356
270
+ },
271
+ "location_type" : "APPROXIMATE",
272
+ "viewport" : {
273
+ "northeast" : {
274
+ "lat" : 39.49897989999999,
275
+ "lng" : -117.0559103
276
+ },
277
+ "southwest" : {
278
+ "lat" : 39.4850673,
279
+ "lng" : -117.0767529
280
+ }
281
+ }
282
+ },
283
+ "place_id" : "ChIJeW9hoMJfo4AR9_CcY0s-kAQ",
284
+ "types" : [ "locality", "political" ]
285
+ },
286
+ {
287
+ "address_components" : [
288
+ {
289
+ "long_name" : "Austin",
290
+ "short_name" : "Austin",
291
+ "types" : [ "locality", "political" ]
292
+ },
293
+ {
294
+ "long_name" : "Barren County",
295
+ "short_name" : "Barren County",
296
+ "types" : [ "administrative_area_level_2", "political" ]
297
+ },
298
+ {
299
+ "long_name" : "Kentucky",
300
+ "short_name" : "KY",
301
+ "types" : [ "administrative_area_level_1", "political" ]
302
+ },
303
+ {
304
+ "long_name" : "United States",
305
+ "short_name" : "US",
306
+ "types" : [ "country", "political" ]
307
+ },
308
+ {
309
+ "long_name" : "42123",
310
+ "short_name" : "42123",
311
+ "types" : [ "postal_code" ]
312
+ }
313
+ ],
314
+ "formatted_address" : "Austin, KY 42123, USA",
315
+ "geometry" : {
316
+ "location" : {
317
+ "lat" : 36.8253279,
318
+ "lng" : -86.0191478
319
+ },
320
+ "location_type" : "APPROXIMATE",
321
+ "viewport" : {
322
+ "northeast" : {
323
+ "lat" : 36.8266768802915,
324
+ "lng" : -86.01779881970849
325
+ },
326
+ "southwest" : {
327
+ "lat" : 36.8239789197085,
328
+ "lng" : -86.02049678029151
329
+ }
330
+ }
331
+ },
332
+ "place_id" : "ChIJ_T-ED3NsZogReEKcG6NfTYw",
333
+ "types" : [ "locality", "political" ]
334
+ },
335
+ {
336
+ "address_components" : [
337
+ {
338
+ "long_name" : "Austin",
339
+ "short_name" : "Austin",
340
+ "types" : [ "locality", "political" ]
341
+ },
342
+ {
343
+ "long_name" : "Caroline Township",
344
+ "short_name" : "Caroline Township",
345
+ "types" : [ "administrative_area_level_3", "political" ]
346
+ },
347
+ {
348
+ "long_name" : "Lonoke County",
349
+ "short_name" : "Lonoke County",
350
+ "types" : [ "administrative_area_level_2", "political" ]
351
+ },
352
+ {
353
+ "long_name" : "Arkansas",
354
+ "short_name" : "AR",
355
+ "types" : [ "administrative_area_level_1", "political" ]
356
+ },
357
+ {
358
+ "long_name" : "United States",
359
+ "short_name" : "US",
360
+ "types" : [ "country", "political" ]
361
+ },
362
+ {
363
+ "long_name" : "72007",
364
+ "short_name" : "72007",
365
+ "types" : [ "postal_code" ]
366
+ }
367
+ ],
368
+ "formatted_address" : "Austin, AR 72007, USA",
369
+ "geometry" : {
370
+ "bounds" : {
371
+ "northeast" : {
372
+ "lat" : 35.0254679,
373
+ "lng" : -91.971936
374
+ },
375
+ "southwest" : {
376
+ "lat" : 34.984479,
377
+ "lng" : -92.017985
378
+ }
379
+ },
380
+ "location" : {
381
+ "lat" : 34.9984206,
382
+ "lng" : -91.98375519999999
383
+ },
384
+ "location_type" : "APPROXIMATE",
385
+ "viewport" : {
386
+ "northeast" : {
387
+ "lat" : 35.0254679,
388
+ "lng" : -91.971936
389
+ },
390
+ "southwest" : {
391
+ "lat" : 34.984479,
392
+ "lng" : -92.017985
393
+ }
394
+ }
395
+ },
396
+ "place_id" : "ChIJjVluHmfl0ocR3zDQAuf0010",
397
+ "types" : [ "locality", "political" ]
398
+ }
399
+ ],
400
+ "status" : "OK"
401
+ }
402
+ http_version:
403
+ recorded_at: Fri, 24 Jun 2016 17:37:37 GMT
404
+ recorded_with: VCR 3.0.1
@@ -1,38 +1,39 @@
1
1
  # coding: utf-8
2
- lib = File.expand_path("../lib", __FILE__)
2
+ lib = File.expand_path('../lib', __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require "geokit/version"
4
+ require 'geokit/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
- spec.name = "geokit"
7
+ spec.name = 'geokit'
8
8
  spec.version = Geokit::VERSION
9
- spec.authors = ["Michael Noack", "James Cox", "Andre Lewis", "Bill Eisenhauer"]
10
- spec.email = ["michael+geokit@noack.com.au"]
9
+ spec.authors = ['Michael Noack', 'James Cox', 'Andre Lewis', 'Bill Eisenhauer']
10
+ spec.email = ['michael+geokit@noack.com.au']
11
11
  spec.description = 'Geokit provides geocoding and distance calculation in an easy-to-use API'
12
12
  spec.summary = 'Geokit: encoding and distance calculation gem'
13
- spec.homepage = "http://github.com/geokit/geokit"
14
- spec.license = "MIT"
13
+ spec.homepage = 'http://github.com/geokit/geokit'
14
+ spec.license = 'MIT'
15
15
 
16
16
  spec.has_rdoc = true
17
- spec.rdoc_options = ["--main", "README.markdown"]
18
- spec.extra_rdoc_files = ["README.markdown"]
17
+ spec.rdoc_options = ['--main', 'README.markdown']
18
+ spec.extra_rdoc_files = ['README.markdown']
19
19
 
20
20
  spec.files = `git ls-files`.split($/)
21
21
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
22
22
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
23
- spec.require_paths = ["lib"]
23
+ spec.require_paths = ['lib']
24
24
 
25
- spec.required_ruby_version = ">= 1.9.3"
26
- spec.add_development_dependency "bundler", "~> 1.0"
27
- spec.add_development_dependency "coveralls"
28
- spec.add_development_dependency "mocha"
29
- spec.add_development_dependency "pre-commit"
30
- spec.add_development_dependency "rake"
31
- spec.add_development_dependency "rubocop"
32
- spec.add_development_dependency "simplecov"
33
- spec.add_development_dependency "simplecov-rcov"
34
- spec.add_development_dependency "test-unit"
35
- spec.add_development_dependency "typhoeus" # used in net_adapter
36
- spec.add_development_dependency "vcr"
37
- spec.add_development_dependency "webmock" # used in vcr
25
+ spec.required_ruby_version = '>= 1.9.3'
26
+ spec.add_development_dependency 'bundler', '~> 1.0'
27
+ spec.add_development_dependency 'coveralls'
28
+ spec.add_development_dependency 'mocha'
29
+ spec.add_development_dependency 'pre-commit'
30
+ spec.add_development_dependency 'rake'
31
+ spec.add_development_dependency 'rubocop'
32
+ spec.add_development_dependency 'simplecov'
33
+ spec.add_development_dependency 'simplecov-rcov'
34
+ spec.add_development_dependency 'test-unit'
35
+ spec.add_development_dependency 'typhoeus' # used in net_adapter
36
+ spec.add_development_dependency 'vcr'
37
+ # webmock 2 not yet compatible out of the box with VCR
38
+ spec.add_development_dependency 'webmock', '< 2' # used in vcr
38
39
  end