From df48653d48dfeeb537252a10d132992137808666 Mon Sep 17 00:00:00 2001 From: AlanMcCann Date: Wed, 26 Jan 2011 15:57:24 -0800 Subject: [PATCH 1/7] Change case syntax for ruby 1.9 - from "when :" to "when then". Should still work with 1.8 --- lib/yahoo-weather/atmosphere.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 From ab99edde3dfedc3f23e03dcf1ba5ca560cd9f9f2 Mon Sep 17 00:00:00 2001 From: "Thomas R. Koll" Date: Thu, 24 Feb 2011 05:11:01 +0100 Subject: [PATCH 2/7] Add gemspec --- tomk32-yahoo-weather.gemspec | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 tomk32-yahoo-weather.gemspec diff --git a/tomk32-yahoo-weather.gemspec b/tomk32-yahoo-weather.gemspec new file mode 100644 index 0000000..3e1883f --- /dev/null +++ b/tomk32-yahoo-weather.gemspec @@ -0,0 +1,19 @@ +Gem::Specification.new do |s| + s.name = 'tomk32-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.has_rdoc = false + + s.files = Dir['CHANGELOG.rdoc', 'README', 'Manifest.txt', 'Rakefile', 'TODO', 'examples/*', 'lib/**', 'test/**'] + s.require_path = 'lib' + + s.author = "Walter Korman" + s.email = "shaper@fatgoose.com" + s.homepage = "http://rubyforge.org/projects/yahoo-weather" +end From bb188be984b58d30e80966e11f56b4c7c20fb179 Mon Sep 17 00:00:00 2001 From: Kurt Edelbrock Date: Wed, 25 May 2011 22:26:44 -0400 Subject: [PATCH 3/7] Added pubdate method --- lib/yahoo-weather/response.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/yahoo-weather/response.rb b/lib/yahoo-weather/response.rb index 6fe9ce3..0818375 100644 --- a/lib/yahoo-weather/response.rb +++ b/lib/yahoo-weather/response.rb @@ -1,3 +1,4 @@ +# TODO: Add pub date # Describes the weather conditions for a particular requested location. class YahooWeather::Response # a YahooWeather::Astronomy object detailing the sunrise and sunset @@ -54,6 +55,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 +85,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 = item.xpath('pubdate').first.content end end From 1fbddebe88e4bc6ed9fb1ea0c6590d7c3e27dd87 Mon Sep 17 00:00:00 2001 From: Kurt Edelbrock Date: Thu, 26 May 2011 08:46:37 -0400 Subject: [PATCH 4/7] Added pubDate attribute to response object --- lib/yahoo-weather/response.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/yahoo-weather/response.rb b/lib/yahoo-weather/response.rb index 0818375..841821b 100644 --- a/lib/yahoo-weather/response.rb +++ b/lib/yahoo-weather/response.rb @@ -1,4 +1,3 @@ -# TODO: Add pub date # Describes the weather conditions for a particular requested location. class YahooWeather::Response # a YahooWeather::Astronomy object detailing the sunrise and sunset @@ -85,6 +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 = item.xpath('pubdate').first.content + @pubdate = item.xpath('pubDate').first.content end end From 576089c22873662438746662d6251b9eed422bdc Mon Sep 17 00:00:00 2001 From: Kurt Edelbrock Date: Thu, 26 May 2011 08:47:19 -0400 Subject: [PATCH 5/7] Modified to include lib/yahoo-weather/** in gem --- tomk32-yahoo-weather.gemspec | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tomk32-yahoo-weather.gemspec b/tomk32-yahoo-weather.gemspec index 3e1883f..f5b60a5 100644 --- a/tomk32-yahoo-weather.gemspec +++ b/tomk32-yahoo-weather.gemspec @@ -1,5 +1,5 @@ Gem::Specification.new do |s| - s.name = 'tomk32-yahoo-weather' + 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" @@ -8,10 +8,10 @@ Gem::Specification.new do |s| s.add_dependency('hoe', '>= 2.4.0') s.rdoc_options << '--exclude' << '.' - s.has_rdoc = false - s.files = Dir['CHANGELOG.rdoc', 'README', 'Manifest.txt', 'Rakefile', 'TODO', 'examples/*', 'lib/**', 'test/**'] + 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" From 127b9ba966df08c5b22e1c37df5e6463b5a3a4ab Mon Sep 17 00:00:00 2001 From: Kurt Edelbrock Date: Thu, 26 May 2011 08:59:48 -0400 Subject: [PATCH 6/7] Uses _parsetime for pubDate --- lib/yahoo-weather/response.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/yahoo-weather/response.rb b/lib/yahoo-weather/response.rb index 841821b..62db41d 100644 --- a/lib/yahoo-weather/response.rb +++ b/lib/yahoo-weather/response.rb @@ -84,6 +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 = item.xpath('pubDate').first.content + @pubdate = YahooWeather._parse_time(item.xpath('pubDate').first.content) end end From 8a426ee959a88b89366ba05ff9cfdb01074f88ce Mon Sep 17 00:00:00 2001 From: Kurt Edelbrock Date: Thu, 26 May 2011 09:00:19 -0400 Subject: [PATCH 7/7] Added test for pubDate --- test/test_api.rb | 1 + 1 file changed, 1 insertion(+) 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}"))