bin/barometer in barometer-0.7.0 vs bin/barometer in barometer-0.7.1
- old
+ new
@@ -9,18 +9,10 @@
#
# Other examples:
# barometer --yahoo 90210
# barometer --verbose 'new york'
#
-# == Local Web Demo
-# You can easily interact directly with barometer with the command:
-# barometer -w
-#
-# This demo has 2 gem requirements:
-# - sinatra (tested with 0.9.1.1)
-# - vegas (tested with 0.0.1)
-#
# == Usage
# barometer [options] query
#
# For help use: barometer -h
#
@@ -39,36 +31,31 @@
# --bug add weather_bug as a source
# -p, --pop pop threshold used to determine wet?
# -s, --wind wind speed threshold used to determine windy?
# -a, --at time/date used to determine when to calculate summary
#
-# Web Demo:
-# -w, --web run web-app with barometer demo
-# -k, --kill stop the web demo background process
-# -S, --status show the web demo status
-#
# == Author
# Mark G
# http://github.com/attack/barometer
#
# == Copyright
-# Copyright (c) 2009-2010 Mark G. Licensed under the MIT License:
+# Copyright (c) 2009-2011 Mark G. Licensed under the MIT License:
# http://www.opensource.org/licenses/mit-license.php
require 'rubygems'
-#require 'barometer'
-require '/Users/mark/work/fresh/gems/barometer/lib/barometer'
+require 'barometer'
+#require '/Users/mark/code/gems/barometer/lib/barometer'
require 'optparse'
require 'ostruct'
require 'time'
require 'date'
require 'yaml'
# file where API keys are stored
KEY_FILE = File.expand_path(File.join('~', '.barometer'))
-BAROMETER_VERSION = '0.6.8'
+BAROMETER_VERSION = '0.7.1'
class App
attr_reader :options
@@ -81,11 +68,10 @@
@options.geocode = false
@options.timezone = false
@options.metric = true
@options.sources = []
@options.verbode = false
- @options.web = false
@options.at = nil
@options.default = true
# thresholds
@options.windy_m = 10
@@ -131,15 +117,10 @@
opt.on('--google') { @options.sources << :google; @options.default = false }
opt.on('--weather') { @options.sources << :weather_dot_com; @options.default = false }
opt.on('--bug') { @options.sources << :weather_bug; @options.default = false }
opt.on('-p n', '--pop n') {|n| @options.pop = n.to_i || 50 }
opt.on('-s n', '--wind n') {|n| @options.metric ? @options.windy_m = n.to_f || 10 : @options.windy_i = n.to_f || 7 }
-
- # pass these onto vegas
- opt.on('-w', '--web') { @options.web = true; ARGV.shift }
- opt.on('-k', '--kill') { @options.web = true }
- opt.on('-S', '--status') { @options.web = true }
opt.parse!(@arguments) rescue return false
process_options
true
@@ -242,41 +223,32 @@
puts " --weather add weather.com as a source"
puts " --bug add weather_bug as a source"
puts " -p, --pop pop threshold used to determine wet?"
puts " -s, --wind wind speed threshold used to determine windy?"
puts " -a, --at time/date used to determine when to calculate summary"
- puts
- puts " Web Demo:"
- puts " -w, --web run web-app with barometer demo"
- puts " -k, --kill stop the web demo background process"
- puts " -S, --status show the web demo status"
end
def output_version
puts "#{File.basename(__FILE__)} version #{BAROMETER_VERSION}"
end
def process_command
- if @options.web
- run_web_mode(@arguments.join(" "))
- else
- barometer = Barometer.new(@arguments.join(" "))
- begin
- if @options.verbose
- Barometer::debug!
- div(char="*")
- puts "DEBUG LOG"
- blank
- end
- barometer.measure(@options.metric) if barometer
- blank if @options.verbose
- pretty_output(barometer) if barometer.weather
- rescue Barometer::OutOfSources
- puts
- puts " SORRY: your query did not provide any results"
- puts
+ barometer = Barometer.new(@arguments.join(" "))
+ begin
+ if @options.verbose
+ Barometer::debug!
+ div(char="*")
+ puts "DEBUG LOG"
+ blank
end
+ barometer.measure(@options.metric) if barometer
+ blank if @options.verbose
+ pretty_output(barometer) if barometer.weather
+ rescue Barometer::OutOfSources
+ puts
+ puts " SORRY: your query did not provide any results"
+ puts
end
end
end
#
@@ -472,21 +444,9 @@
pretty_summary(weather)
pretty_query(barometer.query)
pretty_measurements(weather)
pretty_info(weather)
div("-")
- end
-end
-
-def run_web_mode(query=nil)
-
- require 'rubygems'
- require File.expand_path(File.dirname(__FILE__) + '/../lib/demometer/demometer.rb')
- require 'vegas'
-
- Vegas::Runner.new(Demometer, 'demometer') do |opts, app|
- # opts is an option parser object
- # app is your app class
end
end
def geocode_google_key_message
puts