geocoder 1.2.5 → 1.2.6

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of geocoder might be problematic. Click here for more details.

Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +7 -0
  3. data/README.md +83 -8
  4. data/lib/geocoder/ip_address.rb +11 -2
  5. data/lib/geocoder/lookup.rb +4 -0
  6. data/lib/geocoder/lookups/geoip2.rb +40 -0
  7. data/lib/geocoder/lookups/google_places_details.rb +50 -0
  8. data/lib/geocoder/lookups/maxmind_local.rb +1 -1
  9. data/lib/geocoder/lookups/okf.rb +43 -0
  10. data/lib/geocoder/lookups/postcode_anywhere_uk.rb +51 -0
  11. data/lib/geocoder/lookups/smarty_streets.rb +1 -1
  12. data/lib/geocoder/results/geoip2.rb +64 -0
  13. data/lib/geocoder/results/google_places_details.rb +35 -0
  14. data/lib/geocoder/results/okf.rb +106 -0
  15. data/lib/geocoder/results/postcode_anywhere_uk.rb +42 -0
  16. data/lib/geocoder/results/test.rb +1 -1
  17. data/lib/geocoder/stores/active_record.rb +22 -11
  18. data/lib/geocoder/version.rb +1 -1
  19. data/test/fixtures/google_places_details_invalid_request +4 -0
  20. data/test/fixtures/google_places_details_madison_square_garden +120 -0
  21. data/test/fixtures/google_places_details_no_results +4 -0
  22. data/test/fixtures/google_places_details_no_reviews +60 -0
  23. data/test/fixtures/google_places_details_no_types +66 -0
  24. data/test/fixtures/okf_kirstinmaki +67 -0
  25. data/test/fixtures/okf_no_results +4 -0
  26. data/test/fixtures/postcode_anywhere_uk_geocode_v2_00_WR26NJ +1 -0
  27. data/test/fixtures/postcode_anywhere_uk_geocode_v2_00_generic_error +1 -0
  28. data/test/fixtures/postcode_anywhere_uk_geocode_v2_00_hampshire +1 -0
  29. data/test/fixtures/postcode_anywhere_uk_geocode_v2_00_key_limit_exceeded +1 -0
  30. data/test/fixtures/postcode_anywhere_uk_geocode_v2_00_no_results +1 -0
  31. data/test/fixtures/postcode_anywhere_uk_geocode_v2_00_romsey +1 -0
  32. data/test/fixtures/postcode_anywhere_uk_geocode_v2_00_unknown_key +1 -0
  33. data/test/test_helper.rb +44 -0
  34. data/test/unit/cache_test.rb +1 -1
  35. data/test/unit/error_handling_test.rb +3 -3
  36. data/test/unit/ip_address_test.rb +3 -0
  37. data/test/unit/lookup_test.rb +1 -1
  38. data/test/unit/lookups/geoip2_test.rb +27 -0
  39. data/test/unit/lookups/google_places_details_test.rb +122 -0
  40. data/test/unit/lookups/okf_test.rb +38 -0
  41. data/test/unit/lookups/postcode_anywhere_uk_test.rb +70 -0
  42. data/test/unit/query_test.rb +1 -0
  43. data/test/unit/test_mode_test.rb +1 -1
  44. metadata +28 -2
@@ -0,0 +1,70 @@
1
+ # encoding: utf-8
2
+ $: << File.join(File.dirname(__FILE__), '..', '..')
3
+ require 'test_helper'
4
+
5
+ class PostcodeAnywhereUkTest < GeocoderTestCase
6
+
7
+ def setup
8
+ Geocoder.configure(lookup: :postcode_anywhere_uk)
9
+ set_api_key!(:postcode_anywhere_uk)
10
+ end
11
+
12
+ def test_result_components_with_placename_search
13
+ results = Geocoder.search('Romsey')
14
+
15
+ assert_equal 1, results.size
16
+ assert_equal 'Romsey, Hampshire', results.first.address
17
+ assert_equal 'SU 35270 21182', results.first.os_grid
18
+ assert_equal [50.9889, -1.4989], results.first.coordinates
19
+ assert_equal 'Romsey', results.first.city
20
+ end
21
+
22
+ def test_result_components_with_postcode
23
+ results = Geocoder.search('WR26NJ')
24
+
25
+ assert_equal 1, results.size
26
+ assert_equal 'Moseley Road, Hallow, Worcester', results.first.address
27
+ assert_equal 'SO 81676 59425', results.first.os_grid
28
+ assert_equal [52.2327, -2.2697], results.first.coordinates
29
+ assert_equal 'Hallow', results.first.city
30
+ end
31
+
32
+ def test_result_components_with_county
33
+ results = Geocoder.search('hampshire')
34
+
35
+ assert_equal 1, results.size
36
+ assert_equal 'Hampshire', results.first.address
37
+ assert_equal 'SU 48701 26642', results.first.os_grid
38
+ assert_equal [51.037, -1.3068], results.first.coordinates
39
+ assert_equal '', results.first.city
40
+ end
41
+
42
+ def test_no_results
43
+ assert_equal [], Geocoder.search('no results')
44
+ end
45
+
46
+ def test_key_limit_exceeded_error
47
+ Geocoder.configure(always_raise: [Geocoder::OverQueryLimitError])
48
+
49
+ assert_raises Geocoder::OverQueryLimitError do
50
+ Geocoder.search('key limit exceeded')
51
+ end
52
+ end
53
+
54
+ def test_unknown_key_error
55
+ Geocoder.configure(always_raise: [Geocoder::InvalidApiKey])
56
+
57
+ assert_raises Geocoder::InvalidApiKey do
58
+ Geocoder.search('unknown key')
59
+ end
60
+ end
61
+
62
+ def test_generic_error
63
+ Geocoder.configure(always_raise: [Geocoder::Error])
64
+
65
+ exception = assert_raises(Geocoder::Error) do
66
+ Geocoder.search('generic error')
67
+ end
68
+ assert_equal 'A generic error occured.', exception.message
69
+ end
70
+ end
@@ -6,6 +6,7 @@ class QueryTest < GeocoderTestCase
6
6
 
7
7
  def test_ip_address_detection
8
8
  assert Geocoder::Query.new("232.65.123.94").ip_address?
9
+ assert Geocoder::Query.new("3ffe:0b00:0000:0000:0001:0000:0000:000a").ip_address?
9
10
  assert !Geocoder::Query.new("232.65.123.94.43").ip_address?
10
11
  assert !Geocoder::Query.new("::ffff:123.456.789").ip_address?
11
12
  end
@@ -21,7 +21,7 @@ class TestModeTest < GeocoderTestCase
21
21
  result = results.first
22
22
 
23
23
  assert_equal 1, results.size
24
- mock_attributes.keys.each do |attr|
24
+ mock_attributes.each_key do |attr|
25
25
  assert_equal mock_attributes[attr], result.send(attr)
26
26
  end
27
27
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: geocoder
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.5
4
+ version: 1.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Reisner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-12 00:00:00.000000000 Z
11
+ date: 2014-11-08 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Provides object geocoding (by street or IP address), reverse geocoding
14
14
  (coordinates to street address), distance queries for ActiveRecord and Mongoid,
@@ -57,16 +57,20 @@ files:
57
57
  - lib/geocoder/lookups/geocoder_ca.rb
58
58
  - lib/geocoder/lookups/geocoder_us.rb
59
59
  - lib/geocoder/lookups/geocodio.rb
60
+ - lib/geocoder/lookups/geoip2.rb
60
61
  - lib/geocoder/lookups/google.rb
62
+ - lib/geocoder/lookups/google_places_details.rb
61
63
  - lib/geocoder/lookups/google_premier.rb
62
64
  - lib/geocoder/lookups/here.rb
63
65
  - lib/geocoder/lookups/mapquest.rb
64
66
  - lib/geocoder/lookups/maxmind.rb
65
67
  - lib/geocoder/lookups/maxmind_local.rb
66
68
  - lib/geocoder/lookups/nominatim.rb
69
+ - lib/geocoder/lookups/okf.rb
67
70
  - lib/geocoder/lookups/opencagedata.rb
68
71
  - lib/geocoder/lookups/ovi.rb
69
72
  - lib/geocoder/lookups/pointpin.rb
73
+ - lib/geocoder/lookups/postcode_anywhere_uk.rb
70
74
  - lib/geocoder/lookups/smarty_streets.rb
71
75
  - lib/geocoder/lookups/telize.rb
72
76
  - lib/geocoder/lookups/test.rb
@@ -90,16 +94,20 @@ files:
90
94
  - lib/geocoder/results/geocoder_ca.rb
91
95
  - lib/geocoder/results/geocoder_us.rb
92
96
  - lib/geocoder/results/geocodio.rb
97
+ - lib/geocoder/results/geoip2.rb
93
98
  - lib/geocoder/results/google.rb
99
+ - lib/geocoder/results/google_places_details.rb
94
100
  - lib/geocoder/results/google_premier.rb
95
101
  - lib/geocoder/results/here.rb
96
102
  - lib/geocoder/results/mapquest.rb
97
103
  - lib/geocoder/results/maxmind.rb
98
104
  - lib/geocoder/results/maxmind_local.rb
99
105
  - lib/geocoder/results/nominatim.rb
106
+ - lib/geocoder/results/okf.rb
100
107
  - lib/geocoder/results/opencagedata.rb
101
108
  - lib/geocoder/results/ovi.rb
102
109
  - lib/geocoder/results/pointpin.rb
110
+ - lib/geocoder/results/postcode_anywhere_uk.rb
103
111
  - lib/geocoder/results/smarty_streets.rb
104
112
  - lib/geocoder/results/telize.rb
105
113
  - lib/geocoder/results/test.rb
@@ -152,6 +160,11 @@ files:
152
160
  - test/fixtures/google_no_locality
153
161
  - test/fixtures/google_no_results
154
162
  - test/fixtures/google_over_limit
163
+ - test/fixtures/google_places_details_invalid_request
164
+ - test/fixtures/google_places_details_madison_square_garden
165
+ - test/fixtures/google_places_details_no_results
166
+ - test/fixtures/google_places_details_no_reviews
167
+ - test/fixtures/google_places_details_no_types
155
168
  - test/fixtures/here_madison_square_garden
156
169
  - test/fixtures/here_no_results
157
170
  - test/fixtures/mapquest_error
@@ -169,6 +182,8 @@ files:
169
182
  - test/fixtures/nominatim_madison_square_garden
170
183
  - test/fixtures/nominatim_no_results
171
184
  - test/fixtures/nominatim_over_limit
185
+ - test/fixtures/okf_kirstinmaki
186
+ - test/fixtures/okf_no_results
172
187
  - test/fixtures/opencagedata_invalid_api_key
173
188
  - test/fixtures/opencagedata_invalid_request
174
189
  - test/fixtures/opencagedata_madison_square_garden
@@ -180,6 +195,13 @@ files:
180
195
  - test/fixtures/pointpin_555_555_555_555
181
196
  - test/fixtures/pointpin_80_111_555_555
182
197
  - test/fixtures/pointpin_no_results
198
+ - test/fixtures/postcode_anywhere_uk_geocode_v2_00_WR26NJ
199
+ - test/fixtures/postcode_anywhere_uk_geocode_v2_00_generic_error
200
+ - test/fixtures/postcode_anywhere_uk_geocode_v2_00_hampshire
201
+ - test/fixtures/postcode_anywhere_uk_geocode_v2_00_key_limit_exceeded
202
+ - test/fixtures/postcode_anywhere_uk_geocode_v2_00_no_results
203
+ - test/fixtures/postcode_anywhere_uk_geocode_v2_00_romsey
204
+ - test/fixtures/postcode_anywhere_uk_geocode_v2_00_unknown_key
183
205
  - test/fixtures/smarty_streets_11211
184
206
  - test/fixtures/smarty_streets_madison_square_garden
185
207
  - test/fixtures/smarty_streets_no_results
@@ -216,14 +238,18 @@ files:
216
238
  - test/unit/lookups/freegeoip_test.rb
217
239
  - test/unit/lookups/geocoder_ca_test.rb
218
240
  - test/unit/lookups/geocodio_test.rb
241
+ - test/unit/lookups/geoip2_test.rb
242
+ - test/unit/lookups/google_places_details_test.rb
219
243
  - test/unit/lookups/google_premier_test.rb
220
244
  - test/unit/lookups/google_test.rb
221
245
  - test/unit/lookups/mapquest_test.rb
222
246
  - test/unit/lookups/maxmind_local_test.rb
223
247
  - test/unit/lookups/maxmind_test.rb
224
248
  - test/unit/lookups/nominatim_test.rb
249
+ - test/unit/lookups/okf_test.rb
225
250
  - test/unit/lookups/opencagedata_test.rb
226
251
  - test/unit/lookups/pointpin_test.rb
252
+ - test/unit/lookups/postcode_anywhere_uk_test.rb
227
253
  - test/unit/lookups/smarty_streets_test.rb
228
254
  - test/unit/lookups/telize_test.rb
229
255
  - test/unit/lookups/yahoo_test.rb