geocoder 1.1.9 → 1.3.7

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 (174) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +157 -0
  3. data/README.md +467 -70
  4. data/examples/reverse_geocode_job.rb +40 -0
  5. data/lib/generators/geocoder/config/templates/initializer.rb +16 -16
  6. data/lib/generators/geocoder/maxmind/geolite_city_generator.rb +28 -0
  7. data/lib/generators/geocoder/maxmind/geolite_country_generator.rb +28 -0
  8. data/lib/generators/geocoder/maxmind/templates/migration/geolite_city.rb +30 -0
  9. data/lib/generators/geocoder/maxmind/templates/migration/geolite_country.rb +17 -0
  10. data/lib/geocoder/cache.rb +3 -2
  11. data/lib/geocoder/calculations.rb +44 -2
  12. data/lib/geocoder/configuration.rb +17 -10
  13. data/lib/geocoder/esri_token.rb +38 -0
  14. data/lib/geocoder/exceptions.rb +19 -0
  15. data/lib/geocoder/ip_address.rb +13 -0
  16. data/lib/geocoder/kernel_logger.rb +25 -0
  17. data/lib/geocoder/logger.rb +47 -0
  18. data/lib/geocoder/lookup.rb +32 -8
  19. data/lib/geocoder/lookups/baidu.rb +18 -13
  20. data/lib/geocoder/lookups/baidu_ip.rb +59 -0
  21. data/lib/geocoder/lookups/base.rb +81 -19
  22. data/lib/geocoder/lookups/bing.rb +40 -7
  23. data/lib/geocoder/lookups/esri.rb +42 -5
  24. data/lib/geocoder/lookups/freegeoip.rb +9 -1
  25. data/lib/geocoder/lookups/geocoder_ca.rb +1 -2
  26. data/lib/geocoder/lookups/geocoder_us.rb +6 -2
  27. data/lib/geocoder/lookups/geocodio.rb +42 -0
  28. data/lib/geocoder/lookups/geoip2.rb +45 -0
  29. data/lib/geocoder/lookups/geoportail_lu.rb +65 -0
  30. data/lib/geocoder/lookups/google.rb +29 -5
  31. data/lib/geocoder/lookups/google_places_details.rb +50 -0
  32. data/lib/geocoder/lookups/google_premier.rb +1 -1
  33. data/lib/geocoder/lookups/here.rb +62 -0
  34. data/lib/geocoder/lookups/ipapi_com.rb +86 -0
  35. data/lib/geocoder/lookups/ipinfo_io.rb +55 -0
  36. data/lib/geocoder/lookups/latlon.rb +59 -0
  37. data/lib/geocoder/lookups/mapbox.rb +53 -0
  38. data/lib/geocoder/lookups/mapquest.rb +6 -6
  39. data/lib/geocoder/lookups/mapzen.rb +15 -0
  40. data/lib/geocoder/lookups/maxmind.rb +4 -2
  41. data/lib/geocoder/lookups/maxmind_geoip2.rb +69 -0
  42. data/lib/geocoder/lookups/maxmind_local.rb +65 -0
  43. data/lib/geocoder/lookups/nominatim.rb +9 -1
  44. data/lib/geocoder/lookups/okf.rb +44 -0
  45. data/lib/geocoder/lookups/opencagedata.rb +58 -0
  46. data/lib/geocoder/lookups/pelias.rb +64 -0
  47. data/lib/geocoder/lookups/pointpin.rb +68 -0
  48. data/lib/geocoder/lookups/postcode_anywhere_uk.rb +51 -0
  49. data/lib/geocoder/lookups/smarty_streets.rb +53 -0
  50. data/lib/geocoder/lookups/telize.rb +55 -0
  51. data/lib/geocoder/lookups/yandex.rb +8 -4
  52. data/lib/geocoder/models/active_record.rb +7 -3
  53. data/lib/geocoder/models/base.rb +1 -4
  54. data/lib/geocoder/models/mongo_base.rb +6 -4
  55. data/lib/geocoder/query.rb +9 -5
  56. data/lib/geocoder/railtie.rb +1 -1
  57. data/lib/geocoder/request.rb +74 -12
  58. data/lib/geocoder/results/baidu_ip.rb +62 -0
  59. data/lib/geocoder/results/bing.rb +4 -0
  60. data/lib/geocoder/results/esri.rb +30 -6
  61. data/lib/geocoder/results/freegeoip.rb +2 -2
  62. data/lib/geocoder/results/geocodio.rb +70 -0
  63. data/lib/geocoder/results/geoip2.rb +62 -0
  64. data/lib/geocoder/results/geoportail_lu.rb +69 -0
  65. data/lib/geocoder/results/google.rb +15 -0
  66. data/lib/geocoder/results/google_places_details.rb +35 -0
  67. data/lib/geocoder/results/here.rb +71 -0
  68. data/lib/geocoder/results/ipapi_com.rb +45 -0
  69. data/lib/geocoder/results/ipinfo_io.rb +48 -0
  70. data/lib/geocoder/results/latlon.rb +71 -0
  71. data/lib/geocoder/results/mapbox.rb +47 -0
  72. data/lib/geocoder/results/mapquest.rb +5 -8
  73. data/lib/geocoder/results/mapzen.rb +5 -0
  74. data/lib/geocoder/results/maxmind_geoip2.rb +9 -0
  75. data/lib/geocoder/results/maxmind_local.rb +49 -0
  76. data/lib/geocoder/results/nominatim.rb +6 -1
  77. data/lib/geocoder/results/okf.rb +106 -0
  78. data/lib/geocoder/results/opencagedata.rb +90 -0
  79. data/lib/geocoder/results/ovi.rb +9 -0
  80. data/lib/geocoder/results/pelias.rb +58 -0
  81. data/lib/geocoder/results/pointpin.rb +40 -0
  82. data/lib/geocoder/results/postcode_anywhere_uk.rb +42 -0
  83. data/lib/geocoder/results/smarty_streets.rb +106 -0
  84. data/lib/geocoder/results/telize.rb +45 -0
  85. data/lib/geocoder/results/test.rb +20 -3
  86. data/lib/geocoder/results/yandex.rb +18 -6
  87. data/lib/geocoder/sql.rb +16 -15
  88. data/lib/geocoder/stores/active_record.rb +51 -18
  89. data/lib/geocoder/stores/base.rb +8 -12
  90. data/lib/geocoder/stores/mongo_base.rb +0 -31
  91. data/lib/geocoder/version.rb +1 -1
  92. data/lib/geocoder.rb +6 -13
  93. data/lib/maxmind_database.rb +109 -0
  94. data/lib/tasks/geocoder.rake +14 -3
  95. data/lib/tasks/maxmind.rake +73 -0
  96. metadata +59 -85
  97. data/.gitignore +0 -5
  98. data/.travis.yml +0 -27
  99. data/Rakefile +0 -25
  100. data/gemfiles/Gemfile.mongoid-2.4.x +0 -15
  101. data/lib/geocoder/lookups/yahoo.rb +0 -86
  102. data/lib/geocoder/results/yahoo.rb +0 -55
  103. data/lib/oauth_util.rb +0 -112
  104. data/test/active_record_test.rb +0 -15
  105. data/test/cache_test.rb +0 -35
  106. data/test/calculations_test.rb +0 -211
  107. data/test/configuration_test.rb +0 -78
  108. data/test/custom_block_test.rb +0 -32
  109. data/test/error_handling_test.rb +0 -43
  110. data/test/fixtures/baidu_invalid_key +0 -1
  111. data/test/fixtures/baidu_no_results +0 -1
  112. data/test/fixtures/baidu_reverse +0 -1
  113. data/test/fixtures/baidu_shanghai_pearl_tower +0 -12
  114. data/test/fixtures/bing_invalid_key +0 -1
  115. data/test/fixtures/bing_madison_square_garden +0 -40
  116. data/test/fixtures/bing_no_results +0 -16
  117. data/test/fixtures/bing_reverse +0 -42
  118. data/test/fixtures/esri_madison_square_garden +0 -59
  119. data/test/fixtures/esri_no_results +0 -8
  120. data/test/fixtures/esri_reverse +0 -21
  121. data/test/fixtures/freegeoip_74_200_247_59 +0 -12
  122. data/test/fixtures/freegeoip_no_results +0 -1
  123. data/test/fixtures/geocoder_ca_madison_square_garden +0 -1
  124. data/test/fixtures/geocoder_ca_no_results +0 -1
  125. data/test/fixtures/geocoder_ca_reverse +0 -34
  126. data/test/fixtures/geocoder_us_madison_square_garden +0 -1
  127. data/test/fixtures/geocoder_us_no_results +0 -1
  128. data/test/fixtures/google_garbage +0 -456
  129. data/test/fixtures/google_madison_square_garden +0 -57
  130. data/test/fixtures/google_no_city_data +0 -44
  131. data/test/fixtures/google_no_locality +0 -51
  132. data/test/fixtures/google_no_results +0 -4
  133. data/test/fixtures/google_over_limit +0 -4
  134. data/test/fixtures/mapquest_error +0 -16
  135. data/test/fixtures/mapquest_invalid_api_key +0 -16
  136. data/test/fixtures/mapquest_invalid_request +0 -16
  137. data/test/fixtures/mapquest_madison_square_garden +0 -52
  138. data/test/fixtures/mapquest_no_results +0 -16
  139. data/test/fixtures/maxmind_24_24_24_21 +0 -1
  140. data/test/fixtures/maxmind_24_24_24_22 +0 -1
  141. data/test/fixtures/maxmind_24_24_24_23 +0 -1
  142. data/test/fixtures/maxmind_24_24_24_24 +0 -1
  143. data/test/fixtures/maxmind_74_200_247_59 +0 -1
  144. data/test/fixtures/maxmind_invalid_key +0 -1
  145. data/test/fixtures/maxmind_no_results +0 -1
  146. data/test/fixtures/nominatim_madison_square_garden +0 -150
  147. data/test/fixtures/nominatim_no_results +0 -1
  148. data/test/fixtures/ovi_madison_square_garden +0 -72
  149. data/test/fixtures/ovi_no_results +0 -8
  150. data/test/fixtures/yahoo_error +0 -1
  151. data/test/fixtures/yahoo_invalid_key +0 -2
  152. data/test/fixtures/yahoo_madison_square_garden +0 -52
  153. data/test/fixtures/yahoo_no_results +0 -10
  154. data/test/fixtures/yahoo_over_limit +0 -2
  155. data/test/fixtures/yandex_invalid_key +0 -1
  156. data/test/fixtures/yandex_kremlin +0 -48
  157. data/test/fixtures/yandex_no_city_and_town +0 -112
  158. data/test/fixtures/yandex_no_results +0 -16
  159. data/test/geocoder_test.rb +0 -59
  160. data/test/https_test.rb +0 -16
  161. data/test/integration/smoke_test.rb +0 -26
  162. data/test/lookup_test.rb +0 -117
  163. data/test/method_aliases_test.rb +0 -25
  164. data/test/mongoid_test.rb +0 -46
  165. data/test/mongoid_test_helper.rb +0 -43
  166. data/test/near_test.rb +0 -61
  167. data/test/oauth_util_test.rb +0 -30
  168. data/test/proxy_test.rb +0 -36
  169. data/test/query_test.rb +0 -52
  170. data/test/request_test.rb +0 -29
  171. data/test/result_test.rb +0 -42
  172. data/test/services_test.rb +0 -393
  173. data/test/test_helper.rb +0 -289
  174. data/test/test_mode_test.rb +0 -59
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.1.9
4
+ version: 1.3.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Reisner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-11 00:00:00.000000000 Z
11
+ date: 2016-06-09 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,
@@ -21,28 +21,34 @@ executables:
21
21
  extensions: []
22
22
  extra_rdoc_files: []
23
23
  files:
24
- - .gitignore
25
- - .travis.yml
26
24
  - CHANGELOG.md
27
25
  - LICENSE
28
26
  - README.md
29
- - Rakefile
30
27
  - bin/geocode
31
28
  - examples/autoexpire_cache_dalli.rb
32
29
  - examples/autoexpire_cache_redis.rb
33
30
  - examples/cache_bypass.rb
34
- - gemfiles/Gemfile.mongoid-2.4.x
31
+ - examples/reverse_geocode_job.rb
35
32
  - lib/generators/geocoder/config/config_generator.rb
36
33
  - lib/generators/geocoder/config/templates/initializer.rb
34
+ - lib/generators/geocoder/maxmind/geolite_city_generator.rb
35
+ - lib/generators/geocoder/maxmind/geolite_country_generator.rb
36
+ - lib/generators/geocoder/maxmind/templates/migration/geolite_city.rb
37
+ - lib/generators/geocoder/maxmind/templates/migration/geolite_country.rb
37
38
  - lib/geocoder.rb
38
39
  - lib/geocoder/cache.rb
39
40
  - lib/geocoder/calculations.rb
40
41
  - lib/geocoder/cli.rb
41
42
  - lib/geocoder/configuration.rb
42
43
  - lib/geocoder/configuration_hash.rb
44
+ - lib/geocoder/esri_token.rb
43
45
  - lib/geocoder/exceptions.rb
46
+ - lib/geocoder/ip_address.rb
47
+ - lib/geocoder/kernel_logger.rb
48
+ - lib/geocoder/logger.rb
44
49
  - lib/geocoder/lookup.rb
45
50
  - lib/geocoder/lookups/baidu.rb
51
+ - lib/geocoder/lookups/baidu_ip.rb
46
52
  - lib/geocoder/lookups/base.rb
47
53
  - lib/geocoder/lookups/bing.rb
48
54
  - lib/geocoder/lookups/dstk.rb
@@ -50,14 +56,32 @@ files:
50
56
  - lib/geocoder/lookups/freegeoip.rb
51
57
  - lib/geocoder/lookups/geocoder_ca.rb
52
58
  - lib/geocoder/lookups/geocoder_us.rb
59
+ - lib/geocoder/lookups/geocodio.rb
60
+ - lib/geocoder/lookups/geoip2.rb
61
+ - lib/geocoder/lookups/geoportail_lu.rb
53
62
  - lib/geocoder/lookups/google.rb
63
+ - lib/geocoder/lookups/google_places_details.rb
54
64
  - lib/geocoder/lookups/google_premier.rb
65
+ - lib/geocoder/lookups/here.rb
66
+ - lib/geocoder/lookups/ipapi_com.rb
67
+ - lib/geocoder/lookups/ipinfo_io.rb
68
+ - lib/geocoder/lookups/latlon.rb
69
+ - lib/geocoder/lookups/mapbox.rb
55
70
  - lib/geocoder/lookups/mapquest.rb
71
+ - lib/geocoder/lookups/mapzen.rb
56
72
  - lib/geocoder/lookups/maxmind.rb
73
+ - lib/geocoder/lookups/maxmind_geoip2.rb
74
+ - lib/geocoder/lookups/maxmind_local.rb
57
75
  - lib/geocoder/lookups/nominatim.rb
76
+ - lib/geocoder/lookups/okf.rb
77
+ - lib/geocoder/lookups/opencagedata.rb
58
78
  - lib/geocoder/lookups/ovi.rb
79
+ - lib/geocoder/lookups/pelias.rb
80
+ - lib/geocoder/lookups/pointpin.rb
81
+ - lib/geocoder/lookups/postcode_anywhere_uk.rb
82
+ - lib/geocoder/lookups/smarty_streets.rb
83
+ - lib/geocoder/lookups/telize.rb
59
84
  - lib/geocoder/lookups/test.rb
60
- - lib/geocoder/lookups/yahoo.rb
61
85
  - lib/geocoder/lookups/yandex.rb
62
86
  - lib/geocoder/models/active_record.rb
63
87
  - lib/geocoder/models/base.rb
@@ -68,6 +92,7 @@ files:
68
92
  - lib/geocoder/railtie.rb
69
93
  - lib/geocoder/request.rb
70
94
  - lib/geocoder/results/baidu.rb
95
+ - lib/geocoder/results/baidu_ip.rb
71
96
  - lib/geocoder/results/base.rb
72
97
  - lib/geocoder/results/bing.rb
73
98
  - lib/geocoder/results/dstk.rb
@@ -75,14 +100,32 @@ files:
75
100
  - lib/geocoder/results/freegeoip.rb
76
101
  - lib/geocoder/results/geocoder_ca.rb
77
102
  - lib/geocoder/results/geocoder_us.rb
103
+ - lib/geocoder/results/geocodio.rb
104
+ - lib/geocoder/results/geoip2.rb
105
+ - lib/geocoder/results/geoportail_lu.rb
78
106
  - lib/geocoder/results/google.rb
107
+ - lib/geocoder/results/google_places_details.rb
79
108
  - lib/geocoder/results/google_premier.rb
109
+ - lib/geocoder/results/here.rb
110
+ - lib/geocoder/results/ipapi_com.rb
111
+ - lib/geocoder/results/ipinfo_io.rb
112
+ - lib/geocoder/results/latlon.rb
113
+ - lib/geocoder/results/mapbox.rb
80
114
  - lib/geocoder/results/mapquest.rb
115
+ - lib/geocoder/results/mapzen.rb
81
116
  - lib/geocoder/results/maxmind.rb
117
+ - lib/geocoder/results/maxmind_geoip2.rb
118
+ - lib/geocoder/results/maxmind_local.rb
82
119
  - lib/geocoder/results/nominatim.rb
120
+ - lib/geocoder/results/okf.rb
121
+ - lib/geocoder/results/opencagedata.rb
83
122
  - lib/geocoder/results/ovi.rb
123
+ - lib/geocoder/results/pelias.rb
124
+ - lib/geocoder/results/pointpin.rb
125
+ - lib/geocoder/results/postcode_anywhere_uk.rb
126
+ - lib/geocoder/results/smarty_streets.rb
127
+ - lib/geocoder/results/telize.rb
84
128
  - lib/geocoder/results/test.rb
85
- - lib/geocoder/results/yahoo.rb
86
129
  - lib/geocoder/results/yandex.rb
87
130
  - lib/geocoder/sql.rb
88
131
  - lib/geocoder/stores/active_record.rb
@@ -92,81 +135,12 @@ files:
92
135
  - lib/geocoder/stores/mongoid.rb
93
136
  - lib/geocoder/version.rb
94
137
  - lib/hash_recursive_merge.rb
95
- - lib/oauth_util.rb
138
+ - lib/maxmind_database.rb
96
139
  - lib/tasks/geocoder.rake
97
- - test/active_record_test.rb
98
- - test/cache_test.rb
99
- - test/calculations_test.rb
100
- - test/configuration_test.rb
101
- - test/custom_block_test.rb
102
- - test/error_handling_test.rb
103
- - test/fixtures/baidu_invalid_key
104
- - test/fixtures/baidu_no_results
105
- - test/fixtures/baidu_reverse
106
- - test/fixtures/baidu_shanghai_pearl_tower
107
- - test/fixtures/bing_invalid_key
108
- - test/fixtures/bing_madison_square_garden
109
- - test/fixtures/bing_no_results
110
- - test/fixtures/bing_reverse
111
- - test/fixtures/esri_madison_square_garden
112
- - test/fixtures/esri_no_results
113
- - test/fixtures/esri_reverse
114
- - test/fixtures/freegeoip_74_200_247_59
115
- - test/fixtures/freegeoip_no_results
116
- - test/fixtures/geocoder_ca_madison_square_garden
117
- - test/fixtures/geocoder_ca_no_results
118
- - test/fixtures/geocoder_ca_reverse
119
- - test/fixtures/geocoder_us_madison_square_garden
120
- - test/fixtures/geocoder_us_no_results
121
- - test/fixtures/google_garbage
122
- - test/fixtures/google_madison_square_garden
123
- - test/fixtures/google_no_city_data
124
- - test/fixtures/google_no_locality
125
- - test/fixtures/google_no_results
126
- - test/fixtures/google_over_limit
127
- - test/fixtures/mapquest_error
128
- - test/fixtures/mapquest_invalid_api_key
129
- - test/fixtures/mapquest_invalid_request
130
- - test/fixtures/mapquest_madison_square_garden
131
- - test/fixtures/mapquest_no_results
132
- - test/fixtures/maxmind_24_24_24_21
133
- - test/fixtures/maxmind_24_24_24_22
134
- - test/fixtures/maxmind_24_24_24_23
135
- - test/fixtures/maxmind_24_24_24_24
136
- - test/fixtures/maxmind_74_200_247_59
137
- - test/fixtures/maxmind_invalid_key
138
- - test/fixtures/maxmind_no_results
139
- - test/fixtures/nominatim_madison_square_garden
140
- - test/fixtures/nominatim_no_results
141
- - test/fixtures/ovi_madison_square_garden
142
- - test/fixtures/ovi_no_results
143
- - test/fixtures/yahoo_error
144
- - test/fixtures/yahoo_invalid_key
145
- - test/fixtures/yahoo_madison_square_garden
146
- - test/fixtures/yahoo_no_results
147
- - test/fixtures/yahoo_over_limit
148
- - test/fixtures/yandex_invalid_key
149
- - test/fixtures/yandex_kremlin
150
- - test/fixtures/yandex_no_city_and_town
151
- - test/fixtures/yandex_no_results
152
- - test/geocoder_test.rb
153
- - test/https_test.rb
154
- - test/integration/smoke_test.rb
155
- - test/lookup_test.rb
156
- - test/method_aliases_test.rb
157
- - test/mongoid_test.rb
158
- - test/mongoid_test_helper.rb
159
- - test/near_test.rb
160
- - test/oauth_util_test.rb
161
- - test/proxy_test.rb
162
- - test/query_test.rb
163
- - test/request_test.rb
164
- - test/result_test.rb
165
- - test/services_test.rb
166
- - test/test_helper.rb
167
- - test/test_mode_test.rb
140
+ - lib/tasks/maxmind.rake
168
141
  homepage: http://www.rubygeocoder.com
169
- licenses: []
142
+ licenses:
143
+ - MIT
170
144
  metadata: {}
171
145
  post_install_message:
172
146
  rdoc_options: []
@@ -174,17 +148,17 @@ require_paths:
174
148
  - lib
175
149
  required_ruby_version: !ruby/object:Gem::Requirement
176
150
  requirements:
177
- - - '>='
151
+ - - ">="
178
152
  - !ruby/object:Gem::Version
179
- version: '0'
153
+ version: 1.9.3
180
154
  required_rubygems_version: !ruby/object:Gem::Requirement
181
155
  requirements:
182
- - - '>='
156
+ - - ">="
183
157
  - !ruby/object:Gem::Version
184
158
  version: '0'
185
159
  requirements: []
186
160
  rubyforge_project:
187
- rubygems_version: 2.0.2
161
+ rubygems_version: 2.5.1
188
162
  signing_key:
189
163
  specification_version: 4
190
164
  summary: Complete geocoding solution for Ruby.
data/.gitignore DELETED
@@ -1,5 +0,0 @@
1
- pkg/*
2
- rdoc/*
3
- *.gem
4
- .bundle
5
- Gemfile.lock
data/.travis.yml DELETED
@@ -1,27 +0,0 @@
1
- rvm:
2
- - 1.8.7
3
- - 1.9.2
4
- - 1.9.3
5
- - 2.0.0
6
- - jruby-19mode
7
- gemfile:
8
- - Gemfile
9
- - gemfiles/Gemfile.mongoid-2.4.x
10
- env: SSL_CERT_DIR=/etc/ssl/certs
11
- matrix:
12
- exclude:
13
- - rvm: 1.8.7
14
- gemfile: Gemfile
15
- env: SSL_CERT_DIR=/etc/ssl/certs
16
- - rvm: 1.9.2
17
- gemfile: Gemfile
18
- env: SSL_CERT_DIR=/etc/ssl/certs
19
- - rvm: 1.9.3
20
- gemfile: gemfiles/Gemfile.mongoid-2.4.x
21
- env: SSL_CERT_DIR=/etc/ssl/certs
22
- - rvm: 2.0.0
23
- gemfile: gemfiles/Gemfile.mongoid-2.4.x
24
- env: SSL_CERT_DIR=/etc/ssl/certs
25
- - rvm: jruby-19mode
26
- gemfile: gemfiles/Gemfile.mongoid-2.4.x
27
- env: SSL_CERT_DIR=/etc/ssl/certs
data/Rakefile DELETED
@@ -1,25 +0,0 @@
1
- require 'bundler'
2
- Bundler::GemHelper.install_tasks
3
-
4
- require 'rake/testtask'
5
- Rake::TestTask.new(:test) do |test|
6
- test.libs << 'lib' << 'test'
7
- test.pattern = 'test/*_test.rb'
8
- test.verbose = true
9
- end
10
-
11
- Rake::TestTask.new(:integration) do |test|
12
- test.libs << 'lib' << 'test'
13
- test.pattern = 'test/integration/*_test.rb'
14
- test.verbose = true
15
- end
16
-
17
- task :default => [:test]
18
-
19
- require 'rdoc/task'
20
- Rake::RDocTask.new do |rdoc|
21
- rdoc.rdoc_dir = 'rdoc'
22
- rdoc.title = "Geocoder #{Geocoder::VERSION}"
23
- rdoc.rdoc_files.include('*.rdoc')
24
- rdoc.rdoc_files.include('lib/**/*.rb')
25
- end
@@ -1,15 +0,0 @@
1
- source "http://rubygems.org"
2
-
3
- gemspec :path => '..'
4
-
5
- group :development, :test do
6
- gem 'rake'
7
- gem 'mongoid', '2.4.11'
8
- gem 'bson_ext', :platforms => :ruby
9
-
10
- gem 'rails'
11
-
12
- platforms :jruby do
13
- gem 'jruby-openssl'
14
- end
15
- end
@@ -1,86 +0,0 @@
1
- require 'geocoder/lookups/base'
2
- require "geocoder/results/yahoo"
3
- require 'oauth_util'
4
-
5
- module Geocoder::Lookup
6
- class Yahoo < Base
7
-
8
- def name
9
- "Yahoo BOSS"
10
- end
11
-
12
- def map_link_url(coordinates)
13
- "http://maps.yahoo.com/#lat=#{coordinates[0]}&lon=#{coordinates[1]}"
14
- end
15
-
16
- def required_api_key_parts
17
- ["consumer key", "consumer secret"]
18
- end
19
-
20
- def query_url(query)
21
- parsed_url = URI.parse(raw_url(query))
22
- o = OauthUtil.new
23
- o.consumer_key = configuration.api_key[0]
24
- o.consumer_secret = configuration.api_key[1]
25
- base_url + o.sign(parsed_url).query_string
26
- end
27
-
28
- private # ---------------------------------------------------------------
29
-
30
- def results(query)
31
- return [] unless doc = fetch_data(query)
32
- doc = doc['bossresponse']
33
- if doc['responsecode'].to_i == 200
34
- if doc['placefinder']['count'].to_i > 0
35
- return doc['placefinder']['results']
36
- else
37
- return []
38
- end
39
- else
40
- warn "Yahoo Geocoding API error: #{doc['responsecode']} (#{doc['reason']})."
41
- return []
42
- end
43
- end
44
-
45
- ##
46
- # Yahoo returns errors as XML even when JSON format is specified.
47
- # Handle that here, without parsing the XML
48
- # (which would add unnecessary complexity).
49
- # Yahoo auth errors can also be cryptic, so add raw error desc
50
- # to warning message.
51
- #
52
- def parse_raw_data(raw_data)
53
- if raw_data.match /^<\?xml/
54
- if raw_data.include?("Rate Limit Exceeded")
55
- raise_error(Geocoder::OverQueryLimitError) || warn("Over API query limit.")
56
- elsif raw_data =~ /<yahoo:description>(Please provide valid credentials.*)<\/yahoo:description>/i
57
- raise_error(Geocoder::InvalidApiKey) || warn("Invalid API key. Error response: #{$1}")
58
- end
59
- else
60
- super(raw_data)
61
- end
62
- end
63
-
64
- def query_url_params(query)
65
- {
66
- :location => query.sanitized_text,
67
- :flags => "JXTSR",
68
- :gflags => "AC#{'R' if query.reverse_geocode?}",
69
- :locale => "#{configuration.language}_US",
70
- :appid => configuration.api_key
71
- }.merge(super)
72
- end
73
-
74
- def cache_key(query)
75
- raw_url(query)
76
- end
77
-
78
- def base_url
79
- "#{protocol}://yboss.yahooapis.com/geo/placefinder?"
80
- end
81
-
82
- def raw_url(query)
83
- base_url + url_query_string(query)
84
- end
85
- end
86
- end
@@ -1,55 +0,0 @@
1
- require 'geocoder/results/base'
2
-
3
- module Geocoder::Result
4
- class Yahoo < Base
5
-
6
- def address(format = :full)
7
- (1..4).to_a.map{ |i| @data["line#{i}"] }.reject{ |i| i.nil? or i == "" }.join(", ")
8
- end
9
-
10
- def city
11
- @data['city']
12
- end
13
-
14
- def state
15
- @data['state']
16
- end
17
-
18
- def state_code
19
- @data['statecode']
20
- end
21
-
22
- def country
23
- @data['country']
24
- end
25
-
26
- def country_code
27
- @data['countrycode']
28
- end
29
-
30
- def postal_code
31
- @data['postal']
32
- end
33
-
34
- def address_hash
35
- @data['hash']
36
- end
37
-
38
- def self.response_attributes
39
- %w[quality offsetlat offsetlon radius boundingbox name
40
- line1 line2 line3 line4 cross house street xstreet unittype unit
41
- city state statecode country countrycode postal
42
- neighborhood county countycode
43
- level0 level1 level2 level3 level4 level0code level1code level2code
44
- timezone areacode uzip hash woeid woetype]
45
- end
46
-
47
- response_attributes.each do |a|
48
- unless method_defined?(a)
49
- define_method a do
50
- @data[a]
51
- end
52
- end
53
- end
54
- end
55
- end
data/lib/oauth_util.rb DELETED
@@ -1,112 +0,0 @@
1
- # A utility for signing an url using OAuth in a way that's convenient for debugging
2
- # Note: the standard Ruby OAuth lib is here http://github.com/mojodna/oauth
3
- # Source: http://gist.github.com/383159
4
- # License: http://gist.github.com/375593
5
- # Usage: see example.rb below
6
- #
7
- # NOTE: This file has been modified from the original Gist:
8
- #
9
- # 1. Fix to prevent param-array conversion, as mentioned in Gist comment.
10
- # 2. Query string escaping has been changed. See:
11
- # https://github.com/alexreisner/geocoder/pull/360
12
- #
13
-
14
- require 'uri'
15
- require 'cgi'
16
- require 'openssl'
17
- require 'base64'
18
-
19
- class OauthUtil
20
-
21
- attr_accessor :consumer_key, :consumer_secret, :token, :token_secret, :req_method,
22
- :sig_method, :oauth_version, :callback_url, :params, :req_url, :base_str
23
-
24
- def initialize
25
- @consumer_key = ''
26
- @consumer_secret = ''
27
- @token = ''
28
- @token_secret = ''
29
- @req_method = 'GET'
30
- @sig_method = 'HMAC-SHA1'
31
- @oauth_version = '1.0'
32
- @callback_url = ''
33
- end
34
-
35
- # openssl::random_bytes returns non-word chars, which need to be removed. using alt method to get length
36
- # ref http://snippets.dzone.com/posts/show/491
37
- def nonce
38
- Array.new( 5 ) { rand(256) }.pack('C*').unpack('H*').first
39
- end
40
-
41
- def percent_encode( string )
42
-
43
- # ref http://snippets.dzone.com/posts/show/1260
44
- return URI.escape( string, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]") ).gsub('*', '%2A')
45
- end
46
-
47
- # @ref http://oauth.net/core/1.0/#rfc.section.9.2
48
- def signature
49
- key = percent_encode( @consumer_secret ) + '&' + percent_encode( @token_secret )
50
-
51
- # ref: http://blog.nathanielbibler.com/post/63031273/openssl-hmac-vs-ruby-hmac-benchmarks
52
- digest = OpenSSL::Digest::Digest.new( 'sha1' )
53
- hmac = OpenSSL::HMAC.digest( digest, key, @base_str )
54
-
55
- # ref http://groups.google.com/group/oauth-ruby/browse_thread/thread/9110ed8c8f3cae81
56
- Base64.encode64( hmac ).chomp.gsub( /\n/, '' )
57
- end
58
-
59
- # sort (very important as it affects the signature), concat, and percent encode
60
- # @ref http://oauth.net/core/1.0/#rfc.section.9.1.1
61
- # @ref http://oauth.net/core/1.0/#9.2.1
62
- # @ref http://oauth.net/core/1.0/#rfc.section.A.5.1
63
- def query_string
64
- pairs = []
65
- @params.sort.each { | key, val |
66
- pairs.push( "#{ CGI.escape(key.to_s).gsub(/%(5B|5D)/n) { [$1].pack('H*') } }=#{ CGI.escape(val.to_s) }" )
67
- }
68
- pairs.join '&'
69
- end
70
-
71
- # organize params & create signature
72
- def sign( parsed_url )
73
-
74
- @params = {
75
- 'oauth_consumer_key' => @consumer_key,
76
- 'oauth_nonce' => nonce,
77
- 'oauth_signature_method' => @sig_method,
78
- 'oauth_timestamp' => Time.now.to_i.to_s,
79
- 'oauth_version' => @oauth_version
80
- }
81
-
82
- # if url has query, merge key/values into params obj overwriting defaults
83
- if parsed_url.query
84
- CGI.parse( parsed_url.query ).each do |k,v|
85
- if v.is_a?(Array) && v.count == 1
86
- @params[k] = v.first
87
- else
88
- @params[k] = v
89
- end
90
- end
91
- end
92
-
93
- # @ref http://oauth.net/core/1.0/#rfc.section.9.1.2
94
- @req_url = parsed_url.scheme + '://' + parsed_url.host + parsed_url.path
95
-
96
- # create base str. make it an object attr for ez debugging
97
- # ref http://oauth.net/core/1.0/#anchor14
98
- @base_str = [
99
- @req_method,
100
- percent_encode( req_url ),
101
-
102
- # normalization is just x-www-form-urlencoded
103
- percent_encode( query_string )
104
-
105
- ].join( '&' )
106
-
107
- # add signature
108
- @params[ 'oauth_signature' ] = signature
109
-
110
- return self
111
- end
112
- end
@@ -1,15 +0,0 @@
1
- # encoding: utf-8
2
- require 'test_helper'
3
-
4
- class ActiveRecordTest < Test::Unit::TestCase
5
-
6
- def test_exclude_condition_when_model_has_a_custom_primary_key
7
- venue = VenuePlus.new(*venue_params(:msg))
8
-
9
- # just call private method directly so we don't have to stub .near scope
10
- conditions = venue.class.send(:add_exclude_condition, ["fake_condition"], venue)
11
-
12
- assert_match( /#{VenuePlus.primary_key}/, conditions.join)
13
- end
14
-
15
- end
data/test/cache_test.rb DELETED
@@ -1,35 +0,0 @@
1
- # encoding: utf-8
2
- require 'test_helper'
3
-
4
- class CacheTest < Test::Unit::TestCase
5
-
6
- def test_second_occurrence_of_request_is_cache_hit
7
- Geocoder.configure(:cache => {})
8
- Geocoder::Lookup.all_services_except_test.each do |l|
9
- Geocoder.configure(:lookup => l)
10
- set_api_key!(l)
11
- results = Geocoder.search("Madison Square Garden")
12
- assert !results.first.cache_hit,
13
- "Lookup #{l} returned erroneously cached result."
14
- results = Geocoder.search("Madison Square Garden")
15
- assert results.first.cache_hit,
16
- "Lookup #{l} did not return cached result."
17
- end
18
- end
19
-
20
- def test_google_over_query_limit_does_not_hit_cache
21
- Geocoder.configure(:cache => {})
22
- Geocoder.configure(:lookup => :google)
23
- set_api_key!(:google)
24
- Geocoder.configure(:always_raise => :all)
25
- assert_raises Geocoder::OverQueryLimitError do
26
- Geocoder.search("over limit")
27
- end
28
- lookup = Geocoder::Lookup.get(:google)
29
- assert_equal false, lookup.instance_variable_get(:@cache_hit)
30
- assert_raises Geocoder::OverQueryLimitError do
31
- Geocoder.search("over limit")
32
- end
33
- assert_equal false, lookup.instance_variable_get(:@cache_hit)
34
- end
35
- end