humanize 1.2.1 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +1 -0
- data/Gemfile.lock +104 -0
- data/README.markdown +6 -0
- data/bin/run_mutant +3 -0
- data/humanize.gemspec +4 -1
- data/lib/humanize.rb +6 -2
- data/lib/words.rb +1 -1
- data/spec/configuration_spec.rb +2 -3
- data/spec/humanize_spec.rb +43 -5
- data/spec/spec_helper.rb +11 -0
- data/spec/tests.rb +1 -0
- metadata +48 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2f4b736de653e7f262d1be96c6b0be4f5bfd7dad
|
4
|
+
data.tar.gz: 47a8b9e66ed64ea87ae09fafd3b8d8020c323d6b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 97d8614d71b227474f395af1c94e8b026c42f9ab3aa2b4d7ecd04319b017785e120ff13f708f80407413f7a32710472dd8e965e4bbb69b487a865ea5b3595555
|
7
|
+
data.tar.gz: 15126879e6a876b89a2cff78f331695dc393354bded16f5ca2997112fae8e81c74fb9570a1466e49711c150385296b51dc89b34cf16487a5db5f4379989c347f
|
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
.byebug_history
|
data/.travis.yml
CHANGED
data/Gemfile.lock
ADDED
@@ -0,0 +1,104 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
humanize (1.2.2)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
abstract_type (0.0.7)
|
10
|
+
adamantium (0.2.0)
|
11
|
+
ice_nine (~> 0.11.0)
|
12
|
+
memoizable (~> 0.4.0)
|
13
|
+
anima (0.3.0)
|
14
|
+
abstract_type (~> 0.0.7)
|
15
|
+
adamantium (~> 0.2)
|
16
|
+
equalizer (~> 0.0.11)
|
17
|
+
ast (2.3.0)
|
18
|
+
byebug (9.0.6)
|
19
|
+
coderay (1.1.1)
|
20
|
+
concord (0.1.5)
|
21
|
+
adamantium (~> 0.2.0)
|
22
|
+
equalizer (~> 0.0.9)
|
23
|
+
diff-lcs (1.2.5)
|
24
|
+
equalizer (0.0.11)
|
25
|
+
ice_nine (0.11.2)
|
26
|
+
memoizable (0.4.2)
|
27
|
+
thread_safe (~> 0.3, >= 0.3.1)
|
28
|
+
method_source (0.8.2)
|
29
|
+
morpher (0.2.6)
|
30
|
+
abstract_type (~> 0.0.7)
|
31
|
+
adamantium (~> 0.2.0)
|
32
|
+
anima (~> 0.3.0)
|
33
|
+
ast (~> 2.2)
|
34
|
+
concord (~> 0.1.5)
|
35
|
+
equalizer (~> 0.0.9)
|
36
|
+
ice_nine (~> 0.11.0)
|
37
|
+
procto (~> 0.0.2)
|
38
|
+
mutant (0.8.12)
|
39
|
+
abstract_type (~> 0.0.7)
|
40
|
+
adamantium (~> 0.2.0)
|
41
|
+
anima (~> 0.3.0)
|
42
|
+
ast (~> 2.2)
|
43
|
+
concord (~> 0.1.5)
|
44
|
+
diff-lcs (~> 1.2)
|
45
|
+
equalizer (~> 0.0.9)
|
46
|
+
ice_nine (~> 0.11.1)
|
47
|
+
memoizable (~> 0.4.2)
|
48
|
+
morpher (~> 0.2.6)
|
49
|
+
parallel (~> 1.3)
|
50
|
+
parser (~> 2.3.1, >= 2.3.1.4)
|
51
|
+
procto (~> 0.0.2)
|
52
|
+
regexp_parser (~> 0.3.6)
|
53
|
+
unparser (~> 0.2.5)
|
54
|
+
mutant-rspec (0.8.11)
|
55
|
+
mutant (~> 0.8.11)
|
56
|
+
rspec-core (>= 3.4.0, < 3.6.0)
|
57
|
+
parallel (1.9.0)
|
58
|
+
parser (2.3.1.4)
|
59
|
+
ast (~> 2.2)
|
60
|
+
procto (0.0.3)
|
61
|
+
pry (0.10.4)
|
62
|
+
coderay (~> 1.1.0)
|
63
|
+
method_source (~> 0.8.1)
|
64
|
+
slop (~> 3.4)
|
65
|
+
pry-byebug (3.4.0)
|
66
|
+
byebug (~> 9.0)
|
67
|
+
pry (~> 0.10)
|
68
|
+
regexp_parser (0.3.6)
|
69
|
+
rspec (3.5.0)
|
70
|
+
rspec-core (~> 3.5.0)
|
71
|
+
rspec-expectations (~> 3.5.0)
|
72
|
+
rspec-mocks (~> 3.5.0)
|
73
|
+
rspec-core (3.5.4)
|
74
|
+
rspec-support (~> 3.5.0)
|
75
|
+
rspec-expectations (3.5.0)
|
76
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
77
|
+
rspec-support (~> 3.5.0)
|
78
|
+
rspec-mocks (3.5.0)
|
79
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
80
|
+
rspec-support (~> 3.5.0)
|
81
|
+
rspec-support (3.5.0)
|
82
|
+
slop (3.6.0)
|
83
|
+
thread_safe (0.3.5)
|
84
|
+
unparser (0.2.5)
|
85
|
+
abstract_type (~> 0.0.7)
|
86
|
+
adamantium (~> 0.2.0)
|
87
|
+
concord (~> 0.1.5)
|
88
|
+
diff-lcs (~> 1.2.5)
|
89
|
+
equalizer (~> 0.0.9)
|
90
|
+
parser (~> 2.3.0)
|
91
|
+
procto (~> 0.0.2)
|
92
|
+
|
93
|
+
PLATFORMS
|
94
|
+
ruby
|
95
|
+
|
96
|
+
DEPENDENCIES
|
97
|
+
humanize!
|
98
|
+
mutant
|
99
|
+
mutant-rspec
|
100
|
+
pry-byebug
|
101
|
+
rspec
|
102
|
+
|
103
|
+
BUNDLED WITH
|
104
|
+
1.13.5
|
data/README.markdown
CHANGED
@@ -78,6 +78,12 @@ Currently supported locales: `:en` and `:fr`
|
|
78
78
|
2. 0.120000 0.000000 0.120000 ( 0.116230)
|
79
79
|
3. 0.130000 0.000000 0.130000 ( 0.122856)
|
80
80
|
|
81
|
+
## Testing
|
82
|
+
|
83
|
+
Install development dependencies by running `bundle install`.
|
84
|
+
|
85
|
+
You can run mutation testing by calling `bin/run_mutant`.
|
86
|
+
|
81
87
|
## Credits
|
82
88
|
|
83
89
|
* *Original idea*: Brenton Fletcher
|
data/bin/run_mutant
ADDED
data/humanize.gemspec
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "humanize"
|
6
|
-
s.version = "1.2.
|
6
|
+
s.version = "1.2.2"
|
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"]
|
@@ -17,4 +17,7 @@ Gem::Specification.new do |s|
|
|
17
17
|
s.summary = "Extension to Numeric to humanize numbers"
|
18
18
|
|
19
19
|
s.add_development_dependency 'rspec'
|
20
|
+
s.add_development_dependency 'mutant'
|
21
|
+
s.add_development_dependency 'mutant-rspec'
|
22
|
+
s.add_development_dependency 'pry-byebug'
|
20
23
|
end
|
data/lib/humanize.rb
CHANGED
@@ -26,7 +26,7 @@ module Humanize
|
|
26
26
|
sets << LOTS[locale][i] + (!sets.empty? ? (f ? ' ' + WORDS[locale][:and] : WORDS[locale][:comma]) : '') if !(r.zero? || i.zero?)
|
27
27
|
f = true if i.zero? && r < 100
|
28
28
|
|
29
|
-
sets << SUB_ONE_THOUSAND[locale][r] if !r.zero?
|
29
|
+
sets << SUB_ONE_THOUSAND[locale][r] if !r.zero? && !exactly_one_thousand_in_french?(locale, r, sets)
|
30
30
|
i = i.succ
|
31
31
|
|
32
32
|
end
|
@@ -40,7 +40,7 @@ module Humanize
|
|
40
40
|
end
|
41
41
|
o += ' ' + WORDS[locale][:point] + ' ' + decimals_as_words
|
42
42
|
end
|
43
|
-
o
|
43
|
+
o.gsub(/ +/, ' ')
|
44
44
|
end
|
45
45
|
|
46
46
|
class << self
|
@@ -61,6 +61,10 @@ module Humanize
|
|
61
61
|
|
62
62
|
private
|
63
63
|
|
64
|
+
def exactly_one_thousand_in_french?(locale, r, sets)
|
65
|
+
locale == :fr && r == 1 && sets.last.to_s.strip == 'mille'
|
66
|
+
end
|
67
|
+
|
64
68
|
class Configuration
|
65
69
|
attr_accessor :default_locale, :decimals_as
|
66
70
|
|
data/lib/words.rb
CHANGED
data/spec/configuration_spec.rb
CHANGED
data/spec/humanize_spec.rb
CHANGED
@@ -1,6 +1,4 @@
|
|
1
|
-
require '
|
2
|
-
require 'humanize'
|
3
|
-
require 'rspec'
|
1
|
+
require 'spec_helper'
|
4
2
|
|
5
3
|
describe "Humanize" do
|
6
4
|
require_relative 'tests'
|
@@ -19,12 +17,52 @@ describe "Humanize" do
|
|
19
17
|
|
20
18
|
it 'uses default locale' do
|
21
19
|
Humanize.config.default_locale = :fr
|
22
|
-
expect(42.humanize).to eql(
|
20
|
+
expect(42.humanize).to eql('quarante-deux')
|
23
21
|
end
|
24
22
|
|
25
23
|
it 'uses locale passed as argument if given' do
|
26
24
|
Humanize.config.default_locale = :en
|
27
|
-
expect(42.humanize(:locale => :fr)).to eql(
|
25
|
+
expect(42.humanize(:locale => :fr)).to eql('quarante-deux')
|
26
|
+
end
|
27
|
+
|
28
|
+
describe 'french specific rules' do
|
29
|
+
|
30
|
+
it 'one thousand and one equals "mille un"' do
|
31
|
+
expect(1002.humanize(:locale => :fr)).to eql('mille deux')
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'two thousand and one equals "deux mille un"' do
|
35
|
+
expect(2001.humanize(:locale => :fr)).to eql('deux mille un')
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'ten thousand equals "dix mille"' do
|
39
|
+
expect(2001.humanize(:locale => :fr)).to eql('deux mille un')
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
describe 'decimals_as option' do
|
47
|
+
|
48
|
+
it 'uses value from configuration' do
|
49
|
+
Humanize.config.decimals_as = :number
|
50
|
+
expect(0.42.humanize).to eql('zero point forty-two')
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'uses value passed as argument if given' do
|
54
|
+
Humanize.config.decimals_as = :number
|
55
|
+
expect(0.42.humanize(:decimals_as => :digits)).to eql('zero point four two')
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
describe 'both options work together' do
|
61
|
+
|
62
|
+
it 'work together' do
|
63
|
+
expect(
|
64
|
+
0.42.humanize(:locale => :fr, :decimals_as => :number)
|
65
|
+
).to eql('zéro virgule quarante-deux')
|
28
66
|
end
|
29
67
|
|
30
68
|
end
|
data/spec/spec_helper.rb
ADDED
data/spec/tests.rb
CHANGED
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.2.
|
4
|
+
version: 1.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jack Chen
|
@@ -25,19 +25,64 @@ dependencies:
|
|
25
25
|
- - ">="
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: '0'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: mutant
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: mutant-rspec
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ">="
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: pry-byebug
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
28
70
|
description:
|
29
71
|
email: radarlistener@gmail.com
|
30
72
|
executables: []
|
31
73
|
extensions: []
|
32
74
|
extra_rdoc_files: []
|
33
75
|
files:
|
76
|
+
- ".gitignore"
|
34
77
|
- ".travis.yml"
|
35
78
|
- Gemfile
|
79
|
+
- Gemfile.lock
|
36
80
|
- LICENSE.md
|
37
81
|
- README.markdown
|
38
82
|
- Rakefile
|
39
83
|
- Wordlist.source
|
40
84
|
- bench.rb
|
85
|
+
- bin/run_mutant
|
41
86
|
- humanize.gemspec
|
42
87
|
- lib/cache.rb
|
43
88
|
- lib/humanize.rb
|
@@ -47,6 +92,7 @@ files:
|
|
47
92
|
- spec/TODO
|
48
93
|
- spec/configuration_spec.rb
|
49
94
|
- spec/humanize_spec.rb
|
95
|
+
- spec/spec_helper.rb
|
50
96
|
- spec/tests.rb
|
51
97
|
homepage: https://github.com/radar/humanize
|
52
98
|
licenses: []
|
@@ -75,4 +121,5 @@ test_files:
|
|
75
121
|
- spec/TODO
|
76
122
|
- spec/configuration_spec.rb
|
77
123
|
- spec/humanize_spec.rb
|
124
|
+
- spec/spec_helper.rb
|
78
125
|
- spec/tests.rb
|