yahoo_weatherman 1.1.2 → 1.1.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,11 @@
1
1
  # coding: utf-8
2
2
  module Weatherman
3
+
4
+ # = I18n
5
+ #
6
+ # This class uses the locale files to translate the response sent from the Yahoo! Weather
7
+ # feed.
8
+ #
3
9
  class I18N
4
10
  I18N_YAML_DIR = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'i18n'))
5
11
 
@@ -7,10 +13,18 @@ module Weatherman
7
13
 
8
14
  attr_accessor :language
9
15
 
16
+ #
17
+ # Expects a string with the locale file name.
18
+ # Eg. I18N.new('pt-br') will load the i18n/pt-br.yml file.
19
+ #
10
20
  def initialize(language)
11
21
  @language = language
12
22
  end
13
23
 
24
+ #
25
+ # Translates the messages in the response if a locale file was specified in the constructor.
26
+ # It modifies the hash passed in place.
27
+ #
14
28
  def translate!(attributes)
15
29
  if i18n?
16
30
  translate_text! attributes
@@ -48,7 +62,7 @@ module Weatherman
48
62
  end
49
63
 
50
64
  def load_language_yaml!
51
- YAML::load File.read(File.join(I18N_YAML_DIR, language + '.yml'))
65
+ YAML.load(File.read(File.join(I18N_YAML_DIR, language + '.yml')))
52
66
  end
53
67
 
54
68
  def i18n?
@@ -2,8 +2,6 @@
2
2
  path = File.expand_path(File.dirname(__FILE__))
3
3
  $LOAD_PATH.unshift(path) unless $LOAD_PATH.include?(path)
4
4
 
5
- require 'rubygems'
6
-
7
5
  require 'yaml'
8
6
  require 'open-uri'
9
7
  require 'nokogiri'
@@ -14,7 +12,7 @@ require 'yahoo_weatherman/response'
14
12
 
15
13
  module Weatherman
16
14
 
17
- VERSION = '1.1.2'
15
+ VERSION = '1.1.3'
18
16
 
19
17
  URI = 'http://weather.yahooapis.com/forecastrss'
20
18
 
@@ -26,7 +24,7 @@ module Weatherman
26
24
  attr_reader :options
27
25
 
28
26
  #
29
- # Accepts a optional hash containing the client options.
27
+ # Accepts an optional hash containing the client options.
30
28
  #
31
29
  # Options:
32
30
  #
@@ -63,7 +61,7 @@ module Weatherman
63
61
  end
64
62
 
65
63
  def get(url)
66
- open(url) { |stream| stream.read }
64
+ open(url).read
67
65
  end
68
66
  end
69
67
  end
data/spec/spec_helper.rb CHANGED
@@ -29,7 +29,7 @@ module YAML
29
29
  end
30
30
 
31
31
  def test_translation_file_stream
32
- File.read(File.join([File.dirname(__FILE__), 'files', 'test_i18n.yml']))
32
+ File.read(File.join(File.dirname(__FILE__), 'files', 'test_i18n.yml'))
33
33
  end
34
34
 
35
35
  end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |gem|
2
2
  gem.name = "yahoo_weatherman"
3
- gem.version = "1.1.2"
3
+ gem.version = "1.1.3"
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,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yahoo_weatherman
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
4
+ hash: 21
5
+ prerelease:
5
6
  segments:
6
7
  - 1
7
8
  - 1
8
- - 2
9
- version: 1.1.2
9
+ - 3
10
+ version: 1.1.3
10
11
  platform: ruby
11
12
  authors:
12
13
  - Dalto Curvelano Junior
@@ -14,7 +15,7 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2011-01-26 00:00:00 -02:00
18
+ date: 2011-04-29 00:00:00 -03:00
18
19
  default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
@@ -25,6 +26,7 @@ dependencies:
25
26
  requirements:
26
27
  - - ">="
27
28
  - !ruby/object:Gem::Version
29
+ hash: 3
28
30
  segments:
29
31
  - 0
30
32
  version: "0"
@@ -38,6 +40,7 @@ dependencies:
38
40
  requirements:
39
41
  - - ">="
40
42
  - !ruby/object:Gem::Version
43
+ hash: 3
41
44
  segments:
42
45
  - 0
43
46
  version: "0"
@@ -51,6 +54,7 @@ dependencies:
51
54
  requirements:
52
55
  - - ">="
53
56
  - !ruby/object:Gem::Version
57
+ hash: 3
54
58
  segments:
55
59
  - 0
56
60
  version: "0"
@@ -91,6 +95,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
91
95
  requirements:
92
96
  - - ">="
93
97
  - !ruby/object:Gem::Version
98
+ hash: 3
94
99
  segments:
95
100
  - 0
96
101
  version: "0"
@@ -99,13 +104,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
99
104
  requirements:
100
105
  - - ">="
101
106
  - !ruby/object:Gem::Version
107
+ hash: 3
102
108
  segments:
103
109
  - 0
104
110
  version: "0"
105
111
  requirements: []
106
112
 
107
113
  rubyforge_project:
108
- rubygems_version: 1.3.7
114
+ rubygems_version: 1.5.2
109
115
  signing_key:
110
116
  specification_version: 3
111
117
  summary: A ruby wrapper to the Yahoo! Weather feed with i18n support.