Sha256: 8e62788f6c9c1b8c3e2867e159466cbd07da33f46933218b64ae65039333dd0b
Contents?: true
Size: 1 KB
Versions: 2
Compression:
Stored size: 1 KB
Contents
require 'rubygems' require 'sinatra' require 'barometer' # load API keys keys = YAML.load_file(File.expand_path(File.join('~', '.barometer'))) if keys["geocode_google"] Barometer.google_geocode_key = keys["geocode_google"] else exit end class Demometer < Sinatra::Default helpers do def data(title, value) return if value.nil? "<li>#{title}: #{value}</li>" end end get '/' do erb :index end post '/' do # apply options Barometer.force_geocode = (params[:query][:geocode].to_s == "1" ? true : false) metric = (params[:query][:metric].to_s == "1" ? true : false) # determine sources Barometer.selection = { 1 => params[:query][:source].collect{|s| s.to_sym } } if params[:query] && !params[:query][:q].empty? @barometer = Barometer.new(params[:query][:q]) @weather = @barometer.measure(metric) end erb :index end get '/contributing.html' do erb :contributing end get '/readme.html' do erb :readme end end
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
attack-barometer-0.3.2 | lib/demometer/demometer.rb |
barometer-0.3.2 | lib/demometer/demometer.rb |