weather_weasel 0.1.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.
- data/.DS_Store +0 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +1 -0
- data/lib/.DS_Store +0 -0
- data/lib/weather_weasel.rb +17 -0
- data/lib/weather_weasel/almanac.rb +15 -0
- data/lib/weather_weasel/client.rb +18 -0
- data/lib/weather_weasel/conditions.rb +15 -0
- data/lib/weather_weasel/current_hurricane.rb +12 -0
- data/lib/weather_weasel/forecast.rb +140 -0
- data/lib/weather_weasel/location.rb +130 -0
- data/lib/weather_weasel/version.rb +3 -0
- data/spec/.DS_Store +0 -0
- data/spec/awesomepring.txt +294 -0
- data/spec/cassettes/WeatherWeasel_Location/returns_a_high_temperature.yml +124 -0
- data/spec/cassettes/WeatherWeasel_Location/returns_a_low_temperature.yml +124 -0
- data/spec/cassettes/WeatherWeasel_Location/returns_an_array_of_all_low_temperatures.yml +124 -0
- data/spec/forecast_spec.rb +105 -0
- data/spec/location_spec.rb +19 -0
- data/spec/spec_helper.rb +21 -0
- data/weather_weasel.gemspec +25 -0
- data/weather_weasel.gemspec.orig +25 -0
- metadata +133 -0
@@ -0,0 +1,124 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://api.wunderground.com/api/<WUNDERGROUND_API_KEY>/forecast/q/OR/Portland.json
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers: {}
|
10
|
+
response:
|
11
|
+
status:
|
12
|
+
code: 200
|
13
|
+
message: OK
|
14
|
+
headers:
|
15
|
+
date:
|
16
|
+
- Mon, 11 Mar 2013 17:45:59 GMT
|
17
|
+
server:
|
18
|
+
- Apache/1.3.42 (Unix) PHP/5.3.2
|
19
|
+
cache-control:
|
20
|
+
- max-age=300
|
21
|
+
expires:
|
22
|
+
- Mon, 11 Mar 2013 17:50:59 GMT
|
23
|
+
x-creationtime:
|
24
|
+
- '0.213'
|
25
|
+
set-cookie:
|
26
|
+
- DT=1363023959:26040:365-m1; path=/; expires=Fri, 01-Jan-2020 00:00:00 GMT;
|
27
|
+
domain=.wunderground.com
|
28
|
+
connection:
|
29
|
+
- close
|
30
|
+
transfer-encoding:
|
31
|
+
- chunked
|
32
|
+
content-type:
|
33
|
+
- application/json; charset=UTF-8
|
34
|
+
body:
|
35
|
+
encoding: US-ASCII
|
36
|
+
string: ! "\n{\n\t\"response\": {\n\t\t\"version\": \"0.1\"\n\t\t,\"termsofService\":
|
37
|
+
\"http://www.wunderground.com/weather/api/d/terms.html\"\n\t\t,\"features\":
|
38
|
+
{\n\t\t\"forecast\": 1\n\t\t}\n\t}\n\t\t,\n\t\"forecast\":{\n\t\t\"txt_forecast\":
|
39
|
+
{\n\t\t\"date\":\"8:00 AM PDT\",\n\t\t\"forecastday\": [\n\t\t{\n\t\t\"period\":0,\n\t\t\"icon\":\"chancerain\",\n\t\t\"icon_url\":\"http://icons-ak.wxug.com/i/c/k/chancerain.gif\",\n\t\t\"title\":\"Monday\",\n\t\t\"fcttext\":\"Overcast
|
40
|
+
with a chance of rain. High of 61F. Winds less than 5 mph. Chance of rain
|
41
|
+
40%.\",\n\t\t\"fcttext_metric\":\"Overcast with a chance of rain. High of
|
42
|
+
16C. Winds less than 5 km/h. Chance of rain 40%.\",\n\t\t\"pop\":\"40\"\n\t\t}\n\t\t,\n\t\t{\n\t\t\"period\":1,\n\t\t\"icon\":\"chancerain\",\n\t\t\"icon_url\":\"http://icons-ak.wxug.com/i/c/k/chancerain.gif\",\n\t\t\"title\":\"Monday
|
43
|
+
Night\",\n\t\t\"fcttext\":\"Overcast with a chance of rain. Fog overnight.
|
44
|
+
Low of 46F. Winds less than 5 mph. Chance of rain 40%.\",\n\t\t\"fcttext_metric\":\"Overcast
|
45
|
+
with a chance of rain. Fog overnight. Low of 8C. Winds less than 5 km/h. Chance
|
46
|
+
of rain 40%.\",\n\t\t\"pop\":\"40\"\n\t\t}\n\t\t,\n\t\t{\n\t\t\"period\":2,\n\t\t\"icon\":\"cloudy\",\n\t\t\"icon_url\":\"http://icons-ak.wxug.com/i/c/k/cloudy.gif\",\n\t\t\"title\":\"Tuesday\",\n\t\t\"fcttext\":\"Overcast
|
47
|
+
with a chance of rain. Fog early. High of 64F. Winds from the SSW at 5 to
|
48
|
+
10 mph. Chance of rain 20%.\",\n\t\t\"fcttext_metric\":\"Overcast with a chance
|
49
|
+
of rain. Fog early. High of 18C. Winds from the SSW at 5 to 15 km/h.\",\n\t\t\"pop\":\"20\"\n\t\t}\n\t\t,\n\t\t{\n\t\t\"period\":3,\n\t\t\"icon\":\"chancerain\",\n\t\t\"icon_url\":\"http://icons-ak.wxug.com/i/c/k/chancerain.gif\",\n\t\t\"title\":\"Tuesday
|
50
|
+
Night\",\n\t\t\"fcttext\":\"Overcast with a chance of rain. Low of 50F. Winds
|
51
|
+
from the SSW at 5 to 10 mph. Chance of rain 30% with rainfall amounts near
|
52
|
+
0.2 in. possible.\",\n\t\t\"fcttext_metric\":\"Overcast with a chance of rain.
|
53
|
+
Low of 10C. Winds from the SSW at 5 to 15 km/h. Chance of rain 30% with rainfall
|
54
|
+
amounts near 5.3 mm possible.\",\n\t\t\"pop\":\"30\"\n\t\t}\n\t\t,\n\t\t{\n\t\t\"period\":4,\n\t\t\"icon\":\"chancerain\",\n\t\t\"icon_url\":\"http://icons-ak.wxug.com/i/c/k/chancerain.gif\",\n\t\t\"title\":\"Wednesday\",\n\t\t\"fcttext\":\"Mostly
|
55
|
+
cloudy with a chance of rain. High of 64F. Winds from the SSW at 5 to 10 mph.
|
56
|
+
Chance of rain 30%.\",\n\t\t\"fcttext_metric\":\"Mostly cloudy with a chance
|
57
|
+
of rain. High of 18C. Winds from the SSW at 10 to 15 km/h. Chance of rain
|
58
|
+
30%.\",\n\t\t\"pop\":\"30\"\n\t\t}\n\t\t,\n\t\t{\n\t\t\"period\":5,\n\t\t\"icon\":\"mostlycloudy\",\n\t\t\"icon_url\":\"http://icons-ak.wxug.com/i/c/k/mostlycloudy.gif\",\n\t\t\"title\":\"Wednesday
|
59
|
+
Night\",\n\t\t\"fcttext\":\"Mostly cloudy with a chance of rain in the evening,
|
60
|
+
then overcast. Low of 52F. Winds less than 5 mph. Chance of rain 20%.\",\n\t\t\"fcttext_metric\":\"Mostly
|
61
|
+
cloudy with a chance of rain in the evening, then overcast. Low of 11C. Winds
|
62
|
+
less than 5 km/h.\",\n\t\t\"pop\":\"20\"\n\t\t}\n\t\t,\n\t\t{\n\t\t\"period\":6,\n\t\t\"icon\":\"mostlycloudy\",\n\t\t\"icon_url\":\"http://icons-ak.wxug.com/i/c/k/mostlycloudy.gif\",\n\t\t\"title\":\"Thursday\",\n\t\t\"fcttext\":\"Overcast.
|
63
|
+
High of 61F. Winds from the SSW at 5 to 10 mph.\",\n\t\t\"fcttext_metric\":\"Overcast.
|
64
|
+
High of 16C. Winds from the SSW at 5 to 15 km/h.\",\n\t\t\"pop\":\"0\"\n\t\t}\n\t\t,\n\t\t{\n\t\t\"period\":7,\n\t\t\"icon\":\"mostlycloudy\",\n\t\t\"icon_url\":\"http://icons-ak.wxug.com/i/c/k/mostlycloudy.gif\",\n\t\t\"title\":\"Thursday
|
65
|
+
Night\",\n\t\t\"fcttext\":\"Mostly cloudy in the evening, then overcast with
|
66
|
+
a chance of rain. Low of 54F. Winds from the South at 5 to 10 mph.\",\n\t\t\"fcttext_metric\":\"Mostly
|
67
|
+
cloudy in the evening, then overcast with a chance of rain. Low of 12C. Winds
|
68
|
+
from the South at 10 to 15 km/h.\",\n\t\t\"pop\":\"20\"\n\t\t}\n\t\t]\n\t\t},\n\t\t\"simpleforecast\":
|
69
|
+
{\n\t\t\"forecastday\": [\n\t\t{\"date\":{\n\t\"epoch\":\"1363068000\",\n\t\"pretty\":\"11:00
|
70
|
+
PM PDT on March 11, 2013\",\n\t\"day\":11,\n\t\"month\":3,\n\t\"year\":2013,\n\t\"yday\":69,\n\t\"hour\":23,\n\t\"min\":\"00\",\n\t\"sec\":0,\n\t\"isdst\":\"1\",\n\t\"monthname\":\"March\",\n\t\"weekday_short\":\"Mon\",\n\t\"weekday\":\"Monday\",\n\t\"ampm\":\"PM\",\n\t\"tz_short\":\"PDT\",\n\t\"tz_long\":\"America/Los_Angeles\"\n},\n\t\t\"period\":1,\n\t\t\"high\":
|
71
|
+
{\n\t\t\"fahrenheit\":\"61\",\n\t\t\"celsius\":\"16\"\n\t\t},\n\t\t\"low\":
|
72
|
+
{\n\t\t\"fahrenheit\":\"46\",\n\t\t\"celsius\":\"8\"\n\t\t},\n\t\t\"conditions\":\"Chance
|
73
|
+
of Rain\",\n\t\t\"icon\":\"chancerain\",\n\t\t\"icon_url\":\"http://icons-ak.wxug.com/i/c/k/chancerain.gif\",\n\t\t\"skyicon\":\"mostlycloudy\",\n\t\t\"pop\":40,\n\t\t\"qpf_allday\":
|
74
|
+
{\n\t\t\"in\": 0.01,\n\t\t\"mm\": 0.3\n\t\t},\n\t\t\"qpf_day\": {\n\t\t\"in\":
|
75
|
+
0.00,\n\t\t\"mm\": 0.0\n\t\t},\n\t\t\"qpf_night\": {\n\t\t\"in\": 0.00,\n\t\t\"mm\":
|
76
|
+
0.0\n\t\t},\n\t\t\"snow_allday\": {\n\t\t\"in\": 0,\n\t\t\"cm\": 0\n\t\t},\n\t\t\"snow_day\":
|
77
|
+
{\n\t\t\"in\": 0,\n\t\t\"cm\": 0\n\t\t},\n\t\t\"snow_night\": {\n\t\t\"in\":
|
78
|
+
0,\n\t\t\"cm\": 0\n\t\t},\n\t\t\"maxwind\": {\n\t\t\"mph\": 7,\n\t\t\"kph\":
|
79
|
+
11,\n\t\t\"dir\": \"South\",\n\t\t\"degrees\": 180\n\t\t},\n\t\t\"avewind\":
|
80
|
+
{\n\t\t\"mph\": 5,\n\t\t\"kph\": 8,\n\t\t\"dir\": \"South\",\n\t\t\"degrees\":
|
81
|
+
169\n\t\t},\n\t\t\"avehumidity\": 73,\n\t\t\"maxhumidity\": 95,\n\t\t\"minhumidity\":
|
82
|
+
66\n\t\t}\n\t\t,\n\t\t{\"date\":{\n\t\"epoch\":\"1363154400\",\n\t\"pretty\":\"11:00
|
83
|
+
PM PDT on March 12, 2013\",\n\t\"day\":12,\n\t\"month\":3,\n\t\"year\":2013,\n\t\"yday\":70,\n\t\"hour\":23,\n\t\"min\":\"00\",\n\t\"sec\":0,\n\t\"isdst\":\"1\",\n\t\"monthname\":\"March\",\n\t\"weekday_short\":\"Tue\",\n\t\"weekday\":\"Tuesday\",\n\t\"ampm\":\"PM\",\n\t\"tz_short\":\"PDT\",\n\t\"tz_long\":\"America/Los_Angeles\"\n},\n\t\t\"period\":2,\n\t\t\"high\":
|
84
|
+
{\n\t\t\"fahrenheit\":\"64\",\n\t\t\"celsius\":\"18\"\n\t\t},\n\t\t\"low\":
|
85
|
+
{\n\t\t\"fahrenheit\":\"50\",\n\t\t\"celsius\":\"10\"\n\t\t},\n\t\t\"conditions\":\"Chance
|
86
|
+
of Rain\",\n\t\t\"icon\":\"cloudy\",\n\t\t\"icon_url\":\"http://icons-ak.wxug.com/i/c/k/cloudy.gif\",\n\t\t\"skyicon\":\"cloudy\",\n\t\t\"pop\":20,\n\t\t\"qpf_allday\":
|
87
|
+
{\n\t\t\"in\": 0.18,\n\t\t\"mm\": 4.6\n\t\t},\n\t\t\"qpf_day\": {\n\t\t\"in\":
|
88
|
+
0.00,\n\t\t\"mm\": 0.0\n\t\t},\n\t\t\"qpf_night\": {\n\t\t\"in\": 0.21,\n\t\t\"mm\":
|
89
|
+
5.3\n\t\t},\n\t\t\"snow_allday\": {\n\t\t\"in\": 0,\n\t\t\"cm\": 0\n\t\t},\n\t\t\"snow_day\":
|
90
|
+
{\n\t\t\"in\": 0,\n\t\t\"cm\": 0\n\t\t},\n\t\t\"snow_night\": {\n\t\t\"in\":
|
91
|
+
0,\n\t\t\"cm\": 0\n\t\t},\n\t\t\"maxwind\": {\n\t\t\"mph\": 8,\n\t\t\"kph\":
|
92
|
+
13,\n\t\t\"dir\": \"SSW\",\n\t\t\"degrees\": 192\n\t\t},\n\t\t\"avewind\":
|
93
|
+
{\n\t\t\"mph\": 6,\n\t\t\"kph\": 10,\n\t\t\"dir\": \"SSW\",\n\t\t\"degrees\":
|
94
|
+
196\n\t\t},\n\t\t\"avehumidity\": 72,\n\t\t\"maxhumidity\": 99,\n\t\t\"minhumidity\":
|
95
|
+
65\n\t\t}\n\t\t,\n\t\t{\"date\":{\n\t\"epoch\":\"1363240800\",\n\t\"pretty\":\"11:00
|
96
|
+
PM PDT on March 13, 2013\",\n\t\"day\":13,\n\t\"month\":3,\n\t\"year\":2013,\n\t\"yday\":71,\n\t\"hour\":23,\n\t\"min\":\"00\",\n\t\"sec\":0,\n\t\"isdst\":\"1\",\n\t\"monthname\":\"March\",\n\t\"weekday_short\":\"Wed\",\n\t\"weekday\":\"Wednesday\",\n\t\"ampm\":\"PM\",\n\t\"tz_short\":\"PDT\",\n\t\"tz_long\":\"America/Los_Angeles\"\n},\n\t\t\"period\":3,\n\t\t\"high\":
|
97
|
+
{\n\t\t\"fahrenheit\":\"64\",\n\t\t\"celsius\":\"18\"\n\t\t},\n\t\t\"low\":
|
98
|
+
{\n\t\t\"fahrenheit\":\"52\",\n\t\t\"celsius\":\"11\"\n\t\t},\n\t\t\"conditions\":\"Chance
|
99
|
+
of Rain\",\n\t\t\"icon\":\"chancerain\",\n\t\t\"icon_url\":\"http://icons-ak.wxug.com/i/c/k/chancerain.gif\",\n\t\t\"skyicon\":\"mostlycloudy\",\n\t\t\"pop\":30,\n\t\t\"qpf_allday\":
|
100
|
+
{\n\t\t\"in\": 0.10,\n\t\t\"mm\": 2.5\n\t\t},\n\t\t\"qpf_day\": {\n\t\t\"in\":
|
101
|
+
0.03,\n\t\t\"mm\": 0.8\n\t\t},\n\t\t\"qpf_night\": {\n\t\t\"in\": 0.04,\n\t\t\"mm\":
|
102
|
+
1.0\n\t\t},\n\t\t\"snow_allday\": {\n\t\t\"in\": 0,\n\t\t\"cm\": 0\n\t\t},\n\t\t\"snow_day\":
|
103
|
+
{\n\t\t\"in\": 0,\n\t\t\"cm\": 0\n\t\t},\n\t\t\"snow_night\": {\n\t\t\"in\":
|
104
|
+
0,\n\t\t\"cm\": 0\n\t\t},\n\t\t\"maxwind\": {\n\t\t\"mph\": 8,\n\t\t\"kph\":
|
105
|
+
13,\n\t\t\"dir\": \"SW\",\n\t\t\"degrees\": 217\n\t\t},\n\t\t\"avewind\":
|
106
|
+
{\n\t\t\"mph\": 6,\n\t\t\"kph\": 10,\n\t\t\"dir\": \"SSW\",\n\t\t\"degrees\":
|
107
|
+
203\n\t\t},\n\t\t\"avehumidity\": 65,\n\t\t\"maxhumidity\": 79,\n\t\t\"minhumidity\":
|
108
|
+
52\n\t\t}\n\t\t,\n\t\t{\"date\":{\n\t\"epoch\":\"1363327200\",\n\t\"pretty\":\"11:00
|
109
|
+
PM PDT on March 14, 2013\",\n\t\"day\":14,\n\t\"month\":3,\n\t\"year\":2013,\n\t\"yday\":72,\n\t\"hour\":23,\n\t\"min\":\"00\",\n\t\"sec\":0,\n\t\"isdst\":\"1\",\n\t\"monthname\":\"March\",\n\t\"weekday_short\":\"Thu\",\n\t\"weekday\":\"Thursday\",\n\t\"ampm\":\"PM\",\n\t\"tz_short\":\"PDT\",\n\t\"tz_long\":\"America/Los_Angeles\"\n},\n\t\t\"period\":4,\n\t\t\"high\":
|
110
|
+
{\n\t\t\"fahrenheit\":\"61\",\n\t\t\"celsius\":\"16\"\n\t\t},\n\t\t\"low\":
|
111
|
+
{\n\t\t\"fahrenheit\":\"54\",\n\t\t\"celsius\":\"12\"\n\t\t},\n\t\t\"conditions\":\"Mostly
|
112
|
+
Cloudy\",\n\t\t\"icon\":\"mostlycloudy\",\n\t\t\"icon_url\":\"http://icons-ak.wxug.com/i/c/k/mostlycloudy.gif\",\n\t\t\"skyicon\":\"cloudy\",\n\t\t\"pop\":0,\n\t\t\"qpf_allday\":
|
113
|
+
{\n\t\t\"in\": 0.01,\n\t\t\"mm\": 0.3\n\t\t},\n\t\t\"qpf_day\": {\n\t\t\"in\":
|
114
|
+
0.00,\n\t\t\"mm\": 0.0\n\t\t},\n\t\t\"qpf_night\": {\n\t\t\"in\": 0.03,\n\t\t\"mm\":
|
115
|
+
0.8\n\t\t},\n\t\t\"snow_allday\": {\n\t\t\"in\": 0,\n\t\t\"cm\": 0\n\t\t},\n\t\t\"snow_day\":
|
116
|
+
{\n\t\t\"in\": 0,\n\t\t\"cm\": 0\n\t\t},\n\t\t\"snow_night\": {\n\t\t\"in\":
|
117
|
+
0,\n\t\t\"cm\": 0\n\t\t},\n\t\t\"maxwind\": {\n\t\t\"mph\": 7,\n\t\t\"kph\":
|
118
|
+
11,\n\t\t\"dir\": \"SSW\",\n\t\t\"degrees\": 211\n\t\t},\n\t\t\"avewind\":
|
119
|
+
{\n\t\t\"mph\": 6,\n\t\t\"kph\": 10,\n\t\t\"dir\": \"SSW\",\n\t\t\"degrees\":
|
120
|
+
200\n\t\t},\n\t\t\"avehumidity\": 61,\n\t\t\"maxhumidity\": 74,\n\t\t\"minhumidity\":
|
121
|
+
54\n\t\t}\n\t\t]\n\t\t}\n\t}\n}\n"
|
122
|
+
http_version: '1.1'
|
123
|
+
recorded_at: Mon, 11 Mar 2013 17:46:00 GMT
|
124
|
+
recorded_with: VCR 2.4.0
|
@@ -0,0 +1,105 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
describe WeatherWeasel::Forecast do
|
3
|
+
before(:all) do
|
4
|
+
@test_data = [{"date"=>{"epoch"=>"1362722400", "pretty"=>"10:00 PM PST on March 07, 2013", "day"=>7, "month"=>3, "year"=>2013, "yday"=>65, "hour"=>22, "min"=>"00", "sec"=>0, "isdst"=>"0", "monthname"=>"March", "weekday_short"=>"Thu", "weekday"=>"Thursday", "ampm"=>"PM", "tz_short"=>"PST", "tz_long"=>"America/Los_Angeles"}, "period"=>1, "high"=>{"fahrenheit"=>"55", "celsius"=>"13"}, "low"=>{"fahrenheit"=>"37", "celsius"=>"3"}, "conditions"=>"Rain Showers", "icon"=>"rain", "icon_url"=>"http://icons-ak.wxug.com/i/c/k/rain.gif", "skyicon"=>"partlycloudy", "pop"=>40, "qpf_allday"=>{"in"=>0.07, "mm"=>1.8}, "qpf_day"=>{"in"=>0.04, "mm"=>1.0}, "qpf_night"=>{"in"=>0.0, "mm"=>0.0}, "snow_allday"=>{"in"=>0, "cm"=>0}, "snow_day"=>{"in"=>0, "cm"=>0}, "snow_night"=>{"in"=>0, "cm"=>0}, "maxwind"=>{"mph"=>9, "kph"=>14, "dir"=>"South", "degrees"=>172}, "avewind"=>{"mph"=>7, "kph"=>11, "dir"=>"WNW", "degrees"=>294}, "avehumidity"=>70, "maxhumidity"=>90, "minhumidity"=>59}, {"date"=>{"epoch"=>"1362808800", "pretty"=>"10:00 PM PST on March 08, 2013", "day"=>8, "month"=>3, "year"=>2013, "yday"=>66, "hour"=>22, "min"=>"00", "sec"=>0, "isdst"=>"0", "monthname"=>"March", "weekday_short"=>"Fri", "weekday"=>"Friday", "ampm"=>"PM", "tz_short"=>"PST", "tz_long"=>"America/Los_Angeles"}, "period"=>2, "high"=>{"fahrenheit"=>"57", "celsius"=>"14"}, "low"=>{"fahrenheit"=>"37", "celsius"=>"3"}, "conditions"=>"Partly Cloudy", "icon"=>"partlycloudy", "icon_url"=>"http://icons-ak.wxug.com/i/c/k/partlycloudy.gif", "skyicon"=>"partlycloudy", "pop"=>10, "qpf_allday"=>{"in"=>0.0, "mm"=>0.0}, "qpf_day"=>{"in"=>0.0, "mm"=>0.0}, "qpf_night"=>{"in"=>0.0, "mm"=>0.0}, "snow_allday"=>{"in"=>0, "cm"=>0}, "snow_day"=>{"in"=>0, "cm"=>0}, "snow_night"=>{"in"=>0, "cm"=>0}, "maxwind"=>{"mph"=>9, "kph"=>14, "dir"=>"NW", "degrees"=>312}, "avewind"=>{"mph"=>7, "kph"=>11, "dir"=>"NW", "degrees"=>306}, "avehumidity"=>68, "maxhumidity"=>82, "minhumidity"=>48}, {"date"=>{"epoch"=>"1362895200", "pretty"=>"10:00 PM PST on March 09, 2013", "day"=>9, "month"=>3, "year"=>2013, "yday"=>67, "hour"=>22, "min"=>"00", "sec"=>0, "isdst"=>"0", "monthname"=>"March", "weekday_short"=>"Sat", "weekday"=>"Saturday", "ampm"=>"PM", "tz_short"=>"PST", "tz_long"=>"America/Los_Angeles"}, "period"=>3, "high"=>{"fahrenheit"=>"55", "celsius"=>"13"}, "low"=>{"fahrenheit"=>"45", "celsius"=>"7"}, "conditions"=>"Partly Cloudy", "icon"=>"partlycloudy", "icon_url"=>"http://icons-ak.wxug.com/i/c/k/partlycloudy.gif", "skyicon"=>"mostlysunny", "pop"=>0, "qpf_allday"=>{"in"=>0.0, "mm"=>0.0}, "qpf_day"=>{"in"=>0.0, "mm"=>0.0}, "qpf_night"=>{"in"=>0.0, "mm"=>0.0}, "snow_allday"=>{"in"=>0, "cm"=>0}, "snow_day"=>{"in"=>0, "cm"=>0}, "snow_night"=>{"in"=>0, "cm"=>0}, "maxwind"=>{"mph"=>9, "kph"=>14, "dir"=>"NNW", "degrees"=>329}, "avewind"=>{"mph"=>4, "kph"=>6, "dir"=>"NW", "degrees"=>320}, "avehumidity"=>51, "maxhumidity"=>76, "minhumidity"=>46}, {"date"=>{"epoch"=>"1362981600", "pretty"=>"11:00 PM PDT on March 10, 2013", "day"=>10, "month"=>3, "year"=>2013, "yday"=>68, "hour"=>23, "min"=>"00", "sec"=>0, "isdst"=>"1", "monthname"=>"March", "weekday_short"=>"Sun", "weekday"=>"Sunday", "ampm"=>"PM", "tz_short"=>"PDT", "tz_long"=>"America/Los_Angeles"}, "period"=>4, "high"=>{"fahrenheit"=>"57", "celsius"=>"14"}, "low"=>{"fahrenheit"=>"39", "celsius"=>"4"}, "conditions"=>"Chance of Rain", "icon"=>"chancerain", "icon_url"=>"http://icons-ak.wxug.com/i/c/k/chancerain.gif", "skyicon"=>"cloudy", "pop"=>40, "qpf_allday"=>{"in"=>0.21, "mm"=>5.3}, "qpf_day"=>{"in"=>0.12, "mm"=>3.0}, "qpf_night"=>{"in"=>0.12, "mm"=>3.0}, "snow_allday"=>{"in"=>0, "cm"=>0}, "snow_day"=>{"in"=>0, "cm"=>0}, "snow_night"=>{"in"=>0, "cm"=>0}, "maxwind"=>{"mph"=>4, "kph"=>6, "dir"=>"SSE", "degrees"=>167}, "avewind"=>{"mph"=>3, "kph"=>5, "dir"=>"South", "degrees"=>176}, "avehumidity"=>71, "maxhumidity"=>76, "minhumidity"=>55}]
|
5
|
+
|
6
|
+
@portland = WeatherWeasel::Forecast.new("Portland", "OR", "test")
|
7
|
+
end
|
8
|
+
before(:each) do
|
9
|
+
@portland.stub(:forecast_days).and_return(@test_data)
|
10
|
+
end
|
11
|
+
|
12
|
+
it "can return the highest temperature in its forecast days in fahrenheit" do
|
13
|
+
@portland.high("imperial").should == 57
|
14
|
+
end
|
15
|
+
|
16
|
+
it "can return the highest temperature in its forecast days in celsius" do
|
17
|
+
@portland.high("metric").should == 14
|
18
|
+
end
|
19
|
+
|
20
|
+
it "can return the lowest temperature in its forecast days in fahrenheit" do
|
21
|
+
@portland.low("imperial").should == 37
|
22
|
+
end
|
23
|
+
|
24
|
+
it "can return the lowest temperature in its forecast days in celsius" do
|
25
|
+
@portland.low("metric").should == 3
|
26
|
+
end
|
27
|
+
|
28
|
+
it "can return the an array of highs in its forecast days" do
|
29
|
+
@portland.all_highs("imperial").should == [55, 57, 55, 57]
|
30
|
+
end
|
31
|
+
|
32
|
+
it "can return the an array of lows in its forecast days" do
|
33
|
+
@portland.all_lows("imperial").should == [37, 37, 45, 39]
|
34
|
+
end
|
35
|
+
|
36
|
+
it "can return fahrenheit when passed imperial" do
|
37
|
+
@portland.set_scale("imperial") == "fahrenheit"
|
38
|
+
end
|
39
|
+
|
40
|
+
it "can return celsius when passed metric" do
|
41
|
+
@portland.set_scale("metric") == "celsius"
|
42
|
+
end
|
43
|
+
|
44
|
+
it "can return the array of max wind speeds in its forecast days" do
|
45
|
+
@portland.all_max_wind("imperial").should == [9, 9, 9, 4]
|
46
|
+
end
|
47
|
+
|
48
|
+
it "can return the highest wind speed in its forecast days" do
|
49
|
+
@portland.max_wind("imperial").should == 9
|
50
|
+
end
|
51
|
+
|
52
|
+
it "can return the highest wind speed in its forecast days" do
|
53
|
+
@portland.max_wind("metric").should == 14
|
54
|
+
end
|
55
|
+
|
56
|
+
it "can return an array of the snow accumulation for each day in the forecast" do
|
57
|
+
@portland.all_snow_day("imperial").should == [0, 0, 0, 0]
|
58
|
+
end
|
59
|
+
|
60
|
+
it "can return the highest snow day accumulation of the forecast in inches" do
|
61
|
+
@portland.highest_snow_day("imperial").should == 0
|
62
|
+
end
|
63
|
+
|
64
|
+
it "can return the highest snow accumulation of the forecast in centimeters" do
|
65
|
+
@portland.highest_snow_day("metric").should == 0
|
66
|
+
end
|
67
|
+
|
68
|
+
it "can return the snow accumulation for a given day in the forecast" do
|
69
|
+
@portland.snow_day(0, "metric").should == 0
|
70
|
+
end
|
71
|
+
|
72
|
+
it "can return an array of the snow night accumilation for each day in the forecast" do
|
73
|
+
@portland.all_snow_night("imperial").should == [0, 0, 0, 0]
|
74
|
+
end
|
75
|
+
|
76
|
+
it "can return an array of the all day accumilation for each day in the forecast" do
|
77
|
+
@portland.all_snow_allday("imperial").should == [0, 0, 0, 0]
|
78
|
+
end
|
79
|
+
|
80
|
+
it "can return all skyicon in its forecast days" do
|
81
|
+
@portland.skyicon(0).should == "partlycloudy"
|
82
|
+
end
|
83
|
+
|
84
|
+
it "can return all skyicons in its forecast days" do
|
85
|
+
@portland.skyicons.should == ["partlycloudy", "partlycloudy", "mostlysunny", "cloudy"]
|
86
|
+
end
|
87
|
+
|
88
|
+
it "can return the pops for its forecast days" do
|
89
|
+
@portland.pops.should == [40, 10, 0, 40]
|
90
|
+
end
|
91
|
+
|
92
|
+
it "can return the qpf_alldays for its forecast days" do
|
93
|
+
@portland.qpf_alldays("imperial").should == [0.07, 0.0, 0.0, 0.21]
|
94
|
+
end
|
95
|
+
|
96
|
+
it "can return all forecast_conditions in its forecast days" do
|
97
|
+
@portland.forecast_conditions.should == ["Rain Showers", "Partly Cloudy", "Partly Cloudy", "Chance of Rain"]
|
98
|
+
end
|
99
|
+
|
100
|
+
it "can return all forecast_condition in its forecast days" do
|
101
|
+
@portland.forecast_condition(0).should == "Rain Showers"
|
102
|
+
end
|
103
|
+
|
104
|
+
end
|
105
|
+
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe WeatherWeasel::Location do
|
4
|
+
before(:all) do
|
5
|
+
@location = WeatherWeasel::Location.new("Portland", "OR")
|
6
|
+
end
|
7
|
+
|
8
|
+
it "returns a high temperature", :vcr do
|
9
|
+
@location.high.should == 64
|
10
|
+
end
|
11
|
+
|
12
|
+
it "returns a low temperature", :vcr do
|
13
|
+
@location.low.should == 46
|
14
|
+
end
|
15
|
+
|
16
|
+
it "returns an array of all low temperatures", :vcr do
|
17
|
+
@location.all_lows.should == [46, 50, 52, 54]
|
18
|
+
end
|
19
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'simplecov'
|
2
|
+
SimpleCov.start
|
3
|
+
|
4
|
+
require 'weather_weasel'
|
5
|
+
require 'vcr'
|
6
|
+
require 'fakeweb'
|
7
|
+
|
8
|
+
VCR.configure do |c|
|
9
|
+
c.cassette_library_dir = 'spec/cassettes'
|
10
|
+
c.hook_into :fakeweb
|
11
|
+
c.configure_rspec_metadata!
|
12
|
+
c.filter_sensitive_data("<WUNDERGROUND_API_KEY>") do
|
13
|
+
ENV['WUNDERGROUND_API_KEY']
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
RSpec.configure do |c|
|
18
|
+
# so we can use :vcr rather than :vcr => true;
|
19
|
+
# in RSpec 3 this will no longer be necessary.
|
20
|
+
c.treat_symbols_as_metadata_keys_with_true_values = true
|
21
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'weather_weasel/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "weather_weasel"
|
8
|
+
gem.version = WeatherWeasel::VERSION
|
9
|
+
gem.authors = ["Elizabeth Tabler, Duncan Miller, Michael LaPeter"]
|
10
|
+
gem.email = ["opensourceportland@gmail.com"]
|
11
|
+
gem.description = "Wrapper for the Wunderground API"
|
12
|
+
gem.summary = "A location-centric system for consuming the Wunderground API"
|
13
|
+
gem.homepage = "https://github.com/OpenSourcePortland/weather_weasel"
|
14
|
+
gem.add_dependency 'httparty', ">= 0.10.2"
|
15
|
+
gem.add_dependency 'rspec'
|
16
|
+
gem.add_dependency 'vcr'
|
17
|
+
gem.add_dependency 'simplecov'
|
18
|
+
gem.add_dependency 'fakeweb'
|
19
|
+
|
20
|
+
|
21
|
+
gem.files = `git ls-files`.split($/)
|
22
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
23
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
24
|
+
gem.require_paths = ["lib"]
|
25
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'weather_weasel/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "weather_weasel"
|
8
|
+
gem.version = WeatherWeasel::VERSION
|
9
|
+
gem.authors = ["Elizabeth Tabler, Duncan Miller, Michael LaPeter"]
|
10
|
+
gem.email = ["opensourceportland@gmail.com"]
|
11
|
+
gem.description = %q{TODO: Write a gem description}
|
12
|
+
gem.summary = %q{TODO: Write a gem summary}
|
13
|
+
gem.homepage = ""
|
14
|
+
gem.add_dependency 'httparty', ">= 0.10.2"
|
15
|
+
<<<<<<< HEAD
|
16
|
+
gem.add_dependency 'simplecov'
|
17
|
+
=======
|
18
|
+
gem.add_dependency 'fakeweb'
|
19
|
+
>>>>>>> duncan_methods
|
20
|
+
|
21
|
+
gem.files = `git ls-files`.split($/)
|
22
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
23
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
24
|
+
gem.require_paths = ["lib"]
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,133 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: weather_weasel
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Elizabeth Tabler, Duncan Miller, Michael LaPeter
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-03-11 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: httparty
|
16
|
+
requirement: &70199978042920 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 0.10.2
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70199978042920
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rspec
|
27
|
+
requirement: &70199978042480 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70199978042480
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: vcr
|
38
|
+
requirement: &70199978041840 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :runtime
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70199978041840
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: simplecov
|
49
|
+
requirement: &70199978041420 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
type: :runtime
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *70199978041420
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: fakeweb
|
60
|
+
requirement: &70199978041000 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
type: :runtime
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *70199978041000
|
69
|
+
description: Wrapper for the Wunderground API
|
70
|
+
email:
|
71
|
+
- opensourceportland@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- .DS_Store
|
77
|
+
- .gitignore
|
78
|
+
- Gemfile
|
79
|
+
- LICENSE.txt
|
80
|
+
- README.md
|
81
|
+
- Rakefile
|
82
|
+
- lib/.DS_Store
|
83
|
+
- lib/weather_weasel.rb
|
84
|
+
- lib/weather_weasel/almanac.rb
|
85
|
+
- lib/weather_weasel/client.rb
|
86
|
+
- lib/weather_weasel/conditions.rb
|
87
|
+
- lib/weather_weasel/current_hurricane.rb
|
88
|
+
- lib/weather_weasel/forecast.rb
|
89
|
+
- lib/weather_weasel/location.rb
|
90
|
+
- lib/weather_weasel/version.rb
|
91
|
+
- spec/.DS_Store
|
92
|
+
- spec/awesomepring.txt
|
93
|
+
- spec/cassettes/WeatherWeasel_Location/returns_a_high_temperature.yml
|
94
|
+
- spec/cassettes/WeatherWeasel_Location/returns_a_low_temperature.yml
|
95
|
+
- spec/cassettes/WeatherWeasel_Location/returns_an_array_of_all_low_temperatures.yml
|
96
|
+
- spec/forecast_spec.rb
|
97
|
+
- spec/location_spec.rb
|
98
|
+
- spec/spec_helper.rb
|
99
|
+
- weather_weasel.gemspec
|
100
|
+
- weather_weasel.gemspec.orig
|
101
|
+
homepage: https://github.com/OpenSourcePortland/weather_weasel
|
102
|
+
licenses: []
|
103
|
+
post_install_message:
|
104
|
+
rdoc_options: []
|
105
|
+
require_paths:
|
106
|
+
- lib
|
107
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
108
|
+
none: false
|
109
|
+
requirements:
|
110
|
+
- - ! '>='
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: '0'
|
113
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
114
|
+
none: false
|
115
|
+
requirements:
|
116
|
+
- - ! '>='
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '0'
|
119
|
+
requirements: []
|
120
|
+
rubyforge_project:
|
121
|
+
rubygems_version: 1.8.17
|
122
|
+
signing_key:
|
123
|
+
specification_version: 3
|
124
|
+
summary: A location-centric system for consuming the Wunderground API
|
125
|
+
test_files:
|
126
|
+
- spec/.DS_Store
|
127
|
+
- spec/awesomepring.txt
|
128
|
+
- spec/cassettes/WeatherWeasel_Location/returns_a_high_temperature.yml
|
129
|
+
- spec/cassettes/WeatherWeasel_Location/returns_a_low_temperature.yml
|
130
|
+
- spec/cassettes/WeatherWeasel_Location/returns_an_array_of_all_low_temperatures.yml
|
131
|
+
- spec/forecast_spec.rb
|
132
|
+
- spec/location_spec.rb
|
133
|
+
- spec/spec_helper.rb
|