weather_jp 1.0.4 → 2.0.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/HISTORY.md DELETED
@@ -1,16 +0,0 @@
1
- v 1.0.4
2
-
3
- Bug fixes
4
-
5
- * Rain probability and tempratures are returned as Fixnum. [Sho Hashimoto - @shokai]
6
- * Can handle tempratures below zero. [Sho Hashimoto - @shokai]
7
-
8
- ----
9
-
10
- v 1.0.0
11
-
12
- Add parse method to WeatherJp
13
-
14
- see READEME for more description
15
-
16
- ----
@@ -1,107 +0,0 @@
1
- [![Build Status](https://secure.travis-ci.org/Taiki45/weather_jp.png?branch=master)](http://travis-ci.org/Taiki45/weather_jp)
2
-
3
- ## About
4
-
5
- 天気予報サービス API ラッパーです。
6
-
7
- 天気予報を簡単に Ruby オブジェクトにします。
8
-
9
- http://taiki45.github.com/weather_jp
10
-
11
- https://rubygems.org/gems/weather_jp
12
-
13
- ## インストール
14
-
15
- この一行をあなたのアプリケーションの Gemfile に追記して下さい:
16
-
17
- gem 'weather_jp'
18
-
19
- そしてこう実行します:
20
-
21
- $ bundle
22
-
23
- または gem コマンドを使ってインストールします:
24
-
25
- $ gem install weather_jp
26
-
27
- ## 使い方
28
-
29
- ```ruby
30
- # 全体の天気予報を扱うオブジェクトを作るいくつかの方法
31
- tokyo = WeatherJp.get :tokyo
32
- akiba = WeatherJp.get "秋葉原"
33
- abuja = WeatherJp::Weather.new("アブジャ")
34
- tsuyama = WeatherJp.get "津山"
35
-
36
- # 天気予報を文字列として取得
37
- tokyo.today.to_s
38
- #=> これは "東京都 東京の天気は曇りのち晴れ、最高気温34度...etc" になります
39
-
40
- # もしくは解析したい文字列があるなら
41
- WeatherJp.parse("今日のうどん県の天気教えて下され〜〜").to_s
42
- #=> "香川県 高松の今日の天気は曇のち晴れ 最高気温25度 最低気温17度 降水確率は20% です。"
43
-
44
- # Weather オブジェクトを取得するいくつかの方法
45
- akiba.get_weather(4) #=> <#DayWeather object>
46
- tokyo.today.forecast #=> can be "晴れ"
47
- tokyo.get_weather(:tomorrow).rain
48
- akiba.day_after_tomorrow.to_s
49
- WeatherJp.get(:tokyo, :today).forecast
50
-
51
- # Weather オブジェクトを使ってみる
52
- tokyo.each do |w|
53
- puts w.city_name
54
- puts w.day
55
- puts w.forecast
56
- puts w.max_temp
57
- puts w.min_temp
58
- puts w.rain
59
- w.each_pair {|k,v| puts k, v }
60
- end
61
-
62
- akiba.map {|w| [w.day, w.forecast] }
63
-
64
- # もしくは単純な Array や Hash として扱う方法
65
- tokyo.to_a
66
- tsuyama.each {|w| p w.to_hash }
67
- akiba.day_weathers
68
-
69
- # DayWeather#to_s メソッドをカスタマイズすることもできます
70
- WeatherJp.get(:tokyo).today.to_s #=> "東京 東京都の天気は晴れ....etc"
71
-
72
- WeatherJp.customize_to_s do
73
- word = "#{day}の#{city_name}は#{forecast} "
74
- word << "最高気温は#{max_temp} " if max_temp
75
- word << "最低気温は#{min_temp} " if min_temp
76
- word << "降水確率は#{rain}%" if rain
77
- word << "でし"
78
- word
79
- end
80
-
81
- WeatherJp.get(:tokyo).today.to_s #=> "本日の東京 東京都は晴れ...."
82
-
83
- ```
84
-
85
- ## 必要な環境
86
-
87
- Ruby >= 1.9.2
88
-
89
- ## ドキュメント
90
-
91
- http://rubydoc.info/gems/weather_jp/
92
-
93
- ## 作者
94
-
95
- [@taiki45](https://twitter.com/taiki45)
96
-
97
- ## 貢献方法
98
-
99
- 1. Fork してください
100
- 2. あなたの機能を盛り込んだブランチを作って下さい (`git checkout -b my-new-feature`)
101
- 3. コミットしてください (`git commit -am 'Added some feature'`)
102
- 4. あなたの変更をプッシュしてください (`git push origin my-new-feature`)
103
- 5. Pull Request を作ってください
104
-
105
- どんな要望やバグ報告、イッシュー、コメントも歓迎します
106
-
107
- Thank you :)
@@ -1,69 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- require 'spec_helper'
3
-
4
- describe "DayWeather" do
5
- before :all do
6
- @weather = WeatherJp.get(:tokyo, :today)
7
- end
8
-
9
- describe "#initialize" do
10
- it "should have @city_name" do
11
- @weather.city_name.should == "tokyo"
12
- end
13
-
14
- it "should have @weather as Hash" do
15
- @weather.instance_variable_get(:@weather).class.
16
- should == Hash
17
- end
18
- end
19
-
20
- describe "#inspect" do
21
- it "should return String" do
22
- @weather.inspect.class.should == String
23
- end
24
-
25
- it "should have certain format" do
26
- @weather.inspect.should == "#<DayWeather:@city_name = tokyo, @day=今日, @forecast=晴のち雨, @max_temp=29, @min_temp=24, @rain=80>"
27
- end
28
- end
29
-
30
- describe "#to_hash" do
31
- it "should return Hash" do
32
- @weather.to_hash.class.should == Hash
33
- end
34
-
35
- it "should be certain structure" do
36
- @weather.to_hash.should have_key(:day)
37
- @weather.to_hash.should have_key(:forecast)
38
- @weather.to_hash.should have_key(:max_temp)
39
- @weather.to_hash.should have_key(:rain)
40
- end
41
- end
42
-
43
- describe "#each" do
44
- it "should yield only value" do
45
- @weather.each {|v| v.class.should_not == Array }
46
- @weather.each do |v, n|
47
- n.should == nil
48
- end
49
- end
50
-
51
- it "should yield value" do
52
- ->(){ @weather.each {|v|} }.should_not raise_error(Exception)
53
- end
54
- end
55
-
56
- describe "#each_pair" do
57
- it "should yield pair" do
58
- ->(){ @weather.each_pair {|k,v|} }.
59
- should_not raise_error(Exception)
60
- end
61
- end
62
-
63
- describe "Enumerable#methods" do
64
- it "should not raise error when use Enumerable#mehod" do
65
- ->(){ @weather.map{|v| v } }.should_not raise_error(NoMethodError)
66
- end
67
- end
68
- end
69
-
@@ -1 +0,0 @@
1
- <?xml version="1.0" ?><?xml-stylesheet type='text/xsl' href='rss/xslt/rss-ja-JP.xsl' version='1.0'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>東京都 東京 - MSN 天気予報</title><link>http://weather.jp.msn.com/local.aspx?wealocations=wc:JAXX0085&amp;q=%e6%9d%b1%e4%ba%ac%e9%83%bd+%e6%9d%b1%e4%ba%ac&amp;src=rss</link><description>東京都 東京 の天気予報</description><image><url>http://kaw.stc.s-msn.com/as/wea3/i/ja/weather_h_pos_c_171x30.gif</url><title>MSN 天気予報</title><link>http://weather.jp.msn.com/default.aspx?src=rss</link></image><language>ja-JP</language><category>天気</category><ttl>60</ttl><lastBuildDate>Sat, 29 Sep 2012 16:00:00 GMT</lastBuildDate><generator>MSN 天気予報</generator><copyright>© 2012 Microsoft</copyright><item><title>東京都 東京 の 2012年9月30日 の天気予報</title><link>http://weather.jp.msn.com/local.aspx?wealocations=wc:JAXX0085&amp;q=%e6%9d%b1%e4%ba%ac%e9%83%bd+%e6%9d%b1%e4%ba%ac&amp;src=rss</link><pubDate>Sat, 29 Sep 2012 08:00:00 GMT</pubDate><guid isPermaLink="false">GUID:http://weather.msn.com/rss.aspx?wealocations=wc:JAXX0085&amp;q=%e6%9d%b1%e4%ba%ac%e9%83%bd+%e6%9d%b1%e4%ba%ac&amp;degreetype=C&amp;ja-JP+Sat, 29 Sep 2012 08:00:00 GMT+FORECAST</guid><description><![CDATA[<p><strong><a href="http://weather.jp.msn.com/local.aspx?wealocations=wc:JAXX0085&amp;q=%e6%9d%b1%e4%ba%ac%e9%83%bd+%e6%9d%b1%e4%ba%ac&amp;src=rss">今日</a>: </strong>晴のち雨.<img src="http://kaw.stc.s-msn.com/as/wea3/i/ja/saw/61.gif" width="35" height="21" alt="晴のち雨" title="晴のち雨" /> 最低: 24&#176;C. 最高: 29&#176;C. 降水確率: 80%<br /><strong><a href="http://weather.jp.msn.com/local.aspx?wealocations=wc:JAXX0085&amp;q=%e6%9d%b1%e4%ba%ac%e9%83%bd+%e6%9d%b1%e4%ba%ac&amp;src=rss">明日</a>: </strong>雨のち晴.<img src="http://kaw.stc.s-msn.com/as/wea3/i/ja/saw/66.gif" width="35" height="21" alt="雨のち晴" title="雨のち晴" /> 最低: 22&#176;C. 最高: 30&#176;C. 降水確率: 60%<br /><strong><a href="http://weather.jp.msn.com/local.aspx?wealocations=wc:JAXX0085&amp;q=%e6%9d%b1%e4%ba%ac%e9%83%bd+%e6%9d%b1%e4%ba%ac&amp;src=rss">火曜日</a>: </strong>曇時々晴.<img src="http://kaw.stc.s-msn.com/as/wea3/i/ja/saw/51.gif" width="35" height="21" alt="曇時々晴" title="曇時々晴" /> 最低: 22&#176;C. 最高: 27&#176;C. 降水確率: 30%<br /><strong><a href="http://weather.jp.msn.com/local.aspx?wealocations=wc:JAXX0085&amp;q=%e6%9d%b1%e4%ba%ac%e9%83%bd+%e6%9d%b1%e4%ba%ac&amp;src=rss">水曜日</a>: </strong>曇時々雨.<img src="http://kaw.stc.s-msn.com/as/wea3/i/ja/saw/52.gif" width="35" height="21" alt="曇時々雨" title="曇時々雨" /> 最低: 20&#176;C. 最高: 25&#176;C. 降水確率: 50%<br /><strong><a href="http://weather.jp.msn.com/local.aspx?wealocations=wc:JAXX0085&amp;q=%e6%9d%b1%e4%ba%ac%e9%83%bd+%e6%9d%b1%e4%ba%ac&amp;src=rss">木曜日</a>: </strong>曇り.<img src="http://kaw.stc.s-msn.com/as/wea3/i/ja/saw/26.gif" width="35" height="21" alt="曇り" title="曇り" /> 最低: 20&#176;C. 最高: 28&#176;C. 降水確率: 40%<br /></p><p><a href="http://weather.jp.msn.com/local.aspx?wealocations=wc:JAXX0085&amp;q=%e6%9d%b1%e4%ba%ac%e9%83%bd+%e6%9d%b1%e4%ba%ac&amp;src=rss">MSN 天気予報でもっと情報を見る</a><br />(Foreca 提供データ (米国およびカナダ以外), WDT 提供データ (米国およびカナダ向け))</p>]]></description></item></channel></rss>
@@ -1,33 +0,0 @@
1
- <?xml-stylesheet type='text/xsl' href='rss/xslt/rss-ja-JP.xsl' version='1.0'?>
2
- <rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
3
- <channel>
4
- <title>アメリカ合衆国 ニューヨーク - MSN 天気予報</title>
5
- <link>http://weather.jp.msn.com/local.aspx?wealocations=wc:USNY0996&amp;q=%e3%82%a2%e3%83%a1%e3%83%aa%e3%82%ab%e5%90%88%e8%a1%86%e5%9b%bd+%e3%83%8b%e3%83%a5%e3%83%bc%e3%83%a8%e3%83%bc%e3%82%af&amp;src=rss</link>
6
- <description>アメリカ合衆国 ニューヨーク の天気予報</description>
7
- <image>
8
- <url>http://kaw.stc.s-msn.com/as/wea3/i/ja/weather_h_pos_c_171x30.gif</url>
9
- <title>MSN 天気予報</title>
10
- <link>http://weather.jp.msn.com/default.aspx?src=rss</link>
11
- </image>
12
- <language>ja-JP</language>
13
- <category>天気</category>
14
- <ttl>60</ttl>
15
- <lastBuildDate>Mon, 08 Oct 2012 09:51:00 GMT</lastBuildDate>
16
- <generator>MSN 天気予報</generator>
17
- <copyright>© 2012 Microsoft</copyright>
18
- <item>
19
- <title>現在の天気: アメリカ合衆国 ニューヨークの晴れ (5時51分 2012年10月8日)</title>
20
- <link>http://weather.jp.msn.com/local.aspx?wealocations=wc:USNY0996&amp;q=%e3%82%a2%e3%83%a1%e3%83%aa%e3%82%ab%e5%90%88%e8%a1%86%e5%9b%bd+%e3%83%8b%e3%83%a5%e3%83%bc%e3%83%a8%e3%83%bc%e3%82%af&amp;src=rss</link>
21
- <pubDate>Mon, 08 Oct 2012 09:51:00 GMT</pubDate>
22
- <guid isPermaLink="false">GUID:http://weather.msn.com/rss.aspx?wealocations=wc:USNY0996&amp;q=%e3%82%a2%e3%83%a1%e3%83%aa%e3%82%ab%e5%90%88%e8%a1%86%e5%9b%bd+%e3%83%8b%e3%83%a5%e3%83%bc%e3%83%a8%e3%83%bc%e3%82%af&amp;degreetype=C&amp;ja-JP+Mon, 08 Oct 2012 09:51:00 GMT+CONDITIONS</guid>
23
- <description><![CDATA[<p><strong>現在の天気: (5時51分 現在)</strong><br /><img src="http://kaw.stc.s-msn.com/as/wea3/i/ja/law/31.gif" width="55" height="45" alt="晴れ" title="晴れ" /><br />晴れ. 7&#176;C (体感気温 8). 湿度: 89% 風速: 風向: 西北西 / 風速: 2 m/s.<br />アメリカ合衆国 ニューヨーク の現地時刻で表示<br /><a href="http://weather.jp.msn.com/tenday.aspx?wealocations=wc:USNY0996&amp;q=%e3%82%a2%e3%83%a1%e3%83%aa%e3%82%ab%e5%90%88%e8%a1%86%e5%9b%bd+%e3%83%8b%e3%83%a5%e3%83%bc%e3%83%a8%e3%83%bc%e3%82%af&amp;src=rss">10 日間予報の詳細</a>&nbsp;&nbsp;&nbsp;<a href="http://weather.jp.msn.com/hourly.aspx?wealocations=wc:USNY0996&amp;q=%e3%82%a2%e3%83%a1%e3%83%aa%e3%82%ab%e5%90%88%e8%a1%86%e5%9b%bd+%e3%83%8b%e3%83%a5%e3%83%bc%e3%83%a8%e3%83%bc%e3%82%af&amp;src=rss">時間毎の予報</a> &nbsp;&nbsp;&nbsp;<a href="http://weather.jp.msn.com/localmaps.aspx?wealocations=wc:USNY0996&amp;q=%e3%82%a2%e3%83%a1%e3%83%aa%e3%82%ab%e5%90%88%e8%a1%86%e5%9b%bd+%e3%83%8b%e3%83%a5%e3%83%bc%e3%83%a8%e3%83%bc%e3%82%af&amp;src=rss">天気画像</a> &nbsp;&nbsp;&nbsp;<a href="http://weather.jp.msn.com/monthly_averages.aspx?wealocations=wc:USNY0996&amp;q=%e3%82%a2%e3%83%a1%e3%83%aa%e3%82%ab%e5%90%88%e8%a1%86%e5%9b%bd+%e3%83%8b%e3%83%a5%e3%83%bc%e3%83%a8%e3%83%bc%e3%82%af&amp;src=rss">【平均値と観測史上の記録】 気温・降水量</a> </p>]]></description>
24
- </item>
25
- <item>
26
- <title>アメリカ合衆国 ニューヨーク の 2012年10月8日 の天気予報</title>
27
- <link>http://weather.jp.msn.com/local.aspx?wealocations=wc:USNY0996&amp;q=%e3%82%a2%e3%83%a1%e3%83%aa%e3%82%ab%e5%90%88%e8%a1%86%e5%9b%bd+%e3%83%8b%e3%83%a5%e3%83%bc%e3%83%a8%e3%83%bc%e3%82%af&amp;src=rss</link>
28
- <pubDate>Mon, 08 Oct 2012 09:00:00 GMT</pubDate>
29
- <guid isPermaLink="false">GUID:http://weather.msn.com/rss.aspx?wealocations=wc:USNY0996&amp;q=%e3%82%a2%e3%83%a1%e3%83%aa%e3%82%ab%e5%90%88%e8%a1%86%e5%9b%bd+%e3%83%8b%e3%83%a5%e3%83%bc%e3%83%a8%e3%83%bc%e3%82%af&amp;degreetype=C&amp;ja-JP+Mon, 08 Oct 2012 09:00:00 GMT+FORECAST</guid>
30
- <description><![CDATA[<p><strong><a href="http://weather.jp.msn.com/tenday.aspx?wealocations=wc:USNY0996&amp;q=%e3%82%a2%e3%83%a1%e3%83%aa%e3%82%ab%e5%90%88%e8%a1%86%e5%9b%bd+%e3%83%8b%e3%83%a5%e3%83%bc%e3%83%a8%e3%83%bc%e3%82%af&amp;src=rss">今日</a>: </strong>曇時々晴.<img src="http://kaw.stc.s-msn.com/as/wea3/i/ja/saw/28.gif" width="35" height="21" alt="曇時々晴" title="曇時々晴" /> 最低: 9&#176;C. 最高: 17&#176;C. 降水確率: 0%<br /><strong><a href="http://weather.jp.msn.com/tenday.aspx?wealocations=wc:USNY0996&amp;q=%e3%82%a2%e3%83%a1%e3%83%aa%e3%82%ab%e5%90%88%e8%a1%86%e5%9b%bd+%e3%83%8b%e3%83%a5%e3%83%bc%e3%83%a8%e3%83%bc%e3%82%af&amp;src=rss">明日</a>: </strong>雨.<img src="http://kaw.stc.s-msn.com/as/wea3/i/ja/saw/11.gif" width="35" height="21" alt="雨" title="雨" /> 最低: 15&#176;C. 最高: 16&#176;C. 降水確率: 40%<br /><strong><a href="http://weather.jp.msn.com/tenday.aspx?wealocations=wc:USNY0996&amp;q=%e3%82%a2%e3%83%a1%e3%83%aa%e3%82%ab%e5%90%88%e8%a1%86%e5%9b%bd+%e3%83%8b%e3%83%a5%e3%83%bc%e3%83%a8%e3%83%bc%e3%82%af&amp;src=rss">水曜日</a>: </strong>雨.<img src="http://kaw.stc.s-msn.com/as/wea3/i/ja/saw/11.gif" width="35" height="21" alt="雨" title="雨" /> 最低: 11&#176;C. 最高: 18&#176;C. 降水確率: 20%<br /><strong><a href="http://weather.jp.msn.com/tenday.aspx?wealocations=wc:USNY0996&amp;q=%e3%82%a2%e3%83%a1%e3%83%aa%e3%82%ab%e5%90%88%e8%a1%86%e5%9b%bd+%e3%83%8b%e3%83%a5%e3%83%bc%e3%83%a8%e3%83%bc%e3%82%af&amp;src=rss">木曜日</a>: </strong>晴れ.<img src="http://kaw.stc.s-msn.com/as/wea3/i/ja/saw/32.gif" width="35" height="21" alt="晴れ" title="晴れ" /> 最低: 11&#176;C. 最高: 17&#176;C. 降水確率: 0%<br /><strong><a href="http://weather.jp.msn.com/tenday.aspx?wealocations=wc:USNY0996&amp;q=%e3%82%a2%e3%83%a1%e3%83%aa%e3%82%ab%e5%90%88%e8%a1%86%e5%9b%bd+%e3%83%8b%e3%83%a5%e3%83%bc%e3%83%a8%e3%83%bc%e3%82%af&amp;src=rss">金曜日</a>: </strong>雨.<img src="http://kaw.stc.s-msn.com/as/wea3/i/ja/saw/11.gif" width="35" height="21" alt="雨" title="雨" /> 最低: 9&#176;C. 最高: 17&#176;C. 降水確率: 20%<br /></p><p><a href="http://weather.jp.msn.com/local.aspx?wealocations=wc:USNY0996&amp;q=%e3%82%a2%e3%83%a1%e3%83%aa%e3%82%ab%e5%90%88%e8%a1%86%e5%9b%bd+%e3%83%8b%e3%83%a5%e3%83%bc%e3%83%a8%e3%83%bc%e3%82%af&amp;src=rss">MSN 天気予報でもっと情報を見る</a><br />(Foreca 提供データ (米国およびカナダ以外), WDT 提供データ (米国およびカナダ向け))</p>]]></description>
31
- </item>
32
- </channel>
33
- </rss>
@@ -1,125 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- require 'spec_helper'
4
-
5
- describe "Weather" do
6
- describe "with Internet connetion" do
7
- before(:all) do
8
- @weather = WeatherJp::Weather.new(:tokyo)
9
- end
10
-
11
- describe "#initialize" do
12
- it "should have @area_code and can access" do
13
- @weather.area_code.should == "JAXX0085"
14
- end
15
-
16
- it "should accept Symbol argument" do
17
- weather = WeatherJp::Weather.new :tokyo
18
- weather.city_name.should == "tokyo"
19
- end
20
-
21
- it "should have @day_weathers as Array" do
22
- @weather.day_weathers.class.should == Array
23
- end
24
-
25
- it "should have DayWeather instance in @day_weathers" do
26
- @weather.day_weathers.each do |w|
27
- w.class.should == WeatherJp::Weather::DayWeather
28
- end
29
- end
30
-
31
- it "should have 5 DayWeather instance in @day_weathers" do
32
- @weather.day_weathers.size.should == 5
33
- end
34
- end
35
-
36
- describe "#to_hash" do
37
- it "should return Array and include Hashs" do
38
- @weather.to_hash.class.should == Array
39
- @weather.to_hash.each {|e| e.class.should == Hash }
40
- end
41
-
42
- it "should return with vaild structure" do
43
- @weather.to_hash.each do |e|
44
- e.should have_key(:day)
45
- e.should have_key(:forecast)
46
- e.should have_key(:max_temp)
47
- e.should have_key(:rain)
48
- end
49
- end
50
- end
51
-
52
- describe "#to_a" do
53
- it "should return and behavior same as #to_hash" do
54
- @weather.to_a.should equal(@weather.to_hash)
55
- end
56
- end
57
-
58
- describe "#each" do
59
- it "should yield DayWeather object" do
60
- @weather.each {|w| w.class.should == WeatherJp::Weather::DayWeather }
61
- end
62
- end
63
-
64
- describe "Enumerable mehods" do
65
- it "should respond to Enumerable methods" do
66
- @weather.should respond_to(:map)
67
- end
68
-
69
- it "should yield DayWeather Object" do
70
- @weather.map {|w| w.class.should == WeatherJp::Weather::DayWeather }
71
- end
72
- end
73
-
74
- describe "#get_weather" do
75
- it "should accept Symbol argument" do
76
- ->(){ @weather.get_weather(:today) }.
77
- should_not raise_error(WeatherJp::WeatherJpError)
78
- ->(){ @weather.get_weather(:tomorrow) }.
79
- should_not raise_error(WeatherJp::WeatherJpError)
80
- end
81
-
82
- it "should accept String argument" do
83
- ->(){ @weather.get_weather('today') }.
84
- should_not raise_error(WeatherJp::WeatherJpError)
85
- ->(){ @weather.get_weather('tomorrow') }.
86
- should_not raise_error(WeatherJp::WeatherJpError)
87
- end
88
-
89
- it "should accept 0 to 4 number as argument" do
90
- (0..4).each do |n|
91
- ->(){ @weather.get_weather(n) }.
92
- should_not raise_error(WeatherJp::WeatherJpError)
93
- end
94
- end
95
-
96
- it "should raise WeatherJp::WeatherJpError when got invaild aregument" do
97
- ->(){ @weather.get_weather(:yesterday) }.
98
- should raise_error(WeatherJp::WeatherJpError)
99
- ->(){ @weather.get_weather(5) }.
100
- should raise_error(WeatherJp::WeatherJpError)
101
- end
102
-
103
- it "should return DayWeather object" do
104
- @weather.get_weather(0).class.
105
- should == WeatherJp::Weather::DayWeather
106
- end
107
- end
108
-
109
- describe "#today, #tomorrow, #day_after_tomorrow" do
110
- it "should not error when call #today or something" do
111
- %w(today tomorrow day_after_tomorrow).each do |s|
112
- ->(){ @weather.send(s.to_sym) }.
113
- should_not raise_error(NoMethodError)
114
- end
115
- end
116
-
117
- it "should return DayWeather object" do
118
- %w(today tomorrow day_after_tomorrow).each do |s|
119
- @weather.send(s.to_sym).class.
120
- should == WeatherJp::Weather::DayWeather
121
- end
122
- end
123
- end
124
- end
125
- end
@@ -1,56 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- require 'spec_helper'
3
-
4
- describe "Wrapper" do
5
- describe ".set_weathers" do
6
- it "should make vaild data" do
7
- expect = [{:day=>"今日", :forecast=>"晴のち雨", :max_temp=>29, :min_temp=>24, :rain=>80},
8
- {:day=>"明日", :forecast=>"雨のち晴", :max_temp=>30, :min_temp=>22, :rain=>60},
9
- {:day=>"火曜日", :forecast=>"曇時々晴", :max_temp=>27, :min_temp=>22, :rain=>30},
10
- {:day=>"水曜日", :forecast=>"曇時々雨", :max_temp=>25, :min_temp=>20, :rain=>50},
11
- {:day=>"木曜日", :forecast=>"曇り", :max_temp=>28, :min_temp=>20, :rain=>40},
12
- {:day=>"金曜日", :forecast=>"曇り", :max_temp=>-3, :min_temp=>-20, :rain=>40}
13
- ]
14
- dummy_data = ["今日: 晴のち雨. 最低: 24&#176;C. 最高: 29&#176;C. 降水確率: 80",
15
- "明日: 雨のち晴. 最低: 22&#176;C. 最高: 30&#176;C. 降水確率: 60",
16
- "火曜日: 曇時々晴. 最低: 22&#176;C. 最高: 27&#176;C. 降水確率: 30",
17
- "水曜日: 曇時々雨. 最低: 20&#176;C. 最高: 25&#176;C. 降水確率: 50",
18
- "木曜日: 曇り. 最低: 20&#176;C. 最高: 28&#176;C. 降水確率: 40",
19
- "金曜日: 曇り. 最低: -20&#176;C. 最高: -3&#176;C. 降水確率: 40"
20
- ]
21
- WeatherJp::Wrapper.set_weathers(dummy_data).should == expect
22
- end
23
-
24
- it "should parse non-japan weather info" do
25
- #expect = [{:day=>"現在の天気", :forecast=>"(5時51分 現在)晴れ", :max_temp=>nil, :min_temp=>nil, :rain=>nil}]
26
- expect = [{:day=>"現在", :forecast=>"(5時51分 現在)晴れ", :max_temp=>nil, :min_temp=>nil, :rain=>nil}]
27
- dummy = ["現在の天気: (5時51分 現在)晴れ. 7&#176;C (体感気温 8). 湿度: 89"]
28
- WeatherJp::Wrapper.set_weathers(dummy).should == expect
29
- end
30
- end
31
-
32
- describe ".parse_rss" do
33
- it "should parse rss data" do
34
- expect = ["今日: 晴のち雨. 最低: 24&#176;C. 最高: 29&#176;C. 降水確率: 80",
35
- "明日: 雨のち晴. 最低: 22&#176;C. 最高: 30&#176;C. 降水確率: 60",
36
- "火曜日: 曇時々晴. 最低: 22&#176;C. 最高: 27&#176;C. 降水確率: 30",
37
- "水曜日: 曇時々雨. 最低: 20&#176;C. 最高: 25&#176;C. 降水確率: 50",
38
- "木曜日: 曇り. 最低: 20&#176;C. 最高: 28&#176;C. 降水確率: 40"
39
- ]
40
- WeatherJp::Wrapper.parse_rss(get_dummy_rss).should == expect
41
- end
42
-
43
- it "should parse non-japan data" do
44
- expect = ["現在の天気: (5時51分 現在)晴れ. 7&#176;C (体感気温 8). 湿度: 89"]
45
- WeatherJp::Wrapper.parse_rss(get_ny_rss).should == expect
46
- end
47
-
48
- describe ".remove_html_tag" do
49
- it "should remove html tags" do
50
- str = %q(<html>a<a href="dummy">b</a><span>c</sapan></html>)
51
- WeatherJp::Wrapper.remove_html_tag(str).should == %(""a""b""""c"""")
52
- end
53
- end
54
- end
55
- end
56
-