weather-report 0.3.1 → 0.3.2
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/.travis.yml +7 -0
- data/README.md +7 -0
- data/Rakefile +7 -0
- data/lib/weather-report/day.rb +12 -1
- data/lib/weather-report/version.rb +1 -1
- data/lib/weather-report/weather.rb +9 -1
- data/test/{weather-report/test_day.rb → test_day.rb} +12 -3
- data/test/test_helper.rb +2 -0
- data/test/test_weather-report.rb +1 -1
- data/test/{weather-report/test_weather.rb → test_weather.rb} +6 -1
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2b75cb645e6ecd1bf0b54880928626456b1194c5
|
4
|
+
data.tar.gz: 443e87046fdbfa512e7cccc8e0c9c66fc8a6f7a1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 21e6fa7479494286ab6a38c755678955fe20622a7cac1c3d0140aeaaf987aa650ea515e5f5764975158b25ac72ce623a6b547bab9b6f7f54c33297da56ab80ac
|
7
|
+
data.tar.gz: 888f337f9ae7380e454d9d19a07d2f5558b616aaa9fd66c54bab84c36db58ce8c7f5d7c1548a6fba85a8f481cb83964a0a345d87c92b36251df21d64634741df
|
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
A Ruby library and CLI to get Japanese Weather via Livedoor Weather Web Service(http://weather.livedoor.com/weather_hacks/webservice).
|
4
4
|
|
5
|
+
[](https://travis-ci.org/zakuni/weather-report)
|
6
|
+
|
5
7
|
## Installation
|
6
8
|
|
7
9
|
Add this line to your application's Gemfile:
|
@@ -21,6 +23,11 @@ Or install it yourself as:
|
|
21
23
|
```ruby
|
22
24
|
require 'weather-report'
|
23
25
|
|
26
|
+
# for easy use
|
27
|
+
tokyo = WeatherReport.get("東京")
|
28
|
+
tokyo.today.telop # => "晴れ"
|
29
|
+
|
30
|
+
# or you can write like this
|
24
31
|
id = WeatherReport::Weather.request_cityid("東京")
|
25
32
|
weather = WeatherReport::Weather.new(id)
|
26
33
|
weather.tomorrow.date # => <Date: 2013-05-04 ((2456417j,0s,0n),+0s,2299161j)>
|
data/Rakefile
CHANGED
data/lib/weather-report/day.rb
CHANGED
@@ -6,9 +6,19 @@ module WeatherReport
|
|
6
6
|
|
7
7
|
def initialize(forecasts, dateLabel)
|
8
8
|
@forecast = forecast(forecasts, dateLabel)
|
9
|
+
end
|
10
|
+
|
11
|
+
# @return [Trueclass, Falseclass] return true if it rains.
|
12
|
+
def rain?
|
13
|
+
telop =~ /[雨]/ ? true : false
|
14
|
+
end
|
15
|
+
|
16
|
+
# @return [Trueclass, Falseclass] return true if it snows.
|
17
|
+
def snow?
|
18
|
+
telop =~ /[雪]/ ? true : false
|
9
19
|
end
|
10
20
|
|
11
|
-
# @return [
|
21
|
+
# @return [Boolean] return true if it will be rainy or snowy or sleety or hailstorm
|
12
22
|
def umbrella?
|
13
23
|
telop =~ /[雨雪霙雹]/ ? true : false
|
14
24
|
end
|
@@ -40,6 +50,7 @@ module WeatherReport
|
|
40
50
|
max ? max["celsius"].to_i : nil
|
41
51
|
end
|
42
52
|
|
53
|
+
# @return [Hash] return with hash format.
|
43
54
|
def to_h
|
44
55
|
{
|
45
56
|
"date" => date.to_s,
|
@@ -31,11 +31,19 @@ module WeatherReport
|
|
31
31
|
@day_after_tomorrow ||= Day.new(forecasts, "明後日")
|
32
32
|
end
|
33
33
|
|
34
|
+
# @return [String] the URL of the requested livedoor weather
|
35
|
+
def link
|
36
|
+
@response ||= read
|
37
|
+
@response["link"]
|
38
|
+
end
|
39
|
+
|
40
|
+
# @return [Hash] the weather with Hash format
|
34
41
|
def to_h
|
35
42
|
{
|
36
43
|
"today" => today.to_h,
|
37
44
|
"tomorrow" => tomorrow.to_h,
|
38
|
-
"day_after_tomorrow" => day_after_tomorrow.to_h
|
45
|
+
"day_after_tomorrow" => day_after_tomorrow.to_h,
|
46
|
+
"link" => link
|
39
47
|
}
|
40
48
|
end
|
41
49
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# -*- coding: utf-8 -*-
|
3
|
-
require 'test_helper'
|
3
|
+
require File.expand_path 'test_helper', File.dirname(__FILE__)
|
4
4
|
|
5
5
|
class TestDay < MiniTest::Unit::TestCase
|
6
6
|
include WeatherReport
|
@@ -16,6 +16,14 @@ class TestDay < MiniTest::Unit::TestCase
|
|
16
16
|
assert_instance_of Day, Day.new(@forecasts, "明日")
|
17
17
|
end
|
18
18
|
|
19
|
+
def test_rain?
|
20
|
+
assert_respond_to @day, :rain?
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_snow?
|
24
|
+
assert_respond_to @day, :snow?
|
25
|
+
end
|
26
|
+
|
19
27
|
def test_umbrella?
|
20
28
|
assert_respond_to @day, :umbrella?
|
21
29
|
end
|
@@ -27,16 +35,17 @@ class TestDay < MiniTest::Unit::TestCase
|
|
27
35
|
|
28
36
|
def test_telop
|
29
37
|
assert_respond_to @day, :telop
|
38
|
+
assert_instance_of String, @day.telop
|
30
39
|
end
|
31
40
|
|
32
41
|
def test_temperature_min
|
33
42
|
assert_respond_to @day, :temperature_min
|
34
|
-
|
43
|
+
assert [Fixnum, NilClass].include? @day.temperature_min.class
|
35
44
|
end
|
36
45
|
|
37
46
|
def test_temperature_max
|
38
47
|
assert_respond_to @day, :temperature_max
|
39
|
-
|
48
|
+
assert [Fixnum, NilClass].include? @day.temperature_max.class
|
40
49
|
end
|
41
50
|
|
42
51
|
def test_to_h
|
data/test/test_helper.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
|
+
require 'rubygems'
|
1
2
|
require 'minitest/autorun'
|
2
3
|
require 'minitest/reporters'
|
3
4
|
require 'minitest/pride'
|
4
5
|
|
6
|
+
$:.unshift File.expand_path '../lib', File.dirname(__FILE__)
|
5
7
|
require 'weather-report'
|
6
8
|
|
7
9
|
MiniTest::Reporters.use! [MiniTest::Reporters::DefaultReporter.new, MiniTest::Reporters::GuardReporter.new]
|
data/test/test_weather-report.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# -*- coding: utf-8 -*-
|
3
|
-
require 'test_helper'
|
3
|
+
require File.expand_path 'test_helper', File.dirname(__FILE__)
|
4
4
|
|
5
5
|
class TestWeather < MiniTest::Unit::TestCase
|
6
6
|
include WeatherReport
|
@@ -38,6 +38,11 @@ class TestWeather < MiniTest::Unit::TestCase
|
|
38
38
|
assert_instance_of Day, day_after_tomorrow
|
39
39
|
end
|
40
40
|
|
41
|
+
def test_link
|
42
|
+
assert_respond_to @weather, :link
|
43
|
+
assert_instance_of String, @weather.link
|
44
|
+
end
|
45
|
+
|
41
46
|
def test_request_cityid
|
42
47
|
assert_respond_to Weather, :request_cityid
|
43
48
|
assert_equal "130010", Weather.request_cityid("東京")
|
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.3.
|
4
|
+
version: 0.3.2
|
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-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -118,6 +118,7 @@ extensions: []
|
|
118
118
|
extra_rdoc_files: []
|
119
119
|
files:
|
120
120
|
- .gitignore
|
121
|
+
- .travis.yml
|
121
122
|
- Gemfile
|
122
123
|
- Guardfile
|
123
124
|
- LICENSE.txt
|
@@ -128,10 +129,10 @@ files:
|
|
128
129
|
- lib/weather-report/day.rb
|
129
130
|
- lib/weather-report/version.rb
|
130
131
|
- lib/weather-report/weather.rb
|
132
|
+
- test/test_day.rb
|
131
133
|
- test/test_helper.rb
|
132
134
|
- test/test_weather-report.rb
|
133
|
-
- test/
|
134
|
-
- test/weather-report/test_weather.rb
|
135
|
+
- test/test_weather.rb
|
135
136
|
- weather-report.gemspec
|
136
137
|
homepage: https://github.com/zakuni/weather-report
|
137
138
|
licenses:
|
@@ -158,8 +159,8 @@ signing_key:
|
|
158
159
|
specification_version: 4
|
159
160
|
summary: A Ruby client of Livedoor Weather Web Service.
|
160
161
|
test_files:
|
162
|
+
- test/test_day.rb
|
161
163
|
- test/test_helper.rb
|
162
164
|
- test/test_weather-report.rb
|
163
|
-
- test/
|
164
|
-
- test/weather-report/test_weather.rb
|
165
|
+
- test/test_weather.rb
|
165
166
|
has_rdoc:
|