weather-report 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a4f67b3b626ee3062de01ce4de35db316294011d
4
- data.tar.gz: 862150e4ee81120765b9d670e88cc5a3885f9408
3
+ metadata.gz: 2b75cb645e6ecd1bf0b54880928626456b1194c5
4
+ data.tar.gz: 443e87046fdbfa512e7cccc8e0c9c66fc8a6f7a1
5
5
  SHA512:
6
- metadata.gz: df4f657b9bb1b5e4a9d7b0eaa4fb4e44198e7db04ac1af56d734b48cefd3bdb76095f599d613c54af2a229d8aa18836b1e8dc4e9f0bcc77d51b22a1e5e972786
7
- data.tar.gz: 9eadde1bb864a2f20a5afc9631459fd5c53e671bbee7ebde84eca34644556f891c035db806072bb106e29d11214d136964e19026270fe95ba3d3ef30a9c612e3
6
+ metadata.gz: 21e6fa7479494286ab6a38c755678955fe20622a7cac1c3d0140aeaaf987aa650ea515e5f5764975158b25ac72ce623a6b547bab9b6f7f54c33297da56ab80ac
7
+ data.tar.gz: 888f337f9ae7380e454d9d19a07d2f5558b616aaa9fd66c54bab84c36db58ce8c7f5d7c1548a6fba85a8f481cb83964a0a345d87c92b36251df21d64634741df
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ language: ruby
2
+ rvm:
3
+ - "1.9.2"
4
+ - "1.9.3"
5
+ - "2.0.0"
6
+ - jruby-19mode # JRuby in 1.9 mode
7
+ - rbx-19mode
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
+ [![Build Status](https://travis-ci.org/zakuni/weather-report.png)](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
@@ -1 +1,8 @@
1
1
  require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new do |t|
5
+ t.pattern = "test/test_*.rb"
6
+ end
7
+
8
+ task :default => :test
@@ -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 [Trueclass, Falseclass] return true if it will be rainy or snowy or sleety or hailstorm
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,
@@ -1,3 +1,3 @@
1
1
  module WeatherReport
2
- VERSION = "0.3.1"
2
+ VERSION = "0.3.2"
3
3
  end
@@ -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
- assert_instance_of Fixnum, @day.temperature_min
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
- assert_instance_of Fixnum, @day.temperature_max
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]
@@ -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 TestWeatherReport < MiniTest::Unit::TestCase
6
6
 
@@ -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.1
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-04 00:00:00.000000000 Z
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/weather-report/test_day.rb
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/weather-report/test_day.rb
164
- - test/weather-report/test_weather.rb
165
+ - test/test_weather.rb
165
166
  has_rdoc: