From 33cd371bfc3fa2e7895c10cb7c0b01641c1a3e71 Mon Sep 17 00:00:00 2001 From: Selem Delul Date: Fri, 22 Mar 2013 06:54:53 -0400 Subject: [PATCH] WeatherAgent should take the Wunderground API key as an option. --- app/models/agents/weather_agent.rb | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/models/agents/weather_agent.rb b/app/models/agents/weather_agent.rb index b8efb150..86d2df2b 100644 --- a/app/models/agents/weather_agent.rb +++ b/app/models/agents/weather_agent.rb @@ -44,15 +44,20 @@ module Agents end def wunderground - Wunderground.new("your-api-key") + Wunderground.new(options[:api_key]) end def default_options - { :zipcode => "94103" } + { + :api_key => "", + :zipcode => "94103" + } + end def validate_options errors.add(:base, "zipcode is required") unless options[:zipcode].present? + errors.add(:base, "api_key is required") unless options[:api_key].present? end def check @@ -67,4 +72,4 @@ module Agents Time.zone.at(day["date"]["epoch"].to_i).to_date == Time.zone.now.tomorrow.to_date end end -end \ No newline at end of file +end