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 CHANGED
@@ -10,7 +10,7 @@ unavailable.
10
10
 
11
11
  == version
12
12
 
13
- Version 0.3.1 is the current release of this gem.
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
@@ -1,4 +1,4 @@
1
1
  ---
2
- :patch: 1
2
+ :patch: 2
3
3
  :major: 0
4
4
  :minor: 3
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.1'
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
- RDoc::usage('Usage') #exits app
171
+ #output_usage
172
172
  end
173
173
 
174
174
  def output_usage
175
- RDoc::usage('Usage') # gets usage from comments above
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
@@ -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
- current.icon = data['icon']['data'] if data['icon']
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
- forecast_measurement.icon = forecast['icon']['data'] if forecast['icon']
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
@@ -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
@@ -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
- <li>Date: <%= forecast.date %></li>
5
- <li>Icon: <%= forecast.icon %></li>
6
- <li>Condition: <%= forecast.condition %></li>
7
- <li>High: <%= forecast.high %></li>
8
- <li>Low: <%= forecast.low %></li>
9
- <li>POP: <%= forecast.pop %></li>
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
- <li>Sun: rise - <%= forecast.sun.rise %>, set - <%= forecast.sun.set %></li>
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="radio" name="query[source]" value="wunderground" checked="checked" /> Wunderground
18
- <input type="radio" name="query[source]" value="yahoo" /> Yahoo
19
- <input type="radio" name="query[source]" value="google" /> Google
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
- <li>Humidity: <%= @weather.humidity.to_i %></li>
39
- <li>Temperature: <%= @weather.temperature %></li>
40
- <li>Wind: <%= @weather.wind %></li>
41
- <li>Pressure: <%= @weather.pressure %></li>
42
- <li>Dew Point: <%= @weather.dew_point %></li>
43
- <li>Heat Index: <%= @weather.heat_index %></li>
44
- <li>Wind Chill: <%= @weather.wind_chill %></li>
45
- <li>Visibility: <%= @weather.visibility %></li>
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
- <li>Day?: <%= @weather.day? %></li>
53
- <li>Sunny?: <%= @weather.sunny? %></li>
54
- <li>Windy?: <%= @weather.windy? %></li>
55
- <li>Wet?: <%= @weather.wet? %></li>
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
- <li>Format: <%= @barometer.query.format %></li>
63
+ <%= data("Format", @barometer.query.format) %>
64
64
  <% if @barometer.query.geo %>
65
- <li>Locality: <%= @barometer.query.geo.locality %></li>
66
- <li>Region: <%= @barometer.query.geo.region %></li>
67
- <li>Country: <%= @barometer.query.geo.country %></li>
68
- <li>Country Code: <%= @barometer.query.geo.country_code %></li>
69
- <li>Latitude: <%= @barometer.query.geo.latitude %></li>
70
- <li>Longitude: <%= @barometer.query.geo.longitude %></li>
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
- <li>Source: <%= measurement.source %></li>
5
- <li>Time: <%= measurement.time %></li>
6
- <li>Metric: <%= measurement.metric? %></li>
7
- <li>Success: <%= measurement.success? %></li>
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
- <li>id: <%= measurement.location.id %></li>
16
- <li>Name: <%= measurement.location.name %></li>
17
- <li>City: <%= measurement.location.city %> %</li>
18
- <li>State Name: <%= measurement.location.state_name %></li>
19
- <li>State Code: <%= measurement.location.state_code %></li>
20
- <li>Country: <%= measurement.location.country %></li>
21
- <li>Country Code: <%= measurement.location.country_code %></li>
22
- <li>Zip Code: <%= measurement.location.zip_code %></li>
23
- <li>Latitude: <%= measurement.location.latitude %></li>
24
- <li>Longitude: <%= measurement.location.longitude %></li>
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
- <li>id: <%= measurement.station.id %></li>
34
- <li>Name: <%= measurement.station.name %></li>
35
- <li>City: <%= measurement.station.city %> %</li>
36
- <li>State Name: <%= measurement.station.state_name %></li>
37
- <li>State Code: <%= measurement.station.state_code %></li>
38
- <li>Country: <%= measurement.station.country %></li>
39
- <li>Country Code: <%= measurement.station.country_code %></li>
40
- <li>Zip Code: <%= measurement.station.zip_code %></li>
41
- <li>Latitude: <%= measurement.station.latitude %></li>
42
- <li>Longitude: <%= measurement.station.longitude %></li>
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
- <li>Long: <%= measurement.timezone.timezone %></li>
52
- <li>Code: <%= measurement.timezone.code %></li>
53
- <li>DST?: <%= measurement.timezone.dst? %></li>
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
- <li>Time: <%= measurement.current.time %></li>
63
- <li>Local Time: <%= measurement.current.local_time %></li>
64
- <li>Humidity: <%= measurement.current.humidity %> %</li>
65
- <li>Icon: <%= measurement.current.icon %></li>
66
- <li>Condition: <%= measurement.current.condition %></li>
67
- <li>Temperature: <%= measurement.current.temperature %></li>
68
- <li>Dew Point: <%= measurement.current.dew_point %></li>
69
- <li>Heat Index: <%= measurement.current.heat_index %></li>
70
- <li>Wind Chill: <%= measurement.current.wind_chill %></li>
71
- <li>Wind: <%= measurement.current.wind %> @ <%= measurement.current.wind.direction %> [<%= measurement.current.wind.degrees %> degrees]</li>
72
- <li>Pressure: <%= measurement.current.pressure %></li>
73
- <li>Visibility: <%= measurement.current.visibility %></li>
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
- <li>Sun: rise - <%= measurement.current.sun.rise %>, set - <%= measurement.current.sun.set %></li>
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>
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: barometer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark G