humanize 1.5.0 → 1.6.0

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
  SHA1:
3
- metadata.gz: 04423347ffc9c0535b9468a69e175d31304b22e9
4
- data.tar.gz: c2dcf65fa8b595ae0c635ab8ae4195d87c4a46f4
3
+ metadata.gz: 1a4e43c1d739513348d02de2ff1ff5a9f70ae5d9
4
+ data.tar.gz: 1f9b6e062f12066a8c6bc8b35ebfd2f270416cf7
5
5
  SHA512:
6
- metadata.gz: 136f6423100d0fade6cc41dc7fdd62b3fb059d54eef89dcb979ea9f469f908bce201f50941a20bc521a3489670d4ec41b5643aaf1436e515adcb2989d010ec74
7
- data.tar.gz: a1c08f3c8713d9c1c318b1d159b5afc0bd4092a6ef18d06dab06610b6a39c30c65e09a5eb55155fd45f2eb289833175f1ac83896473608bb0e10bc3130b55f35
6
+ metadata.gz: 5bac4a44f2dcbf47b79c88bedcb37abc5e08d668af8c29739fc38c80e5dd24c1e6cbebad5f8cf82865b51c3b549579e4dc9a51d38e21d68ab790e370c6815c20
7
+ data.tar.gz: 27c0004f535b4beaf57c6e0c03f2daf6679dfd424b0417ef287b40cf69501edded9b30790e97d14628eaa21751d38bfed1f72ccf4f097618733dad65804cd072
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- humanize (1.4.0)
4
+ humanize (1.5.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -101,4 +101,4 @@ DEPENDENCIES
101
101
  rspec
102
102
 
103
103
  BUNDLED WITH
104
- 1.15.3
104
+ 1.16.0.pre.2
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'humanize'
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require 'irb'
14
+ IRB.start
15
+
@@ -3,7 +3,7 @@
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "humanize"
6
- s.version = "1.5.0"
6
+ s.version = "1.6.0"
7
7
 
8
8
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
9
9
  s.require_paths = ["lib"]
@@ -36,12 +36,19 @@ module Humanize
36
36
  end
37
37
  if self.class == Float
38
38
  decimals = self.to_s.split(/\./, 2).last
39
+ has_leading_zeroes = decimals[/^0+/].to_s.length > 0
40
+ decimals_as = :digits if has_leading_zeroes
39
41
  decimals_as_words = case decimals_as
40
42
  when :digits then decimals.scan(/./).map { |n| SUB_ONE_THOUSAND[locale][n.to_i] }.join(' ')
41
43
  when :number then decimals.to_i.humanize(:locale => locale)
42
44
  end
43
45
  o += ' ' + WORDS[locale][:point] + ' ' + decimals_as_words
44
46
  end
47
+ if locale == :id
48
+ lots = LOTS[:id].drop(2).map{|n| n + ' '}
49
+ wrong_1000_re = /(?<=#{lots.join("|")})\s*satu ribu|^satu ribu/
50
+ o.sub!(wrong_1000_re, 'seribu')
51
+ end
45
52
  o.gsub(/ +/, ' ')
46
53
  end
47
54
 
@@ -59,6 +59,26 @@ describe "Humanize" do
59
59
 
60
60
  end
61
61
 
62
+ describe 'indonesian specific rules' do
63
+ before do
64
+ Humanize.config.default_locale = :id
65
+ end
66
+
67
+ context 'one thousand' do
68
+ it 'equals "satu ribu" when it is not the only thousand in its thousands range' do
69
+ expect(1_101_000.humanize).to eql('satu juta seratus satu ribu')
70
+ expect(2_201_042.humanize).to eql('dua juta dua ratus satu ribu empat puluh dua')
71
+ end
72
+
73
+ it 'equals "seribu" when it is the lone thousand in its thousands range' do
74
+ expect(1_000.humanize).to eql('seribu')
75
+ expect(1_042.humanize).to eql('seribu empat puluh dua')
76
+ expect(1_001_042.humanize).to eql('satu juta seribu empat puluh dua')
77
+ expect(1_000_001_042.humanize).to eql('satu miliar seribu empat puluh dua')
78
+ end
79
+ end
80
+ end
81
+
62
82
  end
63
83
 
64
84
  describe 'decimals_as option' do
@@ -73,6 +93,19 @@ describe "Humanize" do
73
93
  expect(0.42.humanize(:decimals_as => :digits)).to eql('zero point four two')
74
94
  end
75
95
 
96
+ describe 'when set as number' do
97
+
98
+ before do
99
+ Humanize.config.decimals_as = :number
100
+ end
101
+
102
+ it 'reads the decimals as digits if led by zero(s)' do
103
+ expect(0.042.humanize).to eql('zero point zero four two')
104
+ expect(0.0042.humanize).to eql('zero point zero zero four two')
105
+ end
106
+
107
+ end
108
+
76
109
  end
77
110
 
78
111
  describe 'both options work together' do
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: 1.5.0
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jack Chen
@@ -82,6 +82,7 @@ files:
82
82
  - Rakefile
83
83
  - Wordlist.source
84
84
  - bench.rb
85
+ - bin/console
85
86
  - bin/run_mutant
86
87
  - humanize.gemspec
87
88
  - lib/humanize.rb