weather_hacker 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +4 -0
- data/README.md +4 -2
- data/Rakefile +17 -0
- data/lib/weather_hacker/client.rb +7 -7
- data/lib/weather_hacker/version.rb +1 -1
- data/spec/weather_hacker/client_spec.rb +5 -5
- data/weather_hacker.gemspec +2 -1
- metadata +25 -7
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
[![Build Status](https://secure.travis-ci.org/r7kamura/weather_hacker.png?branch=master)](http://travis-ci.org/r7kamura/weather_hacker)
|
2
|
+
|
1
3
|
# WeatherHacker
|
2
4
|
|
3
5
|
Library for [Livedoor Weather Web Service](http://weather.livedoor.com/weather_hacks/webservice.html)
|
@@ -29,14 +31,14 @@ client.get_weather(zipcode)
|
|
29
31
|
# "temperature" => { "max" => "18", "min" => "1" }
|
30
32
|
# }
|
31
33
|
|
32
|
-
client.get_weather(zipcode
|
34
|
+
client.get_weather(zipcode, :day => :tomorrow)
|
33
35
|
#=> {
|
34
36
|
# "weather" => "晴時々曇",
|
35
37
|
# "temperature" => { "max" => 21, "min" => 9 }
|
36
38
|
# }
|
37
39
|
|
38
40
|
|
39
|
-
client.get_weather(zipcode
|
41
|
+
client.get_weather(zipcode, :day => :dayaftertomorrow)
|
40
42
|
#=> {
|
41
43
|
# "weather" => "晴時々曇",
|
42
44
|
# "temperature" => { "max" => nil, "min" => nil }
|
data/Rakefile
CHANGED
@@ -1,2 +1,19 @@
|
|
1
1
|
#!/usr/bin/env rake
|
2
|
+
|
2
3
|
require "bundler/gem_tasks"
|
4
|
+
require "bundler"
|
5
|
+
|
6
|
+
begin
|
7
|
+
Bundler.setup(:default, :development)
|
8
|
+
rescue Bundler::BundlerError => e
|
9
|
+
$stderr.puts e.message
|
10
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
11
|
+
exit e.status_code
|
12
|
+
end
|
13
|
+
|
14
|
+
require "rspec/core"
|
15
|
+
require "rspec/core/rake_task"
|
16
|
+
|
17
|
+
RSpec::Core::RakeTask.new(:spec)
|
18
|
+
|
19
|
+
task :default => :spec
|
@@ -23,6 +23,13 @@ module WeatherHacker
|
|
23
23
|
}
|
24
24
|
end
|
25
25
|
|
26
|
+
private
|
27
|
+
|
28
|
+
# use HTTParty.get
|
29
|
+
def get(*args)
|
30
|
+
self.class.get(*args)
|
31
|
+
end
|
32
|
+
|
26
33
|
# set @pref_by_city and @id_by_city
|
27
34
|
def update_area_table
|
28
35
|
hash = get AREA_TABLE_URL
|
@@ -40,13 +47,6 @@ module WeatherHacker
|
|
40
47
|
id_by_city[city] || id_by_city[pref] || id_by_pref[pref]
|
41
48
|
end
|
42
49
|
|
43
|
-
private
|
44
|
-
|
45
|
-
# use HTTParty.get
|
46
|
-
def get(*args)
|
47
|
-
self.class.get(*args)
|
48
|
-
end
|
49
|
-
|
50
50
|
# return like following Hash
|
51
51
|
# {
|
52
52
|
# "state_kana" => "トウキョウト",
|
@@ -5,12 +5,12 @@ require "spec_helper"
|
|
5
5
|
describe "WeatherHacker::Client" do
|
6
6
|
before do
|
7
7
|
@client = WeatherHacker::Client.new
|
8
|
+
@zipcode = "690-0261"
|
8
9
|
end
|
9
10
|
|
10
11
|
describe "#get_weather" do
|
11
12
|
before do
|
12
|
-
|
13
|
-
@result = @client.get_weather(zipcode)
|
13
|
+
@result = @client.get_weather(@zipcode)
|
14
14
|
end
|
15
15
|
|
16
16
|
it "get parsed weather data in Hash" do
|
@@ -28,13 +28,13 @@ describe "WeatherHacker::Client" do
|
|
28
28
|
end
|
29
29
|
|
30
30
|
describe "#update_area_table" do
|
31
|
-
it "has not table
|
31
|
+
it "has not table before call" do
|
32
32
|
@client.instance_variable_get(:@id_by_city).should be_nil
|
33
33
|
@client.instance_variable_get(:@pref_by_city).should be_nil
|
34
34
|
end
|
35
35
|
|
36
36
|
it "has area table after call" do
|
37
|
-
@client.update_area_table
|
37
|
+
@client.send(:update_area_table)
|
38
38
|
@client.send(:id_by_city).keys.size.should_not == 0
|
39
39
|
@client.send(:pref_by_city).keys.size.should_not == 0
|
40
40
|
end
|
@@ -42,7 +42,7 @@ describe "WeatherHacker::Client" do
|
|
42
42
|
|
43
43
|
describe "#city_id_by_zipcode" do
|
44
44
|
it "return city_id" do
|
45
|
-
city_id = @client.city_id_by_zipcode
|
45
|
+
city_id = @client.send(:city_id_by_zipcode, @zipcode)
|
46
46
|
city_id.should be_kind_of Integer
|
47
47
|
end
|
48
48
|
end
|
data/weather_hacker.gemspec
CHANGED
@@ -6,7 +6,7 @@ Gem::Specification.new do |gem|
|
|
6
6
|
gem.email = ["r7kamura@gmail.com"]
|
7
7
|
gem.description = %q{Library for Livedoor Weather Web Service}
|
8
8
|
gem.summary = %q{Weather Forecaster via Livedoor Weather Web Service}
|
9
|
-
gem.homepage = "
|
9
|
+
gem.homepage = "http://r7kamura.github.com/weather_hacker/"
|
10
10
|
|
11
11
|
gem.files = `git ls-files`.split($\)
|
12
12
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
@@ -15,6 +15,7 @@ Gem::Specification.new do |gem|
|
|
15
15
|
gem.require_paths = ["lib"]
|
16
16
|
gem.version = WeatherHacker::VERSION
|
17
17
|
|
18
|
+
gem.add_dependency 'rake', '>= 0.9.2'
|
18
19
|
gem.add_dependency "httparty"
|
19
20
|
gem.add_development_dependency "rspec"
|
20
21
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: weather_hacker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,22 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-04-
|
12
|
+
date: 2012-04-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rake
|
16
|
+
requirement: &70309970750560 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 0.9.2
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70309970750560
|
14
25
|
- !ruby/object:Gem::Dependency
|
15
26
|
name: httparty
|
16
|
-
requirement: &
|
27
|
+
requirement: &70309970750140 !ruby/object:Gem::Requirement
|
17
28
|
none: false
|
18
29
|
requirements:
|
19
30
|
- - ! '>='
|
@@ -21,10 +32,10 @@ dependencies:
|
|
21
32
|
version: '0'
|
22
33
|
type: :runtime
|
23
34
|
prerelease: false
|
24
|
-
version_requirements: *
|
35
|
+
version_requirements: *70309970750140
|
25
36
|
- !ruby/object:Gem::Dependency
|
26
37
|
name: rspec
|
27
|
-
requirement: &
|
38
|
+
requirement: &70309970749680 !ruby/object:Gem::Requirement
|
28
39
|
none: false
|
29
40
|
requirements:
|
30
41
|
- - ! '>='
|
@@ -32,7 +43,7 @@ dependencies:
|
|
32
43
|
version: '0'
|
33
44
|
type: :development
|
34
45
|
prerelease: false
|
35
|
-
version_requirements: *
|
46
|
+
version_requirements: *70309970749680
|
36
47
|
description: Library for Livedoor Weather Web Service
|
37
48
|
email:
|
38
49
|
- r7kamura@gmail.com
|
@@ -41,6 +52,7 @@ extensions: []
|
|
41
52
|
extra_rdoc_files: []
|
42
53
|
files:
|
43
54
|
- .gitignore
|
55
|
+
- .travis.yml
|
44
56
|
- Gemfile
|
45
57
|
- LICENSE
|
46
58
|
- README.md
|
@@ -55,7 +67,7 @@ files:
|
|
55
67
|
- spec/weather_hacker/client_spec.rb
|
56
68
|
- spec/weather_hacker_spec.rb
|
57
69
|
- weather_hacker.gemspec
|
58
|
-
homepage:
|
70
|
+
homepage: http://r7kamura.github.com/weather_hacker/
|
59
71
|
licenses: []
|
60
72
|
post_install_message:
|
61
73
|
rdoc_options: []
|
@@ -67,12 +79,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
67
79
|
- - ! '>='
|
68
80
|
- !ruby/object:Gem::Version
|
69
81
|
version: '0'
|
82
|
+
segments:
|
83
|
+
- 0
|
84
|
+
hash: -1050853293578998898
|
70
85
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
86
|
none: false
|
72
87
|
requirements:
|
73
88
|
- - ! '>='
|
74
89
|
- !ruby/object:Gem::Version
|
75
90
|
version: '0'
|
91
|
+
segments:
|
92
|
+
- 0
|
93
|
+
hash: -1050853293578998898
|
76
94
|
requirements: []
|
77
95
|
rubyforge_project:
|
78
96
|
rubygems_version: 1.8.15
|