undergroundweather 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
data/README.md
CHANGED
@@ -1,9 +1,31 @@
|
|
1
1
|
# Underground Weather
|
2
|
+
http://www.wunderground.com/weather/api/d/documentation.html
|
2
3
|
|
3
4
|
## Usage
|
4
5
|
|
6
|
+
Implemented Endpoints
|
7
|
+
|
8
|
+
* conditions - Returns the current temperature, weather condition, humidity, wind, 'feels like' temperature, barometric pressure, and visibility.
|
9
|
+
* forecast - Returns a summary of the weather for the next 3 days. This includes high and low temperatures, a string text forecast and the conditions.
|
10
|
+
* astronomy - Returns The moon phase, sunrise and sunset times.
|
11
|
+
* radar - Returns a URL link to the .gif radar image.
|
12
|
+
* satellite - Returns a URL link to .gif visual and infrared satellite images.
|
13
|
+
* webcams - Returns locations of nearby Personal Weather Stations and URL's for images from their web cams.
|
14
|
+
|
15
|
+
```
|
16
|
+
gem install undergroundweather
|
17
|
+
api_key = 'xxxxxxxx' # Your WU API Key
|
18
|
+
uw = UndergroundWeather.new(api_key)
|
19
|
+
|
20
|
+
zip_code = 19106
|
21
|
+
uw.<endpoint>(zip_code) # conditions, forecast, astronomy, etc...
|
22
|
+
```
|
23
|
+
|
5
24
|
## Development
|
6
25
|
|
26
|
+
### ToDo
|
27
|
+
https://github.com/brookemckim/undergroundweather/issues?labels=Story&sort=created&direction=desc&state=open&page=1
|
28
|
+
|
7
29
|
### Testing
|
8
30
|
Using minitest/spec
|
9
31
|
|
@@ -15,7 +15,7 @@ module UndergroundWeather
|
|
15
15
|
@error = false
|
16
16
|
|
17
17
|
@response = JSON.parse(get)
|
18
|
-
@error = true if @response['error']
|
18
|
+
@error = true if @response['response']['error']
|
19
19
|
end
|
20
20
|
|
21
21
|
def url
|
@@ -23,14 +23,14 @@ module UndergroundWeather
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def get
|
26
|
-
puts "Calling #{url}"
|
27
26
|
resp = Net::HTTP.get_response(url)
|
28
27
|
|
29
28
|
if resp.code == "200"
|
30
29
|
resp.body
|
31
30
|
else
|
32
|
-
puts "error retrieving weather feed"
|
33
31
|
@error = true
|
32
|
+
|
33
|
+
# raise exception here
|
34
34
|
{}
|
35
35
|
end
|
36
36
|
end
|
@@ -7,23 +7,24 @@ module UndergroundWeather
|
|
7
7
|
:astronomy => { :class => Astronomy },
|
8
8
|
:radar => { :class => Radar },
|
9
9
|
:satellite => { :class => Satellite },
|
10
|
-
:webcams => { :class => Webcams }
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
10
|
+
:webcams => { :class => Webcams }
|
11
|
+
#:history => { :class => ''},
|
12
|
+
#:alerts => { :class => ''},
|
13
|
+
#:hourly => { :class => ''},
|
14
|
+
#:hourly7day => { :class => ''},
|
15
|
+
#:forecast7day => { :class => ''},
|
16
|
+
#:yesterday => { :class => ''}
|
17
17
|
}
|
18
18
|
|
19
19
|
features.each do |feature, v|
|
20
20
|
define_method(feature) do |zip_code|
|
21
21
|
call = ApiCall.new(@api_key, feature, zip_code)
|
22
|
+
|
22
23
|
if call.response && !call.error
|
23
24
|
v[:class].new(call.response)
|
24
25
|
else
|
25
|
-
|
26
|
-
|
26
|
+
# raise exception here
|
27
|
+
[]
|
27
28
|
end
|
28
29
|
end
|
29
30
|
end
|