weatherhacks 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.
- data/History.txt +12 -3
- data/License.txt +1 -1
- data/Manifest.txt +0 -18
- data/README.txt +18 -7
- data/Rakefile +22 -3
- data/bin/lwws +0 -0
- data/lib/weatherhacks.rb +17 -1
- data/lib/weatherhacks/lwws.rb +27 -14
- data/spec/lwws_spec.rb +115 -122
- metadata +41 -57
- data/config/hoe.rb +0 -71
- data/config/requirements.rb +0 -17
- data/lib/weatherhacks/version.rb +0 -9
- data/script/destroy +0 -14
- data/script/generate +0 -14
- data/script/txt2html +0 -74
- data/spec/spec.opts +0 -1
- data/spec/spec_helper.rb +0 -11
- data/tasks/deployment.rake +0 -34
- data/tasks/environment.rake +0 -7
- data/tasks/rspec.rake +0 -21
- data/tasks/weatherhacks.rake +0 -20
- data/tasks/website.rake +0 -17
- data/website/index.html +0 -121
- data/website/index.txt +0 -57
- data/website/javascripts/rounded_corners_lite.inc.js +0 -285
- data/website/stylesheets/screen.css +0 -138
- data/website/template.rhtml +0 -48
data/History.txt
CHANGED
@@ -1,9 +1,18 @@
|
|
1
|
+
== 0.2.0 2008-04-11
|
2
|
+
|
3
|
+
* Keita Yamaguchi
|
4
|
+
* GitHub: http://github.com/keita/ruby-weatherhacks/tree/master
|
5
|
+
* Reduced files included in the gem package
|
6
|
+
* New: WeatherHacks.lwws and WeatherHacks::LWWS[] are alias of WeatherHacks::LWWS.request
|
7
|
+
* WeatherHacks::LWWS.request can handle city name(e.g. request("松江"))
|
8
|
+
* WeatherHacks::LWWS.request(city, :all) returns 3 days forecasts.
|
9
|
+
|
1
10
|
== 0.1.1 2007-12-12
|
2
11
|
|
3
|
-
* Keita Yamaguchi
|
4
|
-
*
|
12
|
+
* Keita Yamaguchi
|
13
|
+
* Fixed bin/lwws
|
5
14
|
|
6
15
|
== 0.1.0 2007-12-12
|
7
16
|
|
8
|
-
* Keita Yamaguchi
|
17
|
+
* Keita Yamaguchi
|
9
18
|
* Initial release
|
data/License.txt
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
ruby-weatherhacks is copyrighted free software by Keita Yamaguchi <keita.yamaguchi@gmail.com>.
|
2
2
|
You can redistribute it and/or modify it under either the terms of the GPL
|
3
3
|
(see the file GPL), or the conditions below:
|
4
4
|
|
data/Manifest.txt
CHANGED
@@ -4,27 +4,9 @@ Manifest.txt
|
|
4
4
|
README.txt
|
5
5
|
Rakefile
|
6
6
|
bin/lwws
|
7
|
-
config/hoe.rb
|
8
|
-
config/requirements.rb
|
9
7
|
lib/weatherhacks.rb
|
10
8
|
lib/weatherhacks/forecastmap.rb
|
11
9
|
lib/weatherhacks/lwws.rb
|
12
|
-
lib/weatherhacks/version.rb
|
13
10
|
misc/forecastmap.xsl
|
14
|
-
script/destroy
|
15
|
-
script/generate
|
16
|
-
script/txt2html
|
17
11
|
setup.rb
|
18
12
|
spec/lwws_spec.rb
|
19
|
-
spec/spec.opts
|
20
|
-
spec/spec_helper.rb
|
21
|
-
tasks/deployment.rake
|
22
|
-
tasks/environment.rake
|
23
|
-
tasks/rspec.rake
|
24
|
-
tasks/weatherhacks.rake
|
25
|
-
tasks/website.rake
|
26
|
-
website/index.html
|
27
|
-
website/index.txt
|
28
|
-
website/javascripts/rounded_corners_lite.inc.js
|
29
|
-
website/stylesheets/screen.css
|
30
|
-
website/template.rhtml
|
data/README.txt
CHANGED
@@ -1,9 +1,20 @@
|
|
1
|
-
|
2
|
-
============================
|
3
|
-
ruby-weatherhacks is a wrapper library for livdoor WeatherHacks API.
|
1
|
+
= ruby-weatherhacks
|
4
2
|
|
5
|
-
|
6
|
-
|
3
|
+
Author:: Keita Yamaguchi(山口 慶太) <keita.yamaguchi@gmail.com>
|
4
|
+
Copyright:: © Keita Yamaguchi, 2007ー2008. All rights reserved.
|
5
|
+
License:: Ruby License
|
7
6
|
|
8
|
-
|
9
|
-
|
7
|
+
ruby-weatherhacks is a wrapper library for {livdoor WeatherHacks}[http://weather.livedoor.com/weather_hacks/] API.
|
8
|
+
|
9
|
+
== Usage
|
10
|
+
|
11
|
+
See {the documentation}[http://github.com/keita/ruby-weatherhacks/wikis].
|
12
|
+
|
13
|
+
== Links
|
14
|
+
|
15
|
+
* {livedoor WeatherHacks}[http://weather.livedoor.com/weather_hacks/]
|
16
|
+
* ruby-weatherhacks
|
17
|
+
* {RubyForge}[http://rubyforge.org/projects/weatherhacks/]
|
18
|
+
* {GitHub}[http://github.com/keita/ruby-weatherhacks/tree/master]
|
19
|
+
* author's blog(written in Japanese)
|
20
|
+
* {¬¬日常日記}[http://d.hatena.ne.jp/keita_yamaguchi/]
|
data/Rakefile
CHANGED
@@ -1,4 +1,23 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "rubygems"
|
2
|
+
require "rtask"
|
3
|
+
|
4
|
+
RTask.new
|
5
|
+
|
6
|
+
desc "Run the specs"
|
7
|
+
task :spec do
|
8
|
+
sh "bacon"
|
9
|
+
end
|
10
|
+
|
11
|
+
desc 'Update forecastmap.rb'
|
12
|
+
task :forecastmap do
|
13
|
+
# download forecastmap.xml
|
14
|
+
url = "http://weather.livedoor.com/forecast/rss/forecastmap.xml"
|
15
|
+
sh "wget -O forecastmap.xml #{url}"
|
16
|
+
# generate
|
17
|
+
out = "lib/weatherhacks/forecastmap.rb"
|
18
|
+
xsl = "misc/forecastmap.xsl"
|
19
|
+
sh "xsltproc -o #{out} #{xsl} forecastmap.xml"
|
20
|
+
# remove
|
21
|
+
sh "rm forecastmap.xml"
|
22
|
+
end
|
3
23
|
|
4
|
-
Dir['tasks/**/*.rake'].each { |rake| load rake }
|
data/bin/lwws
CHANGED
File without changes
|
data/lib/weatherhacks.rb
CHANGED
@@ -1,4 +1,13 @@
|
|
1
1
|
module WeatherHacks
|
2
|
+
module Version #:nodoc:
|
3
|
+
MAJOR = 0
|
4
|
+
MINOR = 2
|
5
|
+
TINY = 0
|
6
|
+
|
7
|
+
STRING = [MAJOR, MINOR, TINY].join('.')
|
8
|
+
end
|
9
|
+
VERSION = Version::STRING
|
10
|
+
|
2
11
|
module ForecastMap
|
3
12
|
class Area
|
4
13
|
attr_reader :name, :rss, :prefs
|
@@ -55,4 +64,11 @@ end
|
|
55
64
|
|
56
65
|
require "weatherhacks/lwws"
|
57
66
|
require "weatherhacks/forecastmap"
|
58
|
-
|
67
|
+
|
68
|
+
module WeatherHacks
|
69
|
+
module_function
|
70
|
+
|
71
|
+
def lwws(city, day = :all)
|
72
|
+
LWWS.request(city, day)
|
73
|
+
end
|
74
|
+
end
|
data/lib/weatherhacks/lwws.rb
CHANGED
@@ -121,20 +121,33 @@ module WeatherHacks::LWWS
|
|
121
121
|
end
|
122
122
|
end
|
123
123
|
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
124
|
+
class << self
|
125
|
+
|
126
|
+
# Returns a Forecast object.
|
127
|
+
# city_id:: city id
|
128
|
+
# day:: :today, :tomorrow or :dayaftertomorrow
|
129
|
+
def request(city, day = :all)
|
130
|
+
city_id = if city.kind_of?(String)
|
131
|
+
WeatherHacks::ForecastMap::CITY[city].id
|
132
|
+
else city end
|
133
|
+
unless day.to_s =~ /today|tomorrow|dayaftertomorrow|all/
|
134
|
+
raise ArgumentError, day
|
135
|
+
end
|
136
|
+
if day == :all
|
137
|
+
return [ request(city, :today),
|
138
|
+
request(city, :tomorrow),
|
139
|
+
request(city, :dayaftertomorrow) ]
|
140
|
+
end
|
141
|
+
req = Net::HTTP::Get.new(path(city_id, day.to_s))
|
142
|
+
http = Net::HTTP.new(URL.host)
|
143
|
+
case res = http.request(req)
|
144
|
+
when Net::HTTPSuccess
|
145
|
+
Forecast.new(REXML::Document.new(res.body))
|
146
|
+
else
|
147
|
+
raise Error.new(res)
|
148
|
+
end
|
138
149
|
end
|
150
|
+
|
151
|
+
alias [] request
|
139
152
|
end
|
140
153
|
end
|
data/spec/lwws_spec.rb
CHANGED
@@ -1,106 +1,100 @@
|
|
1
|
-
|
1
|
+
$LOAD_PATH.unshift File.join(File.join(File.dirname(__FILE__), ".."), "lib")
|
2
|
+
require "weatherhacks"
|
3
|
+
require "rubygems"
|
4
|
+
require "bacon"
|
2
5
|
|
3
|
-
|
4
|
-
before do
|
5
|
-
@forecast = WeatherHacks::LWWS::Forecast.new($today)
|
6
|
-
end
|
6
|
+
include WeatherHacks::LWWS
|
7
7
|
|
8
|
-
|
9
|
-
@forecast.author.should be_a_kind_of(String)
|
10
|
-
end
|
11
|
-
|
12
|
-
it "can read location as a WeatherHacks::LWWS::Location" do
|
13
|
-
@forecast.location.should be_a_kind_of(WeatherHacks::LWWS::Location)
|
14
|
-
end
|
8
|
+
$today, $tomorrow, $dayaftertomorrow = WeatherHacks.lwws("松江")
|
15
9
|
|
16
|
-
|
17
|
-
@forecast.title.should be_a_kind_of(String)
|
18
|
-
end
|
10
|
+
describe "WeatherHacks::LWWS::Forecast" do
|
19
11
|
|
20
|
-
|
21
|
-
|
12
|
+
def forecast(&block)
|
13
|
+
[$today, $tomorrow, $dayaftertomorrow].each {|f| yield f }
|
22
14
|
end
|
23
15
|
|
24
|
-
it "
|
25
|
-
|
16
|
+
it "#author" do
|
17
|
+
forecast {|f| f.author.should.be.kind_of(String) }
|
26
18
|
end
|
27
19
|
|
28
|
-
it "
|
29
|
-
|
20
|
+
it "#location" do
|
21
|
+
forecast {|f| f.location.should.be.kind_of(::Location) }
|
30
22
|
end
|
31
23
|
|
32
|
-
it "
|
33
|
-
|
24
|
+
it "#title" do
|
25
|
+
forecast {|f| f.title.should.be.kind_of(String) }
|
34
26
|
end
|
35
27
|
|
36
|
-
it "
|
37
|
-
|
28
|
+
it "#link" do
|
29
|
+
forecast {|f| f.link.should.be.kind_of(URI) }
|
38
30
|
end
|
39
31
|
|
40
|
-
it "
|
41
|
-
|
32
|
+
it "#forecastday" do
|
33
|
+
$today.forecastday.should == "today"
|
34
|
+
$tomorrow.forecastday.should == "tomorrow"
|
35
|
+
$dayaftertomorrow.forecastday.should == "dayaftertomorrow"
|
42
36
|
end
|
43
37
|
|
44
|
-
it "
|
45
|
-
|
38
|
+
it "#day" do
|
39
|
+
forecast {|f| f.day.should =~ /(Sun|Mon|Tues|Wednes|Thurs|Fri|Satur)day/ }
|
46
40
|
end
|
47
41
|
|
48
|
-
it "
|
49
|
-
|
42
|
+
it "#forecastdate" do
|
43
|
+
forecast {|f| f.forecastdate.should.be.kind_of(Time) }
|
50
44
|
end
|
51
45
|
|
52
|
-
it "
|
53
|
-
|
46
|
+
it "#publictime" do
|
47
|
+
forecast {|f| f.publictime.should.be.kind_of(Time) }
|
54
48
|
end
|
55
49
|
|
56
|
-
it "
|
57
|
-
|
50
|
+
it "#telop" do
|
51
|
+
forecast {|f| f.telop.should.be.kind_of(String) }
|
58
52
|
end
|
59
53
|
|
60
|
-
it "
|
61
|
-
|
62
|
-
location.should be_a_kind_of(WeatherHacks::LWWS::PinpointLocation)
|
63
|
-
end
|
54
|
+
it "#description" do
|
55
|
+
forecast {|f| f.description.should.be.kind_of(String) }
|
64
56
|
end
|
65
57
|
|
66
|
-
it "
|
67
|
-
|
58
|
+
it "#image" do
|
59
|
+
forecast {|f| f.image.should.be.kind_of(Image) }
|
68
60
|
end
|
69
61
|
|
70
|
-
|
71
|
-
|
62
|
+
it "#celsius" do
|
63
|
+
forecast {|f| f.celsius.should.be.kind_of(Celsius) }
|
72
64
|
end
|
73
|
-
end
|
74
65
|
|
75
|
-
|
76
|
-
|
77
|
-
WeatherHacks::LWWS::Forecast.new($today).forecastday.should eql("today")
|
66
|
+
it "#fahrenheit" do
|
67
|
+
forecast {|f| f.fahrenheit.should.be.kind_of(Fahrenheit) }
|
78
68
|
end
|
79
69
|
|
80
|
-
it "
|
81
|
-
|
70
|
+
it "#pinpoints" do
|
71
|
+
forecast do |f|
|
72
|
+
f.pinpoints.each do |location|
|
73
|
+
location.should.be.kind_of(PinpointLocation)
|
74
|
+
end
|
75
|
+
end
|
82
76
|
end
|
83
77
|
|
84
|
-
it "
|
85
|
-
|
78
|
+
it "#copyright" do
|
79
|
+
forecast{|f| f.copyright.should.be.kind_of(Copyright) }
|
86
80
|
end
|
87
81
|
end
|
88
82
|
|
89
|
-
describe WeatherHacks::LWWS::Location do
|
83
|
+
describe "WeatherHacks::LWWS::Location" do
|
90
84
|
before do
|
91
|
-
@location =
|
85
|
+
@location = $today.location
|
92
86
|
end
|
93
87
|
|
94
|
-
it "
|
95
|
-
@location.area.should
|
88
|
+
it "area" do
|
89
|
+
@location.area.should.be.kind_of(String)
|
96
90
|
end
|
97
91
|
|
98
|
-
it "
|
99
|
-
@location.pref.should
|
92
|
+
it "pref" do
|
93
|
+
@location.pref.should.be.kind_of(String)
|
100
94
|
end
|
101
95
|
|
102
|
-
it "
|
103
|
-
@location.city.should
|
96
|
+
it "city" do
|
97
|
+
@location.city.should.be.kind_of(String)
|
104
98
|
end
|
105
99
|
|
106
100
|
after do
|
@@ -108,136 +102,135 @@ describe WeatherHacks::LWWS::Location do
|
|
108
102
|
end
|
109
103
|
end
|
110
104
|
|
111
|
-
describe WeatherHacks::LWWS::Image do
|
105
|
+
describe "WeatherHacks::LWWS::Image" do
|
112
106
|
before do
|
113
|
-
@image =
|
107
|
+
@image = $today.image
|
114
108
|
end
|
115
109
|
|
116
|
-
|
117
|
-
@image
|
110
|
+
after do
|
111
|
+
@image = nil
|
118
112
|
end
|
119
113
|
|
120
|
-
it "
|
121
|
-
@image.
|
114
|
+
it "title" do
|
115
|
+
@image.title.should.be.kind_of(String)
|
122
116
|
end
|
123
117
|
|
124
|
-
it "
|
125
|
-
@image.
|
118
|
+
it "link" do
|
119
|
+
@image.link.should.be.kind_of(URI)
|
126
120
|
end
|
127
121
|
|
128
|
-
it "
|
129
|
-
@image.
|
122
|
+
it "url" do
|
123
|
+
@image.url.should.be.kind_of(URI)
|
130
124
|
end
|
131
125
|
|
132
|
-
it "
|
133
|
-
@image.
|
126
|
+
it "width" do
|
127
|
+
@image.width.should.be.kind_of(Integer)
|
134
128
|
end
|
135
129
|
|
136
|
-
|
137
|
-
@image
|
130
|
+
it "height" do
|
131
|
+
@image.height.should.be.kind_of(Integer)
|
138
132
|
end
|
139
133
|
end
|
140
134
|
|
141
|
-
describe WeatherHacks::LWWS::Temperature do
|
135
|
+
describe "WeatherHacks::LWWS::Temperature" do
|
142
136
|
before do
|
143
|
-
|
144
|
-
@
|
145
|
-
@fahrenheit = forecast.fahrenheit
|
137
|
+
@celsius = $today.celsius
|
138
|
+
@fahrenheit = $today.fahrenheit
|
146
139
|
end
|
147
140
|
|
148
|
-
|
149
|
-
@celsius
|
150
|
-
|
141
|
+
after do
|
142
|
+
@celsius = nil
|
143
|
+
@fahrenheit = nil
|
151
144
|
end
|
152
145
|
|
153
|
-
it "
|
154
|
-
@celsius.
|
146
|
+
it "min celsius" do
|
147
|
+
@celsius.min.should.be.kind_of(Integer) if @celsius.min
|
155
148
|
end
|
156
149
|
|
157
|
-
it "
|
158
|
-
@
|
150
|
+
it "max celsius" do
|
151
|
+
@celsius.max.should.be.kind_of(Integer) if @celsius.max
|
159
152
|
end
|
160
153
|
|
161
|
-
it "
|
162
|
-
@fahrenheit.
|
154
|
+
it "min fahrenheit" do
|
155
|
+
@fahrenheit.min.should.be.kind_of(Float) if @fahrenheit.min
|
163
156
|
end
|
164
157
|
|
165
|
-
|
166
|
-
@
|
167
|
-
@fahrenheit = nil
|
158
|
+
it "max fahrenheit" do
|
159
|
+
@fahrenheit.max.should.be.kind_of(Float) if @fahrenheit.max
|
168
160
|
end
|
169
161
|
end
|
170
162
|
|
171
|
-
describe WeatherHacks::LWWS::PinpointLocation do
|
163
|
+
describe "WeatherHacks::LWWS::PinpointLocation" do
|
172
164
|
before do
|
173
|
-
@pinpoints =
|
165
|
+
@pinpoints = $today.pinpoints
|
174
166
|
end
|
175
167
|
|
176
|
-
|
177
|
-
@pinpoints
|
178
|
-
location.title.should be_a_kind_of(String)
|
179
|
-
end
|
168
|
+
after do
|
169
|
+
@pinpoints = nil
|
180
170
|
end
|
181
171
|
|
182
|
-
it "
|
172
|
+
it "title" do
|
183
173
|
@pinpoints.each do |location|
|
184
|
-
location.
|
174
|
+
location.title.should.be.kind_of(String)
|
185
175
|
end
|
186
176
|
end
|
187
177
|
|
188
|
-
it "
|
178
|
+
it "link" do
|
189
179
|
@pinpoints.each do |location|
|
190
|
-
location.
|
180
|
+
location.link.should.be.kind_of(URI)
|
191
181
|
end
|
192
182
|
end
|
193
183
|
|
194
|
-
|
195
|
-
@pinpoints
|
184
|
+
it "publictime" do
|
185
|
+
@pinpoints.each do |location|
|
186
|
+
location.publictime.should.be.kind_of(Time)
|
187
|
+
end
|
196
188
|
end
|
197
189
|
end
|
198
190
|
|
199
|
-
describe WeatherHacks::LWWS::Copyright do
|
191
|
+
describe "WeatherHacks::LWWS::Copyright" do
|
200
192
|
before do
|
201
|
-
@copyright =
|
193
|
+
@copyright = $today.copyright
|
194
|
+
end
|
195
|
+
|
196
|
+
after do
|
197
|
+
@copyright = nil
|
202
198
|
end
|
203
199
|
|
204
|
-
it "
|
205
|
-
@copyright.title.should
|
200
|
+
it "title" do
|
201
|
+
@copyright.title.should.be.kind_of(String)
|
206
202
|
end
|
207
203
|
|
208
|
-
it "
|
209
|
-
@copyright.link.should
|
204
|
+
it "link" do
|
205
|
+
@copyright.link.should.be.kind_of(URI)
|
210
206
|
end
|
211
207
|
|
212
|
-
it "
|
213
|
-
@copyright.image.should
|
208
|
+
it "image" do
|
209
|
+
@copyright.image.should.be.kind_of(WeatherHacks::LWWS::Image)
|
214
210
|
end
|
215
211
|
|
216
|
-
it "
|
212
|
+
it "providers" do
|
217
213
|
@copyright.providers.each do |provider|
|
218
|
-
provider.should
|
214
|
+
provider.should.be.kind_of(WeatherHacks::LWWS::Provider)
|
219
215
|
end
|
220
216
|
end
|
221
217
|
|
222
|
-
after do
|
223
|
-
@copyright = nil
|
224
|
-
end
|
225
218
|
end
|
226
219
|
|
227
|
-
describe WeatherHacks::LWWS::Provider do
|
220
|
+
describe "WeatherHacks::LWWS::Provider" do
|
228
221
|
before do
|
229
|
-
@provider =
|
222
|
+
@provider = $today.copyright.providers[0]
|
230
223
|
end
|
231
224
|
|
232
|
-
|
233
|
-
@provider
|
225
|
+
after do
|
226
|
+
@provider = nil
|
234
227
|
end
|
235
228
|
|
236
|
-
it "
|
237
|
-
@provider.
|
229
|
+
it "name" do
|
230
|
+
@provider.name.should.be.kind_of(String)
|
238
231
|
end
|
239
232
|
|
240
|
-
|
241
|
-
@provider
|
233
|
+
it "link" do
|
234
|
+
@provider.link.should.be.kind_of(URI)
|
242
235
|
end
|
243
236
|
end
|