barometer 0.7.3 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +1 -0
- data/.travis.yml +7 -0
- data/LICENSE +1 -1
- data/{README.rdoc → README.md} +124 -110
- data/Rakefile +1 -21
- data/TODO +8 -9
- data/barometer.gemspec +20 -19
- data/bin/barometer +36 -83
- data/lib/barometer.rb +13 -11
- data/lib/barometer/base.rb +10 -10
- data/lib/barometer/data.rb +1 -1
- data/lib/barometer/data/distance.rb +25 -25
- data/lib/barometer/data/geo.rb +9 -9
- data/lib/barometer/data/local_datetime.rb +24 -20
- data/lib/barometer/data/local_time.rb +13 -13
- data/lib/barometer/data/location.rb +6 -6
- data/lib/barometer/data/pressure.rb +24 -24
- data/lib/barometer/data/speed.rb +28 -28
- data/lib/barometer/data/sun.rb +7 -7
- data/lib/barometer/data/temperature.rb +29 -29
- data/lib/barometer/data/units.rb +9 -9
- data/lib/barometer/data/zone.rb +19 -19
- data/lib/barometer/formats.rb +1 -1
- data/lib/barometer/formats/coordinates.rb +7 -7
- data/lib/barometer/formats/format.rb +6 -6
- data/lib/barometer/formats/geocode.rb +5 -5
- data/lib/barometer/formats/icao.rb +6 -6
- data/lib/barometer/formats/postalcode.rb +3 -3
- data/lib/barometer/formats/short_zipcode.rb +2 -2
- data/lib/barometer/formats/weather_id.rb +10 -10
- data/lib/barometer/formats/woe_id.rb +20 -20
- data/lib/barometer/formats/zipcode.rb +3 -3
- data/lib/barometer/key_file_parser.rb +20 -0
- data/lib/barometer/measurements/measurement.rb +32 -32
- data/lib/barometer/measurements/result.rb +39 -39
- data/lib/barometer/measurements/result_array.rb +12 -12
- data/lib/barometer/query.rb +15 -15
- data/lib/barometer/services.rb +3 -3
- data/lib/barometer/translations/icao_country_codes.yml +20 -20
- data/lib/barometer/translations/weather_country_codes.yml +1 -1
- data/lib/barometer/translations/zone_codes.yml +2 -2
- data/lib/barometer/version.rb +3 -0
- data/lib/barometer/weather.rb +27 -27
- data/lib/barometer/weather_services/noaa.rb +314 -3
- data/lib/barometer/weather_services/service.rb +32 -30
- data/lib/barometer/weather_services/weather_bug.rb +35 -33
- data/lib/barometer/weather_services/wunderground.rb +31 -29
- data/lib/barometer/weather_services/yahoo.rb +36 -35
- data/lib/barometer/web_services/geocode.rb +5 -7
- data/lib/barometer/web_services/noaa_station_id.rb +53 -0
- data/lib/barometer/web_services/placemaker.rb +11 -13
- data/lib/barometer/web_services/timezone.rb +5 -7
- data/lib/barometer/web_services/weather_id.rb +4 -6
- data/lib/barometer/web_services/web_service.rb +4 -4
- data/spec/barometer_spec.rb +25 -27
- data/spec/cassettes/Barometer.json +1 -0
- data/spec/cassettes/Query.json +1 -0
- data/spec/cassettes/Query_Format_Coordinates.json +1 -0
- data/spec/cassettes/Query_Format_Geocode.json +1 -0
- data/spec/cassettes/Query_Format_WeatherID.json +1 -0
- data/spec/cassettes/Query_Format_WoeID.json +1 -0
- data/spec/cassettes/WeatherService.json +1 -0
- data/spec/cassettes/WeatherService_Noaa.json +1 -0
- data/spec/cassettes/WeatherService_WeatherBug.json +1 -0
- data/spec/cassettes/WeatherService_Wunderground.json +1 -0
- data/spec/cassettes/WeatherService_Yahoo.json +1 -0
- data/spec/cassettes/WebService_Geocode.json +1 -0
- data/spec/cassettes/WebService_NoaaStation.json +1 -0
- data/spec/data/distance_spec.rb +60 -60
- data/spec/data/geo_spec.rb +23 -23
- data/spec/data/local_datetime_spec.rb +44 -44
- data/spec/data/local_time_spec.rb +47 -47
- data/spec/data/location_spec.rb +16 -16
- data/spec/data/pressure_spec.rb +61 -61
- data/spec/data/speed_spec.rb +69 -69
- data/spec/data/sun_spec.rb +25 -25
- data/spec/data/temperature_spec.rb +68 -68
- data/spec/data/units_spec.rb +21 -21
- data/spec/data/zone_spec.rb +35 -35
- data/spec/formats/coordinates_spec.rb +27 -27
- data/spec/formats/format_spec.rb +17 -25
- data/spec/formats/geocode_spec.rb +23 -31
- data/spec/formats/icao_spec.rb +26 -32
- data/spec/formats/postalcode_spec.rb +22 -28
- data/spec/formats/short_zipcode_spec.rb +20 -26
- data/spec/formats/weather_id_spec.rb +57 -67
- data/spec/formats/woe_id_spec.rb +59 -59
- data/spec/formats/zipcode_spec.rb +39 -47
- data/spec/key_file_parser_spec.rb +28 -0
- data/spec/measurements/measurement_spec.rb +79 -133
- data/spec/measurements/result_array_spec.rb +23 -38
- data/spec/measurements/result_spec.rb +100 -128
- data/spec/query_spec.rb +83 -100
- data/spec/spec_helper.rb +24 -6
- data/spec/weather_services/noaa_spec.rb +179 -0
- data/spec/weather_services/services_spec.rb +28 -36
- data/spec/weather_services/weather_bug_spec.rb +57 -77
- data/spec/weather_services/wunderground_spec.rb +36 -65
- data/spec/weather_services/yahoo_spec.rb +38 -60
- data/spec/weather_spec.rb +79 -79
- data/spec/web_services/geocode_spec.rb +7 -11
- data/spec/web_services/noaa_station_id_spec.rb +33 -0
- data/spec/web_services/placemaker_spec.rb +7 -12
- data/spec/web_services/web_services_spec.rb +3 -9
- metadata +214 -163
- data/VERSION.yml +0 -5
- data/lib/barometer/weather_services/google.rb +0 -142
- data/lib/barometer/weather_services/weather_dot_com.rb +0 -279
- data/spec/fakeweb_helper.rb +0 -179
- data/spec/fixtures/formats/weather_id/90210.xml +0 -7
- data/spec/fixtures/formats/weather_id/from_USGA0028.xml +0 -3
- data/spec/fixtures/formats/weather_id/ksfo.xml +0 -1
- data/spec/fixtures/formats/weather_id/manhattan.xml +0 -7
- data/spec/fixtures/formats/weather_id/new_york.xml +0 -1
- data/spec/fixtures/formats/weather_id/the_hills.xml +0 -1
- data/spec/fixtures/geocode/40_73_v3.json +0 -497
- data/spec/fixtures/geocode/90210_v3.json +0 -63
- data/spec/fixtures/geocode/T5B4M9_v3.json +0 -68
- data/spec/fixtures/geocode/atlanta_v3.json +0 -58
- data/spec/fixtures/geocode/calgary_ab_v3.json +0 -58
- data/spec/fixtures/geocode/ksfo_v3.json +0 -73
- data/spec/fixtures/geocode/newyork_ny_v3.json +0 -58
- data/spec/fixtures/services/google/calgary_ab.xml +0 -1
- data/spec/fixtures/services/placemaker/T5B4M9.xml +0 -65
- data/spec/fixtures/services/placemaker/atlanta.xml +0 -65
- data/spec/fixtures/services/placemaker/coords.xml +0 -65
- data/spec/fixtures/services/placemaker/ksfo.xml +0 -65
- data/spec/fixtures/services/placemaker/new_york.xml +0 -65
- data/spec/fixtures/services/placemaker/the_hills.xml +0 -65
- data/spec/fixtures/services/placemaker/w615702.xml +0 -47
- data/spec/fixtures/services/weather_bug/90210_current.xml +0 -93
- data/spec/fixtures/services/weather_bug/90210_forecast.xml +0 -76
- data/spec/fixtures/services/weather_dot_com/90210.xml +0 -1
- data/spec/fixtures/services/wunderground/current_calgary_ab.xml +0 -9
- data/spec/fixtures/services/wunderground/forecast_calgary_ab.xml +0 -13
- data/spec/fixtures/services/yahoo/90210.xml +0 -3
- data/spec/weather_services/google_spec.rb +0 -181
- data/spec/weather_services/weather_dot_com_spec.rb +0 -224
data/spec/query_spec.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
2
|
|
3
|
-
describe
|
4
|
-
|
3
|
+
describe Barometer::Query, :vcr => {
|
4
|
+
:cassette_name => "Query"
|
5
|
+
} do
|
5
6
|
before(:each) do
|
6
7
|
@short_zipcode = "90210"
|
7
8
|
@zipcode = @short_zipcode
|
@@ -11,13 +12,13 @@ describe "Query" do
|
|
11
12
|
@coordinates = "40.756054,-73.986951"
|
12
13
|
@geocode = "New York, NY"
|
13
14
|
@icao = "KSFO"
|
14
|
-
|
15
|
+
|
15
16
|
# actual conversions
|
16
17
|
@zipcode_to_coordinates = "34.1030032,-118.4104684"
|
17
18
|
@zipcode_to_geocode = "Beverly Hills, CA, United States"
|
18
19
|
@zipcode_to_weather_id = "USCA0090"
|
19
|
-
@postalcode_to_coordinates = "53.
|
20
|
-
@geocode_to_coordinates = "40.7143528,-74.
|
20
|
+
@postalcode_to_coordinates = "53.5721719,-113.4551835"
|
21
|
+
@geocode_to_coordinates = "40.7143528,-74.0059731"
|
21
22
|
@geocode_to_weather_id = "USNY0996"
|
22
23
|
@coordinates_to_geocode = "Manhattan, NY, United States"
|
23
24
|
@coordinates_to_weather_id = "USNY0996"
|
@@ -25,9 +26,8 @@ describe "Query" do
|
|
25
26
|
@icao_to_geocode = "San Francisco, CA, United States"
|
26
27
|
@icao_to_weather_id = "USCA0987"
|
27
28
|
end
|
28
|
-
|
29
|
+
|
29
30
|
describe "determines the query format" do
|
30
|
-
|
31
31
|
before(:each) do
|
32
32
|
@query = Barometer::Query.new
|
33
33
|
@query.country_code.should be_nil
|
@@ -48,7 +48,7 @@ describe "Query" do
|
|
48
48
|
@query.format.to_sym.should == :zipcode
|
49
49
|
@query.country_code.should == "US"
|
50
50
|
end
|
51
|
-
|
51
|
+
|
52
52
|
it "recognizes a postal code" do
|
53
53
|
@query.q = @postal_code
|
54
54
|
@query.format.should be_nil
|
@@ -56,7 +56,7 @@ describe "Query" do
|
|
56
56
|
@query.format.to_sym.should == :postalcode
|
57
57
|
@query.country_code.should == "CA"
|
58
58
|
end
|
59
|
-
|
59
|
+
|
60
60
|
it "recognizes icao" do
|
61
61
|
@query.q = @icao
|
62
62
|
@query.format.should be_nil
|
@@ -64,7 +64,7 @@ describe "Query" do
|
|
64
64
|
@query.format.to_sym.should == :icao
|
65
65
|
@query.country_code.should == "US"
|
66
66
|
end
|
67
|
-
|
67
|
+
|
68
68
|
it "recognizes weather_id" do
|
69
69
|
@query.q = @weather_id
|
70
70
|
@query.format.should be_nil
|
@@ -72,7 +72,7 @@ describe "Query" do
|
|
72
72
|
@query.format.to_sym.should == :weather_id
|
73
73
|
@query.country_code.should == "US"
|
74
74
|
end
|
75
|
-
|
75
|
+
|
76
76
|
it "recognizes latitude/longitude" do
|
77
77
|
@query.q = @coordinates
|
78
78
|
@query.format.should be_nil
|
@@ -80,7 +80,7 @@ describe "Query" do
|
|
80
80
|
@query.format.to_sym.should == :coordinates
|
81
81
|
@query.country_code.should be_nil
|
82
82
|
end
|
83
|
-
|
83
|
+
|
84
84
|
it "defaults to a general geo_location" do
|
85
85
|
@query.q = @geocode
|
86
86
|
@query.format.should be_nil
|
@@ -88,62 +88,60 @@ describe "Query" do
|
|
88
88
|
@query.format.to_sym.should == :geocode
|
89
89
|
@query.country_code.should be_nil
|
90
90
|
end
|
91
|
-
|
92
91
|
end
|
93
|
-
|
92
|
+
|
94
93
|
describe "when initialized" do
|
95
|
-
|
96
94
|
before(:each) do
|
97
95
|
@query = Barometer::Query.new
|
98
96
|
end
|
99
|
-
|
97
|
+
|
100
98
|
it "responds to q" do
|
101
99
|
@query.q.should be_nil
|
102
100
|
end
|
103
|
-
|
101
|
+
|
104
102
|
it "attempts query conversion when reading q (if format known)" do
|
105
103
|
query = Barometer::Query.new(@geocode)
|
106
104
|
query.format.should == :geocode
|
107
105
|
Barometer::Query::Format::Geocode.should_receive(:convert_query).once.with(@geocode).and_return(@geocode)
|
108
106
|
query.q.should == @geocode
|
109
107
|
end
|
110
|
-
|
108
|
+
|
111
109
|
it "does not attempt query conversion when reading q (if format unknown)" do
|
112
110
|
@query.format.should be_nil
|
113
111
|
Barometer::Query::Format.should_not_receive(:convert_query)
|
114
112
|
@query.q.should be_nil
|
115
113
|
end
|
116
|
-
|
114
|
+
|
117
115
|
it "responds to format" do
|
118
116
|
@query.format.should be_nil
|
119
117
|
end
|
120
|
-
|
118
|
+
|
121
119
|
it "responds to country_code" do
|
122
120
|
@query.country_code.should be_nil
|
123
121
|
end
|
124
|
-
|
122
|
+
|
125
123
|
it "sets the query" do
|
126
124
|
query = Barometer::Query.new(@geocode)
|
127
125
|
query.q.should == @geocode
|
128
126
|
end
|
129
|
-
|
127
|
+
|
130
128
|
it "determines the format" do
|
131
129
|
query = Barometer::Query.new(@geocode)
|
132
130
|
query.format.should_not be_nil
|
133
131
|
end
|
134
|
-
|
132
|
+
|
135
133
|
it "responds to geo" do
|
136
134
|
@query.geo.should be_nil
|
137
135
|
end
|
138
|
-
|
136
|
+
|
139
137
|
it "responds to timezone" do
|
140
138
|
@query.timezone.should be_nil
|
141
139
|
end
|
142
|
-
|
140
|
+
|
143
141
|
it "responds to conversions" do
|
144
142
|
@query.conversions.should be_nil
|
145
143
|
end
|
146
|
-
|
144
|
+
|
147
145
|
it "returns latitude for when recognized as coordinates" do
|
148
146
|
@query.q = @coordinates
|
149
147
|
@query.format.should be_nil
|
@@ -151,7 +149,7 @@ describe "Query" do
|
|
151
149
|
@query.format.to_sym.should == :coordinates
|
152
150
|
@query.latitude.should == @coordinates.split(',')[0]
|
153
151
|
end
|
154
|
-
|
152
|
+
|
155
153
|
it "returns longitude for when recognized as coordinates" do
|
156
154
|
@query.q = @coordinates
|
157
155
|
@query.format.should be_nil
|
@@ -159,7 +157,7 @@ describe "Query" do
|
|
159
157
|
@query.format.to_sym.should == :coordinates
|
160
158
|
@query.longitude.should == @coordinates.split(',')[1]
|
161
159
|
end
|
162
|
-
|
160
|
+
|
163
161
|
it "returns nothing for latitude/longitude when not coordinates" do
|
164
162
|
@query.q = @geocode
|
165
163
|
@query.format.should be_nil
|
@@ -168,348 +166,333 @@ describe "Query" do
|
|
168
166
|
@query.latitude.should be_nil
|
169
167
|
@query.longitude.should be_nil
|
170
168
|
end
|
171
|
-
|
172
169
|
end
|
173
|
-
|
170
|
+
|
174
171
|
describe "when returning the query to a Weather API" do
|
175
|
-
|
176
172
|
it "raises an error if there are NO acceptable formats" do
|
177
173
|
acceptable_formats = nil
|
178
174
|
query = Barometer::Query.new
|
179
175
|
lambda { query.convert!(acceptable_formats) }.should raise_error
|
180
|
-
|
176
|
+
|
181
177
|
acceptable_formats = []
|
182
178
|
lambda { query.convert!(acceptable_formats) }.should raise_error
|
183
179
|
end
|
184
|
-
|
180
|
+
|
185
181
|
describe "and the query is already the preferred format" do
|
186
|
-
|
187
182
|
it "returns the short_zipcode untouched" do
|
188
183
|
preferred = [:short_zipcode]
|
189
184
|
query = Barometer::Query.new(@short_zipcode)
|
190
185
|
query.convert!(preferred).q.should == @short_zipcode
|
191
186
|
query.country_code.should == "US"
|
192
187
|
end
|
193
|
-
|
188
|
+
|
194
189
|
it "returns the long_zipcode untouched" do
|
195
190
|
preferred = [:zipcode]
|
196
191
|
query = Barometer::Query.new(@long_zipcode)
|
197
192
|
query.convert!(preferred).q.should == @long_zipcode
|
198
193
|
query.country_code.should == "US"
|
199
194
|
end
|
200
|
-
|
195
|
+
|
201
196
|
it "returns the postalcode untouched" do
|
202
197
|
preferred = [:postalcode]
|
203
198
|
query = Barometer::Query.new(@postal_code)
|
204
199
|
query.convert!(preferred).q.should == @postal_code
|
205
200
|
query.country_code.should == "CA"
|
206
201
|
end
|
207
|
-
|
202
|
+
|
208
203
|
it "returns the icao untouched" do
|
209
204
|
preferred = [:icao]
|
210
205
|
query = Barometer::Query.new(@icao)
|
211
206
|
query.convert!(preferred).q.should == @icao
|
212
207
|
end
|
213
|
-
|
208
|
+
|
214
209
|
it "returns the coordinates untouched" do
|
215
210
|
preferred = [:coordinates]
|
216
211
|
query = Barometer::Query.new(@coordinates)
|
217
212
|
query.convert!(preferred).q.should == @coordinates
|
218
213
|
end
|
219
|
-
|
214
|
+
|
220
215
|
it "returns the geocode untouched" do
|
221
216
|
preferred = [:geocode]
|
222
217
|
query = Barometer::Query.new(@geocode)
|
223
218
|
query.convert!(preferred).q.should == @geocode
|
224
219
|
end
|
225
|
-
|
226
220
|
end
|
227
|
-
|
221
|
+
|
228
222
|
describe "and the query needs converting" do
|
229
|
-
|
230
223
|
describe "with an intial format of :short_zipcode," do
|
231
|
-
|
232
224
|
before(:each) do
|
233
225
|
@query = Barometer::Query.new(@short_zipcode)
|
234
226
|
end
|
235
|
-
|
227
|
+
|
236
228
|
it "converts to zipcode" do
|
237
229
|
acceptable_formats = [:zipcode]
|
238
230
|
query = @query.convert!(acceptable_formats)
|
239
231
|
query.q.should == @zipcode
|
240
232
|
query.country_code.should == "US"
|
241
233
|
end
|
242
|
-
|
234
|
+
|
243
235
|
it "converts to coordinates" do
|
244
236
|
acceptable_formats = [:coordinates]
|
245
237
|
query = @query.convert!(acceptable_formats)
|
246
238
|
query.q.should == @zipcode_to_coordinates
|
247
239
|
query.country_code.should == "US"
|
248
240
|
end
|
249
|
-
|
241
|
+
|
250
242
|
it "converts to geocode" do
|
251
243
|
acceptable_formats = [:geocode]
|
252
244
|
query = @query.convert!(acceptable_formats)
|
253
245
|
query.q.should == @zipcode_to_geocode
|
254
246
|
query.country_code.should == "US"
|
255
247
|
end
|
256
|
-
|
248
|
+
|
257
249
|
it "converts to weather_id" do
|
258
250
|
acceptable_formats = [:weather_id]
|
259
251
|
query = @query.convert!(acceptable_formats)
|
260
252
|
query.q.should == @zipcode_to_weather_id
|
261
253
|
query.country_code.should == "US"
|
262
254
|
end
|
263
|
-
|
255
|
+
|
264
256
|
it "skips converting to icao" do
|
265
257
|
acceptable_formats = [:icao]
|
266
258
|
query = @query.convert!(acceptable_formats)
|
267
259
|
query.should be_nil
|
268
260
|
end
|
269
|
-
|
261
|
+
|
270
262
|
it "skips converting to postalcode" do
|
271
263
|
acceptable_formats = [:postalcode]
|
272
264
|
query = @query.convert!(acceptable_formats)
|
273
265
|
query.should be_nil
|
274
266
|
end
|
275
|
-
|
276
267
|
end
|
277
|
-
|
268
|
+
|
278
269
|
describe "with an intial format of :zipcode," do
|
279
|
-
|
280
270
|
before(:each) do
|
281
271
|
@query = Barometer::Query.new(@zipcode)
|
282
272
|
Barometer.force_geocode = false
|
283
273
|
end
|
284
|
-
|
274
|
+
|
285
275
|
it "converts to coordinates" do
|
286
276
|
acceptable_formats = [:coordinates]
|
287
277
|
query = @query.convert!(acceptable_formats)
|
288
278
|
query.q.should == @zipcode_to_coordinates
|
289
279
|
query.country_code.should == "US"
|
290
280
|
end
|
291
|
-
|
281
|
+
|
292
282
|
it "converts to geocode" do
|
293
283
|
acceptable_formats = [:geocode]
|
294
284
|
query = @query.convert!(acceptable_formats)
|
295
285
|
query.q.should == @zipcode_to_geocode
|
296
286
|
query.country_code.should == "US"
|
297
287
|
end
|
298
|
-
|
288
|
+
|
299
289
|
it "skips converting to icao" do
|
300
290
|
acceptable_formats = [:icao]
|
301
291
|
query = @query.convert!(acceptable_formats)
|
302
292
|
query.should be_nil
|
303
293
|
end
|
304
|
-
|
294
|
+
|
305
295
|
it "skips converting to postalcode" do
|
306
296
|
acceptable_formats = [:postalcode]
|
307
297
|
query = @query.convert!(acceptable_formats)
|
308
298
|
query.should be_nil
|
309
299
|
end
|
310
|
-
|
300
|
+
|
311
301
|
it "skips converting to short_zipcode" do
|
312
302
|
@query = Barometer::Query.new(@long_zipcode)
|
313
303
|
acceptable_formats = [:short_zipcode]
|
314
304
|
query = @query.convert!(acceptable_formats)
|
315
305
|
query.should be_nil
|
316
306
|
end
|
317
|
-
|
307
|
+
|
318
308
|
it "converts to weather_id" do
|
319
309
|
acceptable_formats = [:weather_id]
|
320
310
|
query = @query.convert!(acceptable_formats)
|
321
311
|
query.q.should == @zipcode_to_weather_id
|
322
312
|
query.country_code.should == "US"
|
323
313
|
end
|
324
|
-
|
325
314
|
end
|
326
|
-
|
315
|
+
|
327
316
|
describe "with an intial format of :postalcode," do
|
328
|
-
|
329
317
|
before(:each) do
|
330
318
|
@query = Barometer::Query.new(@postal_code)
|
331
319
|
end
|
332
|
-
|
320
|
+
|
333
321
|
it "converts to coordinates" do
|
334
322
|
acceptable_formats = [:coordinates]
|
335
323
|
query = @query.convert!(acceptable_formats)
|
336
324
|
query.q.should == @postalcode_to_coordinates
|
337
325
|
query.country_code.should == "CA"
|
338
326
|
end
|
339
|
-
|
327
|
+
|
340
328
|
it "skips converting to geocode" do
|
341
329
|
acceptable_formats = [:geocode]
|
342
330
|
query = @query.convert!(acceptable_formats)
|
343
331
|
query.should be_nil
|
344
332
|
end
|
345
|
-
|
333
|
+
|
346
334
|
it "skips converting to icao" do
|
347
335
|
acceptable_formats = [:icao]
|
348
336
|
query = @query.convert!(acceptable_formats)
|
349
337
|
query.should be_nil
|
350
338
|
end
|
351
|
-
|
339
|
+
|
352
340
|
it "skips converting to short_zipcode" do
|
353
341
|
acceptable_formats = [:short_zipcode]
|
354
342
|
query = @query.convert!(acceptable_formats)
|
355
343
|
query.should be_nil
|
356
344
|
end
|
357
|
-
|
345
|
+
|
358
346
|
it "skips converting to weather_id" do
|
359
347
|
acceptable_formats = [:weather_id]
|
360
348
|
query = @query.convert!(acceptable_formats)
|
361
349
|
query.should be_nil
|
362
350
|
end
|
363
|
-
|
351
|
+
|
364
352
|
it "skips converting to zipcode" do
|
365
353
|
acceptable_formats = [:zipcode]
|
366
354
|
query = @query.convert!(acceptable_formats)
|
367
355
|
query.should be_nil
|
368
356
|
end
|
369
|
-
|
370
357
|
end
|
371
|
-
|
358
|
+
|
372
359
|
describe "with an intial format of :icao," do
|
373
|
-
|
374
360
|
before(:each) do
|
375
361
|
@query = Barometer::Query.new(@icao)
|
376
362
|
end
|
377
|
-
|
363
|
+
|
378
364
|
it "converts to coordinates" do
|
379
365
|
acceptable_formats = [:coordinates]
|
380
366
|
query = @query.convert!(acceptable_formats)
|
381
367
|
query.q.should == @icao_to_coordinates
|
382
368
|
query.country_code.should == "US"
|
383
369
|
end
|
384
|
-
|
370
|
+
|
385
371
|
it "converts to geocode" do
|
386
372
|
acceptable_formats = [:geocode]
|
387
373
|
query = @query.convert!(acceptable_formats)
|
388
374
|
query.q.should == @icao_to_geocode
|
389
375
|
query.country_code.should == "US"
|
390
376
|
end
|
391
|
-
|
377
|
+
|
392
378
|
it "skips converting to postalcode" do
|
393
379
|
acceptable_formats = [:postalcode]
|
394
380
|
query = @query.convert!(acceptable_formats)
|
395
381
|
query.should be_nil
|
396
382
|
end
|
397
|
-
|
383
|
+
|
398
384
|
it "skips converting to short_zipcode" do
|
399
385
|
acceptable_formats = [:short_zipcode]
|
400
386
|
query = @query.convert!(acceptable_formats)
|
401
387
|
query.should be_nil
|
402
388
|
end
|
403
|
-
|
389
|
+
|
404
390
|
it "converts to weather_id" do
|
405
391
|
acceptable_formats = [:weather_id]
|
406
392
|
query = @query.convert!(acceptable_formats)
|
407
393
|
query.q.should == @icao_to_weather_id
|
408
394
|
query.country_code.should == "US"
|
409
395
|
end
|
410
|
-
|
396
|
+
|
411
397
|
it "skips converting to zipcode" do
|
412
398
|
acceptable_formats = [:zipcode]
|
413
399
|
query = @query.convert!(acceptable_formats)
|
414
400
|
query.should be_nil
|
415
401
|
end
|
416
|
-
|
417
402
|
end
|
418
|
-
|
403
|
+
|
419
404
|
describe "with an intial format of :geocode," do
|
420
|
-
|
421
405
|
before(:each) do
|
422
406
|
@query = Barometer::Query.new(@geocode)
|
423
407
|
end
|
424
|
-
|
408
|
+
|
425
409
|
it "converts to coordinates" do
|
426
410
|
acceptable_formats = [:coordinates]
|
427
411
|
query = @query.convert!(acceptable_formats)
|
428
|
-
|
412
|
+
|
413
|
+
query_coords = query.q.split(',').map{|c| c.to_f}
|
414
|
+
expected_coords = @geocode_to_coordinates.split(',').map{|c| c.to_f}
|
415
|
+
|
416
|
+
query_coords[0].should be_within(0.00001).of(expected_coords[0])
|
417
|
+
query_coords[1].should be_within(0.00001).of(expected_coords[1])
|
429
418
|
query.country_code.should == "US"
|
430
419
|
end
|
431
|
-
|
420
|
+
|
432
421
|
it "skips converting to icao" do
|
433
422
|
acceptable_formats = [:icao]
|
434
423
|
query = @query.convert!(acceptable_formats)
|
435
424
|
query.should be_nil
|
436
425
|
end
|
437
|
-
|
426
|
+
|
438
427
|
it "skips converting to postalcode" do
|
439
428
|
acceptable_formats = [:postalcode]
|
440
429
|
query = @query.convert!(acceptable_formats)
|
441
430
|
query.should be_nil
|
442
431
|
end
|
443
|
-
|
432
|
+
|
444
433
|
it "skips converting to short_zipcode" do
|
445
434
|
acceptable_formats = [:short_zipcode]
|
446
435
|
query = @query.convert!(acceptable_formats)
|
447
436
|
query.should be_nil
|
448
437
|
end
|
449
|
-
|
438
|
+
|
450
439
|
it "converts to weather_id" do
|
451
440
|
acceptable_formats = [:weather_id]
|
452
441
|
query = @query.convert!(acceptable_formats)
|
453
442
|
query.q.should == @geocode_to_weather_id
|
454
443
|
query.country_code.should == "US"
|
455
444
|
end
|
456
|
-
|
445
|
+
|
457
446
|
it "skips converting to zipcode" do
|
458
447
|
acceptable_formats = [:zipcode]
|
459
448
|
query = @query.convert!(acceptable_formats)
|
460
449
|
query.should be_nil
|
461
450
|
end
|
462
|
-
|
463
451
|
end
|
464
|
-
|
452
|
+
|
465
453
|
describe "with an intial format of :coordinates," do
|
466
|
-
|
467
454
|
before(:each) do
|
468
455
|
@query = Barometer::Query.new(@coordinates)
|
469
456
|
end
|
470
|
-
|
457
|
+
|
471
458
|
it "converts to geocode" do
|
472
459
|
acceptable_formats = [:geocode]
|
473
460
|
query = @query.convert!(acceptable_formats)
|
474
461
|
query.q.should == @coordinates_to_geocode
|
475
462
|
query.country_code.should == "US"
|
476
463
|
end
|
477
|
-
|
464
|
+
|
478
465
|
it "skips converting to icao" do
|
479
466
|
acceptable_formats = [:icao]
|
480
467
|
query = @query.convert!(acceptable_formats)
|
481
468
|
query.should be_nil
|
482
469
|
end
|
483
|
-
|
470
|
+
|
484
471
|
it "skips converting to postalcode" do
|
485
472
|
acceptable_formats = [:postalcode]
|
486
473
|
query = @query.convert!(acceptable_formats)
|
487
474
|
query.should be_nil
|
488
475
|
end
|
489
|
-
|
476
|
+
|
490
477
|
it "skips converting to short_zipcode" do
|
491
478
|
acceptable_formats = [:short_zipcode]
|
492
479
|
query = @query.convert!(acceptable_formats)
|
493
480
|
query.should be_nil
|
494
481
|
end
|
495
|
-
|
482
|
+
|
496
483
|
it "converts to weather_id" do
|
497
484
|
acceptable_formats = [:weather_id]
|
498
485
|
query = @query.convert!(acceptable_formats)
|
499
486
|
query.q.should == @coordinates_to_weather_id
|
500
487
|
query.country_code.should == "US"
|
501
488
|
end
|
502
|
-
|
489
|
+
|
503
490
|
it "skips converting to zipcode" do
|
504
491
|
acceptable_formats = [:zipcode]
|
505
492
|
query = @query.convert!(acceptable_formats)
|
506
493
|
query.should be_nil
|
507
494
|
end
|
508
|
-
|
509
495
|
end
|
510
|
-
|
511
496
|
end
|
512
|
-
|
513
497
|
end
|
514
|
-
|
515
|
-
end
|
498
|
+
end
|