yahoo_weatherman 0.6 → 0.7

Sign up to get free protection for your applications and to get access to all the features.
data/i18n/pt-br.yml CHANGED
@@ -50,3 +50,13 @@
50
50
 
51
51
  locations:
52
52
  Brazil: Brasil
53
+
54
+ forecasts:
55
+ days:
56
+ Mon: Segunda-feira
57
+ Tue: Terça-feira
58
+ Wed: Quarta-feira
59
+ Thu: Quinta-feira
60
+ Fri: Sexta-feira
61
+ Sat: Sábado
62
+ Sun: Domingo
@@ -10,7 +10,7 @@ require 'yahoo_weatherman/response'
10
10
 
11
11
  module Weatherman
12
12
 
13
- VERSION = '0.2'
13
+ VERSION = '0.7'
14
14
 
15
15
  URI = 'http://weather.yahooapis.com/forecastrss'
16
16
 
@@ -28,7 +28,7 @@ module Weatherman
28
28
  # condition['date'] => #<Date: -1/2,0,2299161>
29
29
  #
30
30
  def condition
31
- condition = item_attribute 'yweather:condition'
31
+ condition = item_attribute('yweather:condition')
32
32
  translate! do_convertions(condition, [:code, :to_i], [:temp, :to_i], [:date, :to_date], :text)
33
33
  end
34
34
 
@@ -82,7 +82,7 @@ module Weatherman
82
82
  # units['speed'] => "km/h"
83
83
  #
84
84
  def units
85
- attribute 'yweather:units'
85
+ attribute('yweather:units')
86
86
  end
87
87
 
88
88
  #
@@ -93,7 +93,7 @@ module Weatherman
93
93
  # astronomy['sunset'] => "7:20 pm"
94
94
  #
95
95
  def astronomy
96
- attribute 'yweather:astronomy'
96
+ attribute('yweather:astronomy')
97
97
  end
98
98
 
99
99
  #
@@ -101,7 +101,7 @@ module Weatherman
101
101
  #
102
102
  # response.latitude => -49.90
103
103
  def latitude
104
- geo_attribute('lat').to_f
104
+ geo_attribute('lat')
105
105
  end
106
106
 
107
107
  #
@@ -110,7 +110,7 @@ module Weatherman
110
110
  # response.longitude => -45.32
111
111
  #
112
112
  def longitude
113
- geo_attribute('long').to_f
113
+ geo_attribute('long')
114
114
  end
115
115
 
116
116
  #
@@ -139,7 +139,7 @@ module Weatherman
139
139
  # A short HTML snippet (raw text) with a simple weather description.
140
140
  #
141
141
  def description
142
- text_attribute 'description'
142
+ text_attribute('description')
143
143
  end
144
144
  alias :summary :description
145
145
 
@@ -164,7 +164,7 @@ module Weatherman
164
164
 
165
165
  def geo_attribute(attr)
166
166
  geo = item_attribute('geo:' + attr)
167
- geo.children.first.text
167
+ geo.children.first.text.to_f
168
168
  end
169
169
 
170
170
  def text_attribute(attr)
@@ -186,6 +186,7 @@ module Weatherman
186
186
 
187
187
  def translate!(attributes)
188
188
  if i18n?
189
+ translate_days! attributes
189
190
  translate_text! attributes
190
191
  translate_locations! attributes
191
192
  end
@@ -210,13 +211,21 @@ module Weatherman
210
211
  end
211
212
  end
212
213
 
214
+ def translate_days!(attributes)
215
+ days_translations = language_translations['forecasts']['days']
216
+ day = attributes['day']
217
+ if day
218
+ attributes['day'] = days_translations[day]
219
+ end
220
+ end
221
+
213
222
  def language_translations
214
223
  LANGUAGES[language] ||= load_language_yaml!
215
224
  end
216
225
 
217
226
  def load_language_yaml!
218
227
  stream = File.read(File.join([I18N_YAML_DIR, language + '.yml']))
219
- YAML.load(stream)
228
+ YAML::load(stream)
220
229
  end
221
230
 
222
231
  def i18n?
@@ -107,6 +107,8 @@ DESCRIPTION
107
107
  it 'should translate the forecasts details' do
108
108
  @response.forecasts.first['text'].should == 'Chuva'
109
109
  @response.forecasts.last['text'].should == 'Tempestades Intermitentes'
110
+ @response.forecasts.first['day'].should == 'Sábado'
111
+ @response.forecasts.last['day'].should == 'Domingo'
110
112
  end
111
113
  end
112
114
 
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |gem|
2
2
  gem.name = "yahoo_weatherman"
3
- gem.version = "0.6"
3
+ gem.version = "0.7"
4
4
  gem.authors = ["Dalto Curvelano Junior"]
5
5
  gem.description = "A ruby wrapper to the Yahoo! Weather feed with i18n support."
6
6
  gem.summary = "A ruby wrapper to the Yahoo! Weather feed with i18n support."
metadata CHANGED
@@ -1,11 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yahoo_weatherman
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 6
8
- version: "0.6"
4
+ version: "0.7"
9
5
  platform: ruby
10
6
  authors:
11
7
  - Dalto Curvelano Junior
@@ -13,7 +9,7 @@ autorequire:
13
9
  bindir: bin
14
10
  cert_chain: []
15
11
 
16
- date: 2010-03-18 00:00:00 -03:00
12
+ date: 2010-03-31 00:00:00 -03:00
17
13
  default_executable:
18
14
  dependencies: []
19
15
 
@@ -49,20 +45,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
49
45
  requirements:
50
46
  - - ">="
51
47
  - !ruby/object:Gem::Version
52
- segments:
53
- - 0
54
48
  version: "0"
49
+ version:
55
50
  required_rubygems_version: !ruby/object:Gem::Requirement
56
51
  requirements:
57
52
  - - ">="
58
53
  - !ruby/object:Gem::Version
59
- segments:
60
- - 0
61
54
  version: "0"
55
+ version:
62
56
  requirements: []
63
57
 
64
58
  rubyforge_project:
65
- rubygems_version: 1.3.6
59
+ rubygems_version: 1.3.5
66
60
  signing_key:
67
61
  specification_version: 3
68
62
  summary: A ruby wrapper to the Yahoo! Weather feed with i18n support.