lib/demometer/demometer.rb in attack-barometer-0.5.0 vs lib/demometer/demometer.rb in attack-barometer-0.6.0
- old
+ new
@@ -30,10 +30,27 @@
exit
end
{ :weather_dot_com => { :keys => { :partner => partner_key, :license => license_key } } }
end
+ def config_weather_bug
+ if File.exists?(@@config_file)
+ keys = YAML.load_file(@@config_file)
+ if keys["weather_bug"] && keys["weather_bug"]["code"]
+ code = keys["weather_bug"]["code"].to_s
+ else
+ raise RunTimeError "no weatherbug.com keys"
+ exit
+ end
+ else
+ File.open(@@config_file, 'w') {|f| f << "\weather_bug:\n code: API_CODE" }
+ raise RunTimeError "no weatherbug.com keys"
+ exit
+ end
+ { :weather_bug => { :keys => { :code => code } } }
+ end
+
helpers do
def data(title, value)
return if value.nil?
"<li>#{title}: #{value}</li>"
end
@@ -56,10 +73,17 @@
Barometer::Base.config[1].include?(:weather_dot_com)
Barometer::Base.config[1].delete(:weather_dot_com)
Barometer::Base.config[1] << config_weather_dot_com
end
+ # setup weatherbug.com
+ if Barometer::Base.config && Barometer::Base.config[1] &&
+ Barometer::Base.config[1].include?(:weather_bug)
+ Barometer::Base.config[1].delete(:weather_bug)
+ Barometer::Base.config[1] << config_weather_bug
+ end
+
if params[:query] && !params[:query][:q].empty?
@barometer = Barometer.new(params[:query][:q])
@weather = @barometer.measure(metric)
end
erb :index
@@ -69,8 +93,12 @@
erb :contributing
end
get '/readme.html' do
erb :readme
+ end
+
+ get '/about.html' do
+ erb :about
end
end
\ No newline at end of file