humanize 2.4.0 → 2.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/humanize.gemspec +1 -1
- data/lib/humanize.rb +10 -9
- data/lib/humanize/locales/es.rb +0 -1
- data/lib/humanize/locales/jp.rb +2 -2
- data/spec/locales/jp_spec.rb +35 -33
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5f9cdb19077b40926c9c10dddd5c22eedf5534332d909d67db6ce40f62bdce1a
|
4
|
+
data.tar.gz: 8213cfd2c275c83681e37294e64984acc8515120bf6e8fcb5b100286b0f4e29d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a0ec450dbe6f00973d2ecc0bc94f68024c1827dca512c07d84be2bad683c003b4e2e579e636520e6564059e98b9b3b5fcf4d7bf86f3df42d37e312cf08503c6e
|
7
|
+
data.tar.gz: 3fd51e3028b37cd95c09c0d67ff0556a765a8744cea634005c6fd32b7e9d7e43ed3245e0232a1fce8d2561f7c83b0ae1162e7cbb5245d28b44d99b6243bad4c4
|
data/humanize.gemspec
CHANGED
data/lib/humanize.rb
CHANGED
@@ -75,17 +75,18 @@ module Humanize
|
|
75
75
|
leading_zeroes = [grouping[0]] * exponent.abs
|
76
76
|
decimals_as = :digits if leading_zeroes.any?
|
77
77
|
|
78
|
-
decimals_as_words =
|
79
|
-
|
80
|
-
digits
|
81
|
-
|
78
|
+
decimals_as_words =
|
79
|
+
case decimals_as
|
80
|
+
when :digits
|
81
|
+
digits = significant_digits.chars.map do |num|
|
82
|
+
grouping[num.to_i]
|
83
|
+
end
|
84
|
+
|
85
|
+
(leading_zeroes + digits).join(spacer)
|
86
|
+
when :number
|
87
|
+
significant_digits.to_i.humanize(locale: locale)
|
82
88
|
end
|
83
89
|
|
84
|
-
(leading_zeroes + digits).join(spacer)
|
85
|
-
when :number
|
86
|
-
significant_digits.to_i.humanize(locale: locale)
|
87
|
-
end
|
88
|
-
|
89
90
|
parts.insert(0, decimals_as_words, locale_class::POINT)
|
90
91
|
end
|
91
92
|
|
data/lib/humanize/locales/es.rb
CHANGED
data/lib/humanize/locales/jp.rb
CHANGED
@@ -6,7 +6,7 @@ module Humanize
|
|
6
6
|
iteration = 0
|
7
7
|
parts = []
|
8
8
|
until number.zero?
|
9
|
-
number, remainder = number.divmod(
|
9
|
+
number, remainder = number.divmod(10_000)
|
10
10
|
unless remainder.zero?
|
11
11
|
add_grouping(parts, iteration)
|
12
12
|
parts << SUB_ONE_GROUPING[remainder]
|
@@ -24,7 +24,7 @@ module Humanize
|
|
24
24
|
grouping = LOTS[iteration]
|
25
25
|
return unless grouping
|
26
26
|
|
27
|
-
parts <<
|
27
|
+
parts << grouping.to_s
|
28
28
|
end
|
29
29
|
end
|
30
30
|
end
|
data/spec/locales/jp_spec.rb
CHANGED
@@ -132,38 +132,40 @@ RSpec.describe Humanize, 'jp locale' do
|
|
132
132
|
[5678, '五千六百七十八'],
|
133
133
|
[6789, '六千七百八十九'],
|
134
134
|
[9999, '九千九百九十九'],
|
135
|
-
[
|
136
|
-
[
|
137
|
-
[
|
138
|
-
[
|
139
|
-
[
|
140
|
-
[
|
141
|
-
[
|
142
|
-
[
|
143
|
-
[
|
144
|
-
[
|
145
|
-
[
|
146
|
-
[
|
147
|
-
[
|
148
|
-
[
|
149
|
-
[
|
150
|
-
[
|
151
|
-
[
|
152
|
-
[
|
153
|
-
[
|
154
|
-
[
|
155
|
-
[
|
156
|
-
[
|
157
|
-
[
|
158
|
-
[
|
159
|
-
[
|
160
|
-
[
|
161
|
-
[
|
162
|
-
[
|
163
|
-
[
|
164
|
-
[
|
165
|
-
|
166
|
-
|
135
|
+
[10_000, '一万'],
|
136
|
+
[11_000, '一万一千'],
|
137
|
+
[11_100, '一万一千百'],
|
138
|
+
[11_110, '一万一千百十'],
|
139
|
+
[11_111, '一万一千百十一'],
|
140
|
+
[20_000, '二万'],
|
141
|
+
[21_000, '二万一千'],
|
142
|
+
[21_100, '二万一千百'],
|
143
|
+
[21_110, '二万一千百十'],
|
144
|
+
[21_111, '二万一千百十一'],
|
145
|
+
[23_456, '二万三千四百五十六'],
|
146
|
+
[345_678, '三十四万五千六百七十八'],
|
147
|
+
[456_789, '四十五万六千七百八十九'],
|
148
|
+
[678_901, '六十七万八千九百一'],
|
149
|
+
[9_876_543, '九百八十七万六千五百四十三'],
|
150
|
+
[10_000_000, '一千万'],
|
151
|
+
[11_110_000, '一千百十一万'],
|
152
|
+
[20_000_000, '二千万'],
|
153
|
+
[22_220_000, '二千二百二十二万'],
|
154
|
+
[87_654_321, '八千七百六十五万四千三百二十一'],
|
155
|
+
[100_000_000, '一億'],
|
156
|
+
[765_432_109, '七億六千五百四十三万二千百九'],
|
157
|
+
[543_210_987, '五億四千三百二十一万九百八十七'],
|
158
|
+
[5_678_000_000, '五十六億七千八百万'],
|
159
|
+
[1_000_000_000_000, '一兆'],
|
160
|
+
[1_000_000_000_001, '一兆一'],
|
161
|
+
[1_000_100_010_000, '一兆一億一万'],
|
162
|
+
[1_000_100_010_001, '一兆一億一万一'],
|
163
|
+
[1_100_110_011_001, '一兆一千一億一千一万一千一'],
|
164
|
+
[2_200_220_022_002, '二兆二千二億二千二万二千二'],
|
165
|
+
# rubocop:disable Metrics/LineLength
|
166
|
+
[999_999_999_999_999_999_999_999_999_999_999_999_999_999_999_999_999_999_999_999_999_999_999_999, '九千九百九十九無量大数九千九百九十九不可思議九千九百九十九那由他九千九百九十九阿僧祇九千九百九十九恒河沙九千九百九十九極九千九百九十九載九千九百九十九正九千九百九十九澗九千九百九十九溝九千九百九十九穣九千九百九十九𥝱九千九百九十九垓九千九百九十九京九千九百九十九兆九千九百九十九億九千九百九十九万九千九百九十九'],
|
167
|
+
# rubocop:enable Metrics/LineLength
|
168
|
+
[-123_422_223.48_948_753, 'マイナス一億二千三百四十二万二千二百二十三・四八九四八八']
|
167
169
|
]
|
168
170
|
|
169
171
|
tests.each do |num, output|
|
@@ -175,7 +177,7 @@ RSpec.describe Humanize, 'jp locale' do
|
|
175
177
|
context 'decimals: number' do
|
176
178
|
it 'returns the decimals as whole numbers' do
|
177
179
|
num = 8.159265358
|
178
|
-
expect(num.humanize
|
180
|
+
expect(num.humanize).to eq('八・一五九二六五三五八')
|
179
181
|
expect(num.humanize(decimals_as: :number)).to eq('八・一億五千九百二十六万五千三百五十八')
|
180
182
|
end
|
181
183
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: humanize
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.4.
|
4
|
+
version: 2.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jack Chen
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2020-01-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mutant
|