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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 472a0141b600f7c9bbb378b46d7e922cb6e316e505bbfa2b875352eb470e6c5b
4
- data.tar.gz: ab0da50e9a77b43baacb2968d130c5011b42669e83b53ac04e2399204dc5abd3
3
+ metadata.gz: 5f9cdb19077b40926c9c10dddd5c22eedf5534332d909d67db6ce40f62bdce1a
4
+ data.tar.gz: 8213cfd2c275c83681e37294e64984acc8515120bf6e8fcb5b100286b0f4e29d
5
5
  SHA512:
6
- metadata.gz: 0e4069ccfdb3ec72e7412a4a042aaf5f5e3d164463869e44e2ef7f4b49552113e849bf467a4e144de3d0a4265468d1356fd0fd76fdc53bc2a32591032f09c92c
7
- data.tar.gz: 304a2ae874741ed483f1dbe2d76bf5fde7fbfa6ad6532d6a9a3354468db4f2f0926734c12c3719f643a37755696990dea648cb7b67ecaa8d5dbe4f76d338a2f0
6
+ metadata.gz: a0ec450dbe6f00973d2ecc0bc94f68024c1827dca512c07d84be2bad683c003b4e2e579e636520e6564059e98b9b3b5fcf4d7bf86f3df42d37e312cf08503c6e
7
+ data.tar.gz: 3fd51e3028b37cd95c09c0d67ff0556a765a8744cea634005c6fd32b7e9d7e43ed3245e0232a1fce8d2561f7c83b0ae1162e7cbb5245d28b44d99b6243bad4c4
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "humanize"
3
- s.version = "2.4.0"
3
+ s.version = "2.4.1"
4
4
 
5
5
  s.required_ruby_version = '>= 2.3'
6
6
  s.require_paths = ["lib"]
@@ -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 = case decimals_as
79
- when :digits
80
- digits = significant_digits.chars.map do |num|
81
- grouping[num.to_i]
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
 
@@ -1,5 +1,4 @@
1
1
  require_relative 'constants/es'
2
- require 'pry'
3
2
 
4
3
  module Humanize
5
4
  class Es
@@ -6,7 +6,7 @@ module Humanize
6
6
  iteration = 0
7
7
  parts = []
8
8
  until number.zero?
9
- number, remainder = number.divmod(10000)
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 << "#{grouping}"
27
+ parts << grouping.to_s
28
28
  end
29
29
  end
30
30
  end
@@ -132,38 +132,40 @@ RSpec.describe Humanize, 'jp locale' do
132
132
  [5678, '五千六百七十八'],
133
133
  [6789, '六千七百八十九'],
134
134
  [9999, '九千九百九十九'],
135
- [10000, '一万'],
136
- [11000, '一万一千'],
137
- [11100, '一万一千百'],
138
- [11110, '一万一千百十'],
139
- [11111, '一万一千百十一'],
140
- [20000, '二万'],
141
- [21000, '二万一千'],
142
- [21100, '二万一千百'],
143
- [21110, '二万一千百十'],
144
- [21111, '二万一千百十一'],
145
- [23456, '二万三千四百五十六'],
146
- [345678, '三十四万五千六百七十八'],
147
- [456789, '四十五万六千七百八十九'],
148
- [678901, '六十七万八千九百一'],
149
- [9876543, '九百八十七万六千五百四十三'],
150
- [10000000, '一千万'],
151
- [11110000, '一千百十一万'],
152
- [20000000, '二千万'],
153
- [22220000, '二千二百二十二万'],
154
- [87654321, '八千七百六十五万四千三百二十一'],
155
- [100000000, '一億'],
156
- [765432109, '七億六千五百四十三万二千百九'],
157
- [543210987, '五億四千三百二十一万九百八十七'],
158
- [5678000000, '五十六億七千八百万'],
159
- [1000000000000, '一兆'],
160
- [1000000000001, '一兆一'],
161
- [1000100010000, '一兆一億一万'],
162
- [1000100010001, '一兆一億一万一'],
163
- [1100110011001, '一兆一千一億一千一万一千一'],
164
- [2200220022002, '二兆二千二億二千二万二千二'],
165
- [999999999999999999999999999999999999999999999999999999999999999999999999, '九千九百九十九無量大数九千九百九十九不可思議九千九百九十九那由他九千九百九十九阿僧祇九千九百九十九恒河沙九千九百九十九極九千九百九十九載九千九百九十九正九千九百九十九澗九千九百九十九溝九千九百九十九穣九千九百九十九𥝱九千九百九十九垓九千九百九十九京九千九百九十九兆九千九百九十九億九千九百九十九万九千九百九十九',
166
- [-123422223.48948753, 'マイナス一億二千三百四十二万二千二百二十三・四八九四八八']]
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()).to eq('八・一五九二六五三五八')
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.0
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: 2019-10-31 00:00:00.000000000 Z
12
+ date: 2020-01-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mutant