attack-barometer 0.5.0 → 0.6.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/README.rdoc +51 -9
- data/VERSION.yml +1 -1
- data/bin/barometer +57 -7
- data/lib/barometer/base.rb +3 -0
- data/lib/barometer/data/sun.rb +10 -0
- data/lib/barometer/data/zone.rb +79 -188
- data/lib/barometer/data.rb +11 -6
- data/lib/barometer/formats/coordinates.rb +4 -1
- data/lib/barometer/formats/geocode.rb +9 -7
- data/lib/barometer/formats/icao.rb +2 -2
- data/lib/barometer/formats/weather_id.rb +2 -2
- data/lib/barometer/measurements/common.rb +113 -0
- data/lib/barometer/{data → measurements}/current.rb +17 -42
- data/lib/barometer/measurements/forecast.rb +62 -0
- data/lib/barometer/measurements/forecast_array.rb +72 -0
- data/lib/barometer/{data → measurements}/measurement.rb +57 -45
- data/lib/barometer/measurements/night.rb +27 -0
- data/lib/barometer/query.rb +55 -5
- data/lib/barometer/services.rb +3 -1
- data/lib/barometer/translations/zone_codes.yml +360 -0
- data/lib/barometer/weather.rb +5 -4
- data/lib/barometer/weather_services/google.rb +19 -35
- data/lib/barometer/weather_services/service.rb +113 -255
- data/lib/barometer/weather_services/weather_bug.rb +291 -2
- data/lib/barometer/weather_services/weather_dot_com.rb +45 -54
- data/lib/barometer/weather_services/wunderground.rb +83 -89
- data/lib/barometer/weather_services/yahoo.rb +44 -91
- data/lib/barometer/web_services/geocode.rb +1 -0
- data/lib/barometer/web_services/timezone.rb +40 -0
- data/lib/barometer/web_services/weather_id.rb +17 -2
- data/lib/barometer.rb +11 -0
- data/lib/demometer/demometer.rb +28 -0
- data/lib/demometer/public/css/master.css +259 -1
- data/lib/demometer/views/index.erb +2 -0
- data/lib/demometer/views/layout.erb +3 -2
- data/lib/demometer/views/measurement.erb +4 -1
- data/lib/demometer/views/readme.erb +116 -88
- data/spec/data/sun_spec.rb +53 -0
- data/spec/data/zone_spec.rb +330 -100
- data/spec/fixtures/formats/weather_id/ksfo.xml +1 -0
- data/spec/fixtures/services/weather_bug/90210_current.xml +1 -0
- data/spec/fixtures/services/weather_bug/90210_forecast.xml +1 -0
- data/spec/formats/weather_id_spec.rb +10 -5
- data/spec/measurements/common_spec.rb +352 -0
- data/spec/{data → measurements}/current_spec.rb +40 -103
- data/spec/measurements/forecast_array_spec.rb +165 -0
- data/spec/measurements/forecast_spec.rb +135 -0
- data/spec/{data → measurements}/measurement_spec.rb +86 -107
- data/spec/measurements/night_measurement_spec.rb +49 -0
- data/spec/query_spec.rb +12 -2
- data/spec/spec_helper.rb +28 -1
- data/spec/weather_services/google_spec.rb +27 -117
- data/spec/weather_services/services_spec.rb +49 -1024
- data/spec/weather_services/weather_bug_spec.rb +274 -0
- data/spec/weather_services/weather_dot_com_spec.rb +45 -125
- data/spec/weather_services/wunderground_spec.rb +42 -136
- data/spec/weather_services/yahoo_spec.rb +26 -116
- data/spec/weather_spec.rb +45 -45
- metadata +23 -11
- data/lib/barometer/data/forecast.rb +0 -84
- data/lib/barometer/data/night.rb +0 -69
- data/lib/barometer/extensions/graticule.rb +0 -51
- data/spec/data/forecast_spec.rb +0 -192
- data/spec/data/night_measurement_spec.rb +0 -136
data/spec/data/sun_spec.rb
CHANGED
@@ -46,4 +46,57 @@ describe "Data::Sun" do
|
|
46
46
|
|
47
47
|
end
|
48
48
|
|
49
|
+
describe "comparisons" do
|
50
|
+
|
51
|
+
before(:each) do
|
52
|
+
now = Time.local(2009,5,5,11,40,00)
|
53
|
+
@mid_time = Data::LocalTime.new.parse(now)
|
54
|
+
@early_time = Data::LocalTime.new.parse(now - (60*60*8))
|
55
|
+
@late_time = Data::LocalTime.new.parse(now + (60*60*8))
|
56
|
+
end
|
57
|
+
|
58
|
+
describe "after_rise?" do
|
59
|
+
|
60
|
+
it "requires a LocalTime object" do
|
61
|
+
sun = Data::Sun.new(@early_time,@late_time)
|
62
|
+
lambda { sun.after_rise? }.should raise_error(ArgumentError)
|
63
|
+
lambda { sun.after_rise?("invalid") }.should raise_error(ArgumentError)
|
64
|
+
lambda { sun.after_rise?(@mid_time) }.should_not raise_error(ArgumentError)
|
65
|
+
end
|
66
|
+
|
67
|
+
it "returns true when after sun rise" do
|
68
|
+
sun = Data::Sun.new(@early_time,@late_time)
|
69
|
+
sun.after_rise?(@mid_time).should be_true
|
70
|
+
end
|
71
|
+
|
72
|
+
it "returns false when before sun rise" do
|
73
|
+
sun = Data::Sun.new(@mid_time,@late_time)
|
74
|
+
sun.after_rise?(@early_time).should be_false
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
78
|
+
|
79
|
+
describe "before_set?" do
|
80
|
+
|
81
|
+
it "requires a LocalTime object" do
|
82
|
+
sun = Data::Sun.new(@early_time,@late_time)
|
83
|
+
lambda { sun.before_set? }.should raise_error(ArgumentError)
|
84
|
+
lambda { sun.before_set?("invalid") }.should raise_error(ArgumentError)
|
85
|
+
lambda { sun.before_set?(@mid_time) }.should_not raise_error(ArgumentError)
|
86
|
+
end
|
87
|
+
|
88
|
+
it "returns true when before sun set" do
|
89
|
+
sun = Data::Sun.new(@early_time,@late_time)
|
90
|
+
sun.before_set?(@mid_time).should be_true
|
91
|
+
end
|
92
|
+
|
93
|
+
it "returns false when before sun set" do
|
94
|
+
sun = Data::Sun.new(@early_time,@mid_time)
|
95
|
+
sun.before_set?(@late_time).should be_false
|
96
|
+
end
|
97
|
+
|
98
|
+
end
|
99
|
+
|
100
|
+
end
|
101
|
+
|
49
102
|
end
|
data/spec/data/zone_spec.rb
CHANGED
@@ -2,130 +2,360 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe "Data::Zone" do
|
4
4
|
|
5
|
-
describe "and class methods" do
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
end
|
5
|
+
# describe "and class methods" do
|
6
|
+
#
|
7
|
+
# it "responds to now and returns Time object" do
|
8
|
+
# Data::Zone.respond_to?("now").should be_true
|
9
|
+
# Data::Zone.now.is_a?(Time).should be_true
|
10
|
+
# end
|
11
|
+
#
|
12
|
+
# it "responds to today and returns Date object" do
|
13
|
+
# Data::Zone.respond_to?("today").should be_true
|
14
|
+
# Data::Zone.today.is_a?(Date).should be_true
|
15
|
+
# end
|
16
|
+
#
|
17
|
+
# end
|
18
18
|
|
19
19
|
describe "when initialized" do
|
20
20
|
|
21
|
-
|
22
|
-
@utc = Time.now.utc
|
23
|
-
@timezone = "Europe/Paris"
|
24
|
-
@zone = Data::Zone.new(@timezone)
|
25
|
-
end
|
21
|
+
describe "with a full zone" do
|
26
22
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
23
|
+
before(:each) do
|
24
|
+
@utc = Time.now.utc
|
25
|
+
@timezone = "Europe/Paris"
|
26
|
+
@zone = Data::Zone.new(@timezone)
|
27
|
+
end
|
31
28
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
zone.tz.should_not be_nil
|
37
|
-
end
|
29
|
+
it "responds to zone_full" do
|
30
|
+
@zone.zone_full.should_not be_nil
|
31
|
+
@zone.zone_full.should == @timezone
|
32
|
+
end
|
38
33
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
34
|
+
it "responds to zone_code" do
|
35
|
+
@zone.zone_code.should be_nil
|
36
|
+
end
|
37
|
+
|
38
|
+
it "responds to zone_offset" do
|
39
|
+
@zone.zone_offset.should be_nil
|
40
|
+
end
|
41
|
+
|
42
|
+
it "responds to tz" do
|
43
|
+
lambda { Data::Zone.new("invalid timezone") }.should raise_error(ArgumentError)
|
45
44
|
|
46
|
-
|
47
|
-
|
48
|
-
|
45
|
+
zone = Data::Zone.new(@timezone)
|
46
|
+
zone.tz.should_not be_nil
|
47
|
+
end
|
49
48
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
49
|
+
it "responds to full" do
|
50
|
+
@zone.respond_to?("full").should be_true
|
51
|
+
zone = Data::Zone.new(@timezone)
|
52
|
+
zone.tz = nil
|
53
|
+
zone.tz.should be_nil
|
54
|
+
zone.full.should == @timezone
|
55
|
+
|
56
|
+
zone = Data::Zone.new(@timezone)
|
57
|
+
zone.full.should == @timezone
|
58
|
+
end
|
57
59
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
60
|
+
it "responds to code" do
|
61
|
+
@zone.respond_to?("code").should be_true
|
62
|
+
zone = Data::Zone.new(@timezone)
|
63
|
+
zone.tz = nil
|
64
|
+
zone.tz.should be_nil
|
65
|
+
zone.code.should be_nil
|
62
66
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
+
zone = Data::Zone.new(@timezone)
|
68
|
+
zone.code.should == "CEST"
|
69
|
+
end
|
70
|
+
|
71
|
+
it "responds to dst?" do
|
72
|
+
@zone.respond_to?("dst?").should be_true
|
73
|
+
zone = Data::Zone.new(@timezone)
|
74
|
+
zone.tz = nil
|
75
|
+
zone.tz.should be_nil
|
76
|
+
zone.dst?.should be_nil
|
77
|
+
end
|
67
78
|
|
68
|
-
|
69
|
-
|
70
|
-
|
79
|
+
it "responds to now" do
|
80
|
+
@zone.respond_to?("now").should be_true
|
81
|
+
@zone.now.is_a?(Time).should be_true
|
82
|
+
|
83
|
+
period = @zone.tz.period_for_utc(Time.now)
|
84
|
+
actual_now = Time.now.utc + period.utc_total_offset
|
85
|
+
|
86
|
+
now = @zone.now
|
87
|
+
now.hour.should == actual_now.hour
|
88
|
+
now.min.should == actual_now.min
|
89
|
+
now.sec.should == actual_now.sec
|
90
|
+
now.year.should == actual_now.year
|
91
|
+
now.month.should == actual_now.month
|
92
|
+
now.day.should == actual_now.day
|
93
|
+
end
|
71
94
|
|
72
|
-
|
73
|
-
|
95
|
+
it "responds to today" do
|
96
|
+
@zone.respond_to?("today").should be_true
|
97
|
+
@zone.today.is_a?(Date).should be_true
|
98
|
+
|
99
|
+
period = @zone.tz.period_for_utc(Time.now)
|
100
|
+
actual_now = Time.now.utc + period.utc_total_offset
|
101
|
+
|
102
|
+
now = @zone.today
|
103
|
+
now.year.should == actual_now.year
|
104
|
+
now.month.should == actual_now.month
|
105
|
+
now.day.should == actual_now.day
|
106
|
+
end
|
107
|
+
|
108
|
+
it "converts local_time to utc" do
|
109
|
+
local_time = Time.now.utc
|
110
|
+
utc_time = @zone.local_to_utc(local_time)
|
111
|
+
|
112
|
+
offset = @zone.tz.period_for_utc(local_time).utc_total_offset
|
113
|
+
utc_time.should == (local_time - offset)
|
114
|
+
end
|
115
|
+
|
116
|
+
it "converts utc to local_time" do
|
117
|
+
utc_time = Time.now.utc
|
118
|
+
local_time = @zone.utc_to_local(utc_time)
|
119
|
+
|
120
|
+
offset = @zone.tz.period_for_utc(local_time).utc_total_offset
|
121
|
+
utc_time.should == (local_time - offset)
|
122
|
+
end
|
123
|
+
|
74
124
|
end
|
75
125
|
|
76
|
-
|
77
|
-
local_time = Time.now.utc
|
78
|
-
utc_time = @zone.local_to_utc(local_time)
|
126
|
+
describe "with a zone code" do
|
79
127
|
|
80
|
-
|
81
|
-
|
128
|
+
before(:each) do
|
129
|
+
@utc = Time.now.utc
|
130
|
+
@timezone = "EAST"
|
131
|
+
@zone = Data::Zone.new(@timezone)
|
132
|
+
end
|
133
|
+
|
134
|
+
it "responds to zone_code" do
|
135
|
+
@zone.zone_code.should_not be_nil
|
136
|
+
@zone.zone_code.should == @timezone
|
137
|
+
end
|
138
|
+
|
139
|
+
it "responds to zone_full" do
|
140
|
+
@zone.zone_full.should be_nil
|
141
|
+
end
|
142
|
+
|
143
|
+
it "responds to zone_offset" do
|
144
|
+
@zone.zone_offset.should be_nil
|
145
|
+
end
|
146
|
+
|
147
|
+
it "responds to tz" do
|
148
|
+
zone = Data::Zone.new(@timezone)
|
149
|
+
zone.tz.should be_nil
|
150
|
+
end
|
151
|
+
|
152
|
+
it "responds to code" do
|
153
|
+
@zone.respond_to?("code").should be_true
|
154
|
+
zone = Data::Zone.new(@timezone)
|
155
|
+
zone.tz = nil
|
156
|
+
zone.tz.should be_nil
|
157
|
+
zone.code.should == @timezone
|
158
|
+
|
159
|
+
zone = Data::Zone.new(@timezone)
|
160
|
+
zone.code.should == @timezone
|
161
|
+
end
|
162
|
+
|
163
|
+
it "responds to full" do
|
164
|
+
@zone.respond_to?("full").should be_true
|
165
|
+
zone = Data::Zone.new(@timezone)
|
166
|
+
zone.tz = nil
|
167
|
+
zone.tz.should be_nil
|
168
|
+
zone.full.should be_nil
|
169
|
+
|
170
|
+
zone = Data::Zone.new(@timezone)
|
171
|
+
zone.full.should be_nil
|
172
|
+
end
|
173
|
+
|
174
|
+
it "responds to now" do
|
175
|
+
@zone.respond_to?("now").should be_true
|
176
|
+
@zone.now.is_a?(Time).should be_true
|
177
|
+
|
178
|
+
actual_now = Time.now.utc + (-6*60*60)
|
179
|
+
|
180
|
+
now = @zone.now
|
181
|
+
now.hour.should == actual_now.hour
|
182
|
+
now.min.should == actual_now.min
|
183
|
+
now.sec.should == actual_now.sec
|
184
|
+
now.year.should == actual_now.year
|
185
|
+
now.month.should == actual_now.month
|
186
|
+
now.day.should == actual_now.day
|
187
|
+
end
|
188
|
+
|
189
|
+
it "responds to today" do
|
190
|
+
@zone.respond_to?("today").should be_true
|
191
|
+
@zone.today.is_a?(Date).should be_true
|
192
|
+
|
193
|
+
actual_now = Time.now.utc + (-6*60*60)
|
194
|
+
|
195
|
+
now = @zone.today
|
196
|
+
now.year.should == actual_now.year
|
197
|
+
now.month.should == actual_now.month
|
198
|
+
now.day.should == actual_now.day
|
199
|
+
end
|
200
|
+
|
201
|
+
it "converts local_time to utc" do
|
202
|
+
local_time = Time.now.utc
|
203
|
+
utc_time = @zone.local_to_utc(local_time)
|
204
|
+
|
205
|
+
utc_time.year.should == (local_time - @zone.offset).year
|
206
|
+
utc_time.month.should == (local_time - @zone.offset).month
|
207
|
+
utc_time.day.should == (local_time - @zone.offset).day
|
208
|
+
utc_time.hour.should == (local_time - @zone.offset).hour
|
209
|
+
utc_time.min.should == (local_time - @zone.offset).min
|
210
|
+
utc_time.sec.should == (local_time - @zone.offset).sec
|
211
|
+
end
|
212
|
+
|
213
|
+
it "converts utc to local_time" do
|
214
|
+
utc_time = Time.now.utc
|
215
|
+
local_time = @zone.utc_to_local(utc_time)
|
216
|
+
|
217
|
+
local_time.year.should == (utc_time + @zone.offset).year
|
218
|
+
local_time.month.should == (utc_time + @zone.offset).month
|
219
|
+
local_time.day.should == (utc_time + @zone.offset).day
|
220
|
+
local_time.hour.should == (utc_time + @zone.offset).hour
|
221
|
+
local_time.min.should == (utc_time + @zone.offset).min
|
222
|
+
local_time.sec.should == (utc_time + @zone.offset).sec
|
223
|
+
end
|
224
|
+
|
82
225
|
end
|
83
226
|
|
84
|
-
|
85
|
-
utc_time = Time.now.utc
|
86
|
-
local_time = @zone.utc_to_local(utc_time)
|
227
|
+
describe "with a zone offset" do
|
87
228
|
|
88
|
-
|
89
|
-
|
229
|
+
before(:each) do
|
230
|
+
@utc = Time.now.utc
|
231
|
+
@timezone = 8.5
|
232
|
+
@zone = Data::Zone.new(@timezone)
|
233
|
+
end
|
234
|
+
|
235
|
+
it "responds to zone_offset" do
|
236
|
+
@zone.zone_offset.should_not be_nil
|
237
|
+
@zone.zone_offset.should == @timezone
|
238
|
+
end
|
239
|
+
|
240
|
+
it "responds to zone_full" do
|
241
|
+
@zone.zone_full.should be_nil
|
242
|
+
end
|
243
|
+
|
244
|
+
it "responds to zone_code" do
|
245
|
+
@zone.zone_code.should be_nil
|
246
|
+
end
|
247
|
+
|
248
|
+
it "responds to tz" do
|
249
|
+
zone = Data::Zone.new(@timezone)
|
250
|
+
zone.tz.should be_nil
|
251
|
+
end
|
252
|
+
|
253
|
+
it "responds to offset" do
|
254
|
+
@zone.respond_to?("offset").should be_true
|
255
|
+
zone = Data::Zone.new(@timezone)
|
256
|
+
zone.tz = nil
|
257
|
+
zone.tz.should be_nil
|
258
|
+
zone.offset.should == (@timezone * 60 * 60)
|
259
|
+
|
260
|
+
zone = Data::Zone.new(@timezone)
|
261
|
+
zone.offset.should == (@timezone * 60 * 60)
|
262
|
+
end
|
263
|
+
|
264
|
+
it "responds to full" do
|
265
|
+
@zone.respond_to?("full").should be_true
|
266
|
+
zone = Data::Zone.new(@timezone)
|
267
|
+
zone.tz = nil
|
268
|
+
zone.tz.should be_nil
|
269
|
+
zone.full.should be_nil
|
270
|
+
|
271
|
+
zone = Data::Zone.new(@timezone)
|
272
|
+
zone.full.should be_nil
|
273
|
+
end
|
274
|
+
|
275
|
+
it "responds to code" do
|
276
|
+
@zone.respond_to?("code").should be_true
|
277
|
+
zone = Data::Zone.new(@timezone)
|
278
|
+
zone.tz = nil
|
279
|
+
zone.tz.should be_nil
|
280
|
+
zone.code.should be_nil
|
281
|
+
|
282
|
+
zone = Data::Zone.new(@timezone)
|
283
|
+
zone.code.should be_nil
|
284
|
+
end
|
285
|
+
|
286
|
+
it "responds to now" do
|
287
|
+
@zone.respond_to?("now").should be_true
|
288
|
+
@zone.now.is_a?(Time).should be_true
|
289
|
+
|
290
|
+
actual_now = Time.now.utc + (@timezone.to_f*60*60)
|
291
|
+
|
292
|
+
now = @zone.now
|
293
|
+
now.hour.should == actual_now.hour
|
294
|
+
now.min.should == actual_now.min
|
295
|
+
now.sec.should == actual_now.sec
|
296
|
+
now.year.should == actual_now.year
|
297
|
+
now.month.should == actual_now.month
|
298
|
+
now.day.should == actual_now.day
|
299
|
+
end
|
300
|
+
|
301
|
+
it "responds to today" do
|
302
|
+
@zone.respond_to?("today").should be_true
|
303
|
+
@zone.today.is_a?(Date).should be_true
|
304
|
+
|
305
|
+
actual_now = Time.now.utc + (@timezone.to_f*60*60)
|
306
|
+
|
307
|
+
now = @zone.today
|
308
|
+
now.year.should == actual_now.year
|
309
|
+
now.month.should == actual_now.month
|
310
|
+
now.day.should == actual_now.day
|
311
|
+
end
|
312
|
+
|
313
|
+
it "converts local_time to utc" do
|
314
|
+
local_time = Time.now.utc
|
315
|
+
utc_time = @zone.local_to_utc(local_time)
|
316
|
+
|
317
|
+
utc_time.year.should == (local_time - @zone.offset).year
|
318
|
+
utc_time.month.should == (local_time - @zone.offset).month
|
319
|
+
utc_time.day.should == (local_time - @zone.offset).day
|
320
|
+
utc_time.hour.should == (local_time - @zone.offset).hour
|
321
|
+
utc_time.min.should == (local_time - @zone.offset).min
|
322
|
+
utc_time.sec.should == (local_time - @zone.offset).sec
|
323
|
+
end
|
324
|
+
|
325
|
+
it "converts utc to local_time" do
|
326
|
+
utc_time = Time.now.utc
|
327
|
+
local_time = @zone.utc_to_local(utc_time)
|
328
|
+
|
329
|
+
local_time.year.should == (utc_time + @zone.offset).year
|
330
|
+
local_time.month.should == (utc_time + @zone.offset).month
|
331
|
+
local_time.day.should == (utc_time + @zone.offset).day
|
332
|
+
local_time.hour.should == (utc_time + @zone.offset).hour
|
333
|
+
local_time.min.should == (utc_time + @zone.offset).min
|
334
|
+
local_time.sec.should == (utc_time + @zone.offset).sec
|
335
|
+
end
|
336
|
+
|
90
337
|
end
|
91
338
|
|
92
339
|
end
|
93
340
|
|
94
|
-
describe "when
|
95
|
-
|
96
|
-
it "
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
target_utc_time = Data::Zone.code_to_utc(target_time, target_zone)
|
108
|
-
local_utc_time = local_time.utc
|
109
|
-
|
110
|
-
(target_utc_time - local_time.utc).to_i.should == original_difference.to_i
|
341
|
+
describe "when detecting zones" do
|
342
|
+
|
343
|
+
it "recognozes a full time zone format" do
|
344
|
+
Data::Zone.is_zone_full?("invalid").should be_false
|
345
|
+
Data::Zone.is_zone_full?("America/New York").should be_true
|
346
|
+
end
|
347
|
+
|
348
|
+
it "matches a zone offset" do
|
349
|
+
Data::Zone.is_zone_offset?("invalid").should be_false
|
350
|
+
Data::Zone.is_zone_offset?("MST").should be_false
|
351
|
+
Data::Zone.is_zone_offset?("10").should be_false
|
352
|
+
Data::Zone.is_zone_offset?(-10).should be_true
|
111
353
|
end
|
112
354
|
|
113
|
-
it "
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
date = Date.parse(merge_date)
|
119
|
-
time = Time.parse(merge_time)
|
120
|
-
|
121
|
-
utc_time = Data::Zone.merge(merge_time, merge_date, merge_zonecode)
|
122
|
-
|
123
|
-
utc_time.year.should == date.year
|
124
|
-
utc_time.month.should == date.month
|
125
|
-
utc_time.day.should == date.day
|
126
|
-
utc_time.hour.should == time.hour
|
127
|
-
utc_time.min.should == time.min
|
128
|
-
utc_time.sec.should == time.sec
|
355
|
+
it "matches a zone code" do
|
356
|
+
Data::Zone.is_zone_code?("invalid").should be_false
|
357
|
+
Data::Zone.is_zone_code?("MST").should be_true
|
358
|
+
Data::Zone.is_zone_code?("EAST").should be_true
|
129
359
|
end
|
130
360
|
|
131
361
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
<?xml version="1.0" encoding="ISO-8859-1"?> <!-- This document is intended only for use by authorized licensees of The --> <!-- Weather Channel. Unauthorized use is prohibited. Copyright 1995-2009, --> <!-- The Weather Channel Interactive, Inc. All Rights Reserved. --> <search ver="3.0"> <loc id="USCA0987" type="1">San Francisco, CA</loc> <loc id="USCA1085" type="1">South San Francisco, CA</loc> </search>
|
@@ -0,0 +1 @@
|
|
1
|
+
<aws:weather xmlns:aws="http://www.aws.com/aws"><aws:api version="2.0" /><aws:WebURL>http://weather.weatherbug.com/CA/Los Angeles-weather.html?ZCode=Z5546&Units=1&stat=LSNGH</aws:WebURL><aws:InputLocationURL>http://weather.weatherbug.com/CA/Beverly Hills-weather.html?ZCode=Z5546&Units=1</aws:InputLocationURL><aws:ob><aws:ob-date><aws:year number="2009" /><aws:month number="5" text="May" abbrv="May" /><aws:day number="15" text="Friday" abbrv="Fri" /><aws:hour number="11" hour-24="11" /><aws:minute number="00" /><aws:second number="02" /><aws:am-pm abbrv="AM" /><aws:time-zone offset="-7" text="Pacific Daylight Time" abbrv="PDT" /></aws:ob-date><aws:requested-station-id /><aws:station-id>LSNGH</aws:station-id><aws:station>Milken Community HS</aws:station><aws:city-state zipcode="90049">Los Angeles, CA</aws:city-state><aws:country>USA</aws:country><aws:latitude>34.1258316040039</aws:latitude><aws:longitude>-118.478332519531</aws:longitude><aws:site-url>http://www.milkenschool.org/</aws:site-url><aws:aux-temp units="&deg;C">23.5</aws:aux-temp><aws:aux-temp-rate units="&deg;C">-17.8</aws:aux-temp-rate><aws:current-condition icon="http://deskwx.weatherbug.com/images/Forecast/icons/cond023.gif">Hazy</aws:current-condition><aws:dew-point units="&deg;C">14.4444444444444</aws:dew-point><aws:elevation units="m">383</aws:elevation><aws:feels-like units="&deg;C">22</aws:feels-like><aws:gust-time><aws:year number="2009" /><aws:month number="5" text="May" abbrv="May" /><aws:day number="15" text="Friday" abbrv="Fri" /><aws:hour number="10" hour-24="10" /><aws:minute number="53" /><aws:second number="00" /><aws:am-pm abbrv="AM" /><aws:time-zone offset="-7" text="Pacific Daylight Time" abbrv="PDT" /></aws:gust-time><aws:gust-direction>SSE</aws:gust-direction><aws:gust-speed units="km/h">16</aws:gust-speed><aws:humidity units="%">62</aws:humidity><aws:humidity-high units="%">100</aws:humidity-high><aws:humidity-low units="%">62</aws:humidity-low><aws:humidity-rate>-9</aws:humidity-rate><aws:indoor-temp units="&deg;C">46</aws:indoor-temp><aws:indoor-temp-rate units="&deg;C">1</aws:indoor-temp-rate><aws:light>34.2</aws:light><aws:light-rate>0.4</aws:light-rate><aws:moon-phase moon-phase-img="http://api.wxbug.net/images/moonphase/mphase18.gif">71</aws:moon-phase><aws:pressure units="mb">1011.31</aws:pressure><aws:pressure-high units="mb">1,011.36</aws:pressure-high><aws:pressure-low units="mb">1,010.39</aws:pressure-low><aws:pressure-rate units="mb/h">0.23</aws:pressure-rate><aws:rain-month units="mm">0.00</aws:rain-month><aws:rain-rate units="mm/h">0.00</aws:rain-rate><aws:rain-rate-max units="mm/h">0.00</aws:rain-rate-max><aws:rain-today units="mm">0.00</aws:rain-today><aws:rain-year units="mm">38.35</aws:rain-year><aws:temp units="&deg;C">22.2</aws:temp><aws:temp-high units="&deg;C">22</aws:temp-high><aws:temp-low units="&deg;C">13</aws:temp-low><aws:temp-rate units="&deg;C/h">2.2</aws:temp-rate><aws:sunrise><aws:year number="2009" /><aws:month number="5" text="May" abbrv="May" /><aws:day number="15" text="Friday" abbrv="Fri" /><aws:hour number="5" hour-24="05" /><aws:minute number="52" /><aws:second number="17" /><aws:am-pm abbrv="AM" /><aws:time-zone offset="-7" text="Pacific Daylight Time" abbrv="PDT" /></aws:sunrise><aws:sunset><aws:year number="2009" /><aws:month number="5" text="May" abbrv="May" /><aws:day number="15" text="Friday" abbrv="Fri" /><aws:hour number="7" hour-24="19" /><aws:minute number="48" /><aws:second number="37" /><aws:am-pm abbrv="PM" /><aws:time-zone offset="-7" text="Pacific Daylight Time" abbrv="PDT" /></aws:sunset><aws:wet-bulb units="&deg;C">17.39</aws:wet-bulb><aws:wind-speed units="km/h">11</aws:wind-speed><aws:wind-speed-avg units="km/h">8</aws:wind-speed-avg><aws:wind-direction>SE</aws:wind-direction><aws:wind-direction-avg>SE</aws:wind-direction-avg></aws:ob></aws:weather>
|
@@ -0,0 +1 @@
|
|
1
|
+
<aws:weather xmlns:aws="http://www.aws.com/aws"><aws:api version="2.0" /><aws:WebURL>http://weather.weatherbug.com/CA/Beverly Hills-weather/local-forecast/7-day-forecast.html?ZCode=Z5546&Units=1</aws:WebURL><aws:forecasts type="Detailed" date="5/15/2009 8:26:00 AM"><aws:location><aws:city>Beverly Hills</aws:city><aws:state>CA</aws:state><aws:zip>90210</aws:zip><aws:zone>CA041</aws:zone></aws:location><aws:forecast><aws:title alttitle="FRI">Friday</aws:title><aws:short-prediction>Partly Cloudy</aws:short-prediction><aws:image isNight="0" icon="cond003.gif">http://deskwx.weatherbug.com/images/Forecast/icons/cond003.gif</aws:image><aws:description>Friday</aws:description><aws:prediction>Areas of low clouds and fog in the morning then sunny. Highs in the upper 60s to mid 70s at the beaches to the lower 80s inland.</aws:prediction><aws:high units="&deg;C">27</aws:high><aws:low units="&deg;C">17</aws:low></aws:forecast><aws:forecast><aws:title alttitle="SAT">Saturday</aws:title><aws:short-prediction>Partly Cloudy</aws:short-prediction><aws:image isNight="0" icon="cond003.gif">http://deskwx.weatherbug.com/images/Forecast/icons/cond003.gif</aws:image><aws:description>Saturday</aws:description><aws:prediction>Areas of low clouds and fog in the morning then sunny. Highs in the lower to mid 70s at the beaches to the lower to mid 80s inland.</aws:prediction><aws:high units="&deg;C">28</aws:high><aws:low units="&deg;C">17</aws:low></aws:forecast><aws:forecast><aws:title alttitle="SUN">Sunday</aws:title><aws:short-prediction>Partly Cloudy</aws:short-prediction><aws:image isNight="0" icon="cond003.gif">http://deskwx.weatherbug.com/images/Forecast/icons/cond003.gif</aws:image><aws:description>Sunday</aws:description><aws:prediction>Areas of low clouds and fog in the morning then sunny. Highs in the lower to mid 70s at the beaches to the lower to mid 80s inland.</aws:prediction><aws:high units="&deg;C">28</aws:high><aws:low units="&deg;C">17</aws:low></aws:forecast><aws:forecast><aws:title alttitle="MON">Monday</aws:title><aws:short-prediction>Mostly Sunny</aws:short-prediction><aws:image isNight="0" icon="cond026.gif">http://deskwx.weatherbug.com/images/Forecast/icons/cond026.gif</aws:image><aws:description>Monday</aws:description><aws:prediction>Areas of low clouds and fog in the morning then mostly sunny. Highs around 70 at the beaches to around 80 inland.</aws:prediction><aws:high units="&deg;C">26</aws:high><aws:low units="&deg;C">16</aws:low></aws:forecast><aws:forecast><aws:title alttitle="TUE">Tuesday</aws:title><aws:short-prediction>Mostly Sunny</aws:short-prediction><aws:image isNight="0" icon="cond026.gif">http://deskwx.weatherbug.com/images/Forecast/icons/cond026.gif</aws:image><aws:description>Tuesday</aws:description><aws:prediction>Night through morning low clouds and fog...otherwise mostly clear. Lows around 60. Highs in the mid to upper 60s at the beaches to the 70s inland.</aws:prediction><aws:high units="&deg;C">25</aws:high><aws:low units="&deg;C">16</aws:low></aws:forecast><aws:forecast><aws:title alttitle="WED">Wednesday</aws:title><aws:short-prediction>Mostly Sunny</aws:short-prediction><aws:image isNight="0" icon="cond026.gif">http://deskwx.weatherbug.com/images/Forecast/icons/cond026.gif</aws:image><aws:description>Wednesday</aws:description><aws:prediction>Night through morning low clouds and fog...otherwise mostly clear. Lows around 60. Highs in the mid to upper 60s at the beaches to the 70s inland.</aws:prediction><aws:high units="&deg;C">24</aws:high><aws:low units="&deg;C">16</aws:low></aws:forecast><aws:forecast><aws:title alttitle="THU">Thursday</aws:title><aws:short-prediction>Mostly Sunny</aws:short-prediction><aws:image isNight="0" icon="cond026.gif">http://deskwx.weatherbug.com/images/Forecast/icons/cond026.gif</aws:image><aws:description>Thursday</aws:description><aws:prediction>Night through morning low clouds and fog...otherwise mostly clear. Lows around 60. Highs in the mid to upper 60s at the beaches to the 70s inland.</aws:prediction><aws:high units="&deg;C">24</aws:high><aws:low units="&deg;C">--</aws:low></aws:forecast></aws:forecasts></aws:weather>
|
@@ -167,6 +167,16 @@ describe "Query::WeatherID" do
|
|
167
167
|
new_query.geo.should be_nil
|
168
168
|
end
|
169
169
|
|
170
|
+
it "converts from icao" do
|
171
|
+
query = Barometer::Query.new(@icao)
|
172
|
+
query.format.should == :icao
|
173
|
+
new_query = Query::Format::WeatherID.to(query)
|
174
|
+
new_query.q.should == "USCA0987"
|
175
|
+
new_query.country_code.should == "US"
|
176
|
+
new_query.format.should == :weather_id
|
177
|
+
new_query.geo.should_not be_nil
|
178
|
+
end
|
179
|
+
|
170
180
|
it "returns nil for other formats" do
|
171
181
|
query = Barometer::Query.new(@weather_id)
|
172
182
|
query.format.should == :weather_id
|
@@ -177,11 +187,6 @@ describe "Query::WeatherID" do
|
|
177
187
|
query.format.should == :postalcode
|
178
188
|
new_query = Query::Format::WeatherID.to(query)
|
179
189
|
new_query.should be_nil
|
180
|
-
|
181
|
-
query = Barometer::Query.new(@icao)
|
182
|
-
query.format.should == :icao
|
183
|
-
new_query = Query::Format::WeatherID.to(query)
|
184
|
-
new_query.should be_nil
|
185
190
|
end
|
186
191
|
|
187
192
|
end
|