barometer 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +1 -1
- data/VERSION.yml +1 -1
- data/bin/barometer +25 -3
- data/lib/barometer/data/units.rb +6 -3
- data/lib/barometer/services/google.rb +17 -2
- data/lib/barometer/weather.rb +4 -5
- data/lib/demometer/demometer.rb +10 -1
- data/lib/demometer/views/forecast.erb +8 -7
- data/lib/demometer/views/index.erb +22 -22
- data/lib/demometer/views/measurement.erb +46 -40
- data/spec/service_google_spec.rb +135 -0
- data/spec/weather_spec.rb +12 -0
- metadata +1 -1
data/README.rdoc
CHANGED
@@ -10,7 +10,7 @@ unavailable.
|
|
10
10
|
|
11
11
|
== version
|
12
12
|
|
13
|
-
Version 0.3.
|
13
|
+
Version 0.3.2 is the current release of this gem.
|
14
14
|
The gem is available from github (attack-barometer) or rubyforge (barometer).
|
15
15
|
It is fully functional (for three weather service APIs).
|
16
16
|
|
data/VERSION.yml
CHANGED
data/bin/barometer
CHANGED
@@ -65,7 +65,7 @@ require 'yaml'
|
|
65
65
|
KEY_FILE = File.expand_path(File.join('~', '.barometer'))
|
66
66
|
|
67
67
|
class App
|
68
|
-
VERSION = '0.3.
|
68
|
+
VERSION = '0.3.2'
|
69
69
|
|
70
70
|
attr_reader :options
|
71
71
|
|
@@ -168,11 +168,33 @@ class App
|
|
168
168
|
|
169
169
|
def output_help
|
170
170
|
output_version
|
171
|
-
|
171
|
+
#output_usage
|
172
172
|
end
|
173
173
|
|
174
174
|
def output_usage
|
175
|
-
|
175
|
+
puts "Usage: "
|
176
|
+
puts "barometer [options] query"
|
177
|
+
puts
|
178
|
+
puts "For help use: barometer -h"
|
179
|
+
puts
|
180
|
+
puts "options:"
|
181
|
+
puts " -v, --version Display the version, then exit"
|
182
|
+
puts " -V, --verbose Verbose output"
|
183
|
+
puts " -t, --timeout seconds until service queries will timeout"
|
184
|
+
puts " -g, --geocode Force Geocoding of query"
|
185
|
+
puts " -m, --metric measure in metric"
|
186
|
+
puts " -i, --imperial measure in imperial"
|
187
|
+
puts " --no-wunderground DONT use default wunderground as source"
|
188
|
+
puts " --yahoo use yahoo as source"
|
189
|
+
puts " --google use google as source"
|
190
|
+
puts " -p, --pop pop threshold used to determine wet?"
|
191
|
+
puts " -s, --wind wind speed threshold used to determine windy?"
|
192
|
+
puts " -a, --at time/date used to determine when to calculate summary"
|
193
|
+
puts
|
194
|
+
puts " Web Demo:"
|
195
|
+
puts " -w, --web run web-app with barometer demo"
|
196
|
+
puts " -k, --kill stop the web demo background process"
|
197
|
+
puts " -S, --status show the web demo status"
|
176
198
|
end
|
177
199
|
|
178
200
|
def output_version
|
data/lib/barometer/data/units.rb
CHANGED
@@ -19,16 +19,19 @@ module Barometer
|
|
19
19
|
# assigns a value to the right attribute based on metric setting
|
20
20
|
def <<(value)
|
21
21
|
return unless value
|
22
|
+
|
23
|
+
# these values can be treated like 'nil'
|
24
|
+
nil_values = ["NA"]
|
22
25
|
|
23
26
|
begin
|
24
27
|
if value.is_a?(Array)
|
25
|
-
value_m = value[0].to_f
|
26
|
-
value_i = value[1].to_f
|
28
|
+
value_m = value[0].to_f if (value[0] && !nil_values.include?(value[0]))
|
29
|
+
value_i = value[1].to_f if (value[1] && !nil_values.include?(value[1]))
|
27
30
|
value_b = nil
|
28
31
|
else
|
29
32
|
value_m = nil
|
30
33
|
value_i = nil
|
31
|
-
value_b = value.to_f
|
34
|
+
value_b = value.to_f if (value && !nil_values.include?(value))
|
32
35
|
end
|
33
36
|
rescue
|
34
37
|
# do nothing
|
@@ -40,6 +40,15 @@ module Barometer
|
|
40
40
|
:google
|
41
41
|
end
|
42
42
|
|
43
|
+
# these are the icon codes that indicate "wet", used by wet? function
|
44
|
+
def self.wet_icon_codes
|
45
|
+
%w(rain chance_of_rain chance_of_storm thunderstorm mist)
|
46
|
+
end
|
47
|
+
# these are the icon codes that indicate "sun", used by sunny? function
|
48
|
+
def self.sunny_icon_codes
|
49
|
+
%w(sunny mostly_sunny partly_cloudy)
|
50
|
+
end
|
51
|
+
|
43
52
|
def self._measure(measurement, query, metric=true)
|
44
53
|
raise ArgumentError unless measurement.is_a?(Barometer::Measurement)
|
45
54
|
raise ArgumentError unless query.is_a?(Barometer::Query)
|
@@ -68,7 +77,10 @@ module Barometer
|
|
68
77
|
|
69
78
|
if data['current_conditions']
|
70
79
|
data = data['current_conditions']
|
71
|
-
|
80
|
+
if data['icon']
|
81
|
+
icon_match = data['icon']['data'].match(/.*\/([A-Za-z_]*)\.png/)
|
82
|
+
current.icon = icon_match[1] if icon_match
|
83
|
+
end
|
72
84
|
current.condition = data['condition']['data'] if data['condition']
|
73
85
|
|
74
86
|
humidity_match = data['humidity']['data'].match(/[\d]+/)
|
@@ -100,7 +112,10 @@ module Barometer
|
|
100
112
|
d = 0
|
101
113
|
data.each do |forecast|
|
102
114
|
forecast_measurement = ForecastMeasurement.new
|
103
|
-
|
115
|
+
if forecast['icon']
|
116
|
+
icon_match = forecast['icon']['data'].match(/.*\/([A-Za-z_]*)\.png/)
|
117
|
+
forecast_measurement.icon = icon_match[1] if icon_match
|
118
|
+
end
|
104
119
|
forecast_measurement.condition = forecast['condition']['data'] if forecast['condition']
|
105
120
|
|
106
121
|
if (start_date + d).strftime("%a").downcase == forecast['day_of_week']['data'].downcase
|
data/lib/barometer/weather.rb
CHANGED
@@ -64,25 +64,24 @@ module Barometer
|
|
64
64
|
# averages
|
65
65
|
#
|
66
66
|
|
67
|
-
# TODO: not tested (except via averages)
|
68
67
|
def metric?
|
69
68
|
self.default ? self.default.metric? : true
|
70
69
|
end
|
71
70
|
|
72
|
-
# TODO: not tested (except via averages)
|
73
71
|
# this assumes calculating for current, and that "to_f" for a value
|
74
72
|
# will return the value needed
|
75
73
|
# value_name = the name of the value we are averaging
|
76
74
|
def current_average(value_name)
|
77
75
|
values = []
|
78
76
|
@measurements.each do |measurement|
|
79
|
-
values << measurement.current.send(value_name).to_f if measurement.success?
|
77
|
+
values << measurement.current.send(value_name).to_f if measurement.success? &&
|
78
|
+
measurement.current.send(value_name)
|
80
79
|
end
|
80
|
+
values.compact!
|
81
81
|
return nil unless values && values.size > 0
|
82
|
-
values.inject(0.0) { |sum,v| sum += v } / values.size
|
82
|
+
values.inject(0.0) { |sum,v| sum += v if v } / values.size
|
83
83
|
end
|
84
84
|
|
85
|
-
# TODO: not tested (except via averages)
|
86
85
|
def average(value_name, do_average=true, class_name=nil)
|
87
86
|
if class_name
|
88
87
|
if do_average
|
data/lib/demometer/demometer.rb
CHANGED
@@ -12,6 +12,13 @@ end
|
|
12
12
|
|
13
13
|
class Demometer < Sinatra::Default
|
14
14
|
|
15
|
+
helpers do
|
16
|
+
def data(title, value)
|
17
|
+
return if value.nil?
|
18
|
+
"<li>#{title}: #{value}</li>"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
15
22
|
get '/' do
|
16
23
|
erb :index
|
17
24
|
end
|
@@ -19,9 +26,11 @@ class Demometer < Sinatra::Default
|
|
19
26
|
post '/' do
|
20
27
|
# apply options
|
21
28
|
Barometer.force_geocode = (params[:query][:geocode].to_s == "1" ? true : false)
|
22
|
-
Barometer.selection = { 1 => [ params[:query][:source].to_sym ] }
|
23
29
|
metric = (params[:query][:metric].to_s == "1" ? true : false)
|
24
30
|
|
31
|
+
# determine sources
|
32
|
+
Barometer.selection = { 1 => params[:query][:source].collect{|s| s.to_sym } }
|
33
|
+
|
25
34
|
if params[:query] && !params[:query][:q].empty?
|
26
35
|
@barometer = Barometer.new(params[:query][:q])
|
27
36
|
@weather = @barometer.measure(metric)
|
@@ -1,14 +1,15 @@
|
|
1
1
|
<h4>for: <%= forecast.date %></h4>
|
2
2
|
<p>
|
3
3
|
<ul>
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
4
|
+
<%= data("Date", forecast.date) %>
|
5
|
+
<%= data("Icon", forecast.icon) %>
|
6
|
+
<%= data("Condition", forecast.condition) %>
|
7
|
+
<%= data("High", forecast.high) %>
|
8
|
+
<%= data("Low", forecast.low) %>
|
9
|
+
<%= data("POP", forecast.pop) %>
|
10
10
|
<% if forecast.sun %>
|
11
|
-
|
11
|
+
<%= data("Sun Rise", forecast.sun.rise) %>
|
12
|
+
<%= data("Sun Set", forecast.sun.set) %>
|
12
13
|
<% end %>
|
13
14
|
</ul>
|
14
15
|
</p>
|
@@ -14,9 +14,9 @@
|
|
14
14
|
<input id="query_metric" name="query[metric]" type="checkbox" value="1" checked="checked" />
|
15
15
|
<br/>
|
16
16
|
Source :
|
17
|
-
<input type="
|
18
|
-
<input type="
|
19
|
-
<input type="
|
17
|
+
<input type="checkbox" name="query[source]" value="wunderground" checked="checked" /> Wunderground
|
18
|
+
<input type="checkbox" name="query[source]" value="yahoo" /> Yahoo
|
19
|
+
<input type="checkbox" name="query[source]" value="google" /> Google
|
20
20
|
<br/>
|
21
21
|
Force Geocode? :
|
22
22
|
<input id="query_geocode" name="query[geocode]" type="checkbox" value="1" checked="checked" />
|
@@ -35,24 +35,24 @@
|
|
35
35
|
<h2>Averages</h2>
|
36
36
|
<p>
|
37
37
|
<ul>
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
38
|
+
<%= data("Humidity", @weather.humidity.to_i) %>
|
39
|
+
<%= data("Temperature", @weather.temperature) %>
|
40
|
+
<%= data("Wind", @weather.wind) %>
|
41
|
+
<%= data("Pressure", @weather.pressure) %>
|
42
|
+
<%= data("Dew Point", @weather.dew_point) %>
|
43
|
+
<%= data("Heat Index", @weather.heat_index) %>
|
44
|
+
<%= data("Wind Chill", @weather.wind_chill) %>
|
45
|
+
<%= data("Visibility", @weather.visibility) %>
|
46
46
|
</ul>
|
47
47
|
</p>
|
48
48
|
|
49
49
|
<h2>Summary</h2>
|
50
50
|
<p>
|
51
51
|
<ul>
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
52
|
+
<%= data("Day?", @weather.day?) %>
|
53
|
+
<%= data("Sunny?", @weather.sunny?) %>
|
54
|
+
<%= data("Windy?", @weather.windy?) %>
|
55
|
+
<%= data("Wet?", @weather.wet?) %>
|
56
56
|
</ul>
|
57
57
|
</p>
|
58
58
|
|
@@ -60,14 +60,14 @@
|
|
60
60
|
<h3>Query</h3>
|
61
61
|
<p>
|
62
62
|
<ul>
|
63
|
-
|
63
|
+
<%= data("Format", @barometer.query.format) %>
|
64
64
|
<% if @barometer.query.geo %>
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
65
|
+
<%= data("Locality", @barometer.query.geo.locality) %>
|
66
|
+
<%= data("Region", @barometer.query.geo.region) %>
|
67
|
+
<%= data("Country", @barometer.query.geo.country) %>
|
68
|
+
<%= data("Country Code", @barometer.query.geo.country_code) %>
|
69
|
+
<%= data("Latitude", @barometer.query.geo.latitude) %>
|
70
|
+
<%= data("Longitude", @barometer.query.geo.longitude) %>
|
71
71
|
<% end %>
|
72
72
|
</ul>
|
73
73
|
</p>
|
@@ -1,10 +1,10 @@
|
|
1
1
|
<h2><%= measurement.source.to_s.capitalize %></h2>
|
2
2
|
<p>
|
3
3
|
<ul>
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
<%= data("Source", measurement.source) %>
|
5
|
+
<%= data("Time", measurement.time) %>
|
6
|
+
<%= data("Metric", measurement.metric?) %>
|
7
|
+
<%= data("Success", measurement.success?) %>
|
8
8
|
</ul>
|
9
9
|
</p>
|
10
10
|
|
@@ -12,16 +12,16 @@
|
|
12
12
|
<h3>Location</h3>
|
13
13
|
<p>
|
14
14
|
<ul>
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
15
|
+
<%= data("id", measurement.location.id) %>
|
16
|
+
<%= data("Name", measurement.location.name) %>
|
17
|
+
<%= data("City", measurement.location.city) %>
|
18
|
+
<%= data("State Name", measurement.location.state_name) %>
|
19
|
+
<%= data("State Code", measurement.location.state_code) %>
|
20
|
+
<%= data("Country", measurement.location.country) %>
|
21
|
+
<%= data("Country Code", measurement.location.country_code) %>
|
22
|
+
<%= data("Zip Code", measurement.location.zip_code) %>
|
23
|
+
<%= data("Latitude", measurement.location.latitude) %>
|
24
|
+
<%= data("Longitude", measurement.location.longitude) %>
|
25
25
|
</ul>
|
26
26
|
</p>
|
27
27
|
<% end %>
|
@@ -30,16 +30,17 @@
|
|
30
30
|
<h3>Station</h3>
|
31
31
|
<p>
|
32
32
|
<ul>
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
33
|
+
<%= data("id", measurement.station.id) %>
|
34
|
+
<%= data("Name", measurement.station.name) %>
|
35
|
+
<%= data("City", measurement.station.city) %>
|
36
|
+
<%= data("State Name", measurement.station.state_name) %>
|
37
|
+
<%= data("State Code", measurement.station.state_code) %>
|
38
|
+
<%= data("Country", measurement.station.country) %>
|
39
|
+
<%= data("Country Code", measurement.station.country_code) %>
|
40
|
+
<%= data("Zip Code", measurement.station.zip_code) %>
|
41
|
+
<%= data("Latitude", measurement.station.latitude) %>
|
42
|
+
<%= data("Longitude", measurement.station.longitude) %>
|
43
|
+
</ul>
|
43
44
|
</ul>
|
44
45
|
</p>
|
45
46
|
<% end %>
|
@@ -48,9 +49,9 @@
|
|
48
49
|
<h3>Timezone</h3>
|
49
50
|
<p>
|
50
51
|
<ul>
|
51
|
-
|
52
|
-
|
53
|
-
|
52
|
+
<%= data("Long", measurement.timezone.timezone) %>
|
53
|
+
<%= data("Code", measurement.timezone.code) %>
|
54
|
+
<%= data("DST?", measurement.timezone.dst?) %>
|
54
55
|
</ul>
|
55
56
|
</p>
|
56
57
|
<% end %>
|
@@ -59,20 +60,25 @@
|
|
59
60
|
<h3>Current</h3>
|
60
61
|
<p>
|
61
62
|
<ul>
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
63
|
+
<%= data("Time", measurement.current.time) %>
|
64
|
+
<%= data("Local Time", measurement.current.local_time) %>
|
65
|
+
<%= data("Humidity", measurement.current.humidity) %>
|
66
|
+
<%= data("Icon", measurement.current.icon) %>
|
67
|
+
<%= data("Condition", measurement.current.condition) %>
|
68
|
+
<%= data("Temperature", measurement.current.temperature) %>
|
69
|
+
<%= data("Dew Point", measurement.current.dew_point) %>
|
70
|
+
<%= data("Heat Index", measurement.current.heat_index) %>
|
71
|
+
<%= data("Wind Chill", measurement.current.wind_chill) %>
|
72
|
+
<% if measurement.current.wind %>
|
73
|
+
<%= data("Wind Speed", measurement.current.wind) %>
|
74
|
+
<%= data("Wind Direction", measurement.current.wind.direction) %>
|
75
|
+
<%= data("Wind Degrees", measurement.current.wind.degrees) %>
|
76
|
+
<% end %>
|
77
|
+
<%= data("Pressure", measurement.current.pressure) %>
|
78
|
+
<%= data("Visibility", measurement.current.visibility) %>
|
74
79
|
<% if measurement.current.sun %>
|
75
|
-
|
80
|
+
<%= data("Sun Rise", measurement.current.sun.rise) %>
|
81
|
+
<%= data("Sun Set", measurement.current.sun.set) %>
|
76
82
|
<% end %>
|
77
83
|
</ul>
|
78
84
|
</p>
|
data/spec/service_google_spec.rb
CHANGED
@@ -141,4 +141,139 @@ describe "Google" do
|
|
141
141
|
|
142
142
|
end
|
143
143
|
|
144
|
+
describe "when answering the simple questions," do
|
145
|
+
|
146
|
+
before(:each) do
|
147
|
+
@measurement = Barometer::Measurement.new
|
148
|
+
end
|
149
|
+
|
150
|
+
describe "currently_wet_by_icon?" do
|
151
|
+
|
152
|
+
before(:each) do
|
153
|
+
@measurement.current = Barometer::CurrentMeasurement.new
|
154
|
+
end
|
155
|
+
|
156
|
+
it "returns true if matching icon code" do
|
157
|
+
@measurement.current.icon = "rain"
|
158
|
+
@measurement.current.icon?.should be_true
|
159
|
+
Barometer::Google.currently_wet_by_icon?(@measurement.current).should be_true
|
160
|
+
end
|
161
|
+
|
162
|
+
it "returns false if NO matching icon code" do
|
163
|
+
@measurement.current.icon = "sunny"
|
164
|
+
@measurement.current.icon?.should be_true
|
165
|
+
Barometer::Google.currently_wet_by_icon?(@measurement.current).should be_false
|
166
|
+
end
|
167
|
+
|
168
|
+
end
|
169
|
+
|
170
|
+
describe "forecasted_wet_by_icon?" do
|
171
|
+
|
172
|
+
before(:each) do
|
173
|
+
@measurement.forecast = [Barometer::ForecastMeasurement.new]
|
174
|
+
@measurement.forecast.first.date = Date.today
|
175
|
+
@measurement.forecast.size.should == 1
|
176
|
+
end
|
177
|
+
|
178
|
+
it "returns true if matching icon code" do
|
179
|
+
@measurement.forecast.first.icon = "rain"
|
180
|
+
@measurement.forecast.first.icon?.should be_true
|
181
|
+
Barometer::Google.forecasted_wet_by_icon?(@measurement.forecast.first).should be_true
|
182
|
+
end
|
183
|
+
|
184
|
+
it "returns false if NO matching icon code" do
|
185
|
+
@measurement.forecast.first.icon = "sunny"
|
186
|
+
@measurement.forecast.first.icon?.should be_true
|
187
|
+
Barometer::Google.forecasted_wet_by_icon?(@measurement.forecast.first).should be_false
|
188
|
+
end
|
189
|
+
|
190
|
+
end
|
191
|
+
|
192
|
+
describe "currently_sunny_by_icon?" do
|
193
|
+
|
194
|
+
before(:each) do
|
195
|
+
@measurement.current = Barometer::CurrentMeasurement.new
|
196
|
+
end
|
197
|
+
|
198
|
+
it "returns true if matching icon code" do
|
199
|
+
@measurement.current.icon = "sunny"
|
200
|
+
@measurement.current.icon?.should be_true
|
201
|
+
Barometer::Google.currently_sunny_by_icon?(@measurement.current).should be_true
|
202
|
+
end
|
203
|
+
|
204
|
+
it "returns false if NO matching icon code" do
|
205
|
+
@measurement.current.icon = "rain"
|
206
|
+
@measurement.current.icon?.should be_true
|
207
|
+
Barometer::Google.currently_sunny_by_icon?(@measurement.current).should be_false
|
208
|
+
end
|
209
|
+
|
210
|
+
end
|
211
|
+
|
212
|
+
describe "forecasted_sunny_by_icon?" do
|
213
|
+
|
214
|
+
before(:each) do
|
215
|
+
@measurement.forecast = [Barometer::ForecastMeasurement.new]
|
216
|
+
@measurement.forecast.first.date = Date.today
|
217
|
+
@measurement.forecast.size.should == 1
|
218
|
+
end
|
219
|
+
|
220
|
+
it "returns true if matching icon code" do
|
221
|
+
@measurement.forecast.first.icon = "sunny"
|
222
|
+
@measurement.forecast.first.icon?.should be_true
|
223
|
+
Barometer::Google.forecasted_sunny_by_icon?(@measurement.forecast.first).should be_true
|
224
|
+
end
|
225
|
+
|
226
|
+
it "returns false if NO matching icon code" do
|
227
|
+
@measurement.forecast.first.icon = "rain"
|
228
|
+
@measurement.forecast.first.icon?.should be_true
|
229
|
+
Barometer::Google.forecasted_sunny_by_icon?(@measurement.forecast.first).should be_false
|
230
|
+
end
|
231
|
+
|
232
|
+
end
|
233
|
+
|
234
|
+
end
|
235
|
+
|
236
|
+
# describe "overall data correctness" do
|
237
|
+
#
|
238
|
+
# before(:each) do
|
239
|
+
# @query = Barometer::Query.new("Calgary,AB")
|
240
|
+
# @query.preferred = "Calgary,AB"
|
241
|
+
# @measurement = Barometer::Measurement.new
|
242
|
+
#
|
243
|
+
# FakeWeb.register_uri(:get,
|
244
|
+
# "http://api.wunderground.com/auto/wui/geo/WXCurrentObXML/index.xml?query=#{CGI.escape(@query.preferred)}",
|
245
|
+
# :string => File.read(File.join(File.dirname(__FILE__),
|
246
|
+
# 'fixtures',
|
247
|
+
# 'current_calgary_ab.xml')
|
248
|
+
# )
|
249
|
+
# )
|
250
|
+
# FakeWeb.register_uri(:get,
|
251
|
+
# "http://api.wunderground.com/auto/wui/geo/ForecastXML/index.xml?query=#{CGI.escape(@query.preferred)}",
|
252
|
+
# :string => File.read(File.join(File.dirname(__FILE__),
|
253
|
+
# 'fixtures',
|
254
|
+
# 'forecast_calgary_ab.xml')
|
255
|
+
# )
|
256
|
+
# )
|
257
|
+
# end
|
258
|
+
#
|
259
|
+
# # TODO: complete this
|
260
|
+
# it "should correctly build the data" do
|
261
|
+
# result = Barometer::Wunderground._measure(@measurement, @query)
|
262
|
+
#
|
263
|
+
# # build timezone
|
264
|
+
# @measurement.timezone.timezone.should == "America/Edmonton"
|
265
|
+
#
|
266
|
+
# time = Time.local(2009, 4, 23, 18, 00, 0)
|
267
|
+
# rise = Time.local(time.year, time.month, time.day, 6, 23)
|
268
|
+
# set = Time.local(time.year, time.month, time.day, 20, 45)
|
269
|
+
# sun_rise = @measurement.timezone.tz.local_to_utc(rise)
|
270
|
+
# sun_set = @measurement.timezone.tz.local_to_utc(set)
|
271
|
+
#
|
272
|
+
# # build current
|
273
|
+
# @measurement.current.sun.rise.should == sun_rise
|
274
|
+
# @measurement.current.sun.set.should == sun_set
|
275
|
+
# end
|
276
|
+
#
|
277
|
+
# end
|
278
|
+
|
144
279
|
end
|
data/spec/weather_spec.rb
CHANGED
@@ -94,6 +94,18 @@ describe "Weather" do
|
|
94
94
|
@weather.measurements << @google
|
95
95
|
end
|
96
96
|
|
97
|
+
it "doesn't include nil values" do
|
98
|
+
@weather.source(:wunderground).current.temperature = Barometer::Temperature.new
|
99
|
+
@weather.source(:wunderground).current.temperature.c = 10
|
100
|
+
|
101
|
+
@weather.temperature.c.should == 10
|
102
|
+
|
103
|
+
@weather.source(:yahoo).current.temperature = Barometer::Temperature.new
|
104
|
+
@weather.source(:yahoo).current.temperature.c = nil
|
105
|
+
|
106
|
+
@weather.temperature.c.should == 10
|
107
|
+
end
|
108
|
+
|
97
109
|
describe "for temperature" do
|
98
110
|
|
99
111
|
before(:each) do
|