weather-report 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/bin/weather-report +1 -1
- data/lib/weather-report/day.rb +2 -2
- data/lib/weather-report/version.rb +1 -1
- data/lib/weather-report/weather.rb +18 -1
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1405fd897fc7a64fae00781e20a88ec49034fbe3
|
4
|
+
data.tar.gz: a9e8e87ae7e13ca35a1da79586301c10f3bf901d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 22abbaa9166755a1d2356444467aeade704adfb97fcb94fa9fad918c5d5d808484b08ad6ab27c50bd64b54afd49d95d626b6edf358115b07b2133d838fc25ce0
|
7
|
+
data.tar.gz: 7ee452d24c48801b26f09684d0dde397021ec29f4fc8ea21c9916f938751b01b4e08116abccca24490b2d8471c7714e58438b8d3c5484a2aee36a457d1b40466
|
data/README.md
CHANGED
data/bin/weather-report
CHANGED
@@ -26,5 +26,5 @@ opt_parser = OptionParser.new do |opts|
|
|
26
26
|
end
|
27
27
|
|
28
28
|
city = opt_parser.parse(ARGV)
|
29
|
-
weather = WeatherReport::Weather.new(WeatherReport::Weather.request_cityid(city))
|
29
|
+
weather = WeatherReport::Weather.new(WeatherReport::Weather.request_cityid(*city))
|
30
30
|
puts weather.to_h
|
data/lib/weather-report/day.rb
CHANGED
@@ -8,12 +8,12 @@ module WeatherReport
|
|
8
8
|
@forecast = forecast(forecasts, dateLabel)
|
9
9
|
end
|
10
10
|
|
11
|
-
# @return [
|
11
|
+
# @return [Boolean] return true if it rains.
|
12
12
|
def rain?
|
13
13
|
telop =~ /[雨]/ ? true : false
|
14
14
|
end
|
15
15
|
|
16
|
-
# @return [
|
16
|
+
# @return [Boolean] return true if it snows.
|
17
17
|
def snow?
|
18
18
|
telop =~ /[雪]/ ? true : false
|
19
19
|
end
|
@@ -10,12 +10,29 @@ module WeatherReport
|
|
10
10
|
|
11
11
|
# @return [String] the id of given city
|
12
12
|
def self.request_cityid(city_name)
|
13
|
-
|
13
|
+
proxy = Weather.parse_proxy(ENV["http_proxy"])
|
14
|
+
doc = Nokogiri::XML(open("http://weather.livedoor.com/forecast/rss/primary_area.xml", :proxy_http_basic_authentication => [proxy.server, proxy.user, proxy.pass]))
|
14
15
|
doc.search("//city[@title='#{city_name}']").attr("id").value
|
15
16
|
rescue => e
|
16
17
|
raise WeatherReportError
|
17
18
|
end
|
18
19
|
|
20
|
+
def self.parse_proxy(proxy)
|
21
|
+
# http://user:pass@host:port のように書かれていることを想定
|
22
|
+
# パスワードに@とか入ってる場合があるので一番後ろの@でだけsplitする
|
23
|
+
rserver, raccount = (proxy || '').sub(/http:\/\//, '').reverse.split("@", 2)
|
24
|
+
server = rserver.nil? ? "" : rserver.reverse
|
25
|
+
host, port = server.split(":")
|
26
|
+
account = raccount.nil? ? "" : raccount.reverse.split(":")
|
27
|
+
user, pass = account
|
28
|
+
|
29
|
+
proxy = OpenStruct.new({
|
30
|
+
"server" => server.empty? ? nil : "http://#{server}",
|
31
|
+
"user" => user.nil? ? "" : user,
|
32
|
+
"pass" => pass.nil? ? "" : pass
|
33
|
+
})
|
34
|
+
end
|
35
|
+
|
19
36
|
# @return [Day] the today
|
20
37
|
def today
|
21
38
|
@today ||= Day.new(forecasts, "今日")
|
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.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- zakuni
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-06-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -154,7 +154,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
154
154
|
version: '0'
|
155
155
|
requirements: []
|
156
156
|
rubyforge_project:
|
157
|
-
rubygems_version: 2.0.
|
157
|
+
rubygems_version: 2.0.2
|
158
158
|
signing_key:
|
159
159
|
specification_version: 4
|
160
160
|
summary: A Ruby client of Livedoor Weather Web Service.
|
@@ -163,4 +163,3 @@ test_files:
|
|
163
163
|
- test/test_helper.rb
|
164
164
|
- test/test_weather-report.rb
|
165
165
|
- test/test_weather.rb
|
166
|
-
has_rdoc:
|