geokit 1.13.1 → 1.14.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/ci.yml +22 -0
  3. data/.hound.yml +1 -1
  4. data/.rubocop.yml +28 -20
  5. data/CHANGELOG.md +8 -0
  6. data/README.markdown +8 -9
  7. data/Rakefile +1 -1
  8. data/fixtures/vcr_cassettes/bing_full.yml +1 -1
  9. data/fixtures/vcr_cassettes/bing_full_au.yml +1 -1
  10. data/fixtures/vcr_cassettes/bing_full_de.yml +1 -1
  11. data/fixtures/vcr_cassettes/opencage_reverse_cerdanyola.yml +47 -0
  12. data/fixtures/vcr_cassettes/test_component_filtering_with_special_characters.yml +126 -0
  13. data/geokit.gemspec +4 -5
  14. data/lib/geokit/geo_loc.rb +8 -6
  15. data/lib/geokit/geocoders/bing.rb +1 -1
  16. data/lib/geokit/geocoders/ca_geocoder.rb +2 -1
  17. data/lib/geokit/geocoders/fcc.rb +1 -0
  18. data/lib/geokit/geocoders/google.rb +3 -1
  19. data/lib/geokit/geocoders/opencage.rb +4 -0
  20. data/lib/geokit/geocoders/openstreetmap.rb +1 -0
  21. data/lib/geokit/geocoders/yahoo.rb +4 -1
  22. data/lib/geokit/geocoders/yandex.rb +1 -1
  23. data/lib/geokit/geocoders.rb +12 -2
  24. data/lib/geokit/mappable.rb +13 -6
  25. data/lib/geokit/multi_geocoder.rb +1 -0
  26. data/lib/geokit/version.rb +1 -1
  27. data/test/coverage_loader.rb +1 -1
  28. data/test/helper.rb +1 -1
  29. data/test/test_bing_geocoder.rb +4 -4
  30. data/test/test_ca_geocoder.rb +8 -0
  31. data/test/test_fcc_geocoder.rb +1 -0
  32. data/test/{test_geoloc.rb → test_geo_loc.rb} +1 -0
  33. data/test/test_google_geocoder.rb +15 -1
  34. data/test/test_ip_api_geocoder.rb +1 -1
  35. data/test/test_ipstack_geocoder.rb +1 -1
  36. data/test/test_multi_geocoder.rb +7 -4
  37. data/test/test_multi_ip_geocoder.rb +3 -1
  38. data/test/test_opencage_geocoder.rb +34 -3
  39. data/test/test_openstreetmap_geocoder.rb +2 -0
  40. data/test/test_yandex_geocoder.rb +5 -5
  41. metadata +16 -19
  42. data/.travis.yml +0 -12
  43. data/fixtures/vcr_cassettes/free_geo_ip_geocode.yml +0 -36
  44. data/lib/geokit/geocoders/free_geo_ip.rb +0 -36
  45. data/test/test_free_geo_ip_geocoder.rb +0 -21
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 808d2beadd1bc97170d5cac5db18a8130dff73e0
4
- data.tar.gz: fda085fa6fd111a572028f41d6cf944ff7605e08
2
+ SHA256:
3
+ metadata.gz: c61de87b4682789d1cceb478c63669cc2788f8476247314b8f481bc3382f90df
4
+ data.tar.gz: dfc7a3232b2f7ad0184660e8e5338961289a52418b08efac90eac911a84a3978
5
5
  SHA512:
6
- metadata.gz: 16f2a6b0346097f2f7da712d8a485d4811ed4dccf0de330fcc85e4f07b61845f51a2aff976ad43f619494d5aafd0f452860f74a7b550bc3ee1a018cf4d20a972
7
- data.tar.gz: 1408272ef2d052118dadbbd8c2b3ec7cf785b1e0164d58767fa5960b501584396bd9f19b9d05fb53e949c774f0d1d1fcb405d1606d82ec2d7a34286e566622a1
6
+ metadata.gz: eae3182ab6e7f4dbf337bca53288a76c5b9b71a2d32f7741bd6362605a0d9a0cec63d264cb382a026e7b05c2bee08ed4375db5b0ae7479311b2b3fdd366c80dd
7
+ data.tar.gz: a7c576f5ad8b23463e5730c79cbe0591e9cde53d0031e49e75b23903af6b9f48df87a0ce1fb5ac8472265cf7bf7ac535bc9a4c166b34931966ecd4ff44d30728
@@ -0,0 +1,22 @@
1
+ name: CI
2
+ on: [push, pull_request]
3
+ jobs:
4
+ test:
5
+ runs-on: ubuntu-latest
6
+ strategy:
7
+ matrix:
8
+ ruby: [ '2.5', '2.6', '2.7', '3.0', '3.1' ]
9
+ name: Test w/ Ruby ${{ matrix.ruby }}
10
+ steps:
11
+ - uses: actions/checkout@v2
12
+ - name: Set up Ruby ${{ matrix.ruby }}
13
+ uses: ruby/setup-ruby@v1
14
+ with:
15
+ ruby-version: ${{ matrix.ruby }}
16
+ bundler-cache: true
17
+ - name: Install dependencies
18
+ run: |
19
+ gem install bundler -v '~>1'
20
+ bundle install --jobs 4 --retry 3
21
+ - name: Test
22
+ run: bundle exec rake test
data/.hound.yml CHANGED
@@ -1,2 +1,2 @@
1
- ruby:
1
+ rubocop:
2
2
  config_file: .rubocop.yml
data/.rubocop.yml CHANGED
@@ -63,7 +63,7 @@ Performance/StringReplacement:
63
63
  - 'lib/geokit/inflectors.rb'
64
64
 
65
65
  # Offense count: 1
66
- Style/AccessorMethodName:
66
+ Naming/AccessorMethodName:
67
67
  Exclude:
68
68
  - 'lib/geokit/geocoders/mapbox.rb'
69
69
 
@@ -79,7 +79,7 @@ Style/Alias:
79
79
 
80
80
  # Offense count: 2
81
81
  # Cop supports --auto-correct.
82
- Style/AlignArray:
82
+ Layout/AlignArray:
83
83
  Exclude:
84
84
  - 'lib/geokit/geo_loc.rb'
85
85
 
@@ -87,7 +87,7 @@ Style/AlignArray:
87
87
  # Cop supports --auto-correct.
88
88
  # Configuration parameters: EnforcedStyle, SupportedStyles.
89
89
  # SupportedStyles: with_first_parameter, with_fixed_indentation
90
- Style/AlignParameters:
90
+ Layout/AlignParameters:
91
91
  Exclude:
92
92
  - 'lib/geokit/lat_lng.rb'
93
93
  - 'test/test_google_geocoder.rb'
@@ -151,33 +151,32 @@ Style/Documentation:
151
151
  # Cop supports --auto-correct.
152
152
  # Configuration parameters: EnforcedStyle, SupportedStyles.
153
153
  # SupportedStyles: leading, trailing
154
- Style/DotPosition:
154
+ Layout/DotPosition:
155
155
  Enabled: false
156
156
 
157
157
  # Offense count: 2
158
158
  Style/DoubleNegation:
159
159
  Exclude:
160
- - 'lib/geokit/geocoders/free_geo_ip.rb'
161
160
  - 'lib/geokit/geocoders/geo_plugin.rb'
162
161
 
163
162
  # Offense count: 2
164
163
  # Cop supports --auto-correct.
165
164
  # Configuration parameters: AllowAdjacentOneLineDefs.
166
- Style/EmptyLineBetweenDefs:
165
+ Layout/EmptyLineBetweenDefs:
167
166
  Exclude:
168
167
  - 'lib/geokit/geocoders.rb'
169
168
  - 'lib/geokit/geocoders/opencage.rb'
170
169
 
171
170
  # Offense count: 1
172
171
  # Cop supports --auto-correct.
173
- Style/EmptyLines:
172
+ Layout/EmptyLines:
174
173
  Exclude:
175
174
  - 'test/test_google_geocoder.rb'
176
175
 
177
176
  # Offense count: 15
178
177
  # Cop supports --auto-correct.
179
178
  # Configuration parameters: AllowForAlignment, ForceEqualSignAlignment.
180
- Style/ExtraSpacing:
179
+ Layout/ExtraSpacing:
181
180
  Exclude:
182
181
  - 'lib/geokit/geocoders/bing.rb'
183
182
  - 'lib/geokit/geocoders/yahoo.rb'
@@ -201,7 +200,7 @@ Style/IfInsideElse:
201
200
  # Cop supports --auto-correct.
202
201
  # Configuration parameters: EnforcedStyle, SupportedStyles.
203
202
  # SupportedStyles: normal, rails
204
- Style/IndentationConsistency:
203
+ Layout/IndentationConsistency:
205
204
  Exclude:
206
205
  - 'test/test_google_geocoder.rb'
207
206
  - 'test/test_openstreetmap_geocoder.rb'
@@ -222,7 +221,7 @@ Style/MethodCallWithoutArgsParentheses:
222
221
  # Cop supports --auto-correct.
223
222
  # Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth.
224
223
  # SupportedStyles: aligned, indented
225
- Style/MultilineOperationIndentation:
224
+ Layout/MultilineOperationIndentation:
226
225
  Enabled: false
227
226
 
228
227
  # Offense count: 21
@@ -230,7 +229,6 @@ Style/MultilineOperationIndentation:
230
229
  Style/MutableConstant:
231
230
  Exclude:
232
231
  - 'lib/geokit/geocoders/bing.rb'
233
- - 'lib/geokit/geocoders/free_geo_ip.rb'
234
232
  - 'lib/geokit/geocoders/geo_plugin.rb'
235
233
  - 'lib/geokit/geocoders/geonames.rb'
236
234
  - 'lib/geokit/geocoders/google.rb'
@@ -259,7 +257,7 @@ Style/ParallelAssignment:
259
257
  # NamePrefix: is_, has_, have_
260
258
  # NamePrefixBlacklist: is_, has_, have_
261
259
  # NameWhitelist: is_a?
262
- Style/PredicateName:
260
+ Naming/PredicateName:
263
261
  Exclude:
264
262
  - 'lib/geokit/geo_loc.rb'
265
263
 
@@ -285,13 +283,13 @@ Style/RescueModifier:
285
283
  # Cop supports --auto-correct.
286
284
  # Configuration parameters: EnforcedStyle, SupportedStyles.
287
285
  # SupportedStyles: space, no_space
288
- Style/SpaceAroundEqualsInParameterDefault:
286
+ Layout/SpaceAroundEqualsInParameterDefault:
289
287
  Enabled: false
290
288
 
291
289
  # Offense count: 3
292
290
  # Cop supports --auto-correct.
293
291
  # Configuration parameters: AllowForAlignment.
294
- Style/SpaceAroundOperators:
292
+ Layout/SpaceAroundOperators:
295
293
  Exclude:
296
294
  - 'lib/geokit/geocoders/bing.rb'
297
295
  - 'lib/geokit/geocoders/yahoo.rb'
@@ -299,7 +297,7 @@ Style/SpaceAroundOperators:
299
297
  # Offense count: 5
300
298
  # Cop supports --auto-correct.
301
299
  # Configuration parameters: AllowForAlignment.
302
- Style/SpaceBeforeFirstArg:
300
+ Layout/SpaceBeforeFirstArg:
303
301
  Exclude:
304
302
  - 'test/test_mappable.rb'
305
303
 
@@ -307,14 +305,14 @@ Style/SpaceBeforeFirstArg:
307
305
  # Cop supports --auto-correct.
308
306
  # Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SupportedStyles.
309
307
  # SupportedStyles: space, no_space
310
- Style/SpaceInsideHashLiteralBraces:
308
+ Layout/SpaceInsideHashLiteralBraces:
311
309
  Enabled: false
312
310
 
313
311
  # Offense count: 2
314
312
  # Cop supports --auto-correct.
315
313
  # Configuration parameters: EnforcedStyle, SupportedStyles.
316
314
  # SupportedStyles: space, no_space
317
- Style/SpaceInsideStringInterpolation:
315
+ Layout/SpaceInsideStringInterpolation:
318
316
  Exclude:
319
317
  - 'lib/geokit/geocoders/yahoo.rb'
320
318
 
@@ -339,11 +337,21 @@ Style/TrailingCommaInArguments:
339
337
  # Cop supports --auto-correct.
340
338
  # Configuration parameters: EnforcedStyleForMultiline, SupportedStyles.
341
339
  # SupportedStyles: comma, consistent_comma, no_comma
342
- Style/TrailingCommaInLiteral:
340
+ Style/TrailingCommaInArrayLiteral:
341
+ Exclude:
342
+ - 'lib/geokit/geo_loc.rb'
343
+ - 'lib/geokit/geocoders/bing.rb'
344
+ - 'lib/geokit/geocoders/geo_plugin.rb'
345
+ - 'lib/geokit/geocoders/geocodio.rb'
346
+ - 'lib/geokit/geocoders/geonames.rb'
347
+ - 'lib/geokit/geocoders/google.rb'
348
+ - 'lib/geokit/geocoders/yahoo.rb'
349
+ - 'test/test_ipgeocoder.rb'
350
+
351
+ Style/TrailingCommaInHashLiteral:
343
352
  Exclude:
344
353
  - 'lib/geokit/geo_loc.rb'
345
354
  - 'lib/geokit/geocoders/bing.rb'
346
- - 'lib/geokit/geocoders/free_geo_ip.rb'
347
355
  - 'lib/geokit/geocoders/geo_plugin.rb'
348
356
  - 'lib/geokit/geocoders/geocodio.rb'
349
357
  - 'lib/geokit/geocoders/geonames.rb'
@@ -354,5 +362,5 @@ Style/TrailingCommaInLiteral:
354
362
  # Offense count: 6
355
363
  # Configuration parameters: EnforcedStyle, SupportedStyles.
356
364
  # SupportedStyles: snake_case, camelCase
357
- Style/VariableName:
365
+ Naming/VariableName:
358
366
  Enabled: false
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## 1.14.0
2
+
3
+ * Introduced NoSuchGeocoderError. If you try call a geocoder like :bogus that doesn't exist, an error will be returned.
4
+ * Upgraded to coveralls_reborn
5
+ * Replaced deprecated URI.escape with CGI.escape
6
+ * Fixed old mocha incompatability, now calls mocha/test_unit and not mocha/setup
7
+ * Bumped minimum Ruby version
8
+
1
9
  ## 1.13.1
2
10
 
3
11
  **Existing Geocoder Changes**
data/README.markdown CHANGED
@@ -1,11 +1,11 @@
1
1
  Geokit
2
2
  ======
3
3
 
4
- [![Gem Version](https://badge.fury.io/rb/geokit.png)](http://badge.fury.io/rb/geokit)
5
- [![Build Status](https://travis-ci.org/geokit/geokit.png?branch=master)](https://travis-ci.org/geokit/geokit)
6
- [![Coverage Status](https://coveralls.io/repos/geokit/geokit/badge.png)](https://coveralls.io/r/geokit/geokit)
7
- [![Dependency Status](https://gemnasium.com/geokit/geokit.png)](https://gemnasium.com/geokit/geokit)
8
- [![Code Climate](https://codeclimate.com/github/geokit/geokit.png)](https://codeclimate.com/github/geokit/geokit)
4
+ [![Gem Version](https://badge.fury.io/rb/geokit.svg)](http://badge.fury.io/rb/geokit)
5
+ [![Build Status](https://github.com/geokit/geokit/workflows/CI/badge.svg)](https://github.com/geokit/geokit/actions)
6
+ [![Coverage Status](https://coveralls.io/repos/geokit/geokit/badge.svg)](https://coveralls.io/r/geokit/geokit)
7
+ [![Reviewed by Hound](https://img.shields.io/badge/Reviewed_by-Hound-8E64B0.svg)](https://houndci.com)
8
+ [![Code Climate](https://codeclimate.com/github/geokit/geokit.svg)](https://codeclimate.com/github/geokit/geokit)
9
9
 
10
10
  ## DESCRIPTION
11
11
 
@@ -63,7 +63,6 @@ Combine this gem with the [geokit-rails](http://github.com/geokit/geokit-rails)
63
63
  * RIPE
64
64
  * MaxMind
65
65
  * Ipstack
66
- * freegeoip.net (deprecated, now Ipstack)
67
66
  * IP-API.com
68
67
 
69
68
  ### HTTPS-supporting geocoders
@@ -286,7 +285,7 @@ Multi Geocoder - provides failover for the physical location geocoders, and also
286
285
  ```
287
286
 
288
287
  ## MULTIPLE RESULTS
289
- Some geocoding services will return multple results if the there isn't one clear result.
288
+ Some geocoding services will return multiple results if the there isn't one clear result.
290
289
  Geoloc can capture multiple results through its "all" method.
291
290
 
292
291
  ```ruby
@@ -314,14 +313,14 @@ between two points.
314
313
  LatLng is a simple container for latitude and longitude, but
315
314
  it's made more powerful by mixing in the above-mentioned Mappable
316
315
  module -- therefore, you can calculate easily the distance between two
317
- LatLng ojbects with `distance = first.distance_to(other)`
316
+ LatLng objects with `distance = first.distance_to(other)`
318
317
 
319
318
  GeoLoc represents an address or location which
320
319
  has been geocoded. You can get the city, zipcode, street address, etc.
321
320
  from a GeoLoc object. GeoLoc extends LatLng, so you also get lat/lng
322
321
  AND the Mappable module goodness for free.
323
322
 
324
- geocoders.rb contains all the geocoder implemenations. All the gercoders
323
+ geocoders.rb contains all the geocoder implementations. All the geocoders
325
324
  inherit from a common base (class Geocoder) and implement the private method
326
325
  do_geocode.
327
326
 
data/Rakefile CHANGED
@@ -2,7 +2,7 @@ require 'bundler/gem_tasks'
2
2
  require 'rake/testtask'
3
3
 
4
4
  task :console do
5
- sh "irb -rubygems -I lib -r geokit"
5
+ sh "irb -I lib -r geokit"
6
6
  end
7
7
 
8
8
  Rake::TestTask.new do |t|
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: get
5
- uri: https://dev.virtualearth.net/REST/v1/Locations/100%20Spear%20St,%20San%20Francisco,%20CA,%2094105-1522,%20US?key=AuWcmtBIoPeOubm9BtcN44hTmWw_wNoJ5NEO2L0RaKrGAUE_nlwciKAqwapdq7k7&o=xml
5
+ uri: https://dev.virtualearth.net/REST/v1/Locations/100+Spear+St,+San+Francisco,+CA,+94105-1522,+US?key=AuWcmtBIoPeOubm9BtcN44hTmWw_wNoJ5NEO2L0RaKrGAUE_nlwciKAqwapdq7k7&o=xml
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: ''
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: get
5
- uri: https://dev.virtualearth.net/REST/v1/Locations/440%20King%20William%20Street,%20Adelaide,%20Australia?key=AuWcmtBIoPeOubm9BtcN44hTmWw_wNoJ5NEO2L0RaKrGAUE_nlwciKAqwapdq7k7&o=xml
5
+ uri: https://dev.virtualearth.net/REST/v1/Locations/440+King+William+Street,+Adelaide,+Australia?key=AuWcmtBIoPeOubm9BtcN44hTmWw_wNoJ5NEO2L0RaKrGAUE_nlwciKAqwapdq7k7&o=xml
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: ''
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: get
5
- uri: https://dev.virtualearth.net/REST/v1/Locations/Platz%20der%20Republik%201,%2011011%20Berlin,%20Germany?key=AuWcmtBIoPeOubm9BtcN44hTmWw_wNoJ5NEO2L0RaKrGAUE_nlwciKAqwapdq7k7&o=xml
5
+ uri: https://dev.virtualearth.net/REST/v1/Locations/Platz+der+Republik+1,+11011+Berlin,+Germany?key=AuWcmtBIoPeOubm9BtcN44hTmWw_wNoJ5NEO2L0RaKrGAUE_nlwciKAqwapdq7k7&o=xml
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: ''
@@ -0,0 +1,47 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.opencagedata.com/geocode/v1/json?key=someopencageapikey&no_annotations=1&query=41.493588,2.141879
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
+ Date:
22
+ - Mon, 27 Jan 2020 16:52:19 GMT
23
+ Server:
24
+ - Apache
25
+ Access-Control-Allow-Origin:
26
+ - "*"
27
+ Vary:
28
+ - Accept-Encoding
29
+ Content-Length:
30
+ - '597'
31
+ Content-Type:
32
+ - application/json; charset=utf-8
33
+ Strict-Transport-Security:
34
+ - max-age=31536000; includeSubDomains; preload
35
+ body:
36
+ encoding: UTF-8
37
+ string: '{"documentation":"https://opencagedata.com/api","licenses":[{"name":"see
38
+ attribution guide","url":"https://opencagedata.com/credits"}],"results":[{"bounds":{"northeast":{"lat":41.4950264,"lng":2.1415936},"southwest":{"lat":41.4925907,"lng":2.1411986}},"components":{"ISO_3166-1_alpha-2":"ES","ISO_3166-1_alpha-3":"ESP","_category":"road","_type":"road","continent":"Europe","country":"Spain","country_code":"es","county":"Vall\u00e8s
39
+ Occidental","neighbourhood":"Sant Mart\u00ed","political_union":"European
40
+ Union","postcode":"08290","road":"Passeig de la Riera","road_type":"residential","state":"Catalonia","suburb":"Can
41
+ Costa","town":"Cerdanyola del Vall\u00e8s"},"confidence":9,"formatted":"Passeig
42
+ de la Riera, 08290 Cerdanyola del Vall\u00e8s, Spain","geometry":{"lat":41.4936783,"lng":2.1413932}}],"status":{"code":200,"message":"OK"},"stay_informed":{"blog":"https://blog.opencagedata.com","twitter":"https://twitter.com/opencagedata"},"thanks":"For
43
+ using an OpenCage API","timestamp":{"created_http":"Mon, 27 Jan 2020 16:52:19
44
+ GMT","created_unix":1580143939},"total_results":1}'
45
+ http_version:
46
+ recorded_at: Mon, 27 Jan 2020 16:52:19 GMT
47
+ recorded_with: VCR 5.0.0
@@ -0,0 +1,126 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://maps.google.com/maps/api/geocode/json?address=S%C3%A3o%20Paulo&components=administrative_area:s%C3%A3o%20paulo%7Ccountry:br&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
+ - Wed, 03 Apr 2019 22:15:01 GMT
25
+ Pragma:
26
+ - no-cache
27
+ Expires:
28
+ - Fri, 01 Jan 1990 00:00:00 GMT
29
+ Cache-Control:
30
+ - no-cache, must-revalidate
31
+ Vary:
32
+ - Accept-Language
33
+ Access-Control-Allow-Origin:
34
+ - "*"
35
+ Server:
36
+ - mafe
37
+ X-Xss-Protection:
38
+ - '0'
39
+ X-Frame-Options:
40
+ - SAMEORIGIN
41
+ Server-Timing:
42
+ - gfet4t7; dur=1
43
+ Alt-Svc:
44
+ - quic=":443"; ma=2592000; v="46,44,43,39"
45
+ Transfer-Encoding:
46
+ - chunked
47
+ body:
48
+ encoding: UTF-8
49
+ string: |
50
+ {
51
+ "results": [
52
+ {
53
+ "address_components": [
54
+ {
55
+ "long_name": "São Paulo",
56
+ "short_name": "São Paulo",
57
+ "types": [
58
+ "locality",
59
+ "political"
60
+ ]
61
+ },
62
+ {
63
+ "long_name": "São Paulo",
64
+ "short_name": "São Paulo",
65
+ "types": [
66
+ "administrative_area_level_2",
67
+ "political"
68
+ ]
69
+ },
70
+ {
71
+ "long_name": "State of São Paulo",
72
+ "short_name": "SP",
73
+ "types": [
74
+ "administrative_area_level_1",
75
+ "political"
76
+ ]
77
+ },
78
+ {
79
+ "long_name": "Brazil",
80
+ "short_name": "BR",
81
+ "types": [
82
+ "country",
83
+ "political"
84
+ ]
85
+ }
86
+ ],
87
+ "formatted_address": "São Paulo, State of São Paulo, Brazil",
88
+ "geometry": {
89
+ "bounds": {
90
+ "northeast": {
91
+ "lat": -23.3566039,
92
+ "lng": -46.3650844
93
+ },
94
+ "southwest": {
95
+ "lat": -24.0082209,
96
+ "lng": -46.825514
97
+ }
98
+ },
99
+ "location": {
100
+ "lat": -23.5505199,
101
+ "lng": -46.63330939999999
102
+ },
103
+ "location_type": "APPROXIMATE",
104
+ "viewport": {
105
+ "northeast": {
106
+ "lat": -23.3566039,
107
+ "lng": -46.3650844
108
+ },
109
+ "southwest": {
110
+ "lat": -24.0082209,
111
+ "lng": -46.825514
112
+ }
113
+ }
114
+ },
115
+ "place_id": "ChIJ0WGkg4FEzpQRrlsz_whLqZs",
116
+ "types": [
117
+ "locality",
118
+ "political"
119
+ ]
120
+ }
121
+ ],
122
+ "status": "OK"
123
+ }
124
+ http_version:
125
+ recorded_at: Wed, 03 Apr 2019 22:15:01 GMT
126
+ recorded_with: VCR 4.0.0
data/geokit.gemspec CHANGED
@@ -13,7 +13,6 @@ Gem::Specification.new do |spec|
13
13
  spec.homepage = 'http://github.com/geokit/geokit'
14
14
  spec.license = 'MIT'
15
15
 
16
- spec.has_rdoc = true
17
16
  spec.rdoc_options = ['--main', 'README.markdown']
18
17
  spec.extra_rdoc_files = ['README.markdown']
19
18
 
@@ -22,9 +21,9 @@ Gem::Specification.new do |spec|
22
21
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
23
22
  spec.require_paths = ['lib']
24
23
 
25
- spec.required_ruby_version = '>= 1.9.3'
26
- spec.add_development_dependency 'bundler', '~> 1.0'
27
- spec.add_development_dependency 'coveralls'
24
+ spec.required_ruby_version = '>= 2.5.9'
25
+ spec.add_development_dependency 'bundler', '>= 1.0'
26
+ spec.add_development_dependency 'coveralls_reborn'
28
27
  spec.add_development_dependency 'mocha'
29
28
  spec.add_development_dependency 'pre-commit'
30
29
  spec.add_development_dependency 'rake'
@@ -35,5 +34,5 @@ Gem::Specification.new do |spec|
35
34
  spec.add_development_dependency 'typhoeus' # used in net_adapter
36
35
  spec.add_development_dependency 'vcr'
37
36
  # webmock 2 not yet compatible out of the box with VCR
38
- spec.add_development_dependency 'webmock', '< 2' # used in vcr
37
+ spec.add_development_dependency 'webmock'#, '< 2' # used in vcr
39
38
  end
@@ -25,7 +25,7 @@ module Geokit
25
25
  # 100 Spear St, San Francisco, CA, 94101, US
26
26
  # Street number and street name are extracted from the street address
27
27
  # attribute if they don't exist
28
- attr_accessor :state_name, :state_code, :zip, :country_code, :country
28
+ attr_accessor :county, :state_name, :state_code, :zip, :country_code, :country
29
29
  attr_accessor :all, :district, :sub_premise,
30
30
  :neighborhood
31
31
  attr_writer :state, :full_address, :street_number, :street_name, :formatted_address
@@ -58,6 +58,7 @@ module Geokit
58
58
  @street_number = nil
59
59
  @street_name = nil
60
60
  @city = h[:city]
61
+ @county = h[:county]
61
62
  @state = h[:state]
62
63
  @state_code = h[:state_code]
63
64
  @state_name = h[:state_name]
@@ -109,9 +110,9 @@ module Geokit
109
110
  # gives you all the important fields as key-value pairs
110
111
  def hash
111
112
  res = {}
112
- fields = [:success, :lat, :lng, :country_code, :city, :state, :zip,
113
- :street_address, :district, :provider, :full_address, :is_us?,
114
- :ll, :precision, :district_fips, :state_fips, :block_fips, :sub_premise]
113
+ fields = %i[success lat lng country_code city county state zip
114
+ street_address district provider full_address is_us?
115
+ ll precision district_fips state_fips block_fips sub_premise]
115
116
  fields.each { |s| res[s] = send(s.to_s) }
116
117
  res
117
118
  end
@@ -133,8 +134,8 @@ module Geokit
133
134
  end
134
135
 
135
136
  # Returns a comma-delimited string consisting of the street address, city,
136
- # state, zip, and country code. Only includes those attributes that are
137
- # non-blank.
137
+ # state, zip, and country code. Only includes those attributes
138
+ # that are non-blank.
138
139
  def to_geocodeable_s
139
140
  a = [street_address, district, city, state, zip, country_code].compact
140
141
  a.delete_if { |e| !e || e == '' }
@@ -156,6 +157,7 @@ module Geokit
156
157
  ["Provider: #{provider}",
157
158
  "Street: #{street_address}",
158
159
  "City: #{city}",
160
+ "County: #{county}",
159
161
  "State: #{state}",
160
162
  "Zip: #{zip}",
161
163
  "Latitude: #{lat}",
@@ -21,7 +21,7 @@ module Geokit
21
21
  culture = options && options[:culture]
22
22
  culture_string = culture ? "&c=#{culture}" : ''
23
23
  address_str = address.is_a?(GeoLoc) ? address.to_geocodeable_s : address
24
- "#{protocol}://dev.virtualearth.net/REST/v1/Locations/#{URI.escape(address_str)}?key=#{key}#{culture_string}&o=xml"
24
+ "#{protocol}://dev.virtualearth.net/REST/v1/Locations/#{CGI.escape(address_str)}?key=#{key}#{culture_string}&o=xml"
25
25
  end
26
26
 
27
27
  def self.parse_xml(xml)
@@ -35,7 +35,8 @@ module Geokit
35
35
 
36
36
  # Formats the request in the format acceptable by the CA geocoder.
37
37
  def self.submit_url(loc)
38
- args = ["locate=#{Geokit::Inflector.url_escape(loc)}"]
38
+ loc_str = loc.is_a?(GeoLoc) ? loc.to_geocodeable_s : loc
39
+ args = ["locate=#{Geokit::Inflector.url_escape(loc_str)}"]
39
40
  args << "auth=#{key}" if key
40
41
  args << 'geoit=xml'
41
42
  'http://geocoder.ca/?' + args.join('&')
@@ -38,6 +38,7 @@ module Geokit
38
38
  loc.country_code = 'US'
39
39
  loc.district = results['County']['name']
40
40
  loc.district_fips = results['County']['FIPS']
41
+ loc.county = results['County']['name']
41
42
  loc.state = results['State']['code']
42
43
  loc.state_fips = results['State']['FIPS']
43
44
  loc.block_fips = results['Block']['FIPS']
@@ -108,7 +108,8 @@ module Geokit
108
108
 
109
109
  def self.construct_components_string_from_options(components={})
110
110
  unless components.empty?
111
- "&components=#{components.to_a.map { |pair| pair.join(':').downcase }.join(CGI.escape('|'))}"
111
+ escaped_components = Geokit::Inflector.url_escape(components.to_a.map { |pair| pair.join(":").downcase }.join("|"))
112
+ "&components=#{escaped_components}"
112
113
  end
113
114
  end
114
115
 
@@ -215,6 +216,7 @@ module Geokit
215
216
  loc.country = comp['long_name']
216
217
  when types.include?('administrative_area_level_2')
217
218
  loc.district = comp['long_name']
219
+ loc.county = comp['long_name']
218
220
  when types.include?('neighborhood')
219
221
  loc.neighborhood = comp['short_name']
220
222
  # Use either sublocality or admin area level 3 if google does not return a city
@@ -74,11 +74,15 @@ module Geokit
74
74
  loc.country = address_data['country']
75
75
  loc.country_code = address_data['country_code'].upcase if address_data['country_code']
76
76
  loc.state_name = address_data['state']
77
+ loc.county = address_data['county']
77
78
  loc.city = address_data['city']
79
+ loc.city = address_data['town'] if loc.city.nil? && address_data['town']
78
80
  loc.city = address_data['county'] if loc.city.nil? && address_data['county']
79
81
  loc.zip = address_data['postcode']
80
82
  loc.district = address_data['city_district']
81
83
  loc.district = address_data['state_district'] if loc.district.nil? && address_data['state_district']
84
+ loc.neighborhood = address_data['neighbourhood']
85
+ loc.neighborhood = address_data['suburb'] if loc.neighborhood.nil?
82
86
  loc.street_address = "#{address_data['road']} #{address_data['house_number']}".strip if address_data['road']
83
87
  loc.street_name = address_data['road']
84
88
  loc.street_number = address_data['house_number']
@@ -84,6 +84,7 @@ module Geokit
84
84
  loc.country = address_data['country']
85
85
  loc.country_code = address_data['country_code'].upcase if address_data['country_code']
86
86
  loc.state_name = address_data['state']
87
+ loc.county = address_data['county']
87
88
  loc.city = address_data['city']
88
89
  loc.city = address_data['county'] if loc.city.nil? && address_data['county']
89
90
  loc.zip = address_data['postcode']
@@ -113,7 +113,10 @@ class OauthUtil
113
113
 
114
114
  def percent_encode(string)
115
115
  # ref http://snippets.dzone.com/posts/show/1260
116
- URI.escape(string, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]")).gsub('*', '%2A')
116
+ # puts string
117
+ # puts "---------\n\n\n\n"
118
+ # (URI::Parser.new).escape(string, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]")).gsub('*', '%2A')
119
+ CGI.escape(string)
117
120
  end
118
121
 
119
122
  # @ref http://oauth.net/core/1.0/#rfc.section.9.2