weather_report 0.0.3 → 0.0.4

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.
Files changed (3) hide show
  1. data/History.txt +6 -1
  2. data/lib/weather_report.rb +15 -13
  3. metadata +2 -2
@@ -14,4 +14,9 @@
14
14
  == 0.0.3 2009-07-18
15
15
 
16
16
  * 1 bug fix
17
- * Modify namespace to avoid clashes
17
+ * Modify namespace to avoid clashes
18
+
19
+ == 0.0.4 2009-07-19
20
+
21
+ * 1 bug fix
22
+ * Use more inclusive Backstage feed
@@ -7,7 +7,7 @@ $:.unshift(File.dirname(__FILE__)) unless
7
7
  # Class containing weather observations and forecasts for the location specified by id in the constructor.
8
8
  class WeatherReport
9
9
 
10
- VERSION = '0.0.3'
10
+ VERSION = '0.0.4'
11
11
 
12
12
  # The id is the number (1..9999) the BBC uses to identify cities for weather reports
13
13
  attr_reader :id
@@ -53,12 +53,14 @@ class WeatherReport
53
53
 
54
54
  # The url for getting current weather observations from BBC Backstage
55
55
  def observation_url()
56
- "http://newsrss.bbc.co.uk/weather/forecast/#{@id}/ObservationsRSS.xml"
56
+ "http://feeds.bbc.co.uk/weather/feeds/rss/obs/world/#{@id}.xml"
57
+ #"http://newsrss.bbc.co.uk/weather/forecast/#{@id}/ObservationsRSS.xml"
57
58
  end
58
59
 
59
60
  # The url for getting weather forecasts from BBC Backstage
60
61
  def forecast_url()
61
- "http://newsrss.bbc.co.uk/weather/forecast/#{@id}/Next3DaysRSS.xml"
62
+ "http://feeds.bbc.co.uk/weather/feeds/rss/5day/world/#{@id}.xml"
63
+ #"http://newsrss.bbc.co.uk/weather/forecast/#{@id}/Next3DaysRSS.xml"
62
64
  end
63
65
 
64
66
  end
@@ -87,7 +89,7 @@ end
87
89
  class WeatherReportObservation
88
90
  include WeatherReportLocation
89
91
 
90
- DESCRIPTION = /Temperature: ([-\d\.]+|N\/A|NA|\(none\))(.+)Wind Direction: ([\w -\/\(\)]*), Wind Speed: ([-\d\.]+|N\/A|NA|\(none\))mph, Relative Humidity: ([\d\.]+|N\/A|NA|\(none\))(.*), Pressure: ([\d\.]+|N\/A|NA|\(none\))mB, ([\w -\/]+), Visibility: ([\w -\/]+)/
92
+ DESCRIPTION = /(.*)Temperature: ([-\d\.]+|N\/A|NA|\(none\))(.+)Wind Direction: ([\w -\/\(\)]*), Wind Speed: ([-\d\.]+|N\/A|NA|\(none\))([ ]*)mph, Relative Humidity: ([\d\.]+|N\/A|NA|\(none\))(.*), Pressure: ([\d\.]+|N\/A|NA|\(none\))mB, ([\w -\/]+), Visibility: ([\w -\/]+)/
91
93
  SUMMARY = /(.+):(\W+)([\w -\/\(\)]+). (.+)/m
92
94
 
93
95
  attr_reader :temperature, :wind_direction, :wind_speed, :visibility, :pressure, :pressure_state, :humidity, :reading_date, :description
@@ -107,13 +109,13 @@ class WeatherReportObservation
107
109
  doc.elements.each("rss/channel/item[1]/description[1]") { |element|
108
110
  hasDesc = true
109
111
  md = DESCRIPTION.match(element.text)
110
- @temperature = md[1].to_f
111
- @wind_direction = md[3]
112
- @wind_speed = md[4].to_f * 1.61
113
- @humidity = md[5].to_f
114
- @pressure = md[7].to_f
115
- @pressure_state = md[8]
116
- @visibility = md[9]
112
+ @temperature = md[2].to_f
113
+ @wind_direction = md[4]
114
+ @wind_speed = md[5].to_f * 1.61
115
+ @humidity = md[7].to_f
116
+ @pressure = md[9].to_f
117
+ @pressure_state = md[10]
118
+ @visibility = md[11]
117
119
  }
118
120
  raise WeatherReport::WeatherReportFormatError unless hasDesc
119
121
 
@@ -181,7 +183,7 @@ class WeatherReportForecasts < Array
181
183
  class WeatherReportForecast
182
184
 
183
185
  SUMMARY = /([\w -\/]+): ([\w -]+|N\/A|NA|\(none\)), Max Temp: (.*)/m
184
- DESCRIPTION = /Max Temp: ([-\d\.]+|N\/A|NA|\(none\))(.+)Min Temp: ([-\d\.]+|N\/A|NA|\(none\))(.+)Wind Direction: ([\w -\/\(\)]*), Wind Speed: ([-\d\.]+|N\/A|NA|\(none\))mph, Visibility: ([\w -\/]+), Pressure: ([\d\.]+|N\/A|NA|\(none\))mB, Humidity: ([\d\.]+|N\/A|NA|\(none\))(.*), (.+)/m
186
+ DESCRIPTION = /Max Temp: ([-\d\.]+|N\/A|NA|\(none\))(.+)Min Temp: ([-\d\.]+|N\/A|NA|\(none\))(.+)Wind Direction: ([\w -\/\(\)]*), Wind Speed: ([-\d\.]+|N\/A|NA|\(none\))mph, Visibility: ([\w -\/]+), Pressure: ([\d\.]+|N\/A|NA|\(none\))m([bB]), Humidity: ([\d\.]+|N\/A|NA|\(none\))(.*), (.+)/m
185
187
 
186
188
  attr_reader :max_temperature, :min_temperature, :wind_direction, :wind_speed, :visibility, :pressure, :humidity, :date, :description, :advance_days
187
189
 
@@ -203,7 +205,7 @@ class WeatherReportForecasts < Array
203
205
  @wind_speed = md[6].to_f * 1.61
204
206
  @visibility = md[7]
205
207
  @pressure = md[8].to_f
206
- @humidity = md[9].to_f
208
+ @humidity = md[10].to_f
207
209
  }
208
210
  end
209
211
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: weather_report
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Charles Cordingley
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-07-18 00:00:00 +01:00
12
+ date: 2009-07-19 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency