diff --git a/lib/yahoo-weather/atmosphere.rb b/lib/yahoo-weather/atmosphere.rb index 8a85fb9..39d10a2 100644 --- a/lib/yahoo-weather/atmosphere.rb +++ b/lib/yahoo-weather/atmosphere.rb @@ -32,9 +32,9 @@ def initialize (payload) # map barometric pressure direction to appropriate constant @barometer = nil case payload['rising'].to_i - when 0: @barometer = Barometer::STEADY - when 1: @barometer = Barometer::RISING - when 2: @barometer = Barometer::FALLING + when 0 then @barometer = Barometer::STEADY + when 1 then @barometer = Barometer::RISING + when 2 then @barometer = Barometer::FALLING end end end diff --git a/lib/yahoo-weather/response.rb b/lib/yahoo-weather/response.rb index 6fe9ce3..62db41d 100644 --- a/lib/yahoo-weather/response.rb +++ b/lib/yahoo-weather/response.rb @@ -54,6 +54,9 @@ class YahooWeather::Response # the prose descriptive title of the weather information. attr_reader :title + + # the date in which the weather data was last updated + attr_reader :pubdate def initialize (request_location, request_url, doc) # save off the request params @@ -81,5 +84,6 @@ def initialize (request_location, request_url, doc) @page_url = item.xpath('link').first.content @title = item.xpath('title').first.content @description = item.xpath('description').first.content + @pubdate = YahooWeather._parse_time(item.xpath('pubDate').first.content) end end diff --git a/test/test_api.rb b/test/test_api.rb index f154399..6af30e5 100644 --- a/test/test_api.rb +++ b/test/test_api.rb @@ -122,6 +122,7 @@ def _assert_valid_response (response, request_location, units, assert(response.image.url =~ /yimg\.com/) assert_kind_of Numeric, response.latitude assert_kind_of Numeric, response.longitude + assert_instance_of Time, response.pubdate assert(response.page_url =~ /\.html$/) assert(response.title && response.title.length > 0) assert_not_nil(response.title.index("#{response.location.city}, #{response.location.region}")) diff --git a/tomk32-yahoo-weather.gemspec b/tomk32-yahoo-weather.gemspec new file mode 100644 index 0000000..f5b60a5 --- /dev/null +++ b/tomk32-yahoo-weather.gemspec @@ -0,0 +1,19 @@ +Gem::Specification.new do |s| + s.name = 'yahoo-weather' + s.version = '1.2.1' + s.summary = 'A Ruby object-oriented interface to the Yahoo! Weather service' + s.description = "The yahoo-weather rubygem provides a Ruby object-oriented interface to the Yahoo! Weather service described in detail at: http://developer.yahoo.com/weather" + + s.add_dependency('nokogiri', '>= 1.4.1') + s.add_dependency('hoe', '>= 2.4.0') + + s.rdoc_options << '--exclude' << '.' + + s.files = Dir['CHANGELOG.rdoc', 'README', 'Manifest.txt', 'Rakefile', 'TODO', 'examples/*', 'lib/**', 'lib/**/**', 'test/**'] + s.require_path = 'lib' + s.test_file = 'test/test_api.rb' + + s.author = "Walter Korman" + s.email = "shaper@fatgoose.com" + s.homepage = "http://rubyforge.org/projects/yahoo-weather" +end