thundersnow 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -5,9 +5,11 @@ gem 'htmlentities'
5
5
 
6
6
  # Add dependencies to develop your gem here.
7
7
  # Include everything needed to run rake, tests, features, etc.
8
- group :development do
9
- gem "rspec", "~> 2.3.0"
8
+ group :development, :test do
9
+ gem "rspec", "~> 2.6.0"
10
+ gem 'ruby-debug'
10
11
  gem "bundler", "~> 1.0.0"
11
- gem "jeweler", "~> 1.5.2"
12
+ gem "jeweler", "~> 1.6.2"
12
13
  gem "rcov", ">= 0"
14
+ gem "fakeweb", "~> 1.3.0"
13
15
  end
data/Gemfile.lock CHANGED
@@ -1,32 +1,44 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
+ columnize (0.3.3)
4
5
  diff-lcs (1.1.2)
6
+ fakeweb (1.3.0)
5
7
  git (1.2.5)
6
- htmlentities (4.2.4)
7
- jeweler (1.5.2)
8
- bundler (~> 1.0.0)
8
+ htmlentities (4.3.0)
9
+ jeweler (1.6.2)
10
+ bundler (~> 1.0)
9
11
  git (>= 1.2.5)
10
12
  rake
11
- nokogiri (1.4.4)
12
- rake (0.8.7)
13
+ linecache (0.46)
14
+ rbx-require-relative (> 0.0.4)
15
+ nokogiri (1.4.6)
16
+ rake (0.9.2)
17
+ rbx-require-relative (0.0.5)
13
18
  rcov (0.9.9)
14
- rspec (2.3.0)
15
- rspec-core (~> 2.3.0)
16
- rspec-expectations (~> 2.3.0)
17
- rspec-mocks (~> 2.3.0)
18
- rspec-core (2.3.1)
19
- rspec-expectations (2.3.0)
19
+ rspec (2.6.0)
20
+ rspec-core (~> 2.6.0)
21
+ rspec-expectations (~> 2.6.0)
22
+ rspec-mocks (~> 2.6.0)
23
+ rspec-core (2.6.4)
24
+ rspec-expectations (2.6.0)
20
25
  diff-lcs (~> 1.1.2)
21
- rspec-mocks (2.3.0)
26
+ rspec-mocks (2.6.0)
27
+ ruby-debug (0.10.4)
28
+ columnize (>= 0.1)
29
+ ruby-debug-base (~> 0.10.4.0)
30
+ ruby-debug-base (0.10.4)
31
+ linecache (>= 0.3)
22
32
 
23
33
  PLATFORMS
24
34
  ruby
25
35
 
26
36
  DEPENDENCIES
27
37
  bundler (~> 1.0.0)
38
+ fakeweb (~> 1.3.0)
28
39
  htmlentities
29
- jeweler (~> 1.5.2)
40
+ jeweler (~> 1.6.2)
30
41
  nokogiri (~> 1.0)
31
42
  rcov
32
- rspec (~> 2.3.0)
43
+ rspec (~> 2.6.0)
44
+ ruby-debug
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'rubygems'
2
4
  require 'bundler'
3
5
  begin
@@ -20,9 +22,6 @@ Jeweler::Tasks.new do |gem|
20
22
  gem.email = "github@lette.us"
21
23
  gem.authors = ["Peter Brown"]
22
24
  gem.executables = ["thundersnow"]
23
- gem.add_runtime_dependency 'nokogiri', '~> 1.0'
24
- gem.add_runtime_dependency 'htmlentities'
25
- gem.add_development_dependency "rspec", "~> 2.3.0"
26
25
  end
27
26
  Jeweler::RubygemsDotOrgTasks.new
28
27
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.3.0
data/bin/thundersnow CHANGED
@@ -7,6 +7,9 @@ if ARGV.size == 0
7
7
  puts 'Thundersnow Usage:'
8
8
  puts 'Get weather for a zipcode: thundersnow 05401'
9
9
  puts 'Get weather for a city, state: thundersnow "burlington, vt"'
10
+ puts 'Get forecast for a location: thundersnow 05401 --forecast'
10
11
  else
11
- Thundersnow.run ARGV
12
+ thundersnow = Thundersnow::Bin.new ARGV
13
+ output = thundersnow.run
14
+ puts "\e[32m#{output}\e[0m"
12
15
  end
data/lib/thundersnow.rb CHANGED
@@ -1,115 +1,4 @@
1
1
  require 'nokogiri'
2
2
  require 'open-uri'
3
- require 'htmlentities'
4
-
5
- class Thundersnow
6
- class << self
7
- def run(args)
8
- @args = args
9
-
10
- location = args.reject {|a| a =~ /^--/ }[0]
11
-
12
- uri = URI.encode "http://www.google.com/ig/api?weather=#{location}"
13
- @xml = Nokogiri::XML(open(uri))
14
-
15
- # Invalid locations contain problem_cause xml tag
16
- if @xml.xpath('//weather/problem_cause').size > 0
17
- return puts "Could not locate weather for #{location}"
18
- end
19
-
20
- if show_forecast?
21
- show :forecast
22
- else
23
- show :current
24
- end
25
- end
26
-
27
- private
28
-
29
- def show(name)
30
- puts "\e[32m#{send(name)}\e[0m"
31
- end
32
-
33
- def show_forecast?
34
- @args.detect {|a| a == '--forecast' }
35
- end
36
-
37
- def city
38
- @city ||= read_attr(@xml, '//forecast_information/city')
39
- end
40
-
41
- def current
42
- values = ["Current Conditions for #{city}"]
43
- values << condition
44
- values << temperatures
45
- values << wind
46
- values << humidity
47
- values.join("\n")
48
- end
49
-
50
- def condition
51
- read_attr(current_conditions, 'condition')
52
- end
53
-
54
- def temperatures
55
- "#{temp_f} / #{temp_c}"
56
- end
57
-
58
- def wind
59
- read_attr(current_conditions, 'wind_condition')
60
- end
61
-
62
- def humidity
63
- read_attr(current_conditions, 'humidity')
64
- end
65
-
66
- def temp_f
67
- read_attr(current_conditions, 'temp_f').to_s + deg_symbol + "F"
68
- end
69
-
70
- def temp_c
71
- read_attr(current_conditions, 'temp_c').to_s + deg_symbol + 'C'
72
- end
73
-
74
- def deg_symbol
75
- HTMLEntities.new.decode("&deg;")
76
- end
77
-
78
- def current_conditions
79
- @current_conditions ||= @xml.xpath('//current_conditions')
80
- end
81
-
82
- def forecast
83
- values = ["Weather Forecast for #{city}"]
84
-
85
- @xml.xpath('//forecast_conditions').each do |day|
86
- day_of_week = read_attr(day, 'day_of_week')
87
- values << "Forecast for #{readable_day(day_of_week)}"
88
- values << "High: #{read_attr(day, 'high')+deg_symbol}F / Low: #{read_attr(day, 'low')+deg_symbol}F"
89
- values << "Conditions: #{read_attr(day, 'condition')}"
90
- values << "-------------------------"
91
- end
92
-
93
- values.join("\n")
94
- end
95
-
96
- def readable_day(day_of_week)
97
- return "Today" if day_of_week == today
98
- return "Tomorrow" if day_of_week == tomorrow
99
- day_of_week
100
- end
101
-
102
- def today
103
- Time.now.strftime('%a')
104
- end
105
-
106
- def tomorrow
107
- (Time.now + 86400).strftime('%a')
108
- end
109
-
110
- def read_attr(root, node)
111
- root.xpath(node).attribute('data').to_s
112
- end
113
- end
114
-
115
- end
3
+ require 'thundersnow/bin'
4
+ require 'thundersnow/weather'
@@ -0,0 +1,35 @@
1
+ module Thundersnow
2
+ class Bin
3
+
4
+ def initialize(args)
5
+ @args = args
6
+ end
7
+
8
+ def run
9
+ @weather = Weather.new(location)
10
+
11
+ return "Could not locate weather for #{location}" unless @weather.valid?
12
+
13
+ if show_forecast?
14
+ show :forecast
15
+ else
16
+ show :current
17
+ end
18
+ end
19
+
20
+ private
21
+
22
+ def location
23
+ @args.reject {|a| a =~ /^--/ }[0]
24
+ end
25
+
26
+ def show(name)
27
+ @weather.send(name)
28
+ end
29
+
30
+ def show_forecast?
31
+ @args.include? '--forecast'
32
+ end
33
+
34
+ end
35
+ end
@@ -0,0 +1,100 @@
1
+ require 'htmlentities'
2
+
3
+ module Thundersnow
4
+ class Weather
5
+
6
+ def initialize(location)
7
+ @xml = get_weather_xml(location)
8
+ end
9
+
10
+ def get_weather_xml(location)
11
+ uri = URI.encode "http://www.google.com/ig/api?weather=#{location}"
12
+ Nokogiri::XML(open(uri))
13
+ end
14
+
15
+ # Invalid locations contain problem_cause xml tag
16
+ def valid?
17
+ @xml.xpath('//weather/problem_cause').size == 0
18
+ end
19
+
20
+ def current
21
+ values = ["Current Conditions for #{city}"]
22
+ values << condition
23
+ values << temperatures
24
+ values << wind
25
+ values << humidity
26
+ values.join("\n")
27
+ end
28
+
29
+ def forecast
30
+ values = ["Weather Forecast for #{city}"]
31
+
32
+ @xml.xpath('//forecast_conditions').each do |day|
33
+ values << "Forecast for #{day_of_week(day)}"
34
+ values << "High: #{read_attr(day, 'high')+deg_symbol}F / Low: #{read_attr(day, 'low')+deg_symbol}F"
35
+ values << "Conditions: #{read_attr(day, 'condition')}"
36
+ values << "-------------------------"
37
+ end
38
+
39
+ values.join("\n")
40
+ end
41
+
42
+ def city
43
+ @city ||= read_attr(@xml, '//forecast_information/city')
44
+ end
45
+
46
+ def day_of_week(day)
47
+ day_of_week = read_attr(day, 'day_of_week')
48
+ return "Today" if day_of_week == today
49
+ return "Tomorrow" if day_of_week == tomorrow
50
+ day_of_week
51
+ end
52
+
53
+ def condition
54
+ read_attr(current_conditions, 'condition')
55
+ end
56
+
57
+ def temperatures
58
+ "#{temp_f} #{deg_symbol}F / #{temp_c} #{deg_symbol}C"
59
+ end
60
+
61
+ def wind
62
+ read_attr(current_conditions, 'wind_condition')
63
+ end
64
+
65
+ def humidity
66
+ read_attr(current_conditions, 'humidity')
67
+ end
68
+
69
+ def temp_f
70
+ read_attr(current_conditions, 'temp_f')
71
+ end
72
+
73
+ def temp_c
74
+ read_attr(current_conditions, 'temp_c')
75
+ end
76
+
77
+ def current_conditions
78
+ @current_conditions ||= @xml.xpath('//current_conditions')
79
+ end
80
+
81
+ private
82
+
83
+ def read_attr(root, node)
84
+ root.xpath(node).attribute('data').to_s
85
+ end
86
+
87
+ def today
88
+ Time.now.strftime('%a')
89
+ end
90
+
91
+ def tomorrow
92
+ (Time.now + 86400).strftime('%a')
93
+ end
94
+
95
+ def deg_symbol
96
+ HTMLEntities.new.decode("&deg;")
97
+ end
98
+
99
+ end
100
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,33 +1,10 @@
1
1
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
2
  $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+
3
4
  require 'rspec'
4
5
  require 'thundersnow'
6
+ require 'fakeweb'
5
7
 
6
8
  # Requires supporting files with custom matchers and macros, etc,
7
9
  # in ./support/ and its subdirectories.
8
10
  Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
9
-
10
- RSpec.configure do |config|
11
-
12
- end
13
-
14
- ZIP = "05401"
15
-
16
- XML = '<?xml version="1.0"?>
17
- <xml_api_reply version="1"><weather module_id="0" tab_id="0" mobile_row="0" mobile_zipped="1" row="0" section="0" >
18
- <forecast_information><city data="Burlington, VT"/><postal_code data="05401"/><latitude_e6 data=""/><longitude_e6 data=""/><forecast_date data="2011-02-07"/>
19
- <current_date_time data="2011-02-08 03:19:38 +0000"/><unit_system data="US"/></forecast_information><current_conditions>
20
- <condition data="Snow Showers"/><temp_f data="34"/><temp_c data="1"/><humidity data="Humidity: 87%"/><icon data="/ig/images/weather/snow.gif"/>
21
- <wind_condition data="Wind: S at 6 mph"/></current_conditions><forecast_conditions><day_of_week data="Mon"/><low data="20"/><high data="35"/>
22
- <icon data="/ig/images/weather/snow.gif"/><condition data="Snow"/></forecast_conditions><forecast_conditions><day_of_week data="Tue"/><low data="4"/>
23
- <high data="22"/><icon data="/ig/images/weather/snow.gif"/><condition data="Snow"/></forecast_conditions><forecast_conditions><day_of_week data="Wed"/>
24
- <low data="5"/><high data="22"/><icon data="/ig/images/weather/snow.gif"/><condition data="Snow Showers"/></forecast_conditions><forecast_conditions>
25
- <day_of_week data="Thu"/><low data="5"/><high data="18"/><icon data="/ig/images/weather/partly_cloudy.gif"/><condition data="Partly Cloudy"/>
26
- </forecast_conditions></weather></xml_api_reply>'
27
-
28
-
29
- BAD_XML = '<?xml version="1.0"?>
30
- <xml_api_reply version="1">
31
- <weather module_id="0" tab_id="0" mobile_row="0" mobile_zipped="1" row="0" section="0" >
32
- <problem_cause data=""/>
33
- </weather></xml_api_reply>'
@@ -0,0 +1 @@
1
+ <?xml version="1.0"?><xml_api_reply version="1"><weather module_id="0" tab_id="0" mobile_row="0" mobile_zipped="1" row="0" section="0" ><problem_cause data=""/></weather></xml_api_reply>
@@ -0,0 +1,2 @@
1
+ <?xml version="1.0"?><xml_api_reply version="1"><weather module_id="0" tab_id="0" mobile_row="0" mobile_zipped="1" row="0" section="0" ><forecast_information><city data="Burlington, VT"/><postal_code data="05408"/><latitude_e6 data=""/><longitude_e6 data=""/><forecast_date data="2011-06-25"/><current_date_time data="2011-06-25 23:15:01 +0000"/><unit_system data="US"/></forecast_information><current_conditions><condition data="Mostly Cloudy"/><temp_f data="68"/><temp_c data="20"/><humidity data="Humidity: 87%"/><icon data="/ig/images/weather/mostly_cloudy.gif"/><wind_condition data="Wind: NE at 3 mph"/></current_conditions><forecast_conditions><day_of_week data="Sat"/><low data="58"/><high data="73"/><icon data="/ig/images/weather/rain.gif"/><condition data="Showers"/></forecast_conditions><forecast_conditions><day_of_week data="Sun"/><low data="57"/><high data="75"/><icon data="/ig/images/weather/rain.gif"/><condition data="Showers"/></forecast_conditions><forecast_conditions><day_of_week data="Mon"/><low data="63"/><high data="82"/><icon data="/ig/images/weather/partly_cloudy.gif"/><condition data="Partly Cloudy"/></forecast_conditions><forecast_conditions><day_of_week data="Tue"/><low data="66"/><high data="83"/><icon data="/ig/images/weather/chance_of_storm.gif"/><condition data="Isolated Thunderstorms"/></forecast_conditions></weather></xml_api_reply>
2
+
@@ -0,0 +1,49 @@
1
+ require './spec/spec_helper'
2
+
3
+ describe 'Bin' do
4
+
5
+ context 'valid response' do
6
+ before do
7
+ weather = mock(:weather, :valid? => true)
8
+ Thundersnow::Weather.stub(:new).and_return(weather)
9
+ end
10
+
11
+ context 'w/out --forecast option' do
12
+ before do
13
+ args = ['05408']
14
+ @thundersnow = Thundersnow::Bin.new(args)
15
+ end
16
+
17
+ it 'should show the current conditions' do
18
+ @thundersnow.should_receive(:show).with(:current)
19
+ @thundersnow.run
20
+ end
21
+ end
22
+
23
+ context 'with --forecast' do
24
+ before do
25
+ args = ['05408', '--forecast']
26
+ @thundersnow = Thundersnow::Bin.new(args)
27
+ end
28
+
29
+ it 'should show the forecast conditions' do
30
+ @thundersnow.should_receive(:show).with(:forecast)
31
+ @thundersnow.run
32
+ end
33
+ end
34
+ end
35
+
36
+ context 'invalid response' do
37
+ before do
38
+ weather = mock(:weather, :valid? => false)
39
+ Thundersnow::Weather.stub(:new).and_return(weather)
40
+ args = ['05408']
41
+ @thundersnow = Thundersnow::Bin.new(args)
42
+ end
43
+
44
+ it 'should return without displaying the weather' do
45
+ @thundersnow.should_not_receive(:show)
46
+ @thundersnow.run
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,35 @@
1
+ require './spec/spec_helper'
2
+
3
+ describe 'Weather' do
4
+ context 'with a bad response' do
5
+ before do
6
+ xml = File.read('./spec/support/bad_response.xml')
7
+ FakeWeb.register_uri(:get, %r|http://www\.google\.com/|, :body => xml)
8
+ @weather = Thundersnow::Weather.new('05408')
9
+ end
10
+
11
+ it 'should not be valid' do
12
+ @weather.should_not be_valid
13
+ end
14
+ end
15
+
16
+ context 'with a good response' do
17
+ before do
18
+ xml = File.read('./spec/support/ok_response.xml')
19
+ FakeWeb.register_uri(:get, %r|http://www\.google\.com/|, :body => xml)
20
+ @weather = Thundersnow::Weather.new('05408')
21
+ end
22
+
23
+ subject { @weather }
24
+ it { should be_valid }
25
+ its(:city) { should eql('Burlington, VT') }
26
+ its(:condition) { should eql('Mostly Cloudy') }
27
+ its(:temp_f) { should eql('68') }
28
+ its(:temp_c) { should eql('20') }
29
+ its(:wind) { should eql('Wind: NE at 3 mph') }
30
+ its(:humidity) { should eql('Humidity: 87%') }
31
+ its(:current) { should_not be_empty }
32
+ its(:forecast) { should_not be_empty }
33
+ end
34
+
35
+ end
data/thundersnow.gemspec CHANGED
@@ -5,15 +5,14 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{thundersnow}
8
- s.version = "0.2.0"
8
+ s.version = "0.3.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Peter Brown"]
12
- s.date = %q{2011-03-06}
13
- s.default_executable = %q{thundersnow}
11
+ s.authors = [%q{Peter Brown}]
12
+ s.date = %q{2011-06-26}
14
13
  s.description = %q{Check the weather without leaving your terminal. Uses Google's weather API to provide current conditions and forecast weather information.}
15
14
  s.email = %q{github@lette.us}
16
- s.executables = ["thundersnow"]
15
+ s.executables = [%q{thundersnow}]
17
16
  s.extra_rdoc_files = [
18
17
  "LICENSE.txt",
19
18
  "README.textile"
@@ -29,19 +28,20 @@ Gem::Specification.new do |s|
29
28
  "VERSION",
30
29
  "bin/thundersnow",
31
30
  "lib/thundersnow.rb",
31
+ "lib/thundersnow/bin.rb",
32
+ "lib/thundersnow/weather.rb",
32
33
  "spec/spec_helper.rb",
33
- "spec/thundersnow_spec.rb",
34
+ "spec/support/bad_response.xml",
35
+ "spec/support/ok_response.xml",
36
+ "spec/thundersnow/bin_spec.rb",
37
+ "spec/thundersnow/weather_spec.rb",
34
38
  "thundersnow.gemspec"
35
39
  ]
36
40
  s.homepage = %q{http://github.com/beerlington/thundersnow}
37
- s.licenses = ["MIT"]
38
- s.require_paths = ["lib"]
39
- s.rubygems_version = %q{1.6.1}
41
+ s.licenses = [%q{MIT}]
42
+ s.require_paths = [%q{lib}]
43
+ s.rubygems_version = %q{1.8.5}
40
44
  s.summary = %q{Ruby based command-line utility for viewing the weather}
41
- s.test_files = [
42
- "spec/spec_helper.rb",
43
- "spec/thundersnow_spec.rb"
44
- ]
45
45
 
46
46
  if s.respond_to? :specification_version then
47
47
  s.specification_version = 3
@@ -49,34 +49,31 @@ Gem::Specification.new do |s|
49
49
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
50
50
  s.add_runtime_dependency(%q<nokogiri>, ["~> 1.0"])
51
51
  s.add_runtime_dependency(%q<htmlentities>, [">= 0"])
52
- s.add_development_dependency(%q<rspec>, ["~> 2.3.0"])
52
+ s.add_development_dependency(%q<rspec>, ["~> 2.6.0"])
53
+ s.add_development_dependency(%q<ruby-debug>, [">= 0"])
53
54
  s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
54
- s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
55
+ s.add_development_dependency(%q<jeweler>, ["~> 1.6.2"])
55
56
  s.add_development_dependency(%q<rcov>, [">= 0"])
56
- s.add_runtime_dependency(%q<nokogiri>, ["~> 1.0"])
57
- s.add_runtime_dependency(%q<htmlentities>, [">= 0"])
58
- s.add_development_dependency(%q<rspec>, ["~> 2.3.0"])
57
+ s.add_development_dependency(%q<fakeweb>, ["~> 1.3.0"])
59
58
  else
60
59
  s.add_dependency(%q<nokogiri>, ["~> 1.0"])
61
60
  s.add_dependency(%q<htmlentities>, [">= 0"])
62
- s.add_dependency(%q<rspec>, ["~> 2.3.0"])
61
+ s.add_dependency(%q<rspec>, ["~> 2.6.0"])
62
+ s.add_dependency(%q<ruby-debug>, [">= 0"])
63
63
  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
64
- s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
64
+ s.add_dependency(%q<jeweler>, ["~> 1.6.2"])
65
65
  s.add_dependency(%q<rcov>, [">= 0"])
66
- s.add_dependency(%q<nokogiri>, ["~> 1.0"])
67
- s.add_dependency(%q<htmlentities>, [">= 0"])
68
- s.add_dependency(%q<rspec>, ["~> 2.3.0"])
66
+ s.add_dependency(%q<fakeweb>, ["~> 1.3.0"])
69
67
  end
70
68
  else
71
69
  s.add_dependency(%q<nokogiri>, ["~> 1.0"])
72
70
  s.add_dependency(%q<htmlentities>, [">= 0"])
73
- s.add_dependency(%q<rspec>, ["~> 2.3.0"])
71
+ s.add_dependency(%q<rspec>, ["~> 2.6.0"])
72
+ s.add_dependency(%q<ruby-debug>, [">= 0"])
74
73
  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
75
- s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
74
+ s.add_dependency(%q<jeweler>, ["~> 1.6.2"])
76
75
  s.add_dependency(%q<rcov>, [">= 0"])
77
- s.add_dependency(%q<nokogiri>, ["~> 1.0"])
78
- s.add_dependency(%q<htmlentities>, [">= 0"])
79
- s.add_dependency(%q<rspec>, ["~> 2.3.0"])
76
+ s.add_dependency(%q<fakeweb>, ["~> 1.3.0"])
80
77
  end
81
78
  end
82
79
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thundersnow
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 2
8
+ - 3
9
9
  - 0
10
- version: 0.2.0
10
+ version: 0.3.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Peter Brown
@@ -15,12 +15,10 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-03-06 00:00:00 -05:00
19
- default_executable: thundersnow
18
+ date: 2011-06-26 00:00:00 Z
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
22
- type: :runtime
23
- requirement: &id001 !ruby/object:Gem::Requirement
21
+ version_requirements: &id001 !ruby/object:Gem::Requirement
24
22
  none: false
25
23
  requirements:
26
24
  - - ~>
@@ -30,12 +28,12 @@ dependencies:
30
28
  - 1
31
29
  - 0
32
30
  version: "1.0"
33
- version_requirements: *id001
34
- name: nokogiri
31
+ type: :runtime
32
+ requirement: *id001
35
33
  prerelease: false
34
+ name: nokogiri
36
35
  - !ruby/object:Gem::Dependency
37
- type: :runtime
38
- requirement: &id002 !ruby/object:Gem::Requirement
36
+ version_requirements: &id002 !ruby/object:Gem::Requirement
39
37
  none: false
40
38
  requirements:
41
39
  - - ">="
@@ -44,89 +42,74 @@ dependencies:
44
42
  segments:
45
43
  - 0
46
44
  version: "0"
47
- version_requirements: *id002
48
- name: htmlentities
45
+ type: :runtime
46
+ requirement: *id002
49
47
  prerelease: false
48
+ name: htmlentities
50
49
  - !ruby/object:Gem::Dependency
51
- type: :development
52
- requirement: &id003 !ruby/object:Gem::Requirement
50
+ version_requirements: &id003 !ruby/object:Gem::Requirement
53
51
  none: false
54
52
  requirements:
55
53
  - - ~>
56
54
  - !ruby/object:Gem::Version
57
- hash: 3
55
+ hash: 23
58
56
  segments:
59
57
  - 2
60
- - 3
58
+ - 6
61
59
  - 0
62
- version: 2.3.0
63
- version_requirements: *id003
64
- name: rspec
60
+ version: 2.6.0
61
+ type: :development
62
+ requirement: *id003
65
63
  prerelease: false
64
+ name: rspec
66
65
  - !ruby/object:Gem::Dependency
67
- type: :development
68
- requirement: &id004 !ruby/object:Gem::Requirement
66
+ version_requirements: &id004 !ruby/object:Gem::Requirement
69
67
  none: false
70
68
  requirements:
71
- - - ~>
69
+ - - ">="
72
70
  - !ruby/object:Gem::Version
73
- hash: 23
71
+ hash: 3
74
72
  segments:
75
- - 1
76
73
  - 0
77
- - 0
78
- version: 1.0.0
79
- version_requirements: *id004
80
- name: bundler
74
+ version: "0"
75
+ type: :development
76
+ requirement: *id004
81
77
  prerelease: false
78
+ name: ruby-debug
82
79
  - !ruby/object:Gem::Dependency
83
- type: :development
84
- requirement: &id005 !ruby/object:Gem::Requirement
80
+ version_requirements: &id005 !ruby/object:Gem::Requirement
85
81
  none: false
86
82
  requirements:
87
83
  - - ~>
88
84
  - !ruby/object:Gem::Version
89
- hash: 7
85
+ hash: 23
90
86
  segments:
91
87
  - 1
92
- - 5
93
- - 2
94
- version: 1.5.2
95
- version_requirements: *id005
96
- name: jeweler
97
- prerelease: false
98
- - !ruby/object:Gem::Dependency
99
- type: :development
100
- requirement: &id006 !ruby/object:Gem::Requirement
101
- none: false
102
- requirements:
103
- - - ">="
104
- - !ruby/object:Gem::Version
105
- hash: 3
106
- segments:
107
88
  - 0
108
- version: "0"
109
- version_requirements: *id006
110
- name: rcov
89
+ - 0
90
+ version: 1.0.0
91
+ type: :development
92
+ requirement: *id005
111
93
  prerelease: false
94
+ name: bundler
112
95
  - !ruby/object:Gem::Dependency
113
- type: :runtime
114
- requirement: &id007 !ruby/object:Gem::Requirement
96
+ version_requirements: &id006 !ruby/object:Gem::Requirement
115
97
  none: false
116
98
  requirements:
117
99
  - - ~>
118
100
  - !ruby/object:Gem::Version
119
- hash: 15
101
+ hash: 11
120
102
  segments:
121
103
  - 1
122
- - 0
123
- version: "1.0"
124
- version_requirements: *id007
125
- name: nokogiri
104
+ - 6
105
+ - 2
106
+ version: 1.6.2
107
+ type: :development
108
+ requirement: *id006
126
109
  prerelease: false
110
+ name: jeweler
127
111
  - !ruby/object:Gem::Dependency
128
- type: :runtime
129
- requirement: &id008 !ruby/object:Gem::Requirement
112
+ version_requirements: &id007 !ruby/object:Gem::Requirement
130
113
  none: false
131
114
  requirements:
132
115
  - - ">="
@@ -135,25 +118,26 @@ dependencies:
135
118
  segments:
136
119
  - 0
137
120
  version: "0"
138
- version_requirements: *id008
139
- name: htmlentities
121
+ type: :development
122
+ requirement: *id007
140
123
  prerelease: false
124
+ name: rcov
141
125
  - !ruby/object:Gem::Dependency
142
- type: :development
143
- requirement: &id009 !ruby/object:Gem::Requirement
126
+ version_requirements: &id008 !ruby/object:Gem::Requirement
144
127
  none: false
145
128
  requirements:
146
129
  - - ~>
147
130
  - !ruby/object:Gem::Version
148
- hash: 3
131
+ hash: 27
149
132
  segments:
150
- - 2
133
+ - 1
151
134
  - 3
152
135
  - 0
153
- version: 2.3.0
154
- version_requirements: *id009
155
- name: rspec
136
+ version: 1.3.0
137
+ type: :development
138
+ requirement: *id008
156
139
  prerelease: false
140
+ name: fakeweb
157
141
  description: Check the weather without leaving your terminal. Uses Google's weather API to provide current conditions and forecast weather information.
158
142
  email: github@lette.us
159
143
  executables:
@@ -174,10 +158,14 @@ files:
174
158
  - VERSION
175
159
  - bin/thundersnow
176
160
  - lib/thundersnow.rb
161
+ - lib/thundersnow/bin.rb
162
+ - lib/thundersnow/weather.rb
177
163
  - spec/spec_helper.rb
178
- - spec/thundersnow_spec.rb
164
+ - spec/support/bad_response.xml
165
+ - spec/support/ok_response.xml
166
+ - spec/thundersnow/bin_spec.rb
167
+ - spec/thundersnow/weather_spec.rb
179
168
  - thundersnow.gemspec
180
- has_rdoc: true
181
169
  homepage: http://github.com/beerlington/thundersnow
182
170
  licenses:
183
171
  - MIT
@@ -207,10 +195,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
207
195
  requirements: []
208
196
 
209
197
  rubyforge_project:
210
- rubygems_version: 1.6.1
198
+ rubygems_version: 1.8.5
211
199
  signing_key:
212
200
  specification_version: 3
213
201
  summary: Ruby based command-line utility for viewing the weather
214
- test_files:
215
- - spec/spec_helper.rb
216
- - spec/thundersnow_spec.rb
202
+ test_files: []
203
+
@@ -1,80 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
-
3
- describe Thundersnow do
4
- before do
5
- Thundersnow.stub(:open).and_return(XML)
6
- Thundersnow.stub(:show).and_return(true)
7
- end
8
-
9
- context "for current conditions" do
10
- before do
11
- @args = [ZIP]
12
- end
13
-
14
- context "when running" do
15
-
16
- it "should set the @xml instance variable" do
17
- Thundersnow.run @args
18
- Thundersnow.instance_variable_get('@xml').to_s.should == Nokogiri::XML(XML).to_s
19
- end
20
-
21
- it "should show the current conditions" do
22
- Thundersnow.should_receive(:show).with(:current).once
23
- Thundersnow.run @args
24
- end
25
-
26
- it "should not show the forecast conditions" do
27
- Thundersnow.should_not_receive(:show).with(:forecast)
28
- Thundersnow.run @args
29
- end
30
- end
31
- end
32
-
33
- context "for forecast conditions" do
34
- before do
35
- @args = [ZIP, '--forecast']
36
- end
37
-
38
- context "when running" do
39
-
40
- it "should set the @xml instance variable" do
41
- Thundersnow.run @args
42
- Thundersnow.instance_variable_get('@xml').to_s.should == Nokogiri::XML(XML).to_s
43
- end
44
-
45
- it "should show the forecast conditions" do
46
- Thundersnow.should_receive(:show).with(:forecast).once
47
- Thundersnow.run @args
48
- end
49
-
50
- it "should not show the current conditions" do
51
- Thundersnow.should_not_receive(:show).with(:current)
52
- Thundersnow.run @args
53
- end
54
- end
55
- end
56
-
57
- context "w/ invalid location" do
58
- before do
59
- Thundersnow.stub(:open).and_return(BAD_XML)
60
- end
61
-
62
- context "when running" do
63
- before do
64
- Thundersnow.stub(:show).and_return(true)
65
- @args = [ZIP]
66
- end
67
-
68
- it "should set the @xml instance variable" do
69
- Thundersnow.run @args
70
- Thundersnow.instance_variable_get('@xml').to_s.should == Nokogiri::XML(BAD_XML).to_s
71
- end
72
-
73
- it "should return and not show anything" do
74
- Thundersnow.should_not_receive(:show)
75
- Thundersnow.run @args
76
- end
77
- end
78
- end
79
-
80
- end