amount_inflector 2.0.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.0.
|
1
|
+
2.0.1
|
data/amount_inflector.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "amount_inflector"
|
8
|
-
s.version = "2.0.
|
8
|
+
s.version = "2.0.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Kresimir Bojcic"]
|
12
|
-
s.date = "2012-
|
12
|
+
s.date = "2012-06-09"
|
13
13
|
s.description = "Amount Inflector for year/month/week/day (Croatian)"
|
14
14
|
s.email = "kresimir.bojcic@gmail.com"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -27,7 +27,7 @@ Gem::Specification.new do |s|
|
|
27
27
|
"amount_inflector.gemspec",
|
28
28
|
"lib/amount_inflector.rb",
|
29
29
|
"lib/amount_inflector/amount_inflector.rb",
|
30
|
-
"spec/amount_inflector_spec.rb"
|
30
|
+
"spec/amount_inflector/amount_inflector_spec.rb"
|
31
31
|
]
|
32
32
|
s.homepage = "http://github.com/drKreso/amount_inflector"
|
33
33
|
s.licenses = ["MIT"]
|
@@ -1,6 +1,6 @@
|
|
1
1
|
class AmountInflector
|
2
2
|
|
3
|
-
|
3
|
+
CONFIG = {
|
4
4
|
:godina => { one:"godina", few:"godine", many:"godina" },
|
5
5
|
:mjesec => { one:"mjesec", few:"mjeseca", many:"mjeseci" },
|
6
6
|
:tjedan => { one:"tjedan", few:"tjedna", many:"tjedana" },
|
@@ -8,15 +8,15 @@ class AmountInflector
|
|
8
8
|
}
|
9
9
|
|
10
10
|
def self.inflect(amount, unit)
|
11
|
-
|
12
|
-
raise "Inflection :#{unit} is unsupported" if
|
13
|
-
"#{amount} #{
|
11
|
+
unit = unit.to_s.to_sym
|
12
|
+
raise "Inflection :#{unit} is unsupported" if CONFIG[unit].nil?
|
13
|
+
"#{amount} #{CONFIG[unit][pluralize_form(amount)]}"
|
14
14
|
end
|
15
15
|
|
16
|
-
def self.
|
16
|
+
def self.pluralize_form(n)
|
17
17
|
return :many if (11..14).include?(n % 100)
|
18
18
|
return :few if (2..4).include?(n % 10)
|
19
|
-
(n % 10
|
19
|
+
(n % 10 == 1) ? :one : :many
|
20
20
|
end
|
21
21
|
|
22
22
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
require 'amount_inflector.rb'
|
2
2
|
|
3
3
|
describe AmountInflector do
|
4
4
|
|
@@ -6,6 +6,10 @@ describe AmountInflector do
|
|
6
6
|
AmountInflector.inflect(1, :godina).should == "1 godina"
|
7
7
|
end
|
8
8
|
|
9
|
+
it 'should say 1 godina when given string' do
|
10
|
+
AmountInflector.inflect(1, "godina").should == "1 godina"
|
11
|
+
end
|
12
|
+
|
9
13
|
it 'should say 2 godine' do
|
10
14
|
AmountInflector.inflect(2, :godina).should == "2 godine"
|
11
15
|
end
|
@@ -14,6 +18,10 @@ describe AmountInflector do
|
|
14
18
|
AmountInflector.inflect(92, :godina).should == "92 godine"
|
15
19
|
end
|
16
20
|
|
21
|
+
it 'should say 93 godine' do
|
22
|
+
AmountInflector.inflect(93, :godina).should == "93 godine"
|
23
|
+
end
|
24
|
+
|
17
25
|
it 'should say 12 godina' do
|
18
26
|
AmountInflector.inflect(12, :godina).should == "12 godina"
|
19
27
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: amount_inflector
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-06-09 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec-rails
|
16
|
-
requirement: &
|
16
|
+
requirement: &70192387727880 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 2.3.0
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70192387727880
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: bundler
|
27
|
-
requirement: &
|
27
|
+
requirement: &70192387726780 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 1.0.0
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70192387726780
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: jeweler
|
38
|
-
requirement: &
|
38
|
+
requirement: &70192387726000 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 1.6.4
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70192387726000
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rcov
|
49
|
-
requirement: &
|
49
|
+
requirement: &70192387715820 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,7 +54,7 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70192387715820
|
58
58
|
description: Amount Inflector for year/month/week/day (Croatian)
|
59
59
|
email: kresimir.bojcic@gmail.com
|
60
60
|
executables: []
|
@@ -73,7 +73,7 @@ files:
|
|
73
73
|
- amount_inflector.gemspec
|
74
74
|
- lib/amount_inflector.rb
|
75
75
|
- lib/amount_inflector/amount_inflector.rb
|
76
|
-
- spec/amount_inflector_spec.rb
|
76
|
+
- spec/amount_inflector/amount_inflector_spec.rb
|
77
77
|
homepage: http://github.com/drKreso/amount_inflector
|
78
78
|
licenses:
|
79
79
|
- MIT
|
@@ -89,7 +89,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
89
89
|
version: '0'
|
90
90
|
segments:
|
91
91
|
- 0
|
92
|
-
hash:
|
92
|
+
hash: -3694741291819528788
|
93
93
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|