barometer 0.6.7 → 0.7.0

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.
Files changed (50) hide show
  1. data/.gitignore +4 -0
  2. data/Gemfile +3 -0
  3. data/LICENSE +1 -1
  4. data/README.rdoc +36 -8
  5. data/Rakefile +7 -28
  6. data/TODO +4 -0
  7. data/VERSION.yml +2 -2
  8. data/barometer.gemspec +20 -193
  9. data/bin/barometer +8 -5
  10. data/lib/barometer.rb +5 -1
  11. data/lib/barometer/data/local_datetime.rb +11 -7
  12. data/lib/barometer/formats.rb +2 -1
  13. data/lib/barometer/formats/coordinates.rb +15 -3
  14. data/lib/barometer/formats/format.rb +18 -0
  15. data/lib/barometer/formats/geocode.rb +12 -5
  16. data/lib/barometer/formats/weather_id.rb +0 -15
  17. data/lib/barometer/formats/woe_id.rb +150 -0
  18. data/lib/barometer/query.rb +20 -4
  19. data/lib/barometer/services.rb +2 -1
  20. data/lib/barometer/weather_services/service.rb +0 -4
  21. data/lib/barometer/weather_services/weather_bug.rb +2 -2
  22. data/lib/barometer/weather_services/yahoo.rb +14 -3
  23. data/lib/barometer/web_services/placemaker.rb +95 -0
  24. data/lib/barometer/web_services/web_service.rb +1 -4
  25. data/spec/barometer_spec.rb +14 -32
  26. data/spec/data/local_datetime_spec.rb +7 -2
  27. data/spec/data/zone_spec.rb +5 -2
  28. data/spec/fakeweb_helper.rb +158 -0
  29. data/spec/fixtures/services/placemaker/T5B4M9.xml +65 -0
  30. data/spec/fixtures/services/placemaker/atlanta.xml +65 -0
  31. data/spec/fixtures/services/placemaker/coords.xml +65 -0
  32. data/spec/fixtures/services/placemaker/ksfo.xml +65 -0
  33. data/spec/fixtures/services/placemaker/new_york.xml +65 -0
  34. data/spec/fixtures/services/placemaker/the_hills.xml +65 -0
  35. data/spec/fixtures/services/placemaker/w615702.xml +46 -0
  36. data/spec/fixtures/services/weather_bug/90210_forecast.xml +1 -1
  37. data/spec/formats/coordinates_spec.rb +16 -0
  38. data/spec/formats/format_spec.rb +9 -0
  39. data/spec/formats/woe_id_spec.rb +215 -0
  40. data/spec/query_spec.rb +38 -0
  41. data/spec/spec_helper.rb +7 -160
  42. data/spec/weather_services/google_spec.rb +0 -8
  43. data/spec/weather_services/services_spec.rb +1 -1
  44. data/spec/weather_services/weather_bug_spec.rb +0 -36
  45. data/spec/weather_services/weather_dot_com_spec.rb +0 -20
  46. data/spec/weather_services/wunderground_spec.rb +0 -30
  47. data/spec/weather_services/yahoo_spec.rb +1 -17
  48. data/spec/web_services/placemaker_spec.rb +46 -0
  49. metadata +136 -18
  50. data/lib/barometer/extensions/httparty.rb +0 -21
data/.gitignore CHANGED
@@ -6,3 +6,7 @@ pkg
6
6
  lib/attic
7
7
  coverage
8
8
  *.gem
9
+
10
+ .rvmrc
11
+ .bundle
12
+ Gemfile.lock
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source :rubygems
2
+
3
+ gemspec
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2009 Mark G
1
+ Copyright (c) 2009-2010 Mark G
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.rdoc CHANGED
@@ -15,16 +15,20 @@ this.
15
15
 
16
16
  == version
17
17
 
18
- Version 0.6.7 is the current release of this gem.
19
- The gem is available from github (attack-barometer) or rubyforge (barometer).
18
+ Version 0.6.8 is the current release of this gem. The gem is available from
19
+ gemcutter (barometer: http://gemcutter.org/gems/barometer).
20
+ Older version are available through rubyforge (barometer) and github
21
+ (attack-barometer).
20
22
  It is fully functional (for five weather service APIs).
21
23
 
22
24
  == status
23
25
 
24
- Currently this project is in development and will only work for a few weather
25
- services (wunderground, google, yahoo, weather.com, weather_bug).
26
+ Currently this project has completed initial development and will work for a
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.
26
29
 
27
- Features to be added next:
30
+ Features to be added in the future:
31
+ - better command line output
28
32
  - even more weather service drivers (hamweather)
29
33
  - icon support
30
34
 
@@ -60,6 +64,11 @@ eg. weatherbug.com
60
64
 
61
65
  weather_bug:
62
66
  code: YOUR_API_CODE
67
+
68
+ eg. Yahoo! Placemaker
69
+
70
+ yahoo:
71
+ app_id: YOUR_APP_ID
63
72
 
64
73
  == HTTParty
65
74
 
@@ -67,7 +76,7 @@ Why? HTTParty was created and designed specifically for consuming web services.
67
76
  I choose to use this over using the Net::HTTP library directly to allow for
68
77
  faster development of this project.
69
78
 
70
- HTTParty is also extended to include configurable Timeout support.
79
+ It is possible that I will use Net::HTTP in the future.
71
80
 
72
81
  == tzinfo
73
82
 
@@ -100,6 +109,7 @@ code (ICAO) and it will return the weather as expected.
100
109
  - postal code
101
110
  - weather.com ID
102
111
  - location name (ie address, city, state, landmark, etc.)
112
+ - woeid (where on earth id, by Yahoo!)
103
113
 
104
114
  * if the query is of the formats zipcode or postal code it may not
105
115
  support conversion to other formats.
@@ -130,7 +140,7 @@ with geo-coding.
130
140
  barometer = Barometer.new("Paris")
131
141
  weather = barometer.measure
132
142
 
133
- puts weather.current.temperture
143
+ puts weather.current.temperature
134
144
 
135
145
  == sources
136
146
 
@@ -357,6 +367,24 @@ Barometer attempts to be a common API to any weather service API. I have includ
357
367
  several weather service 'drivers', but I know there are many more available.
358
368
  Please use the provided ones as examples to create more.
359
369
 
370
+ = development
371
+
372
+ Barometer now uses 'bundler'. You just need to 'git clone' the repo and 'bundle install'.
373
+
374
+ == Contributions
375
+
376
+ Thank you to these developers who have contributed. No contribution is too small.
377
+
378
+ - nofxx (https://github.com/nofxx)
379
+ - floere (https://github.com/floere)
380
+ - plukevdh (https://github.com/plukevdh)
381
+
382
+
383
+ = Links
384
+
385
+ - repo: http://github.com/attack/barometer
386
+ - rdoc: http://rdoc.info/projects/attack/barometer
387
+
360
388
  == copyright
361
389
 
362
- Copyright (c) 2009 Mark G. See LICENSE for details.
390
+ Copyright (c) 2009-2011 Mark G. See LICENSE for details.
data/Rakefile CHANGED
@@ -1,40 +1,19 @@
1
1
  require 'rubygems'
2
2
  require 'rake'
3
3
 
4
- begin
5
- require 'jeweler'
6
- Jeweler::Tasks.new do |gem|
7
- gem.name = "barometer"
8
- gem.summary = "A multi API consuming weather forecasting superstar."
9
- gem.description = "A multi API consuming weather forecasting superstar."
10
- gem.email = "barometer@attackcorp.com"
11
- gem.homepage = "http://github.com/attack/barometer"
12
- gem.authors = ["Mark G"]
13
-
14
- gem.add_dependency 'httparty', '>= 0.4.5'
15
- gem.add_dependency 'tzinfo', '>= 0.3.14'
16
-
17
- #gem.add_development_dependency "mocha"
18
- end
19
- Jeweler::GemcutterTasks.new
20
- rescue LoadError
21
- puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
22
- end
4
+ require 'bundler/gem_tasks'
5
+ require 'rspec/core/rake_task'
23
6
 
24
- require 'spec/rake/spectask'
25
- Spec::Rake::SpecTask.new(:spec) do |spec|
26
- spec.libs << 'lib' << 'spec'
27
- spec.spec_files = FileList['spec/**/*_spec.rb']
28
- spec.spec_opts = ["-c"]
7
+ RSpec::Core::RakeTask.new(:spec) do |spec|
8
+ spec.pattern = 'spec/**/*_spec.rb'
9
+ spec.rspec_opts = ["-c"]
29
10
  end
30
11
 
31
- Spec::Rake::SpecTask.new(:rcov) do |spec|
32
- spec.libs << 'lib' << 'spec'
12
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
33
13
  spec.pattern = 'spec/**/*_spec.rb'
34
14
  spec.rcov = true
35
15
  end
36
16
 
37
-
38
17
  task :default => :spec
39
18
 
40
19
  require 'rake/rdoctask'
@@ -50,4 +29,4 @@ Rake::RDocTask.new do |rdoc|
50
29
  rdoc.title = "barometer #{version}"
51
30
  rdoc.rdoc_files.include('README*')
52
31
  rdoc.rdoc_files.include('lib/**/*.rb')
53
- end
32
+ end
data/TODO CHANGED
@@ -3,6 +3,10 @@
3
3
  - google geocoding terms of service indicate that "a map must be shown" ... what to do?
4
4
  - driver: hamweather
5
5
  - driver: meter
6
+ - improve code based on metrics
7
+ - ability to use Placemaker for geocoding (instead of Google)
8
+ - use Geomojo to convert coords to woe_id (when no yahoo key)
9
+ - remove use of HTTParty, use Net:HTTP and Nokogiri instead
6
10
 
7
11
  == soon
8
12
 
data/VERSION.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  ---
2
2
  :major: 0
3
- :minor: 6
4
- :patch: 7
3
+ :minor: 7
4
+ :patch: 0
5
5
  :build:
data/barometer.gemspec CHANGED
@@ -1,208 +1,35 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
1
  # -*- encoding: utf-8 -*-
5
2
 
6
3
  Gem::Specification.new do |s|
7
4
  s.name = %q{barometer}
8
- s.version = "0.6.7"
5
+ s.version = "0.7.0"
9
6
 
10
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.rubygems_version = %q{1.3.5}
9
+
11
10
  s.authors = ["Mark G"]
11
+ s.email = %q{barometer@attackcorp.com}
12
12
  s.date = %q{2010-02-10}
13
- s.default_executable = %q{barometer}
13
+
14
+ s.summary = %q{A multi API consuming weather forecasting superstar.}
14
15
  s.description = %q{A multi API consuming weather forecasting superstar.}
15
- s.email = %q{barometer@attackcorp.com}
16
- s.executables = ["barometer"]
17
- s.extra_rdoc_files = [
18
- "LICENSE",
19
- "README.rdoc",
20
- "TODO"
21
- ]
22
- s.files = [
23
- ".document",
24
- ".gitignore",
25
- "LICENSE",
26
- "README.rdoc",
27
- "Rakefile",
28
- "TODO",
29
- "VERSION.yml",
30
- "barometer.gemspec",
31
- "bin/barometer",
32
- "lib/barometer.rb",
33
- "lib/barometer/base.rb",
34
- "lib/barometer/data.rb",
35
- "lib/barometer/data/distance.rb",
36
- "lib/barometer/data/geo.rb",
37
- "lib/barometer/data/local_datetime.rb",
38
- "lib/barometer/data/local_time.rb",
39
- "lib/barometer/data/location.rb",
40
- "lib/barometer/data/pressure.rb",
41
- "lib/barometer/data/speed.rb",
42
- "lib/barometer/data/sun.rb",
43
- "lib/barometer/data/temperature.rb",
44
- "lib/barometer/data/units.rb",
45
- "lib/barometer/data/zone.rb",
46
- "lib/barometer/extensions/httparty.rb",
47
- "lib/barometer/formats.rb",
48
- "lib/barometer/formats/coordinates.rb",
49
- "lib/barometer/formats/format.rb",
50
- "lib/barometer/formats/geocode.rb",
51
- "lib/barometer/formats/icao.rb",
52
- "lib/barometer/formats/postalcode.rb",
53
- "lib/barometer/formats/short_zipcode.rb",
54
- "lib/barometer/formats/weather_id.rb",
55
- "lib/barometer/formats/zipcode.rb",
56
- "lib/barometer/measurements/measurement.rb",
57
- "lib/barometer/measurements/result.rb",
58
- "lib/barometer/measurements/result_array.rb",
59
- "lib/barometer/query.rb",
60
- "lib/barometer/services.rb",
61
- "lib/barometer/translations/icao_country_codes.yml",
62
- "lib/barometer/translations/weather_country_codes.yml",
63
- "lib/barometer/translations/zone_codes.yml",
64
- "lib/barometer/weather.rb",
65
- "lib/barometer/weather_services/google.rb",
66
- "lib/barometer/weather_services/noaa.rb",
67
- "lib/barometer/weather_services/service.rb",
68
- "lib/barometer/weather_services/weather_bug.rb",
69
- "lib/barometer/weather_services/weather_dot_com.rb",
70
- "lib/barometer/weather_services/wunderground.rb",
71
- "lib/barometer/weather_services/yahoo.rb",
72
- "lib/barometer/web_services/geocode.rb",
73
- "lib/barometer/web_services/timezone.rb",
74
- "lib/barometer/web_services/weather_id.rb",
75
- "lib/barometer/web_services/web_service.rb",
76
- "lib/demometer/demometer.rb",
77
- "lib/demometer/public/css/master.css",
78
- "lib/demometer/public/css/print.css",
79
- "lib/demometer/public/css/syntax.css",
80
- "lib/demometer/public/images/go.png",
81
- "lib/demometer/public/images/link-out.gif",
82
- "lib/demometer/views/about.erb",
83
- "lib/demometer/views/contributing.erb",
84
- "lib/demometer/views/forecast.erb",
85
- "lib/demometer/views/index.erb",
86
- "lib/demometer/views/layout.erb",
87
- "lib/demometer/views/measurement.erb",
88
- "lib/demometer/views/readme.erb",
89
- "spec/barometer_spec.rb",
90
- "spec/data/distance_spec.rb",
91
- "spec/data/geo_spec.rb",
92
- "spec/data/local_datetime_spec.rb",
93
- "spec/data/local_time_spec.rb",
94
- "spec/data/location_spec.rb",
95
- "spec/data/pressure_spec.rb",
96
- "spec/data/speed_spec.rb",
97
- "spec/data/sun_spec.rb",
98
- "spec/data/temperature_spec.rb",
99
- "spec/data/units_spec.rb",
100
- "spec/data/zone_spec.rb",
101
- "spec/fixtures/formats/weather_id/90210.xml",
102
- "spec/fixtures/formats/weather_id/atlanta.xml",
103
- "spec/fixtures/formats/weather_id/from_USGA0028.xml",
104
- "spec/fixtures/formats/weather_id/ksfo.xml",
105
- "spec/fixtures/formats/weather_id/new_york.xml",
106
- "spec/fixtures/geocode/40_73.json",
107
- "spec/fixtures/geocode/40_73.xml",
108
- "spec/fixtures/geocode/90210.json",
109
- "spec/fixtures/geocode/90210.xml",
110
- "spec/fixtures/geocode/T5B4M9.json",
111
- "spec/fixtures/geocode/T5B4M9.xml",
112
- "spec/fixtures/geocode/atlanta.json",
113
- "spec/fixtures/geocode/atlanta.xml",
114
- "spec/fixtures/geocode/calgary_ab.json",
115
- "spec/fixtures/geocode/calgary_ab.xml",
116
- "spec/fixtures/geocode/ksfo.json",
117
- "spec/fixtures/geocode/ksfo.xml",
118
- "spec/fixtures/geocode/newyork_ny.json",
119
- "spec/fixtures/geocode/newyork_ny.xml",
120
- "spec/fixtures/services/google/calgary_ab.xml",
121
- "spec/fixtures/services/weather_bug/90210_current.xml",
122
- "spec/fixtures/services/weather_bug/90210_forecast.xml",
123
- "spec/fixtures/services/weather_dot_com/90210.xml",
124
- "spec/fixtures/services/wunderground/current_calgary_ab.xml",
125
- "spec/fixtures/services/wunderground/forecast_calgary_ab.xml",
126
- "spec/fixtures/services/yahoo/90210.xml",
127
- "spec/formats/coordinates_spec.rb",
128
- "spec/formats/format_spec.rb",
129
- "spec/formats/geocode_spec.rb",
130
- "spec/formats/icao_spec.rb",
131
- "spec/formats/postalcode_spec.rb",
132
- "spec/formats/short_zipcode_spec.rb",
133
- "spec/formats/weather_id_spec.rb",
134
- "spec/formats/zipcode_spec.rb",
135
- "spec/measurements/measurement_spec.rb",
136
- "spec/measurements/result_array_spec.rb",
137
- "spec/measurements/result_spec.rb",
138
- "spec/query_spec.rb",
139
- "spec/spec_helper.rb",
140
- "spec/weather_services/google_spec.rb",
141
- "spec/weather_services/services_spec.rb",
142
- "spec/weather_services/weather_bug_spec.rb",
143
- "spec/weather_services/weather_dot_com_spec.rb",
144
- "spec/weather_services/wunderground_spec.rb",
145
- "spec/weather_services/yahoo_spec.rb",
146
- "spec/weather_spec.rb",
147
- "spec/web_services/geocode_spec.rb",
148
- "spec/web_services/web_services_spec.rb"
149
- ]
150
16
  s.homepage = %q{http://github.com/attack/barometer}
151
- s.rdoc_options = ["--charset=UTF-8"]
17
+
18
+ s.default_executable = %q{barometer}
19
+
20
+ s.files = `git ls-files`.split("\n")
21
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
22
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
152
23
  s.require_paths = ["lib"]
153
- s.rubygems_version = %q{1.3.5}
154
- s.summary = %q{A multi API consuming weather forecasting superstar.}
155
- s.test_files = [
156
- "spec/barometer_spec.rb",
157
- "spec/data/distance_spec.rb",
158
- "spec/data/geo_spec.rb",
159
- "spec/data/local_datetime_spec.rb",
160
- "spec/data/local_time_spec.rb",
161
- "spec/data/location_spec.rb",
162
- "spec/data/pressure_spec.rb",
163
- "spec/data/speed_spec.rb",
164
- "spec/data/sun_spec.rb",
165
- "spec/data/temperature_spec.rb",
166
- "spec/data/units_spec.rb",
167
- "spec/data/zone_spec.rb",
168
- "spec/formats/coordinates_spec.rb",
169
- "spec/formats/format_spec.rb",
170
- "spec/formats/geocode_spec.rb",
171
- "spec/formats/icao_spec.rb",
172
- "spec/formats/postalcode_spec.rb",
173
- "spec/formats/short_zipcode_spec.rb",
174
- "spec/formats/weather_id_spec.rb",
175
- "spec/formats/zipcode_spec.rb",
176
- "spec/measurements/measurement_spec.rb",
177
- "spec/measurements/result_array_spec.rb",
178
- "spec/measurements/result_spec.rb",
179
- "spec/query_spec.rb",
180
- "spec/spec_helper.rb",
181
- "spec/weather_services/google_spec.rb",
182
- "spec/weather_services/services_spec.rb",
183
- "spec/weather_services/weather_bug_spec.rb",
184
- "spec/weather_services/weather_dot_com_spec.rb",
185
- "spec/weather_services/wunderground_spec.rb",
186
- "spec/weather_services/yahoo_spec.rb",
187
- "spec/weather_spec.rb",
188
- "spec/web_services/geocode_spec.rb",
189
- "spec/web_services/web_services_spec.rb"
190
- ]
191
24
 
192
- if s.respond_to? :specification_version then
193
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
194
- s.specification_version = 3
25
+ s.rdoc_options = ["--charset=UTF-8"]
26
+
27
+ s.add_dependency(%q<httparty>, ">= 0.4.5")
28
+ s.add_dependency(%q<tzinfo>, ">= 0.3.14")
29
+ s.add_dependency("nokogiri")
195
30
 
196
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
197
- s.add_runtime_dependency(%q<httparty>, [">= 0.4.5"])
198
- s.add_runtime_dependency(%q<tzinfo>, [">= 0.3.14"])
199
- else
200
- s.add_dependency(%q<httparty>, [">= 0.4.5"])
201
- s.add_dependency(%q<tzinfo>, [">= 0.3.14"])
202
- end
203
- else
204
- s.add_dependency(%q<httparty>, [">= 0.4.5"])
205
- s.add_dependency(%q<tzinfo>, [">= 0.3.14"])
206
- end
31
+ s.add_development_dependency("rspec", "~> 2.6")
32
+ s.add_development_dependency("mocha")
33
+ s.add_development_dependency("fakeweb")
207
34
  end
208
35
 
data/bin/barometer CHANGED
@@ -51,14 +51,14 @@
51
51
  # http://github.com/attack/barometer
52
52
  #
53
53
  # == Copyright
54
- # Copyright (c) 2009 Mark G. Licensed under the MIT License:
54
+ # Copyright (c) 2009-2010 Mark G. Licensed under the MIT License:
55
55
  # http://www.opensource.org/licenses/mit-license.php
56
56
 
57
57
  require 'rubygems'
58
- require 'barometer'
58
+ #require 'barometer'
59
+ require '/Users/mark/work/fresh/gems/barometer/lib/barometer'
59
60
 
60
- require 'optparse'
61
- #require 'rdoc/usage'
61
+ require 'optparse'
62
62
  require 'ostruct'
63
63
  require 'time'
64
64
  require 'date'
@@ -66,7 +66,7 @@ require 'yaml'
66
66
 
67
67
  # file where API keys are stored
68
68
  KEY_FILE = File.expand_path(File.join('~', '.barometer'))
69
- BAROMETER_VERSION = '0.6.7'
69
+ BAROMETER_VERSION = '0.6.8'
70
70
 
71
71
  class App
72
72
 
@@ -526,6 +526,9 @@ end
526
526
  # set API keys
527
527
  if File.exists?(KEY_FILE)
528
528
  keys = YAML.load_file(KEY_FILE)
529
+ if keys["yahoo"] && keys["yahoo"]["app_id"]
530
+ Barometer.yahoo_placemaker_app_id = keys["yahoo"]["app_id"]
531
+ end
529
532
  if keys["google"] && keys["google"]["geocode"]
530
533
  Barometer.google_geocode_key = keys["google"]["geocode"]
531
534
  else