barometer 0.6.1 → 0.6.2
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 +1 -1
- data/VERSION.yml +1 -1
- data/bin/barometer +4 -12
- data/lib/barometer/data.rb +2 -5
- data/lib/barometer/data/local_datetime.rb +2 -2
- data/lib/barometer/measurements/measurement.rb +6 -6
- data/lib/barometer/measurements/result.rb +207 -0
- data/lib/barometer/measurements/{forecast_array.rb → result_array.rb} +16 -13
- data/lib/barometer/translations/weather_country_codes.yml +3 -3
- data/lib/barometer/weather_services/google.rb +3 -3
- data/lib/barometer/weather_services/weather_bug.rb +3 -3
- data/lib/barometer/weather_services/weather_dot_com.rb +65 -38
- data/lib/barometer/weather_services/wunderground.rb +3 -3
- data/lib/barometer/weather_services/yahoo.rb +3 -3
- data/lib/demometer/demometer.rb +2 -2
- data/lib/demometer/public/css/master.css +4 -75
- data/lib/demometer/public/css/print.css +1 -2
- data/lib/demometer/public/css/syntax.css +1 -2
- data/lib/demometer/views/about.erb +1 -1
- data/lib/demometer/views/contributing.erb +4 -4
- data/lib/demometer/views/index.erb +8 -9
- data/lib/demometer/views/layout.erb +1 -2
- data/spec/measurements/measurement_spec.rb +29 -53
- data/spec/measurements/{forecast_array_spec.rb → result_array_spec.rb} +8 -8
- data/spec/measurements/result_spec.rb +660 -0
- data/spec/spec_helper.rb +1 -0
- data/spec/weather_services/google_spec.rb +4 -4
- data/spec/weather_services/services_spec.rb +1 -1
- data/spec/weather_services/weather_bug_spec.rb +3 -3
- data/spec/weather_services/weather_dot_com_spec.rb +19 -22
- data/spec/weather_services/wunderground_spec.rb +2 -2
- data/spec/weather_services/yahoo_spec.rb +2 -2
- data/spec/weather_spec.rb +14 -39
- metadata +6 -12
- data/lib/barometer/measurements/common.rb +0 -113
- data/lib/barometer/measurements/current.rb +0 -76
- data/lib/barometer/measurements/forecast.rb +0 -62
- data/lib/barometer/measurements/night.rb +0 -27
- data/spec/measurements/common_spec.rb +0 -352
- data/spec/measurements/current_spec.rb +0 -186
- data/spec/measurements/forecast_spec.rb +0 -135
- data/spec/measurements/night_measurement_spec.rb +0 -49
@@ -1,186 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe "Current Measurement" do
|
4
|
-
|
5
|
-
describe "when initialized" do
|
6
|
-
|
7
|
-
before(:each) do
|
8
|
-
@current = Measurement::Current.new
|
9
|
-
end
|
10
|
-
|
11
|
-
it "responds to temperature" do
|
12
|
-
@current.temperature.should be_nil
|
13
|
-
end
|
14
|
-
|
15
|
-
it "responds to dew_point" do
|
16
|
-
@current.dew_point.should be_nil
|
17
|
-
end
|
18
|
-
|
19
|
-
it "responds to heat_index" do
|
20
|
-
@current.heat_index.should be_nil
|
21
|
-
end
|
22
|
-
|
23
|
-
it "responds to wind_chill" do
|
24
|
-
@current.wind_chill.should be_nil
|
25
|
-
end
|
26
|
-
|
27
|
-
it "responds to pressure" do
|
28
|
-
@current.pressure.should be_nil
|
29
|
-
end
|
30
|
-
|
31
|
-
it "responds to visibility" do
|
32
|
-
@current.pressure.should be_nil
|
33
|
-
end
|
34
|
-
|
35
|
-
it "responds to current_at" do
|
36
|
-
@current.current_at.should be_nil
|
37
|
-
end
|
38
|
-
|
39
|
-
it "responds to updated_at" do
|
40
|
-
@current.updated_at.should be_nil
|
41
|
-
end
|
42
|
-
|
43
|
-
end
|
44
|
-
|
45
|
-
describe "when writing data" do
|
46
|
-
|
47
|
-
before(:each) do
|
48
|
-
@current = Measurement::Current.new
|
49
|
-
end
|
50
|
-
|
51
|
-
it "only accepts Data::Temperature for temperature" do
|
52
|
-
invalid_data = 1
|
53
|
-
invalid_data.class.should_not == Data::Temperature
|
54
|
-
lambda { @current.temperature = invalid_data }.should raise_error(ArgumentError)
|
55
|
-
|
56
|
-
valid_data = Data::Temperature.new
|
57
|
-
valid_data.class.should == Data::Temperature
|
58
|
-
lambda { @current.temperature = valid_data }.should_not raise_error(ArgumentError)
|
59
|
-
end
|
60
|
-
|
61
|
-
it "only accepts Data::Temperature for dew_point" do
|
62
|
-
invalid_data = 1
|
63
|
-
invalid_data.class.should_not == Data::Temperature
|
64
|
-
lambda { @current.dew_point = invalid_data }.should raise_error(ArgumentError)
|
65
|
-
|
66
|
-
valid_data = Data::Temperature.new
|
67
|
-
valid_data.class.should == Data::Temperature
|
68
|
-
lambda { @current.dew_point = valid_data }.should_not raise_error(ArgumentError)
|
69
|
-
end
|
70
|
-
|
71
|
-
it "only accepts Data::Temperature for heat_index" do
|
72
|
-
invalid_data = 1
|
73
|
-
invalid_data.class.should_not == Data::Temperature
|
74
|
-
lambda { @current.heat_index = invalid_data }.should raise_error(ArgumentError)
|
75
|
-
|
76
|
-
valid_data = Data::Temperature.new
|
77
|
-
valid_data.class.should == Data::Temperature
|
78
|
-
lambda { @current.heat_index = valid_data }.should_not raise_error(ArgumentError)
|
79
|
-
end
|
80
|
-
|
81
|
-
it "only accepts Data::Temperature for wind_chill" do
|
82
|
-
invalid_data = 1
|
83
|
-
invalid_data.class.should_not == Data::Temperature
|
84
|
-
lambda { @current.wind_chill = invalid_data }.should raise_error(ArgumentError)
|
85
|
-
|
86
|
-
valid_data = Data::Temperature.new
|
87
|
-
valid_data.class.should == Data::Temperature
|
88
|
-
lambda { @current.wind_chill = valid_data }.should_not raise_error(ArgumentError)
|
89
|
-
end
|
90
|
-
|
91
|
-
it "only accepts Data::Pressure for pressure" do
|
92
|
-
invalid_data = 1
|
93
|
-
invalid_data.class.should_not == Data::Pressure
|
94
|
-
lambda { @current.pressure = invalid_data }.should raise_error(ArgumentError)
|
95
|
-
|
96
|
-
valid_data = Data::Pressure.new
|
97
|
-
valid_data.class.should == Data::Pressure
|
98
|
-
lambda { @current.pressure = valid_data }.should_not raise_error(ArgumentError)
|
99
|
-
end
|
100
|
-
|
101
|
-
it "only accepts Data::Distance for visibility" do
|
102
|
-
invalid_data = 1
|
103
|
-
invalid_data.class.should_not == Data::Distance
|
104
|
-
lambda { @current.visibility = invalid_data }.should raise_error(ArgumentError)
|
105
|
-
|
106
|
-
valid_data = Data::Distance.new
|
107
|
-
valid_data.class.should == Data::Distance
|
108
|
-
lambda { @current.visibility = valid_data }.should_not raise_error(ArgumentError)
|
109
|
-
end
|
110
|
-
|
111
|
-
it "only accepts Data::LocalTime || Data::LocalDateTime current_at" do
|
112
|
-
invalid_data = 1
|
113
|
-
invalid_data.class.should_not == Data::LocalTime
|
114
|
-
invalid_data.class.should_not == Data::LocalDateTime
|
115
|
-
lambda { @current.current_at = invalid_data }.should raise_error(ArgumentError)
|
116
|
-
|
117
|
-
valid_data = Data::LocalTime.new
|
118
|
-
valid_data.class.should == Data::LocalTime
|
119
|
-
lambda { @current.current_at = valid_data }.should_not raise_error(ArgumentError)
|
120
|
-
|
121
|
-
valid_data = Data::LocalDateTime.new(2009,1,1)
|
122
|
-
valid_data.class.should == Data::LocalDateTime
|
123
|
-
lambda { @current.current_at = valid_data }.should_not raise_error(ArgumentError)
|
124
|
-
end
|
125
|
-
|
126
|
-
it "only accepts Data::LocalTime || Data::LocalDateTime current_at" do
|
127
|
-
invalid_data = 1
|
128
|
-
invalid_data.class.should_not == Data::LocalTime
|
129
|
-
invalid_data.class.should_not == Data::LocalDateTime
|
130
|
-
lambda { @current.updated_at = invalid_data }.should raise_error(ArgumentError)
|
131
|
-
|
132
|
-
valid_data = Data::LocalTime.new
|
133
|
-
valid_data.class.should == Data::LocalTime
|
134
|
-
lambda { @current.updated_at = valid_data }.should_not raise_error(ArgumentError)
|
135
|
-
|
136
|
-
valid_data = Data::LocalDateTime.new(2009,1,1)
|
137
|
-
valid_data.class.should == Data::LocalDateTime
|
138
|
-
lambda { @current.updated_at = valid_data }.should_not raise_error(ArgumentError)
|
139
|
-
end
|
140
|
-
|
141
|
-
end
|
142
|
-
|
143
|
-
describe "answer simple questions, like" do
|
144
|
-
|
145
|
-
before(:each) do
|
146
|
-
@current = Measurement::Current.new
|
147
|
-
@current.temperature = Data::Temperature.new
|
148
|
-
@current.temperature << 5
|
149
|
-
@dew_point = Data::Temperature.new
|
150
|
-
@dew_point << 10
|
151
|
-
end
|
152
|
-
|
153
|
-
describe "wet?" do
|
154
|
-
|
155
|
-
describe "wet_by_dewpoint?" do
|
156
|
-
|
157
|
-
it "returns nil when no dewpoint" do
|
158
|
-
@current.dew_point?.should be_false
|
159
|
-
@current.send("_wet_by_dewpoint?").should be_nil
|
160
|
-
@current.wet?.should be_nil
|
161
|
-
@current.dew_point = @dew_point
|
162
|
-
@current.dew_point?.should be_true
|
163
|
-
@current.send("_wet_by_dewpoint?").should_not be_nil
|
164
|
-
@current.wet?.should_not be_nil
|
165
|
-
end
|
166
|
-
|
167
|
-
it "return true when current dewpoint over temperature" do
|
168
|
-
@current.dew_point = @dew_point
|
169
|
-
@current.send("_wet_by_dewpoint?").should be_true
|
170
|
-
@current.wet?.should be_true
|
171
|
-
end
|
172
|
-
|
173
|
-
it "return false when current dewpoint under temperature" do
|
174
|
-
@current.temperature << 15
|
175
|
-
@current.dew_point = @dew_point
|
176
|
-
@current.send("_wet_by_dewpoint?").should be_false
|
177
|
-
@current.wet?.should be_false
|
178
|
-
end
|
179
|
-
|
180
|
-
end
|
181
|
-
|
182
|
-
end
|
183
|
-
|
184
|
-
end
|
185
|
-
|
186
|
-
end
|
@@ -1,135 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe "Forecast Measurement" do
|
4
|
-
|
5
|
-
describe "when initialized" do
|
6
|
-
|
7
|
-
before(:each) do
|
8
|
-
@forecast = Measurement::Forecast.new
|
9
|
-
end
|
10
|
-
|
11
|
-
it "responds to date" do
|
12
|
-
@forecast.date.should be_nil
|
13
|
-
end
|
14
|
-
|
15
|
-
it "responds to low" do
|
16
|
-
@forecast.low.should be_nil
|
17
|
-
end
|
18
|
-
|
19
|
-
it "responds to high" do
|
20
|
-
@forecast.high.should be_nil
|
21
|
-
end
|
22
|
-
|
23
|
-
it "responds to pop" do
|
24
|
-
@forecast.pop.should be_nil
|
25
|
-
end
|
26
|
-
|
27
|
-
it "responds to night" do
|
28
|
-
@forecast.night.should be_nil
|
29
|
-
end
|
30
|
-
|
31
|
-
end
|
32
|
-
|
33
|
-
describe "when writing data" do
|
34
|
-
|
35
|
-
before(:each) do
|
36
|
-
@forecast = Measurement::Forecast.new
|
37
|
-
end
|
38
|
-
|
39
|
-
it "only accepts Date for date" do
|
40
|
-
invalid_data = 1
|
41
|
-
invalid_data.class.should_not == Date
|
42
|
-
lambda { @forecast.date = invalid_data }.should raise_error(ArgumentError)
|
43
|
-
|
44
|
-
valid_data = Date.new
|
45
|
-
valid_data.class.should == Date
|
46
|
-
lambda { @forecast.date = valid_data }.should_not raise_error(ArgumentError)
|
47
|
-
end
|
48
|
-
|
49
|
-
it "only accepts Data::Temperature for high" do
|
50
|
-
invalid_data = 1
|
51
|
-
invalid_data.class.should_not == Data::Temperature
|
52
|
-
lambda { @forecast.high = invalid_data }.should raise_error(ArgumentError)
|
53
|
-
|
54
|
-
valid_data = Data::Temperature.new
|
55
|
-
valid_data.class.should == Data::Temperature
|
56
|
-
lambda { @forecast.high = valid_data }.should_not raise_error(ArgumentError)
|
57
|
-
end
|
58
|
-
|
59
|
-
it "only accepts Data::Temperature for low" do
|
60
|
-
invalid_data = 1
|
61
|
-
invalid_data.class.should_not == Data::Temperature
|
62
|
-
lambda { @forecast.low = invalid_data }.should raise_error(ArgumentError)
|
63
|
-
|
64
|
-
valid_data = Data::Temperature.new
|
65
|
-
valid_data.class.should == Data::Temperature
|
66
|
-
lambda { @forecast.low = valid_data }.should_not raise_error(ArgumentError)
|
67
|
-
end
|
68
|
-
|
69
|
-
it "only accepts Fixnum for pop" do
|
70
|
-
invalid_data = "test"
|
71
|
-
invalid_data.class.should_not == Fixnum
|
72
|
-
lambda { @forecast.pop = invalid_data }.should raise_error(ArgumentError)
|
73
|
-
|
74
|
-
valid_data = 50
|
75
|
-
valid_data.class.should == Fixnum
|
76
|
-
lambda { @forecast.pop = valid_data }.should_not raise_error(ArgumentError)
|
77
|
-
end
|
78
|
-
|
79
|
-
it "only accepts Measurement::ForecastNight for night" do
|
80
|
-
invalid_data = 1
|
81
|
-
invalid_data.class.should_not == Measurement::ForecastNight
|
82
|
-
lambda { @forecast.night = invalid_data }.should raise_error(ArgumentError)
|
83
|
-
|
84
|
-
valid_data = Measurement::ForecastNight.new
|
85
|
-
valid_data.class.should == Measurement::ForecastNight
|
86
|
-
lambda { @forecast.night = valid_data }.should_not raise_error(ArgumentError)
|
87
|
-
end
|
88
|
-
|
89
|
-
end
|
90
|
-
|
91
|
-
describe "answer simple questions, like" do
|
92
|
-
|
93
|
-
before(:each) do
|
94
|
-
@forecast = Measurement::Forecast.new
|
95
|
-
end
|
96
|
-
|
97
|
-
describe "wet?" do
|
98
|
-
|
99
|
-
describe "wet_by_pop?" do
|
100
|
-
|
101
|
-
it "requires real threshold number (or nil)" do
|
102
|
-
lambda { @forecast.send("_wet_by_pop?","invalid") }.should raise_error(ArgumentError)
|
103
|
-
lambda { @forecast.send("_wet_by_pop?") }.should_not raise_error(ArgumentError)
|
104
|
-
lambda { @forecast.send("_wet_by_pop?",50) }.should_not raise_error(ArgumentError)
|
105
|
-
end
|
106
|
-
|
107
|
-
it "returns nil when no pop" do
|
108
|
-
@forecast.pop?.should be_false
|
109
|
-
@forecast.send("_wet_by_pop?",50).should be_nil
|
110
|
-
@forecast.wet?.should be_nil
|
111
|
-
@forecast.pop = 60
|
112
|
-
@forecast.pop?.should be_true
|
113
|
-
@forecast.send("_wet_by_pop?",50).should_not be_nil
|
114
|
-
@forecast.wet?.should_not be_nil
|
115
|
-
end
|
116
|
-
|
117
|
-
it "return true when current pop over threshold" do
|
118
|
-
@forecast.pop = 60
|
119
|
-
@forecast.send("_wet_by_pop?",50).should be_true
|
120
|
-
@forecast.wet?.should be_true
|
121
|
-
end
|
122
|
-
|
123
|
-
it "return false when current pop under threshold" do
|
124
|
-
@forecast.pop = 40
|
125
|
-
@forecast.send("_wet_by_pop?",50).should be_false
|
126
|
-
@forecast.wet?.should be_false
|
127
|
-
end
|
128
|
-
|
129
|
-
end
|
130
|
-
|
131
|
-
end
|
132
|
-
|
133
|
-
end
|
134
|
-
|
135
|
-
end
|
@@ -1,49 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe "Forecasted Night Measurement" do
|
4
|
-
|
5
|
-
describe "when initialized" do
|
6
|
-
|
7
|
-
before(:each) do
|
8
|
-
@night = Measurement::ForecastNight.new
|
9
|
-
end
|
10
|
-
|
11
|
-
it "responds to date" do
|
12
|
-
@night.date.should be_nil
|
13
|
-
end
|
14
|
-
|
15
|
-
it "responds to pop" do
|
16
|
-
@night.pop.should be_nil
|
17
|
-
end
|
18
|
-
|
19
|
-
end
|
20
|
-
|
21
|
-
describe "when writing data" do
|
22
|
-
|
23
|
-
before(:each) do
|
24
|
-
@night = Measurement::ForecastNight.new
|
25
|
-
end
|
26
|
-
|
27
|
-
it "only accepts Date for date" do
|
28
|
-
invalid_data = 1
|
29
|
-
invalid_data.class.should_not == Date
|
30
|
-
lambda { @night.date = invalid_data }.should raise_error(ArgumentError)
|
31
|
-
|
32
|
-
valid_data = Date.new
|
33
|
-
valid_data.class.should == Date
|
34
|
-
lambda { @night.date = valid_data }.should_not raise_error(ArgumentError)
|
35
|
-
end
|
36
|
-
|
37
|
-
it "only accepts Fixnum for pop" do
|
38
|
-
invalid_data = "test"
|
39
|
-
invalid_data.class.should_not == Fixnum
|
40
|
-
lambda { @night.pop = invalid_data }.should raise_error(ArgumentError)
|
41
|
-
|
42
|
-
valid_data = 50
|
43
|
-
valid_data.class.should == Fixnum
|
44
|
-
lambda { @night.pop = valid_data }.should_not raise_error(ArgumentError)
|
45
|
-
end
|
46
|
-
|
47
|
-
end
|
48
|
-
|
49
|
-
end
|