i18n-inflector 2.5.1 → 2.6.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,7 +2,7 @@
2
2
  #
3
3
  # Author:: Paweł Wilk (mailto:pw@gnu.org)
4
4
  # Copyright:: (c) 2011 by Paweł Wilk
5
- # License:: This program is licensed under the terms of {file:docs/LGPL GNU Lesser General Public License} or {file:COPYING Ruby License}.
5
+ # License:: This program is licensed under the terms of {file:docs/LGPL GNU Lesser General Public License} or {file:docs/COPYING Ruby License}.
6
6
  #
7
7
  # This file contains lazy enumerators.
8
8
 
@@ -34,6 +34,11 @@ module I18n
34
34
  @final_block.call(*arg)
35
35
  end
36
36
  end
37
+
38
+ if method_defined?(:yield) and not method_defined?(:"<<")
39
+ alias_method :"<<", :yield
40
+ end
41
+
37
42
  end
38
43
 
39
44
  unless (self.new{} rescue false)
@@ -43,7 +48,7 @@ module I18n
43
48
  end
44
49
 
45
50
  if method_defined?(:with_object) and not method_defined?(:each_with_object)
46
- alias_method :with_object, :each_with_object
51
+ alias_method :each_with_object, :with_object
47
52
  end
48
53
 
49
54
  end # class LazyEnumerator for ruby18
@@ -55,42 +60,82 @@ module I18n
55
60
 
56
61
  end
57
62
 
58
- # This class implements simple enumerators for arrays
59
- # that allow to do lazy operations on them.
60
- class LazyArrayEnumerator < LazyEnumerator
63
+ # This class adds some lazy operations for collections
64
+ class LazyEnumerator
65
+
66
+ # Addition operator for collections
67
+ # @return [I18n::Inflector::LazyEnumerator] the enumerator
68
+ def +(other)
69
+ self.class.new do |yielder|
70
+ each do |v|
71
+ yielder << v
72
+ end
73
+ other.each do |v|
74
+ yielder << v
75
+ end
76
+ end
77
+ end
78
+
79
+ # Insertion operator for collections
80
+ # @return [I18n::Inflector::LazyEnumerator] the enumerator
81
+ def insert(value)
82
+ self.class.new do |yielder|
83
+ yielder << value
84
+ each do |v|
85
+ yielder << v
86
+ end
87
+ end
88
+ end
89
+
90
+ # Appending operator for collections
91
+ # @return [I18n::Inflector::LazyEnumerator] the enumerator
92
+ def append(value)
93
+ self.class.new do |yielder|
94
+ each do |v|
95
+ yielder << v
96
+ end
97
+ yielder << value
98
+ end
99
+ end
61
100
 
62
101
  # Mapping enumerator
63
102
  # @return [I18n::Inflector::LazyEnumerator] the enumerator
64
103
  def map(&block)
65
- LazyArrayEnumerator.new do |yielder|
66
- self.each do |v|
67
- yielder.yield(block.call(v))
104
+ self.class.new do |yielder|
105
+ each do |v|
106
+ yielder << block[v]
68
107
  end
69
108
  end
70
109
  end
71
110
 
72
- # Array selecting enumerator
73
- # @return [I18n::Inflector::LazyHashEnumerator] the enumerator
111
+ # Selecting enumerator
112
+ # @return [I18n::Inflector::LazyEnumerator] the enumerator
74
113
  def select(&block)
75
- LazyArrayEnumerator.new do |yielder|
76
- self.each do |v|
77
- yielder.yield(v) if block.call(v)
114
+ self.class.new do |yielder|
115
+ each do |v|
116
+ yielder << v if block[v]
78
117
  end
79
118
  end
80
119
  end
81
120
 
82
- # Array rejecting enumerator
83
- # @return [I18n::Inflector::LazyHashEnumerator] the enumerator
121
+ # Rejecting enumerator
122
+ # @return [I18n::Inflector::LazyEnumerator] the enumerator
84
123
  def reject(&block)
85
- LazyArrayEnumerator.new do |yielder|
86
- self.each do |v|
87
- yielder.yield(v) unless block.call(v)
124
+ self.class.new do |yielder|
125
+ each do |v|
126
+ yielder << v unless block[v]
88
127
  end
89
128
  end
90
129
  end
91
130
 
92
131
  end
93
132
 
133
+ # This class implements simple enumerators for arrays
134
+ # that allow to do lazy operations on them.
135
+ class LazyArrayEnumerator < LazyEnumerator
136
+
137
+ end
138
+
94
139
  # This class implements simple enumerators for hashes
95
140
  # that allow to do lazy operations on them.
96
141
  class LazyHashEnumerator < LazyEnumerator
@@ -100,26 +145,48 @@ module I18n
100
145
  # @return [Hash] the resulting hash
101
146
  def to_h
102
147
  h = Hash.new
103
- self.each{|k,v| h[k]=v }
148
+ each{|k,v| h[k]=v }
104
149
  h
105
150
  end
106
151
 
152
+ # Insertion operator for Hash enumerators
153
+ # @return [I18n::Inflector::LazyHashEnumerator] the enumerator
154
+ def insert(key, value)
155
+ self.class.new do |yielder|
156
+ yielder.yield(key, value)
157
+ each do |k,v|
158
+ yielder.yield(k,v)
159
+ end
160
+ end
161
+ end
162
+
163
+ # Appending operator for Hash enumerators
164
+ # @return [I18n::Inflector::LazyHashEnumerator] the enumerator
165
+ def append(key, value)
166
+ self.class.new do |yielder|
167
+ each do |k,v|
168
+ yielder.yield(k,v)
169
+ end
170
+ yielder.yield(key, value)
171
+ end
172
+ end
173
+
107
174
  # Hash mapping enumerator
108
175
  # @return [I18n::Inflector::LazyHashEnumerator] the enumerator
109
176
  def map(&block)
110
177
  LazyHashEnumerator.new do |yielder|
111
- self.each do |k,v|
112
- yielder.yield(k,block.call(k,v))
178
+ each do |k,v|
179
+ yielder.yield(k,block[k,v])
113
180
  end
114
181
  end
115
182
  end
116
183
 
117
184
  # Hash to Array mapping enumerator
118
- # @return [I18n::Inflector::LazyEnumerator] the enumerator
185
+ # @return [I18n::Inflector::LazyHashEnumerator] the enumerator
119
186
  def ary_map(&block)
120
187
  LazyHashEnumerator.new do |yielder|
121
- self.each do |value|
122
- yielder.yield(block.call(value))
188
+ each do |value|
189
+ yielder << block[value]
123
190
  end
124
191
  end
125
192
  end
@@ -128,7 +195,7 @@ module I18n
128
195
  # to an array.
129
196
  def keys
130
197
  ary = []
131
- self.each{ |k,v| ary << k }
198
+ each{ |k,v| ary << k }
132
199
  return ary
133
200
  end
134
201
 
@@ -136,16 +203,36 @@ module I18n
136
203
  # to an array.
137
204
  def values
138
205
  ary = []
139
- self.each{ |k,v| ary << v }
206
+ each{ |k,v| ary << v }
140
207
  return ary
141
208
  end
142
209
 
210
+ # Keys enumerator
211
+ # @return [I18n::Inflector::LazyArrayEnumerator.new] the enumerator
212
+ def each_key(&block)
213
+ LazyArrayEnumerator.new do |yielder|
214
+ each do |k,v|
215
+ yielder << k
216
+ end
217
+ end
218
+ end
219
+
220
+ # Values enumerator
221
+ # @return [I18n::Inflector::LazyArrayEnumerator.new] the enumerator
222
+ def each_value(&block)
223
+ LazyArrayEnumerator.new do |yielder|
224
+ each do |k,v|
225
+ yielder << v
226
+ end
227
+ end
228
+ end
229
+
143
230
  # Hash selecting enumerator
144
231
  # @return [I18n::Inflector::LazyHashEnumerator] the enumerator
145
232
  def select(&block)
146
- LazyHashEnumerator.new do |yielder|
147
- self.each do |k,v|
148
- yielder.yield(k,v) if block.call(k,v)
233
+ self.class.new do |yielder|
234
+ each do |k,v|
235
+ yielder.yield(k,v) if block[k,v]
149
236
  end
150
237
  end
151
238
  end
@@ -153,9 +240,9 @@ module I18n
153
240
  # Hash rejecting enumerator
154
241
  # @return [I18n::Inflector::LazyHashEnumerator] the enumerator
155
242
  def reject(&block)
156
- LazyHashEnumerator.new do |yielder|
157
- self.each do |k,v|
158
- yielder.yield(k,v) unless block.call(k,v)
243
+ self.class.new do |yielder|
244
+ each do |k,v|
245
+ yielder.yield(k,v) unless block[k,v]
159
246
  end
160
247
  end
161
248
  end
@@ -2,7 +2,7 @@
2
2
  #
3
3
  # Author:: Paweł Wilk (mailto:pw@gnu.org)
4
4
  # Copyright:: (c) 2011 by Paweł Wilk
5
- # License:: This program is licensed under the terms of {file:docs/LGPL GNU Lesser General Public License} or {file:COPYING Ruby License}.
5
+ # License:: This program is licensed under the terms of {file:docs/LGPL GNU Lesser General Public License} or {file:docs/COPYING Ruby License}.
6
6
  #
7
7
  # This file contains inline documentation data
8
8
  # that would make the file with code less readable
@@ -2,7 +2,7 @@
2
2
  #
3
3
  # Author:: Paweł Wilk (mailto:pw@gnu.org)
4
4
  # Copyright:: (c) 2011 by Paweł Wilk
5
- # License:: This program is licensed under the terms of {file:docs/LGPL GNU Lesser General Public License} or {file:COPYING Ruby License}.
5
+ # License:: This program is licensed under the terms of {file:docs/LGPL GNU Lesser General Public License} or {file:docs/COPYING Ruby License}.
6
6
  #
7
7
  # This file contains a class used to set up some options,
8
8
  # for engine.
@@ -45,8 +45,8 @@ module I18n
45
45
  r = old_attr_accessor(*args)
46
46
  @known ||= Hash.new
47
47
  args.each do |arg|
48
- key = '@' + arg.to_s
49
- @known[key.to_sym] = (OPTION_PREFIX + arg.to_s).to_sym
48
+ key = '@' << arg.to_s
49
+ @known[key.to_sym] = ("" << OPTION_PREFIX << arg.to_s).to_sym
50
50
  end
51
51
  r
52
52
  end
@@ -2,7 +2,7 @@
2
2
  #
3
3
  # Author:: Paweł Wilk (mailto:pw@gnu.org)
4
4
  # Copyright:: (c) 2011 by Paweł Wilk
5
- # License:: This program is licensed under the terms of {file:docs/LGPL GNU Lesser General Public License} or {file:COPYING Ruby License}.
5
+ # License:: This program is licensed under the terms of {file:docs/LGPL GNU Lesser General Public License} or {file:docs/COPYING Ruby License}.
6
6
  #
7
7
  # This file contains version information.
8
8
 
@@ -14,7 +14,7 @@ module I18n
14
14
  # @private
15
15
  EMAIL = 'pw@gnu.org'
16
16
  # @private
17
- VERSION = '2.5.1'
17
+ VERSION = '2.6.1'
18
18
  # @private
19
19
  NAME = 'i18n-inflector'
20
20
  # @private
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: i18n-inflector
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.1
4
+ version: 2.6.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -48,12 +48,11 @@ cert_chain:
48
48
  -----END CERTIFICATE-----
49
49
 
50
50
  '
51
- date: 2011-02-25 00:00:00.000000000 +01:00
52
- default_executable:
51
+ date: 2011-07-10 00:00:00.000000000Z
53
52
  dependencies:
54
53
  - !ruby/object:Gem::Dependency
55
54
  name: i18n
56
- requirement: &2153400280 !ruby/object:Gem::Requirement
55
+ requirement: &2155640860 !ruby/object:Gem::Requirement
57
56
  none: false
58
57
  requirements:
59
58
  - - ! '>='
@@ -61,10 +60,10 @@ dependencies:
61
60
  version: 0.4.1
62
61
  type: :runtime
63
62
  prerelease: false
64
- version_requirements: *2153400280
63
+ version_requirements: *2155640860
65
64
  - !ruby/object:Gem::Dependency
66
65
  name: hoe-yard
67
- requirement: &2153397980 !ruby/object:Gem::Requirement
66
+ requirement: &2155640120 !ruby/object:Gem::Requirement
68
67
  none: false
69
68
  requirements:
70
69
  - - ! '>='
@@ -72,62 +71,73 @@ dependencies:
72
71
  version: 0.1.2
73
72
  type: :development
74
73
  prerelease: false
75
- version_requirements: *2153397980
74
+ version_requirements: *2155640120
76
75
  - !ruby/object:Gem::Dependency
77
76
  name: test_declarative
78
- requirement: &2153396460 !ruby/object:Gem::Requirement
77
+ requirement: &2155639320 !ruby/object:Gem::Requirement
79
78
  none: false
80
79
  requirements:
81
80
  - - ! '>='
82
81
  - !ruby/object:Gem::Version
83
- version: 0.0.4
82
+ version: 0.0.5
84
83
  type: :development
85
84
  prerelease: false
86
- version_requirements: *2153396460
85
+ version_requirements: *2155639320
87
86
  - !ruby/object:Gem::Dependency
88
87
  name: yard
89
- requirement: &2153389640 !ruby/object:Gem::Requirement
88
+ requirement: &2155638560 !ruby/object:Gem::Requirement
90
89
  none: false
91
90
  requirements:
92
91
  - - ! '>='
93
92
  - !ruby/object:Gem::Version
94
- version: 0.6.4
93
+ version: 0.7.2
95
94
  type: :development
96
95
  prerelease: false
97
- version_requirements: *2153389640
96
+ version_requirements: *2155638560
97
+ - !ruby/object:Gem::Dependency
98
+ name: rdoc
99
+ requirement: &2155637560 !ruby/object:Gem::Requirement
100
+ none: false
101
+ requirements:
102
+ - - ! '>='
103
+ - !ruby/object:Gem::Version
104
+ version: 3.8.0
105
+ type: :development
106
+ prerelease: false
107
+ version_requirements: *2155637560
98
108
  - !ruby/object:Gem::Dependency
99
109
  name: bundler
100
- requirement: &2153387820 !ruby/object:Gem::Requirement
110
+ requirement: &2155635360 !ruby/object:Gem::Requirement
101
111
  none: false
102
112
  requirements:
103
113
  - - ! '>='
104
114
  - !ruby/object:Gem::Version
105
- version: 1.0.10
115
+ version: 1.0.15
106
116
  type: :development
107
117
  prerelease: false
108
- version_requirements: *2153387820
118
+ version_requirements: *2155635360
109
119
  - !ruby/object:Gem::Dependency
110
120
  name: hoe-bundler
111
- requirement: &2153373840 !ruby/object:Gem::Requirement
121
+ requirement: &2155634420 !ruby/object:Gem::Requirement
112
122
  none: false
113
123
  requirements:
114
124
  - - ! '>='
115
125
  - !ruby/object:Gem::Version
116
- version: 1.0.0
126
+ version: 1.1.0
117
127
  type: :development
118
128
  prerelease: false
119
- version_requirements: *2153373840
129
+ version_requirements: *2155634420
120
130
  - !ruby/object:Gem::Dependency
121
131
  name: hoe
122
- requirement: &2153347260 !ruby/object:Gem::Requirement
132
+ requirement: &2155633700 !ruby/object:Gem::Requirement
123
133
  none: false
124
134
  requirements:
125
- - - ! '>='
135
+ - - ~>
126
136
  - !ruby/object:Gem::Version
127
- version: 2.9.1
137
+ version: '2.10'
128
138
  type: :development
129
139
  prerelease: false
130
- version_requirements: *2153347260
140
+ version_requirements: *2155633700
131
141
  description: Enhances simple I18n backend so that it inflects translations using pattern
132
142
  interpolation.
133
143
  email:
@@ -140,12 +150,14 @@ files:
140
150
  - .yardopts
141
151
  - ChangeLog
142
152
  - Gemfile
153
+ - Gemfile.lock
143
154
  - LGPL-LICENSE
144
155
  - Manifest.txt
145
156
  - README.rdoc
146
157
  - Rakefile
147
158
  - ci/i18n-inflector.gemspec
148
159
  - ci/i18nv4-Gemfile
160
+ - ci/i18nv4-Gemfile.lock
149
161
  - docs/COPYING
150
162
  - docs/EXAMPLES
151
163
  - docs/HISTORY
@@ -172,13 +184,12 @@ files:
172
184
  - test/inflector_test.rb
173
185
  - test/test_helper.rb
174
186
  - .gemtest
175
- has_rdoc: true
176
187
  homepage: https://rubygems.org/gems/i18n-inflector/
177
188
  licenses: []
178
189
  post_install_message:
179
190
  rdoc_options:
180
191
  - --title
181
- - I18nInflector Documentation
192
+ - I18n::Inflector Documentation
182
193
  - --quiet
183
194
  require_paths:
184
195
  - lib
@@ -190,7 +201,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
190
201
  version: '0'
191
202
  segments:
192
203
  - 0
193
- hash: -228794564598580435
204
+ hash: -4582047018279432324
194
205
  required_rubygems_version: !ruby/object:Gem::Requirement
195
206
  none: false
196
207
  requirements:
@@ -199,7 +210,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
199
210
  version: '0'
200
211
  requirements: []
201
212
  rubyforge_project: i18n-inflector
202
- rubygems_version: 1.5.2
213
+ rubygems_version: 1.8.5
203
214
  signing_key:
204
215
  specification_version: 3
205
216
  summary: Simple inflection module for I18n