number_to_words_ru 0.2.3 → 0.3.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. data/LICENSE.txt +20 -0
  2. data/README.rdoc +68 -0
  3. data/lib/initializers/i18n.rb +1 -1
  4. data/lib/locales/numbers.en.yml +2 -3
  5. data/lib/locales/plurals.rb +24 -16
  6. data/lib/numbers_and_words/array_additions/helpers.rb +50 -0
  7. data/lib/numbers_and_words/array_additions/validations.rb +9 -0
  8. data/lib/numbers_and_words/array_additions.rb +2 -0
  9. data/lib/numbers_and_words/core_ext/array.rb +9 -0
  10. data/lib/numbers_and_words/core_ext/integer.rb +12 -0
  11. data/lib/numbers_and_words/figures_array.rb +15 -0
  12. data/lib/{number_to_words_ru → numbers_and_words}/pluralization.rb +0 -0
  13. data/lib/numbers_and_words/strategies/base.rb +11 -0
  14. data/lib/numbers_and_words/strategies/en.rb +71 -0
  15. data/lib/numbers_and_words/strategies/ru.rb +71 -0
  16. data/lib/numbers_and_words/strategies.rb +3 -0
  17. data/lib/numbers_and_words/translations_helpers/base.rb +11 -0
  18. data/lib/numbers_and_words/translations_helpers/en.rb +41 -0
  19. data/lib/numbers_and_words/translations_helpers/ru.rb +41 -0
  20. data/lib/numbers_and_words/translations_helpers.rb +3 -0
  21. data/lib/numbers_and_words/version.rb +3 -0
  22. data/lib/numbers_and_words.rb +30 -0
  23. metadata +96 -31
  24. data/lib/number_to_words_ru/array_additions/helpers.rb +0 -48
  25. data/lib/number_to_words_ru/array_additions/validations.rb +0 -7
  26. data/lib/number_to_words_ru/array_additions.rb +0 -2
  27. data/lib/number_to_words_ru/core_ext/array.rb +0 -5
  28. data/lib/number_to_words_ru/core_ext/integer.rb +0 -11
  29. data/lib/number_to_words_ru/figures_array.rb +0 -9
  30. data/lib/number_to_words_ru/strategies/base.rb +0 -10
  31. data/lib/number_to_words_ru/strategies/en.rb +0 -69
  32. data/lib/number_to_words_ru/strategies/ru.rb +0 -69
  33. data/lib/number_to_words_ru/strategies.rb +0 -3
  34. data/lib/number_to_words_ru/translations_helpers/base.rb +0 -9
  35. data/lib/number_to_words_ru/translations_helpers/en.rb +0 -37
  36. data/lib/number_to_words_ru/translations_helpers/ru.rb +0 -37
  37. data/lib/number_to_words_ru/translations_helpers.rb +0 -3
  38. data/lib/number_to_words_ru.rb +0 -26
  39. data/spec/number_to_words_ru/array/ru_spec.rb +0 -27
  40. data/spec/number_to_words_ru/integer/ru_spec.rb +0 -293
  41. data/spec/spec_helper.rb +0 -8
@@ -1,293 +0,0 @@
1
- require './spec/spec_helper'
2
-
3
- describe Integer do
4
- around :each do |example|
5
- I18n.with_locale(:ru) do
6
- example.run
7
- end
8
- end
9
-
10
- describe '#to_words' do
11
- describe 'ones' do
12
- context '0 as uniq example' do
13
- subject { 0 }
14
- its(:to_words) { should == t(:ones_male)[0] }
15
- end
16
-
17
- context '1 as lower example' do
18
- subject { 1 }
19
- its(:to_words) { should == t(:ones_male)[1] }
20
- end
21
-
22
- context '9 as upper example' do
23
- subject { 9 }
24
- its(:to_words) { should == t(:ones_male)[9] }
25
- end
26
- end
27
-
28
- describe 'teens' do
29
- context '10 as uniq example' do
30
- subject { 10 }
31
- its(:to_words) { should == t(:teens)[0] }
32
- end
33
-
34
- context '11 as lower example' do
35
- subject { 11 }
36
- its(:to_words) { should == t(:teens)[1] }
37
- end
38
-
39
- context '19 as upper example' do
40
- subject { 19 }
41
- its(:to_words) { should == t(:teens)[9] }
42
- end
43
- end
44
-
45
- describe 'tens' do
46
- context '20 as lower example' do
47
- subject { 20 }
48
- its(:to_words) { should == t(:tens)[2] }
49
- end
50
-
51
- context '21 as lower example with ones' do
52
- subject { 21 }
53
- its(:to_words) { should == [t(:tens)[2], t(:ones_male)[1]].join(' ') }
54
- end
55
-
56
- context '90 as upper example' do
57
- subject { 90 }
58
- its(:to_words) { should == t(:tens)[9] }
59
- end
60
-
61
- context '99 as upper example with ones' do
62
- subject { 99 }
63
- its(:to_words) { should == [t(:tens)[9], t(:ones_male)[9]].join(' ') }
64
- end
65
- end
66
-
67
- describe 'hundreds' do
68
- context '100 as lower example' do
69
- subject { 100 }
70
- its(:to_words) { should == t(:hundreds)[1] }
71
- end
72
-
73
- context '101 as lower example with ones' do
74
- subject { 101 }
75
- its(:to_words) { should == [t(:hundreds)[1], t(:ones_male)[1]].join(' ') }
76
- end
77
-
78
- context '111 as lower example with teens' do
79
- subject { 111 }
80
- its(:to_words) { should == [t(:hundreds)[1], t(:teens)[1]].join(' ') }
81
- end
82
-
83
- context '120 as lower example with tens' do
84
- subject { 120 }
85
- its(:to_words) { should == [t(:hundreds)[1], t(:tens)[2]].join(' ') }
86
- end
87
-
88
- context '121 as lower example with tens and ones' do
89
- subject { 121 }
90
-
91
- its(:to_words) { should == [
92
- t(:hundreds)[1],
93
- t(:tens)[2],
94
- t(:ones_male)[1]
95
- ].join(' ') }
96
- end
97
-
98
- context '900 as upper example' do
99
- subject { 900 }
100
- its(:to_words) { should == t(:hundreds)[9] }
101
- end
102
-
103
- context '909 as upper example with ones' do
104
- subject { 909 }
105
- its(:to_words) { should == [t(:hundreds)[9], t(:ones_male)[9]].join(' ') }
106
- end
107
-
108
- context '919 as upper example with teens' do
109
- subject { 919 }
110
- its(:to_words) { should == [t(:hundreds)[9], t(:teens)[9]].join(' ') }
111
- end
112
-
113
- context '990 as upper example with tens' do
114
- subject { 990 }
115
- its(:to_words) { should == [t(:hundreds)[9], t(:tens)[9]].join(' ') }
116
- end
117
-
118
- context '999 as upper example with tens and ones' do
119
- subject { 999 }
120
-
121
- its(:to_words) { should == [t(:hundreds)[9], t(:tens)[9], t(:ones_male)[9]].
122
- join(' ') }
123
- end
124
- end
125
-
126
- describe 'thousands' do
127
- describe 'one' do
128
- context '1000 as uniq example' do
129
- subject { 1000 }
130
-
131
- its(:to_words) { should == [t(:ones_female)[1], t(:thousands, :count => 1)].
132
- join(' ') }
133
- end
134
-
135
- context '21000 as uniq example' do
136
- subject { 21000 }
137
-
138
- its(:to_words) { should == [
139
- t(:tens)[2], t(:ones_female)[1], t(:thousands, :count => 1)
140
- ].join(' ') }
141
- end
142
- end
143
-
144
- describe 'few' do
145
- context '2000 as lower example' do
146
- subject { 2000 }
147
-
148
- its(:to_words) { should == [t(:ones_female)[2], t(:thousands, :count => 2)].
149
- join(' ') }
150
- end
151
-
152
- context '4000 as upper example' do
153
- subject { 4000 }
154
-
155
- its(:to_words) { should == [t(:ones_female)[4], t(:thousands, :count => 4)].
156
- join(' ') }
157
- end
158
- end
159
-
160
- describe 'many' do
161
- context '5000 as lower example' do
162
- subject { 5000 }
163
-
164
- its(:to_words) { should == [t(:ones_female)[5], t(:thousands, :count => 5)].
165
- join(' ') }
166
- end
167
-
168
- context '11000 as uniq example' do
169
- subject { 11000 }
170
-
171
- its(:to_words) { should == [t(:teens)[1], t(:thousands, :count => 11)].join(' ') }
172
- end
173
-
174
- context '999000 as upper example' do
175
- subject { 999000 }
176
-
177
- its(:to_words) { should == [t(:hundreds)[9],
178
- t(:tens)[9],
179
- t(:ones_female)[9],
180
- t(:thousands, :count => 999)
181
- ].join(' ') }
182
- end
183
- end
184
-
185
- describe 'custom' do
186
- context '999999 as example with first capacity' do
187
- subject { 999999 }
188
-
189
- its(:to_words) { should == [t(:hundreds)[9],
190
- t(:tens)[9],
191
- t(:ones_female)[9],
192
- t(:thousands, :count => 999),
193
- t(:hundreds)[9],
194
- t(:tens)[9],
195
- t(:ones_male)[9],
196
- ].join(' ') }
197
- end
198
- end
199
- end
200
- end
201
-
202
- describe 'millions' do
203
- describe 'one' do
204
- context '1000000 as uniq example' do
205
- subject { 1000000 }
206
-
207
- its(:to_words) { should == [t(:ones_male)[1], t(:millions, :count => 1)].
208
- join(' ') }
209
- end
210
- end
211
-
212
- context 'few' do
213
- context '2000000 as lower example in few' do
214
- subject { 2000000 }
215
-
216
- its(:to_words) { should == [t(:ones_male)[2], t(:millions, :count => 2)].
217
- join(' ') }
218
- end
219
-
220
- context '4000000 as upper example in few' do
221
- subject { 4000000 }
222
-
223
- its(:to_words) { should == [t(:ones_male)[4], t(:millions, :count => 4)].
224
- join(' ') }
225
- end
226
- end
227
-
228
- context 'many' do
229
- context '5000000 as lower example in many' do
230
- subject { 5000000 }
231
-
232
- its(:to_words) { should == [t(:ones_male)[5], t(:millions, :count => 5)].
233
- join(' ') }
234
- end
235
-
236
- context '99900000 as upper example' do
237
- subject { 999000000 }
238
-
239
- its(:to_words) { should == [t(:hundreds)[9],
240
- t(:tens)[9],
241
- t(:ones_male)[9],
242
- t(:millions, :count => 999)
243
- ].join(' ') }
244
- end
245
- end
246
-
247
- context 'custom' do
248
- context '999000999 as example with first capacity' do
249
- subject { 999000999 }
250
-
251
- its(:to_words) { should == [t(:hundreds)[9],
252
- t(:tens)[9],
253
- t(:ones_male)[9],
254
- t(:millions, :count => 999),
255
- t(:hundreds)[9],
256
- t(:tens)[9],
257
- t(:ones_male)[9],
258
- ].join(' ') }
259
- end
260
-
261
- context '999999000 as example with second capacity' do
262
- subject { 999999000 }
263
-
264
- its(:to_words) { should == [t(:hundreds)[9],
265
- t(:tens)[9],
266
- t(:ones_male)[9],
267
- t(:millions, :count => 999),
268
- t(:hundreds)[9],
269
- t(:tens)[9],
270
- t(:ones_female)[9],
271
- t(:thousands, :count => 999),
272
- ].join(' ') }
273
- end
274
-
275
- context '999999999 as example with first and second capacity' do
276
- subject { 999999999 }
277
-
278
- its(:to_words) { should == [t(:hundreds)[9],
279
- t(:tens)[9],
280
- t(:ones_male)[9],
281
- t(:millions, :count => 999),
282
- t(:hundreds)[9],
283
- t(:tens)[9],
284
- t(:ones_female)[9],
285
- t(:thousands, :count => 999),
286
- t(:hundreds)[9],
287
- t(:tens)[9],
288
- t(:ones_male)[9],
289
- ].join(' ') }
290
- end
291
- end
292
- end
293
- end
data/spec/spec_helper.rb DELETED
@@ -1,8 +0,0 @@
1
- $TESTING=true
2
- $:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
3
-
4
- require 'number_to_words_ru'
5
-
6
- RSpec.configure do
7
- include TranslationsHelpers::Base
8
- end