barometer 0.7.0 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.rdoc CHANGED
@@ -15,7 +15,7 @@ this.
15
15
 
16
16
  == version
17
17
 
18
- Version 0.6.8 is the current release of this gem. The gem is available from
18
+ Version 0.7.1 is the current release of this gem. The gem is available from
19
19
  gemcutter (barometer: http://gemcutter.org/gems/barometer).
20
20
  Older version are available through rubyforge (barometer) and github
21
21
  (attack-barometer).
@@ -25,7 +25,7 @@ It is fully functional (for five weather service APIs).
25
25
 
26
26
  Currently this project has completed initial development and will work for a
27
27
  few weather services (wunderground, google, yahoo, weather.com, weather_bug).
28
- Barometer has been tested on both Ruby 1.8.7 and 1.9.1.
28
+ Barometer is developed using only Ruby 1.9.2, but will probably on both Ruby 1.8.7 and 1.9.1.
29
29
 
30
30
  Features to be added in the future:
31
31
  - better command line output
@@ -198,15 +198,6 @@ This will output the weather information for the given query.
198
198
  See the help for more command line information.
199
199
 
200
200
  # barometer -h
201
-
202
- === web demo
203
-
204
- There is a Sinatra application that demos the functionality of Barometer,
205
- and provides Barometer information. Start this local demo with:
206
-
207
- # barometer -w
208
-
209
- NOTE: This requires the gems "sinatra" and "vegas".
210
201
 
211
202
  === fail
212
203
 
data/VERSION.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  ---
2
2
  :major: 0
3
3
  :minor: 7
4
- :patch: 0
4
+ :patch: 1
5
5
  :build:
data/barometer.gemspec CHANGED
@@ -2,14 +2,14 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{barometer}
5
- s.version = "0.7.0"
5
+ s.version = "0.7.1"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.rubygems_version = %q{1.3.5}
9
9
 
10
10
  s.authors = ["Mark G"]
11
11
  s.email = %q{barometer@attackcorp.com}
12
- s.date = %q{2010-02-10}
12
+ s.date = %q{2011-06-01}
13
13
 
14
14
  s.summary = %q{A multi API consuming weather forecasting superstar.}
15
15
  s.description = %q{A multi API consuming weather forecasting superstar.}
data/bin/barometer CHANGED
@@ -11,14 +11,6 @@
11
11
  # barometer --yahoo 90210
12
12
  # barometer --verbose 'new york'
13
13
  #
14
- # == Local Web Demo
15
- # You can easily interact directly with barometer with the command:
16
- # barometer -w
17
- #
18
- # This demo has 2 gem requirements:
19
- # - sinatra (tested with 0.9.1.1)
20
- # - vegas (tested with 0.0.1)
21
- #
22
14
  # == Usage
23
15
  # barometer [options] query
24
16
  #
@@ -41,22 +33,17 @@
41
33
  # -s, --wind wind speed threshold used to determine windy?
42
34
  # -a, --at time/date used to determine when to calculate summary
43
35
  #
44
- # Web Demo:
45
- # -w, --web run web-app with barometer demo
46
- # -k, --kill stop the web demo background process
47
- # -S, --status show the web demo status
48
- #
49
36
  # == Author
50
37
  # Mark G
51
38
  # http://github.com/attack/barometer
52
39
  #
53
40
  # == Copyright
54
- # Copyright (c) 2009-2010 Mark G. Licensed under the MIT License:
41
+ # Copyright (c) 2009-2011 Mark G. Licensed under the MIT License:
55
42
  # http://www.opensource.org/licenses/mit-license.php
56
43
 
57
44
  require 'rubygems'
58
- #require 'barometer'
59
- require '/Users/mark/work/fresh/gems/barometer/lib/barometer'
45
+ require 'barometer'
46
+ #require '/Users/mark/code/gems/barometer/lib/barometer'
60
47
 
61
48
  require 'optparse'
62
49
  require 'ostruct'
@@ -66,7 +53,7 @@ require 'yaml'
66
53
 
67
54
  # file where API keys are stored
68
55
  KEY_FILE = File.expand_path(File.join('~', '.barometer'))
69
- BAROMETER_VERSION = '0.6.8'
56
+ BAROMETER_VERSION = '0.7.1'
70
57
 
71
58
  class App
72
59
 
@@ -83,7 +70,6 @@ class App
83
70
  @options.metric = true
84
71
  @options.sources = []
85
72
  @options.verbode = false
86
- @options.web = false
87
73
  @options.at = nil
88
74
  @options.default = true
89
75
 
@@ -133,11 +119,6 @@ class App
133
119
  opt.on('--bug') { @options.sources << :weather_bug; @options.default = false }
134
120
  opt.on('-p n', '--pop n') {|n| @options.pop = n.to_i || 50 }
135
121
  opt.on('-s n', '--wind n') {|n| @options.metric ? @options.windy_m = n.to_f || 10 : @options.windy_i = n.to_f || 7 }
136
-
137
- # pass these onto vegas
138
- opt.on('-w', '--web') { @options.web = true; ARGV.shift }
139
- opt.on('-k', '--kill') { @options.web = true }
140
- opt.on('-S', '--status') { @options.web = true }
141
122
 
142
123
  opt.parse!(@arguments) rescue return false
143
124
 
@@ -244,11 +225,6 @@ class App
244
225
  puts " -p, --pop pop threshold used to determine wet?"
245
226
  puts " -s, --wind wind speed threshold used to determine windy?"
246
227
  puts " -a, --at time/date used to determine when to calculate summary"
247
- puts
248
- puts " Web Demo:"
249
- puts " -w, --web run web-app with barometer demo"
250
- puts " -k, --kill stop the web demo background process"
251
- puts " -S, --status show the web demo status"
252
228
  end
253
229
 
254
230
  def output_version
@@ -256,25 +232,21 @@ class App
256
232
  end
257
233
 
258
234
  def process_command
259
- if @options.web
260
- run_web_mode(@arguments.join(" "))
261
- else
262
- barometer = Barometer.new(@arguments.join(" "))
263
- begin
264
- if @options.verbose
265
- Barometer::debug!
266
- div(char="*")
267
- puts "DEBUG LOG"
268
- blank
269
- end
270
- barometer.measure(@options.metric) if barometer
271
- blank if @options.verbose
272
- pretty_output(barometer) if barometer.weather
273
- rescue Barometer::OutOfSources
274
- puts
275
- puts " SORRY: your query did not provide any results"
276
- puts
235
+ barometer = Barometer.new(@arguments.join(" "))
236
+ begin
237
+ if @options.verbose
238
+ Barometer::debug!
239
+ div(char="*")
240
+ puts "DEBUG LOG"
241
+ blank
277
242
  end
243
+ barometer.measure(@options.metric) if barometer
244
+ blank if @options.verbose
245
+ pretty_output(barometer) if barometer.weather
246
+ rescue Barometer::OutOfSources
247
+ puts
248
+ puts " SORRY: your query did not provide any results"
249
+ puts
278
250
  end
279
251
  end
280
252
  end
@@ -477,18 +449,6 @@ def pretty_output(barometer)
477
449
  end
478
450
  end
479
451
 
480
- def run_web_mode(query=nil)
481
-
482
- require 'rubygems'
483
- require File.expand_path(File.dirname(__FILE__) + '/../lib/demometer/demometer.rb')
484
- require 'vegas'
485
-
486
- Vegas::Runner.new(Demometer, 'demometer') do |opts, app|
487
- # opts is an option parser object
488
- # app is your app class
489
- end
490
- end
491
-
492
452
  def geocode_google_key_message
493
453
  puts
494
454
  puts "MISSING KEYS !!!"
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 7
8
- - 0
9
- version: 0.7.0
8
+ - 1
9
+ version: 0.7.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Mark G
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-02-10 00:00:00 -05:00
17
+ date: 2011-06-01 00:00:00 -04:00
18
18
  default_executable: barometer
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -164,19 +164,6 @@ files:
164
164
  - lib/barometer/web_services/timezone.rb
165
165
  - lib/barometer/web_services/weather_id.rb
166
166
  - lib/barometer/web_services/web_service.rb
167
- - lib/demometer/demometer.rb
168
- - lib/demometer/public/css/master.css
169
- - lib/demometer/public/css/print.css
170
- - lib/demometer/public/css/syntax.css
171
- - lib/demometer/public/images/go.png
172
- - lib/demometer/public/images/link-out.gif
173
- - lib/demometer/views/about.erb
174
- - lib/demometer/views/contributing.erb
175
- - lib/demometer/views/forecast.erb
176
- - lib/demometer/views/index.erb
177
- - lib/demometer/views/layout.erb
178
- - lib/demometer/views/measurement.erb
179
- - lib/demometer/views/readme.erb
180
167
  - spec/barometer_spec.rb
181
168
  - spec/data/distance_spec.rb
182
169
  - spec/data/geo_spec.rb
@@ -1,104 +0,0 @@
1
- require 'rubygems'
2
- require 'sinatra'
3
- require 'barometer'
4
-
5
- # load API keys
6
- @@config_file ||= File.expand_path(File.join('~', '.barometer'))
7
- keys = YAML.load_file(@@config_file)
8
- if keys["google"] && keys["google"]["geocode"]
9
- Barometer.google_geocode_key = keys["google"]["geocode"]
10
- else
11
- raise RunTimeError "no geocoding keys"
12
- exit
13
- end
14
-
15
- class Demometer < Sinatra::Default
16
-
17
- def config_weather_dot_com
18
- if File.exists?(@@config_file)
19
- keys = YAML.load_file(@@config_file)
20
- if keys["weather"] && keys["weather"]["partner"] && keys["weather"]["license"]
21
- partner_key = keys["weather"]["partner"].to_s
22
- license_key = keys["weather"]["license"].to_s
23
- else
24
- raise RunTimeError "no weather.com keys"
25
- exit
26
- end
27
- else
28
- File.open(@@config_file, 'w') {|f| f << "\nweather:\n partner: PARTNER_KEY\n license: LICENSE_KEY" }
29
- raise RunTimeError "no weather.com keys"
30
- exit
31
- end
32
- { :weather_dot_com => { :keys => { :partner => partner_key, :license => license_key } } }
33
- end
34
-
35
- def config_weather_bug
36
- if File.exists?(@@config_file)
37
- keys = YAML.load_file(@@config_file)
38
- if keys["weather_bug"] && keys["weather_bug"]["code"]
39
- code = keys["weather_bug"]["code"].to_s
40
- else
41
- raise RunTimeError "no weatherbug.com keys"
42
- exit
43
- end
44
- else
45
- File.open(@@config_file, 'w') {|f| f << "\weather_bug:\n code: API_CODE" }
46
- raise RunTimeError "no weatherbug.com keys"
47
- exit
48
- end
49
- { :weather_bug => { :keys => { :code => code } } }
50
- end
51
-
52
- helpers do
53
- def data(title, value)
54
- return if value.nil?
55
- "<li>#{title}: #{value}</li>"
56
- end
57
- end
58
-
59
- get '/' do
60
- erb :index
61
- end
62
-
63
- post '/' do
64
- # apply options
65
- Barometer.force_geocode = (params[:query][:geocode].to_s == "1" ? true : false)
66
- metric = (params[:query][:metric].to_s == "1" ? true : false)
67
-
68
- # determine sources
69
- Barometer.config = { 1 => params[:query][:source].collect{|s| s.to_sym } }
70
-
71
- # setup weather.com
72
- if Barometer::Base.config && Barometer::Base.config[1] &&
73
- Barometer::Base.config[1].include?(:weather_dot_com)
74
- Barometer::Base.config[1].delete(:weather_dot_com)
75
- Barometer::Base.config[1] << config_weather_dot_com
76
- end
77
-
78
- # setup weatherbug.com
79
- if Barometer::Base.config && Barometer::Base.config[1] &&
80
- Barometer::Base.config[1].include?(:weather_bug)
81
- Barometer::Base.config[1].delete(:weather_bug)
82
- Barometer::Base.config[1] << config_weather_bug
83
- end
84
-
85
- if params[:query] && !params[:query][:q].empty?
86
- @barometer = Barometer.new(params[:query][:q])
87
- @weather = @barometer.measure(metric)
88
- end
89
- erb :index
90
- end
91
-
92
- get '/contributing.html' do
93
- erb :contributing
94
- end
95
-
96
- get '/readme.html' do
97
- erb :readme
98
- end
99
-
100
- get '/about.html' do
101
- erb :about
102
- end
103
-
104
- end
@@ -1,188 +0,0 @@
1
- /*
2
- Inspired By: Blake Mizerany, www.sinatrarb.com
3
- */
4
-
5
- body {
6
- color:#000;
7
- font-family:"Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", Helvetica, Arial, sans-serif;
8
- font-size:100%;
9
- line-height:1.3;
10
- background-color:#fff;
11
- margin:0;
12
- padding:0;
13
- }
14
-
15
- /* HEADER */
16
- #head {
17
- text-align:center;
18
- }
19
- #head h1 {
20
- color:#000;
21
- font-size:4em;
22
- font-weight:normal;
23
- letter-spacing:-3px;
24
- line-height:1;
25
- margin:0;
26
- padding:20px 0 15px 0;
27
- }
28
- #head h1 a, #head h1 a:link, #head h1 a:visited, #head h1 a:hover {
29
- color:#100;
30
- text-decoration:none;
31
- }
32
- #head ul {
33
- font-size:1.1em;
34
- font-weight:normal;
35
- text-transform:uppercase;
36
- letter-spacing:2px;
37
- text-align:center;
38
- margin:0;
39
- padding:0 40px 0.25em 40px;
40
- }
41
- #head ul li {
42
- display:inline;
43
- list-style-type:none;
44
- padding:0 0.5em 0 0;
45
- }
46
- #head ul a, #head ul a:link, #head ul a:visited {
47
- color:#56534f;
48
- text-decoration:none;
49
- }
50
- #head ul a:hover {
51
- color:#000;
52
- text-decoration:underline
53
- }
54
-
55
- /* CONTENT */
56
-
57
- #content {
58
- color:#333;
59
- font-size:1.1em;
60
- max-width:44em;
61
- min-width:30em;
62
- margin:7px auto;
63
- border-top:2px solid #837d7c;
64
- }
65
- strong {
66
- font-weight:bold;
67
- }
68
-
69
- /* HEADINGS */
70
-
71
- h1, h2, h3, h4, h5, h6 {
72
- color:#000;
73
- }
74
- h1, h2 {
75
- color:#211d1f;
76
- font-weight:normal;
77
- }
78
- h1 a, h2 a { color:#222 }
79
- h1 {
80
- font-size:2.25em;
81
- letter-spacing:-1px;
82
- margin-bottom:0;
83
- }
84
- h2 {
85
- font-size:1.5em;
86
- letter-spacing:-1px;
87
- margin:1.25em 0 -0.32em 0;
88
- }
89
- h3 {
90
- color:#211d1f;
91
- font-size:1.02em;
92
- font-weight:bold;
93
- margin:1.8em 0 -0.25em 0;
94
- letter-spacing:-1px;
95
- }
96
- h3 a {
97
- color:#000;
98
- text-decoration:underline;
99
- }
100
-
101
- /* LINKS */
102
- a {
103
- color:#000;
104
- text-decoration:underline;
105
- }
106
- a:hover {
107
- color:#910;
108
- text-decoration:underline;
109
- }
110
- a img {
111
- border:none;
112
- }
113
- a.out {
114
- background: url('/images/link-out.gif') center right no-repeat;
115
- padding-right: 12px;
116
- }
117
-
118
-
119
- /* CODE */
120
-
121
- code, pre, textarea, tt {
122
- font-family:"lucida console", "monaco", "andale mono", "bitstream vera sans mono",
123
- "consolas", monospace;
124
- }
125
- pre {
126
- font-size:0.85em;
127
- background:#f4f5f5;
128
- border:2px solid #d5d0d2;
129
- padding:0.5em;
130
- line-height:1.15;
131
- color:#222;
132
- }
133
- code, tt {
134
- font-size:0.85em;
135
- color:#444;
136
- }
137
- h1 code, h2 code, h3 code, h4 code {
138
- color:#333;
139
- }
140
- pre code {
141
- font-size:1em;
142
- color:#222;
143
- }
144
-
145
- /* MISC */
146
-
147
- hr {
148
- margin:3em 0;
149
- padding:0;
150
- color:#eee;
151
- }
152
-
153
- /* HOME */
154
-
155
- #home #content {
156
- font-size:1.05em;
157
- margin:20px 0 0 0;
158
- padding:0 20px;
159
- border-width:0;
160
- }
161
- #home #head, #home #foot {
162
- display:none;
163
- }
164
- form {
165
- text-align: center;
166
- }
167
-
168
- form .text-input input {
169
- font-family: "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", Helvetica, Arial, sans-serif;
170
- margin: 10px 0 5px 10px;
171
- color: #686868;
172
- font-size: 40px;
173
- text-align: left;
174
- text-transform: lowercase;
175
- }
176
-
177
- form .submit-input input {
178
- position: relative;
179
- margin: 0 7% 0 0;
180
- float: right;
181
- }
182
-
183
- form .options-input {
184
- position: relative;
185
- margin: 0 7% 0 0;
186
- text-align: left;
187
- }
188
-