weather-report 0.1.1 → 0.2.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.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/bin/weather-report +3 -0
- data/lib/weather-report.rb +4 -0
- data/lib/weather-report/day.rb +9 -0
- data/lib/weather-report/version.rb +1 -1
- data/lib/weather-report/weather.rb +10 -2
- data/test/test_weather-report.rb +5 -1
- data/test/weather-report/test_day.rb +5 -0
- data/test/weather-report/test_weather.rb +5 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b9a69683ca8b735ec9e07e7d122d9fd211c0d6f4
|
4
|
+
data.tar.gz: 48b6373985b7cbd42f832a039ac8433c1b3765c7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 718e0f6b78773654966babdce38df8d48b53153456ab38d80b9c0cb03e4c3e68eb21dbe96d6c9035ff900e93c7bcb8879cb4e4139963712414884fae3b5d2aa6
|
7
|
+
data.tar.gz: bd80b590a03d97349c2528b701ee10b503f594ae3434ff47c508c59ce857cbdea5354dfe02db496399766f8dc972043707629f4d166418be9f1d6eb426cf61f6
|
data/README.md
CHANGED
@@ -23,7 +23,7 @@ require 'weather-report'
|
|
23
23
|
|
24
24
|
id = WeatherReport::Weather.request_cityid("東京")
|
25
25
|
weather = WeatherReport::Weather.new(id)
|
26
|
-
weather.tomorrow.date # => Date: 2013-05-04 ((2456417j,0s,0n),+0s,2299161j)>
|
26
|
+
weather.tomorrow.date # => <Date: 2013-05-04 ((2456417j,0s,0n),+0s,2299161j)>
|
27
27
|
weather.tomorrow.telop # => "雨"
|
28
28
|
weather.tomorrow.temperature_min # => 12
|
29
29
|
```
|
data/bin/weather-report
CHANGED
data/lib/weather-report.rb
CHANGED
data/lib/weather-report/day.rb
CHANGED
@@ -35,6 +35,15 @@ module WeatherReport
|
|
35
35
|
max ? max["celsius"].to_i : nil
|
36
36
|
end
|
37
37
|
|
38
|
+
def to_h
|
39
|
+
{
|
40
|
+
"date" => date.to_s,
|
41
|
+
"telop" => telop,
|
42
|
+
"temperature_min" => temperature_min,
|
43
|
+
"temperature_max" => temperature_max
|
44
|
+
}
|
45
|
+
end
|
46
|
+
|
38
47
|
private
|
39
48
|
|
40
49
|
def forecast(forecasts, dateLabel)
|
@@ -12,7 +12,7 @@ module WeatherReport
|
|
12
12
|
def self.request_cityid(city)
|
13
13
|
doc = Nokogiri::XML(open("http://weather.livedoor.com/forecast/rss/primary_area.xml"))
|
14
14
|
doc.search("//city[@title='#{city}']").attr("id").value
|
15
|
-
rescue
|
15
|
+
rescue => e
|
16
16
|
raise WeatherReportError
|
17
17
|
end
|
18
18
|
|
@@ -31,6 +31,14 @@ module WeatherReport
|
|
31
31
|
@day_after_tomorrow ||= Day.new(forecasts, "明後日")
|
32
32
|
end
|
33
33
|
|
34
|
+
def to_h
|
35
|
+
{
|
36
|
+
"today" => today.to_h,
|
37
|
+
"tomorrow" => tomorrow.to_h,
|
38
|
+
"day_after_tomorrow" => day_after_tomorrow.to_h
|
39
|
+
}
|
40
|
+
end
|
41
|
+
|
34
42
|
private
|
35
43
|
|
36
44
|
def forecasts
|
@@ -39,7 +47,7 @@ module WeatherReport
|
|
39
47
|
|
40
48
|
def read
|
41
49
|
@response ||= JSON.parse(@uri.read)
|
42
|
-
rescue e
|
50
|
+
rescue => e
|
43
51
|
raise WeatherReportError
|
44
52
|
end
|
45
53
|
end
|
data/test/test_weather-report.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: weather-report
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- zakuni
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-05-
|
11
|
+
date: 2013-05-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|