yahoo_weather 1.0.6 → 1.0.7
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.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +8 -0
- data/lib/yahoo_weather/client.rb +10 -4
- data/lib/yahoo_weather/version.rb +1 -1
- data/test/dummy/log/test.log +55 -0
- data/test/dummy/tmp/cache/62E/480/woeid+for+Moscow +1 -0
- data/test/dummy/tmp/cache/82F/B30/yahoo_weather_12794004_f +10 -10
- data/test/dummy/tmp/cache/83D/EE0/yahoo_weather_12797168_f +9 -9
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0ec45b4a14877f783fb1a8b539cb66b8c64f6ac2
|
4
|
+
data.tar.gz: 4e1381664533e1e69ae30ca633861aaddf4604be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d672b20528094eb6200d183bf4c01f817f28c2bc6ec40c4d64eb75b310ef62e82ae173001837150346bbe2067dec0fcba9ee5e3f15e36814756d7776b6fecea
|
7
|
+
data.tar.gz: 6324edf6b7d22e017bbe04e1c8c441eba474f9844edd10ff9ebf9d16674735dee6d6f9a077d61a6531ca6acf33a86f3b883a9313579f9ddc23884edeb9257a30
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -22,6 +22,7 @@ http://developer.yahoo.com/weather/
|
|
22
22
|
|
23
23
|
## Example
|
24
24
|
|
25
|
+
Fetch by woeid:
|
25
26
|
```ruby
|
26
27
|
client = YahooWeather::Client.new
|
27
28
|
response = client.fetch(12797168)
|
@@ -32,6 +33,13 @@ response.wind.direction('string') # "ESE"
|
|
32
33
|
response.condition.code # 29
|
33
34
|
response.condition.code('string') # "Partly cloudy (night)"
|
34
35
|
```
|
36
|
+
FYI: If you want to use string condition code don't forget to copy locales
|
37
|
+
|
38
|
+
Fetch by location:
|
39
|
+
```ruby
|
40
|
+
client = YahooWeather::Client.new
|
41
|
+
response = client.fetch_by_location('New York')
|
42
|
+
```
|
35
43
|
|
36
44
|
## Locales
|
37
45
|
|
data/lib/yahoo_weather/client.rb
CHANGED
@@ -9,10 +9,16 @@ class YahooWeather::Client
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def fetch_by_location(location, units = YahooWeather::Units::FAHRENHEIT)
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
woeid_cache_key = "woeid for #{location}"
|
13
|
+
unless Rails.cache.exist? woeid_cache_key
|
14
|
+
url = "http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20geo.placefinder%20where%20text%3D%22#{::CGI.escape(location)}%22%20and%20gflags%3D%22R%22"
|
15
|
+
xml = fetch_xml(url)
|
16
|
+
doc = Nokogiri::XML(xml)
|
17
|
+
woeid = doc.at('woeid').children.text
|
18
|
+
Rails.cache.write(woeid_cache_key, woeid)
|
19
|
+
else
|
20
|
+
woeid = Rails.cache.read woeid_cache_key
|
21
|
+
end
|
16
22
|
fetch(woeid, units)
|
17
23
|
rescue
|
18
24
|
nil
|
data/test/dummy/log/test.log
CHANGED
@@ -326,5 +326,60 @@ YahooWeatherTest: test_Units
|
|
326
326
|
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
327
327
|
---------------------------
|
328
328
|
YahooWeatherTest: test_Wind
|
329
|
+
---------------------------
|
330
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
331
|
+
[1m[36m (0.4ms)[0m [1mbegin transaction[0m
|
332
|
+
--------------------------------
|
333
|
+
YahooWeatherTest: test_Astronomy
|
334
|
+
--------------------------------
|
335
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
336
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
337
|
+
---------------------------------
|
338
|
+
YahooWeatherTest: test_Atmosphere
|
339
|
+
---------------------------------
|
340
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
341
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
342
|
+
--------------------------------
|
343
|
+
YahooWeatherTest: test_Condition
|
344
|
+
--------------------------------
|
345
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
346
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
347
|
+
-------------------------------------
|
348
|
+
YahooWeatherTest: test_Fetch_by_WOEID
|
349
|
+
-------------------------------------
|
350
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
351
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
352
|
+
--------------------------------------------------
|
353
|
+
YahooWeatherTest: test_Fetch_with_the_bad_response
|
354
|
+
--------------------------------------------------
|
355
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
356
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
357
|
+
--------------------------------
|
358
|
+
YahooWeatherTest: test_Forecasts
|
359
|
+
--------------------------------
|
360
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
361
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
362
|
+
------------------------------
|
363
|
+
YahooWeatherTest: test_General
|
364
|
+
------------------------------
|
365
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
366
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
367
|
+
-------------------------------
|
368
|
+
YahooWeatherTest: test_Location
|
369
|
+
-------------------------------
|
370
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
371
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
372
|
+
---------------------------------------
|
373
|
+
YahooWeatherTest: test_Success_response
|
374
|
+
---------------------------------------
|
375
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
376
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
377
|
+
----------------------------
|
378
|
+
YahooWeatherTest: test_Units
|
379
|
+
----------------------------
|
380
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
381
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
382
|
+
---------------------------
|
383
|
+
YahooWeatherTest: test_Wind
|
329
384
|
---------------------------
|
330
385
|
[1m[35m (0.1ms)[0m rollback transaction
|
@@ -0,0 +1 @@
|
|
1
|
+
o: ActiveSupport::Cache::Entry:@valueI"
|
@@ -1,4 +1,4 @@
|
|
1
|
-
o: ActiveSupport::Cache::Entry:@valueI"�
|
1
|
+
o: ActiveSupport::Cache::Entry:@valueI"�
|
2
2
|
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
3
3
|
<rss version="2.0" xmlns:yweather="http://xml.weather.yahoo.com/ns/rss/1.0" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#">
|
4
4
|
<channel>
|
@@ -7,12 +7,12 @@
|
|
7
7
|
<link>http://us.rd.yahoo.com/dailynews/rss/weather/Moscow__ID/*http://weather.yahoo.com/forecast/USID0170_f.html</link>
|
8
8
|
<description>Yahoo! Weather for Moscow, ID</description>
|
9
9
|
<language>en-us</language>
|
10
|
-
<lastBuildDate>Fri, 13 Sep 2013
|
10
|
+
<lastBuildDate>Fri, 13 Sep 2013 10:52 pm PDT</lastBuildDate>
|
11
11
|
<ttl>60</ttl>
|
12
12
|
<yweather:location city="Moscow" region="ID" country="United States"/>
|
13
13
|
<yweather:units temperature="F" distance="mi" pressure="in" speed="mph"/>
|
14
|
-
<yweather:wind chill="
|
15
|
-
<yweather:atmosphere humidity="
|
14
|
+
<yweather:wind chill="63" direction="0" speed="0" />
|
15
|
+
<yweather:atmosphere humidity="54" visibility="10" pressure="29.86" rising="1" />
|
16
16
|
<yweather:astronomy sunrise="6:22 am" sunset="7:04 pm"/>
|
17
17
|
<image>
|
18
18
|
<title>Yahoo! Weather</title>
|
@@ -22,16 +22,16 @@
|
|
22
22
|
<url>http://l.yimg.com/a/i/brand/purplelogo//uh/us/news-wea.gif</url>
|
23
23
|
</image>
|
24
24
|
<item>
|
25
|
-
<title>Conditions for Moscow, ID at
|
25
|
+
<title>Conditions for Moscow, ID at 10:52 pm PDT</title>
|
26
26
|
<geo:lat>46.7</geo:lat>
|
27
27
|
<geo:long>-116.92</geo:long>
|
28
28
|
<link>http://us.rd.yahoo.com/dailynews/rss/weather/Moscow__ID/*http://weather.yahoo.com/forecast/USID0170_f.html</link>
|
29
|
-
<pubDate>Fri, 13 Sep 2013
|
30
|
-
<yweather:condition text="Fair" code="33" temp="
|
29
|
+
<pubDate>Fri, 13 Sep 2013 10:52 pm PDT</pubDate>
|
30
|
+
<yweather:condition text="Fair" code="33" temp="63" date="Fri, 13 Sep 2013 10:52 pm PDT" />
|
31
31
|
<description><![CDATA[
|
32
32
|
<img src="http://l.yimg.com/a/i/us/we/52/33.gif"/><br />
|
33
33
|
<b>Current Conditions:</b><br />
|
34
|
-
Fair,
|
34
|
+
Fair, 63 F<BR />
|
35
35
|
<BR /><b>Forecast:</b><BR />
|
36
36
|
Fri - Mostly Clear. High: 88 Low: 58<br />
|
37
37
|
Sat - Mostly Sunny. High: 91 Low: 59<br />
|
@@ -52,5 +52,5 @@ Tue - Isolated Thunderstorms. High: 67 Low: 46<br />
|
|
52
52
|
</channel>
|
53
53
|
</rss>
|
54
54
|
|
55
|
-
<!--
|
56
|
-
:ET:@created_atf
|
55
|
+
<!-- api30.weather.gq1.yahoo.com Sat Sep 14 06:09:25 PST 2013 -->
|
56
|
+
:ET:@created_atf1379139226.475687:@expires_inf6e1
|
@@ -1,4 +1,4 @@
|
|
1
|
-
o: ActiveSupport::Cache::Entry:@valueI"�
|
1
|
+
o: ActiveSupport::Cache::Entry:@valueI"�
|
2
2
|
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
3
3
|
<rss version="2.0" xmlns:yweather="http://xml.weather.yahoo.com/ns/rss/1.0" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#">
|
4
4
|
<channel>
|
@@ -7,12 +7,12 @@
|
|
7
7
|
<link>http://us.rd.yahoo.com/dailynews/rss/weather/San_Francisco__CA/*http://weather.yahoo.com/forecast/USCA0987_f.html</link>
|
8
8
|
<description>Yahoo! Weather for San Francisco, CA</description>
|
9
9
|
<language>en-us</language>
|
10
|
-
<lastBuildDate>Fri, 13 Sep 2013
|
10
|
+
<lastBuildDate>Fri, 13 Sep 2013 10:52 pm PDT</lastBuildDate>
|
11
11
|
<ttl>60</ttl>
|
12
12
|
<yweather:location city="San Francisco" region="CA" country="United States"/>
|
13
13
|
<yweather:units temperature="F" distance="mi" pressure="in" speed="mph"/>
|
14
|
-
<yweather:wind chill="59" direction="
|
15
|
-
<yweather:atmosphere humidity="100" visibility="10" pressure="29.
|
14
|
+
<yweather:wind chill="59" direction="260" speed="13" />
|
15
|
+
<yweather:atmosphere humidity="100" visibility="10" pressure="29.83" rising="1" />
|
16
16
|
<yweather:astronomy sunrise="6:48 am" sunset="7:19 pm"/>
|
17
17
|
<image>
|
18
18
|
<title>Yahoo! Weather</title>
|
@@ -22,12 +22,12 @@
|
|
22
22
|
<url>http://l.yimg.com/a/i/brand/purplelogo//uh/us/news-wea.gif</url>
|
23
23
|
</image>
|
24
24
|
<item>
|
25
|
-
<title>Conditions for San Francisco, CA at
|
25
|
+
<title>Conditions for San Francisco, CA at 10:52 pm PDT</title>
|
26
26
|
<geo:lat>37.78</geo:lat>
|
27
27
|
<geo:long>-122.46</geo:long>
|
28
28
|
<link>http://us.rd.yahoo.com/dailynews/rss/weather/San_Francisco__CA/*http://weather.yahoo.com/forecast/USCA0987_f.html</link>
|
29
|
-
<pubDate>Fri, 13 Sep 2013
|
30
|
-
<yweather:condition text="Cloudy" code="26" temp="59" date="Fri, 13 Sep 2013
|
29
|
+
<pubDate>Fri, 13 Sep 2013 10:52 pm PDT</pubDate>
|
30
|
+
<yweather:condition text="Cloudy" code="26" temp="59" date="Fri, 13 Sep 2013 10:52 pm PDT" />
|
31
31
|
<description><![CDATA[
|
32
32
|
<img src="http://l.yimg.com/a/i/us/we/52/26.gif"/><br />
|
33
33
|
<b>Current Conditions:</b><br />
|
@@ -52,5 +52,5 @@ Tue - Sunny. High: 70 Low: 57<br />
|
|
52
52
|
</channel>
|
53
53
|
</rss>
|
54
54
|
|
55
|
-
<!--
|
56
|
-
:ET:@created_atf
|
55
|
+
<!-- api18.weather.gq1.yahoo.com Sat Sep 14 06:09:50 PST 2013 -->
|
56
|
+
:ET:@created_atf1379139267.966285:@expires_inf6e1
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yahoo_weather
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ildar Manzhikov
|
@@ -138,6 +138,7 @@ files:
|
|
138
138
|
- test/yahoo_weather_test.rb
|
139
139
|
- yahoo_weather.gemspec
|
140
140
|
- test/dummy/log/test.log
|
141
|
+
- test/dummy/tmp/cache/62E/480/woeid+for+Moscow
|
141
142
|
- test/dummy/tmp/cache/82F/B30/yahoo_weather_12794004_f
|
142
143
|
- test/dummy/tmp/cache/839/E20/yahoo_weather_12788173_f
|
143
144
|
- test/dummy/tmp/cache/839/F10/yahoo_weather_29391445_f
|
@@ -201,6 +202,7 @@ test_files:
|
|
201
202
|
- test/dummy/public/favicon.ico
|
202
203
|
- test/dummy/Rakefile
|
203
204
|
- test/dummy/README.rdoc
|
205
|
+
- test/dummy/tmp/cache/62E/480/woeid+for+Moscow
|
204
206
|
- test/dummy/tmp/cache/82F/B30/yahoo_weather_12794004_f
|
205
207
|
- test/dummy/tmp/cache/839/E20/yahoo_weather_12788173_f
|
206
208
|
- test/dummy/tmp/cache/839/F10/yahoo_weather_29391445_f
|