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,390 @@
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
+ - Mon, 22 Feb 2016 11:49:54 GMT
25
+ Expires:
26
+ - Tue, 23 Feb 2016 11:49:54 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
+ X-Xss-Protection:
36
+ - 1; mode=block
37
+ X-Frame-Options:
38
+ - SAMEORIGIN
39
+ Transfer-Encoding:
40
+ - chunked
41
+ body:
42
+ encoding: UTF-8
43
+ string: |
44
+ {
45
+ "results" : [
46
+ {
47
+ "address_components" : [
48
+ {
49
+ "long_name" : "Austin",
50
+ "short_name" : "Austin",
51
+ "types" : [ "locality", "political" ]
52
+ },
53
+ {
54
+ "long_name" : "Travis County",
55
+ "short_name" : "Travis County",
56
+ "types" : [ "administrative_area_level_2", "political" ]
57
+ },
58
+ {
59
+ "long_name" : "Texas",
60
+ "short_name" : "TX",
61
+ "types" : [ "administrative_area_level_1", "political" ]
62
+ },
63
+ {
64
+ "long_name" : "United States",
65
+ "short_name" : "US",
66
+ "types" : [ "country", "political" ]
67
+ }
68
+ ],
69
+ "formatted_address" : "Austin, TX, USA",
70
+ "geometry" : {
71
+ "bounds" : {
72
+ "northeast" : {
73
+ "lat" : 30.5168629,
74
+ "lng" : -97.56841989999999
75
+ },
76
+ "southwest" : {
77
+ "lat" : 30.0986589,
78
+ "lng" : -97.93838289999999
79
+ }
80
+ },
81
+ "location" : {
82
+ "lat" : 30.267153,
83
+ "lng" : -97.74306079999999
84
+ },
85
+ "location_type" : "APPROXIMATE",
86
+ "viewport" : {
87
+ "northeast" : {
88
+ "lat" : 30.5168629,
89
+ "lng" : -97.56841989999999
90
+ },
91
+ "southwest" : {
92
+ "lat" : 30.0986589,
93
+ "lng" : -97.93838289999999
94
+ }
95
+ }
96
+ },
97
+ "place_id" : "ChIJLwPMoJm1RIYRetVp1EtGm10",
98
+ "types" : [ "locality", "political" ]
99
+ },
100
+ {
101
+ "address_components" : [
102
+ {
103
+ "long_name" : "Austin",
104
+ "short_name" : "Austin",
105
+ "types" : [ "locality", "political" ]
106
+ },
107
+ {
108
+ "long_name" : "Jennings Township",
109
+ "short_name" : "Jennings Township",
110
+ "types" : [ "administrative_area_level_3", "political" ]
111
+ },
112
+ {
113
+ "long_name" : "Scott County",
114
+ "short_name" : "Scott County",
115
+ "types" : [ "administrative_area_level_2", "political" ]
116
+ },
117
+ {
118
+ "long_name" : "Indiana",
119
+ "short_name" : "IN",
120
+ "types" : [ "administrative_area_level_1", "political" ]
121
+ },
122
+ {
123
+ "long_name" : "United States",
124
+ "short_name" : "US",
125
+ "types" : [ "country", "political" ]
126
+ }
127
+ ],
128
+ "formatted_address" : "Austin, IN, USA",
129
+ "geometry" : {
130
+ "bounds" : {
131
+ "northeast" : {
132
+ "lat" : 38.761413,
133
+ "lng" : -85.7941829
134
+ },
135
+ "southwest" : {
136
+ "lat" : 38.725949,
137
+ "lng" : -85.83327109999999
138
+ }
139
+ },
140
+ "location" : {
141
+ "lat" : 38.7415038,
142
+ "lng" : -85.80595819999999
143
+ },
144
+ "location_type" : "APPROXIMATE",
145
+ "viewport" : {
146
+ "northeast" : {
147
+ "lat" : 38.761413,
148
+ "lng" : -85.7941829
149
+ },
150
+ "southwest" : {
151
+ "lat" : 38.725949,
152
+ "lng" : -85.83327109999999
153
+ }
154
+ }
155
+ },
156
+ "place_id" : "ChIJEwoB_irba4gRCuPOsftKQUY",
157
+ "types" : [ "locality", "political" ]
158
+ },
159
+ {
160
+ "address_components" : [
161
+ {
162
+ "long_name" : "Austin",
163
+ "short_name" : "Austin",
164
+ "types" : [ "locality", "political" ]
165
+ },
166
+ {
167
+ "long_name" : "Mower County",
168
+ "short_name" : "Mower County",
169
+ "types" : [ "administrative_area_level_2", "political" ]
170
+ },
171
+ {
172
+ "long_name" : "Minnesota",
173
+ "short_name" : "MN",
174
+ "types" : [ "administrative_area_level_1", "political" ]
175
+ },
176
+ {
177
+ "long_name" : "United States",
178
+ "short_name" : "US",
179
+ "types" : [ "country", "political" ]
180
+ },
181
+ {
182
+ "long_name" : "55912",
183
+ "short_name" : "55912",
184
+ "types" : [ "postal_code" ]
185
+ }
186
+ ],
187
+ "formatted_address" : "Austin, MN 55912, USA",
188
+ "geometry" : {
189
+ "bounds" : {
190
+ "northeast" : {
191
+ "lat" : 43.706833,
192
+ "lng" : -92.918875
193
+ },
194
+ "southwest" : {
195
+ "lat" : 43.6413599,
196
+ "lng" : -93.0286019
197
+ }
198
+ },
199
+ "location" : {
200
+ "lat" : 43.6666296,
201
+ "lng" : -92.97463669999999
202
+ },
203
+ "location_type" : "APPROXIMATE",
204
+ "viewport" : {
205
+ "northeast" : {
206
+ "lat" : 43.706833,
207
+ "lng" : -92.918875
208
+ },
209
+ "southwest" : {
210
+ "lat" : 43.6413599,
211
+ "lng" : -93.0286019
212
+ }
213
+ }
214
+ },
215
+ "place_id" : "ChIJffSKNVXF8IcR7z58vRXIRcM",
216
+ "types" : [ "locality", "political" ]
217
+ },
218
+ {
219
+ "address_components" : [
220
+ {
221
+ "long_name" : "Austin",
222
+ "short_name" : "Austin",
223
+ "types" : [ "locality", "political" ]
224
+ },
225
+ {
226
+ "long_name" : "Lander County",
227
+ "short_name" : "Lander County",
228
+ "types" : [ "administrative_area_level_2", "political" ]
229
+ },
230
+ {
231
+ "long_name" : "Nevada",
232
+ "short_name" : "NV",
233
+ "types" : [ "administrative_area_level_1", "political" ]
234
+ },
235
+ {
236
+ "long_name" : "United States",
237
+ "short_name" : "US",
238
+ "types" : [ "country", "political" ]
239
+ },
240
+ {
241
+ "long_name" : "89310",
242
+ "short_name" : "89310",
243
+ "types" : [ "postal_code" ]
244
+ }
245
+ ],
246
+ "formatted_address" : "Austin, NV 89310, USA",
247
+ "geometry" : {
248
+ "bounds" : {
249
+ "northeast" : {
250
+ "lat" : 39.49897989999999,
251
+ "lng" : -117.0559103
252
+ },
253
+ "southwest" : {
254
+ "lat" : 39.4850673,
255
+ "lng" : -117.0767529
256
+ }
257
+ },
258
+ "location" : {
259
+ "lat" : 39.49257009999999,
260
+ "lng" : -117.0672356
261
+ },
262
+ "location_type" : "APPROXIMATE",
263
+ "viewport" : {
264
+ "northeast" : {
265
+ "lat" : 39.49897989999999,
266
+ "lng" : -117.0559103
267
+ },
268
+ "southwest" : {
269
+ "lat" : 39.4850673,
270
+ "lng" : -117.0767529
271
+ }
272
+ }
273
+ },
274
+ "place_id" : "ChIJeW9hoMJfo4AR9_CcY0s-kAQ",
275
+ "types" : [ "locality", "political" ]
276
+ },
277
+ {
278
+ "address_components" : [
279
+ {
280
+ "long_name" : "Austin",
281
+ "short_name" : "Austin",
282
+ "types" : [ "locality", "political" ]
283
+ },
284
+ {
285
+ "long_name" : "Barren County",
286
+ "short_name" : "Barren County",
287
+ "types" : [ "administrative_area_level_2", "political" ]
288
+ },
289
+ {
290
+ "long_name" : "Kentucky",
291
+ "short_name" : "KY",
292
+ "types" : [ "administrative_area_level_1", "political" ]
293
+ },
294
+ {
295
+ "long_name" : "United States",
296
+ "short_name" : "US",
297
+ "types" : [ "country", "political" ]
298
+ },
299
+ {
300
+ "long_name" : "42123",
301
+ "short_name" : "42123",
302
+ "types" : [ "postal_code" ]
303
+ }
304
+ ],
305
+ "formatted_address" : "Austin, KY 42123, USA",
306
+ "geometry" : {
307
+ "location" : {
308
+ "lat" : 36.8253279,
309
+ "lng" : -86.0191478
310
+ },
311
+ "location_type" : "APPROXIMATE",
312
+ "viewport" : {
313
+ "northeast" : {
314
+ "lat" : 36.8266768802915,
315
+ "lng" : -86.01779881970849
316
+ },
317
+ "southwest" : {
318
+ "lat" : 36.8239789197085,
319
+ "lng" : -86.02049678029151
320
+ }
321
+ }
322
+ },
323
+ "place_id" : "ChIJ_T-ED3NsZogReEKcG6NfTYw",
324
+ "types" : [ "locality", "political" ]
325
+ },
326
+ {
327
+ "address_components" : [
328
+ {
329
+ "long_name" : "Austin",
330
+ "short_name" : "Austin",
331
+ "types" : [ "locality", "political" ]
332
+ },
333
+ {
334
+ "long_name" : "Caroline Township",
335
+ "short_name" : "Caroline Township",
336
+ "types" : [ "administrative_area_level_3", "political" ]
337
+ },
338
+ {
339
+ "long_name" : "Lonoke County",
340
+ "short_name" : "Lonoke County",
341
+ "types" : [ "administrative_area_level_2", "political" ]
342
+ },
343
+ {
344
+ "long_name" : "Arkansas",
345
+ "short_name" : "AR",
346
+ "types" : [ "administrative_area_level_1", "political" ]
347
+ },
348
+ {
349
+ "long_name" : "United States",
350
+ "short_name" : "US",
351
+ "types" : [ "country", "political" ]
352
+ }
353
+ ],
354
+ "formatted_address" : "Austin, AR, USA",
355
+ "geometry" : {
356
+ "bounds" : {
357
+ "northeast" : {
358
+ "lat" : 35.0254679,
359
+ "lng" : -91.97193589999999
360
+ },
361
+ "southwest" : {
362
+ "lat" : 34.9844789,
363
+ "lng" : -92.017985
364
+ }
365
+ },
366
+ "location" : {
367
+ "lat" : 34.9984206,
368
+ "lng" : -91.98375519999999
369
+ },
370
+ "location_type" : "APPROXIMATE",
371
+ "viewport" : {
372
+ "northeast" : {
373
+ "lat" : 35.0254679,
374
+ "lng" : -91.97193589999999
375
+ },
376
+ "southwest" : {
377
+ "lat" : 34.9844789,
378
+ "lng" : -92.017985
379
+ }
380
+ }
381
+ },
382
+ "place_id" : "ChIJjVluHmfl0ocR3zDQAuf0010",
383
+ "types" : [ "locality", "political" ]
384
+ }
385
+ ],
386
+ "status" : "OK"
387
+ }
388
+ http_version:
389
+ recorded_at: Mon, 22 Feb 2016 11:49:57 GMT
390
+ recorded_with: VCR 3.0.1
@@ -0,0 +1,164 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://maps.google.com/maps/api/geocode/json?address=austin&components=administrative_area:il%7Ccountry:us&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
+ - Mon, 22 Feb 2016 11:51:06 GMT
25
+ Expires:
26
+ - Tue, 23 Feb 2016 11:51:06 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
+ X-Xss-Protection:
36
+ - 1; mode=block
37
+ X-Frame-Options:
38
+ - SAMEORIGIN
39
+ Transfer-Encoding:
40
+ - chunked
41
+ body:
42
+ encoding: UTF-8
43
+ string: |
44
+ {
45
+ "results" : [
46
+ {
47
+ "address_components" : [
48
+ {
49
+ "long_name" : "Austin",
50
+ "short_name" : "Austin",
51
+ "types" : [ "neighborhood", "political" ]
52
+ },
53
+ {
54
+ "long_name" : "Chicago",
55
+ "short_name" : "Chicago",
56
+ "types" : [ "locality", "political" ]
57
+ },
58
+ {
59
+ "long_name" : "Cook County",
60
+ "short_name" : "Cook County",
61
+ "types" : [ "administrative_area_level_2", "political" ]
62
+ },
63
+ {
64
+ "long_name" : "Illinois",
65
+ "short_name" : "IL",
66
+ "types" : [ "administrative_area_level_1", "political" ]
67
+ },
68
+ {
69
+ "long_name" : "United States",
70
+ "short_name" : "US",
71
+ "types" : [ "country", "political" ]
72
+ }
73
+ ],
74
+ "formatted_address" : "Austin, Chicago, IL, USA",
75
+ "geometry" : {
76
+ "bounds" : {
77
+ "northeast" : {
78
+ "lat" : 41.9167209,
79
+ "lng" : -87.7393898
80
+ },
81
+ "southwest" : {
82
+ "lat" : 41.8654591,
83
+ "lng" : -87.7755992
84
+ }
85
+ },
86
+ "location" : {
87
+ "lat" : 41.8929529,
88
+ "lng" : -87.7615618
89
+ },
90
+ "location_type" : "APPROXIMATE",
91
+ "viewport" : {
92
+ "northeast" : {
93
+ "lat" : 41.9167209,
94
+ "lng" : -87.7393898
95
+ },
96
+ "southwest" : {
97
+ "lat" : 41.8654591,
98
+ "lng" : -87.7755992
99
+ }
100
+ }
101
+ },
102
+ "place_id" : "ChIJdwbE5kkzDogRoC0zoIn43-o",
103
+ "types" : [ "neighborhood", "political" ]
104
+ },
105
+ {
106
+ "address_components" : [
107
+ {
108
+ "long_name" : "Austin Township",
109
+ "short_name" : "Austin Township",
110
+ "types" : [ "administrative_area_level_3", "political" ]
111
+ },
112
+ {
113
+ "long_name" : "Macon County",
114
+ "short_name" : "Macon County",
115
+ "types" : [ "administrative_area_level_2", "political" ]
116
+ },
117
+ {
118
+ "long_name" : "Illinois",
119
+ "short_name" : "IL",
120
+ "types" : [ "administrative_area_level_1", "political" ]
121
+ },
122
+ {
123
+ "long_name" : "United States",
124
+ "short_name" : "US",
125
+ "types" : [ "country", "political" ]
126
+ }
127
+ ],
128
+ "formatted_address" : "Austin Township, IL, USA",
129
+ "geometry" : {
130
+ "bounds" : {
131
+ "northeast" : {
132
+ "lat" : 40.0498649,
133
+ "lng" : -89.02878699999999
134
+ },
135
+ "southwest" : {
136
+ "lat" : 39.9613829,
137
+ "lng" : -89.14476309999999
138
+ }
139
+ },
140
+ "location" : {
141
+ "lat" : 39.9980892,
142
+ "lng" : -89.0752499
143
+ },
144
+ "location_type" : "APPROXIMATE",
145
+ "viewport" : {
146
+ "northeast" : {
147
+ "lat" : 40.0498649,
148
+ "lng" : -89.02878699999999
149
+ },
150
+ "southwest" : {
151
+ "lat" : 39.9613829,
152
+ "lng" : -89.14476309999999
153
+ }
154
+ }
155
+ },
156
+ "place_id" : "ChIJxSLDVppKC4gRILBnWIjPZIc",
157
+ "types" : [ "administrative_area_level_3", "political" ]
158
+ }
159
+ ],
160
+ "status" : "OK"
161
+ }
162
+ http_version:
163
+ recorded_at: Mon, 22 Feb 2016 11:51:09 GMT
164
+ recorded_with: VCR 3.0.1