weather-report 0.3.2 → 0.3.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2b75cb645e6ecd1bf0b54880928626456b1194c5
4
- data.tar.gz: 443e87046fdbfa512e7cccc8e0c9c66fc8a6f7a1
3
+ metadata.gz: 1405fd897fc7a64fae00781e20a88ec49034fbe3
4
+ data.tar.gz: a9e8e87ae7e13ca35a1da79586301c10f3bf901d
5
5
  SHA512:
6
- metadata.gz: 21e6fa7479494286ab6a38c755678955fe20622a7cac1c3d0140aeaaf987aa650ea515e5f5764975158b25ac72ce623a6b547bab9b6f7f54c33297da56ab80ac
7
- data.tar.gz: 888f337f9ae7380e454d9d19a07d2f5558b616aaa9fd66c54bab84c36db58ce8c7f5d7c1548a6fba85a8f481cb83964a0a345d87c92b36251df21d64634741df
6
+ metadata.gz: 22abbaa9166755a1d2356444467aeade704adfb97fcb94fa9fad918c5d5d808484b08ad6ab27c50bd64b54afd49d95d626b6edf358115b07b2133d838fc25ce0
7
+ data.tar.gz: 7ee452d24c48801b26f09684d0dde397021ec29f4fc8ea21c9916f938751b01b4e08116abccca24490b2d8471c7714e58438b8d3c5484a2aee36a457d1b40466
data/README.md CHANGED
@@ -34,6 +34,7 @@ weather.tomorrow.date # => <Date: 2013-05-04 ((2456417j,0s,0n),+0s,2299161j)>
34
34
  weather.tomorrow.telop # => "雨"
35
35
  weather.tomorrow.temperature_min # => 12
36
36
  ```
37
+ for more info, see http://rubydoc.info/gems/weather-report
37
38
 
38
39
  ## Contributing
39
40
 
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
@@ -8,12 +8,12 @@ module WeatherReport
8
8
  @forecast = forecast(forecasts, dateLabel)
9
9
  end
10
10
 
11
- # @return [Trueclass, Falseclass] return true if it rains.
11
+ # @return [Boolean] return true if it rains.
12
12
  def rain?
13
13
  telop =~ /[雨]/ ? true : false
14
14
  end
15
15
 
16
- # @return [Trueclass, Falseclass] return true if it snows.
16
+ # @return [Boolean] return true if it snows.
17
17
  def snow?
18
18
  telop =~ /[雪]/ ? true : false
19
19
  end
@@ -1,3 +1,3 @@
1
1
  module WeatherReport
2
- VERSION = "0.3.2"
2
+ VERSION = "0.3.3"
3
3
  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
- doc = Nokogiri::XML(open("http://weather.livedoor.com/forecast/rss/primary_area.xml"))
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.2
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-05-07 00:00:00.000000000 Z
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.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: