WeatherAgent should take the Wunderground API key as an option.

This commit is contained in:
Selem Delul 2013-03-22 06:54:53 -04:00
parent d15bb7ccee
commit 33cd371bfc

View file

@ -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
end