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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 21f33d31b5402a8844fa701e0f2b0079baeceb84
4
- data.tar.gz: 2c5002c638c342d9dfb3b676c3d45679a49faf4e
3
+ metadata.gz: 0ec45b4a14877f783fb1a8b539cb66b8c64f6ac2
4
+ data.tar.gz: 4e1381664533e1e69ae30ca633861aaddf4604be
5
5
  SHA512:
6
- metadata.gz: 7300e7478a281ddcd8526a50b694746d51ed8ad2a6ccbe49528867985e3b7857cbffe7cb01fca139424cd0c3651a6180a96e0b5ade9d968c1e7126e44bb742d7
7
- data.tar.gz: 933637281f0dc76727b6f42d99dbba38e7c84af770c27748443a5aee894f2e301cece0f82736cb117eb8054bf67ff043d6b1afca8461f4b6eb1fb181f569e2e7
6
+ metadata.gz: 1d672b20528094eb6200d183bf4c01f817f28c2bc6ec40c4d64eb75b310ef62e82ae173001837150346bbe2067dec0fcba9ee5e3f15e36814756d7776b6fecea
7
+ data.tar.gz: 6324edf6b7d22e017bbe04e1c8c441eba474f9844edd10ff9ebf9d16674735dee6d6f9a077d61a6531ca6acf33a86f3b883a9313579f9ddc23884edeb9257a30
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- yahoo_weather (1.0.6)
4
+ yahoo_weather (1.0.7)
5
5
  nokogiri
6
6
  rails (>= 3.1.0)
7
7
 
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
 
@@ -9,10 +9,16 @@ class YahooWeather::Client
9
9
  end
10
10
 
11
11
  def fetch_by_location(location, units = YahooWeather::Units::FAHRENHEIT)
12
- 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"
13
- xml = fetch_xml(url)
14
- doc = Nokogiri::XML(xml)
15
- woeid = doc.at('woeid').children.text
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
@@ -1,3 +1,3 @@
1
1
  module YahooWeather
2
- VERSION = '1.0.6'.freeze
2
+ VERSION = '1.0.7'.freeze
3
3
  end
@@ -326,5 +326,60 @@ YahooWeatherTest: test_Units
326
326
   (0.1ms) begin transaction
327
327
  ---------------------------
328
328
  YahooWeatherTest: test_Wind
329
+ ---------------------------
330
+  (0.1ms) rollback transaction
331
+  (0.4ms) begin transaction
332
+ --------------------------------
333
+ YahooWeatherTest: test_Astronomy
334
+ --------------------------------
335
+  (0.1ms) rollback transaction
336
+  (0.1ms) begin transaction
337
+ ---------------------------------
338
+ YahooWeatherTest: test_Atmosphere
339
+ ---------------------------------
340
+  (0.1ms) rollback transaction
341
+  (0.1ms) begin transaction
342
+ --------------------------------
343
+ YahooWeatherTest: test_Condition
344
+ --------------------------------
345
+  (0.1ms) rollback transaction
346
+  (0.1ms) begin transaction
347
+ -------------------------------------
348
+ YahooWeatherTest: test_Fetch_by_WOEID
349
+ -------------------------------------
350
+  (0.0ms) rollback transaction
351
+  (0.1ms) begin transaction
352
+ --------------------------------------------------
353
+ YahooWeatherTest: test_Fetch_with_the_bad_response
354
+ --------------------------------------------------
355
+  (0.1ms) rollback transaction
356
+  (0.1ms) begin transaction
357
+ --------------------------------
358
+ YahooWeatherTest: test_Forecasts
359
+ --------------------------------
360
+  (0.1ms) rollback transaction
361
+  (0.0ms) begin transaction
362
+ ------------------------------
363
+ YahooWeatherTest: test_General
364
+ ------------------------------
365
+  (0.1ms) rollback transaction
366
+  (0.0ms) begin transaction
367
+ -------------------------------
368
+ YahooWeatherTest: test_Location
369
+ -------------------------------
370
+  (0.0ms) rollback transaction
371
+  (0.0ms) begin transaction
372
+ ---------------------------------------
373
+ YahooWeatherTest: test_Success_response
374
+ ---------------------------------------
375
+  (0.1ms) rollback transaction
376
+  (0.1ms) begin transaction
377
+ ----------------------------
378
+ YahooWeatherTest: test_Units
379
+ ----------------------------
380
+  (0.0ms) rollback transaction
381
+  (0.0ms) begin transaction
382
+ ---------------------------
383
+ YahooWeatherTest: test_Wind
329
384
  ---------------------------
330
385
   (0.1ms) 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 9:53 pm PDT</lastBuildDate>
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="64" direction="0" speed="0" />
15
- <yweather:atmosphere humidity="52" visibility="9" pressure="29.84" rising="0" />
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 9:53 pm PDT</title>
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 9:53 pm PDT</pubDate>
30
- <yweather:condition text="Fair" code="33" temp="64" date="Fri, 13 Sep 2013 9:53 pm PDT" />
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, 64 F<BR />
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
- <!-- api8.weather.gq1.yahoo.com Sat Sep 14 05:45:40 PST 2013 -->
56
- :ET:@created_atf1379137646.7612648:@expires_inf6e1
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 9:53 pm PDT</lastBuildDate>
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="270" speed="14" />
15
- <yweather:atmosphere humidity="100" visibility="10" pressure="29.82" rising="0" />
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 9:53 pm PDT</title>
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 9:53 pm PDT</pubDate>
30
- <yweather:condition text="Cloudy" code="26" temp="59" date="Fri, 13 Sep 2013 9:53 pm PDT" />
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
- <!-- api26.weather.gq1.yahoo.com Sat Sep 14 05:48:21 PST 2013 -->
56
- :ET:@created_atf1379137770.996958:@expires_inf6e1
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.6
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