cashrb 1.0.0 → 1.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/CHANGELOG.md +7 -0
- data/cashrb.gemspec +1 -1
- data/lib/cash/cash.rb +3 -3
- data/test/test_cash.rb +33 -33
- metadata +40 -32
data/CHANGELOG.md
CHANGED
data/cashrb.gemspec
CHANGED
data/lib/cash/cash.rb
CHANGED
@@ -122,9 +122,9 @@ class Cash
|
|
122
122
|
|
123
123
|
def parse_initialize_options(options)
|
124
124
|
opts = {
|
125
|
-
cents_in_whole
|
126
|
-
rounding_method
|
127
|
-
currency
|
125
|
+
:cents_in_whole => self.class.default_cents_in_whole,
|
126
|
+
:rounding_method => self.class.default_rounding_method,
|
127
|
+
:currency => self.class.default_currency,
|
128
128
|
}.merge(options)
|
129
129
|
|
130
130
|
@cents_in_whole = opts[:cents_in_whole]
|
data/test/test_cash.rb
CHANGED
@@ -41,12 +41,12 @@ class TestCash < MiniTest::Unit::TestCase
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def test_new_with_rounding_method
|
44
|
-
rs = Cash.new(2.5, rounding_method
|
44
|
+
rs = Cash.new(2.5, :rounding_method => BigDecimal::ROUND_HALF_EVEN)
|
45
45
|
assert_equal 2, rs.cents
|
46
46
|
end
|
47
47
|
|
48
48
|
def test_new_with_currency
|
49
|
-
rs = Cash.new(0, currency
|
49
|
+
rs = Cash.new(0, :currency => :usd)
|
50
50
|
assert_equal :usd, rs.currency
|
51
51
|
end
|
52
52
|
|
@@ -57,7 +57,7 @@ class TestCash < MiniTest::Unit::TestCase
|
|
57
57
|
|
58
58
|
def test_plus_with_Cash_Cash_with_different_currencies
|
59
59
|
assert_raises Cash::IncompatibleCurrency do
|
60
|
-
Cash.new(6) + Cash.new(4, currency
|
60
|
+
Cash.new(6) + Cash.new(4, :currency => :usd)
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
@@ -68,7 +68,7 @@ class TestCash < MiniTest::Unit::TestCase
|
|
68
68
|
|
69
69
|
def test_minus_with_Cash_Cash_with_different_currencies
|
70
70
|
assert_raises Cash::IncompatibleCurrency do
|
71
|
-
Cash.new(6) - Cash.new(4, currency
|
71
|
+
Cash.new(6) - Cash.new(4, :currency => :usd)
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
@@ -84,7 +84,7 @@ class TestCash < MiniTest::Unit::TestCase
|
|
84
84
|
|
85
85
|
def test_divide_with_Cash_Cash_with_different_currencies
|
86
86
|
assert_raises Cash::IncompatibleCurrency do
|
87
|
-
Cash.new(6) / Cash.new(4, currency
|
87
|
+
Cash.new(6) / Cash.new(4, :currency => :usd)
|
88
88
|
end
|
89
89
|
end
|
90
90
|
|
@@ -100,7 +100,7 @@ class TestCash < MiniTest::Unit::TestCase
|
|
100
100
|
|
101
101
|
def test_modulo_with_Cash_Cash_with_different_currencies
|
102
102
|
assert_raises Cash::IncompatibleCurrency do
|
103
|
-
Cash.new(6) % Cash.new(4, currency
|
103
|
+
Cash.new(6) % Cash.new(4, :currency => :usd)
|
104
104
|
end
|
105
105
|
end
|
106
106
|
|
@@ -116,7 +116,7 @@ class TestCash < MiniTest::Unit::TestCase
|
|
116
116
|
|
117
117
|
def test_divmod_with_Cash_Cash_with_different_currencies
|
118
118
|
assert_raises Cash::IncompatibleCurrency do
|
119
|
-
Cash.new(6).divmod(Cash.new(4, currency
|
119
|
+
Cash.new(6).divmod(Cash.new(4, :currency => :usd))
|
120
120
|
end
|
121
121
|
end
|
122
122
|
|
@@ -137,7 +137,7 @@ class TestCash < MiniTest::Unit::TestCase
|
|
137
137
|
|
138
138
|
def test_equal_to_with_different_currencies
|
139
139
|
assert_raises Cash::IncompatibleCurrency do
|
140
|
-
Cash.new(6) == Cash.new(6, currency
|
140
|
+
Cash.new(6) == Cash.new(6, :currency => :usd)
|
141
141
|
end
|
142
142
|
end
|
143
143
|
|
@@ -158,7 +158,7 @@ class TestCash < MiniTest::Unit::TestCase
|
|
158
158
|
|
159
159
|
def test_compare_with_different_currencies
|
160
160
|
assert_raises Cash::IncompatibleCurrency do
|
161
|
-
Cash.new(6) <=> Cash.new(6, currency
|
161
|
+
Cash.new(6) <=> Cash.new(6, :currency => :usd)
|
162
162
|
end
|
163
163
|
end
|
164
164
|
|
@@ -179,7 +179,7 @@ class TestCash < MiniTest::Unit::TestCase
|
|
179
179
|
|
180
180
|
def test_greater_than_with_different_currencies
|
181
181
|
assert_raises Cash::IncompatibleCurrency do
|
182
|
-
Cash.new(6) > Cash.new(6, currency
|
182
|
+
Cash.new(6) > Cash.new(6, :currency => :usd)
|
183
183
|
end
|
184
184
|
end
|
185
185
|
|
@@ -200,7 +200,7 @@ class TestCash < MiniTest::Unit::TestCase
|
|
200
200
|
|
201
201
|
def test_less_than_with_different_currencies
|
202
202
|
assert_raises Cash::IncompatibleCurrency do
|
203
|
-
Cash.new(6) < Cash.new(6, currency
|
203
|
+
Cash.new(6) < Cash.new(6, :currency => :usd)
|
204
204
|
end
|
205
205
|
end
|
206
206
|
|
@@ -221,7 +221,7 @@ class TestCash < MiniTest::Unit::TestCase
|
|
221
221
|
|
222
222
|
def test_greater_than_or_equal_to_with_different_currencies
|
223
223
|
assert_raises Cash::IncompatibleCurrency do
|
224
|
-
Cash.new(6) >= Cash.new(6, currency
|
224
|
+
Cash.new(6) >= Cash.new(6, :currency => :usd)
|
225
225
|
end
|
226
226
|
end
|
227
227
|
|
@@ -242,7 +242,7 @@ class TestCash < MiniTest::Unit::TestCase
|
|
242
242
|
|
243
243
|
def test_less_than_or_equal_to_with_different_currencies
|
244
244
|
assert_raises Cash::IncompatibleCurrency do
|
245
|
-
Cash.new(6) <= Cash.new(6, currency
|
245
|
+
Cash.new(6) <= Cash.new(6, :currency => :usd)
|
246
246
|
end
|
247
247
|
end
|
248
248
|
|
@@ -256,16 +256,16 @@ class TestCash < MiniTest::Unit::TestCase
|
|
256
256
|
end
|
257
257
|
|
258
258
|
def test_to_s_with_cents_in_whole
|
259
|
-
assert_equal "0", Cash.new(0, cents_in_whole
|
260
|
-
assert_equal "1", Cash.new(1, cents_in_whole
|
261
|
-
assert_equal "0.4", Cash.new(4, cents_in_whole
|
262
|
-
assert_equal "1.0", Cash.new(5, cents_in_whole
|
263
|
-
assert_equal "0.9", Cash.new(9, cents_in_whole
|
264
|
-
assert_equal "1.0", Cash.new(10, cents_in_whole
|
265
|
-
assert_equal "0.99", Cash.new(99, cents_in_whole
|
266
|
-
assert_equal "1.00", Cash.new(100, cents_in_whole
|
267
|
-
assert_equal "0.999", Cash.new(999, cents_in_whole
|
268
|
-
assert_equal "1.000", Cash.new(1000, cents_in_whole
|
259
|
+
assert_equal "0", Cash.new(0, :cents_in_whole => 1 ).to_s
|
260
|
+
assert_equal "1", Cash.new(1, :cents_in_whole => 1 ).to_s
|
261
|
+
assert_equal "0.4", Cash.new(4, :cents_in_whole => 5 ).to_s
|
262
|
+
assert_equal "1.0", Cash.new(5, :cents_in_whole => 5 ).to_s
|
263
|
+
assert_equal "0.9", Cash.new(9, :cents_in_whole => 10 ).to_s
|
264
|
+
assert_equal "1.0", Cash.new(10, :cents_in_whole => 10 ).to_s
|
265
|
+
assert_equal "0.99", Cash.new(99, :cents_in_whole => 100 ).to_s
|
266
|
+
assert_equal "1.00", Cash.new(100, :cents_in_whole => 100 ).to_s
|
267
|
+
assert_equal "0.999", Cash.new(999, :cents_in_whole => 1000).to_s
|
268
|
+
assert_equal "1.000", Cash.new(1000, :cents_in_whole => 1000).to_s
|
269
269
|
end
|
270
270
|
|
271
271
|
def test_to_f
|
@@ -278,16 +278,16 @@ class TestCash < MiniTest::Unit::TestCase
|
|
278
278
|
end
|
279
279
|
|
280
280
|
def test_to_f_with_cents_in_whole
|
281
|
-
assert_equal 0.0, Cash.new(0, cents_in_whole
|
282
|
-
assert_equal 1.0, Cash.new(1, cents_in_whole
|
283
|
-
assert_equal 0.4, Cash.new(4, cents_in_whole
|
284
|
-
assert_equal 1.0, Cash.new(5, cents_in_whole
|
285
|
-
assert_equal 0.9, Cash.new(9, cents_in_whole
|
286
|
-
assert_equal 1.0, Cash.new(10, cents_in_whole
|
287
|
-
assert_equal 0.99, Cash.new(99, cents_in_whole
|
288
|
-
assert_equal 1.0, Cash.new(100, cents_in_whole
|
289
|
-
assert_equal 0.999, Cash.new(999, cents_in_whole
|
290
|
-
assert_equal 1.0, Cash.new(1000, cents_in_whole
|
281
|
+
assert_equal 0.0, Cash.new(0, :cents_in_whole => 1 ).to_f
|
282
|
+
assert_equal 1.0, Cash.new(1, :cents_in_whole => 1 ).to_f
|
283
|
+
assert_equal 0.4, Cash.new(4, :cents_in_whole => 5 ).to_f
|
284
|
+
assert_equal 1.0, Cash.new(5, :cents_in_whole => 5 ).to_f
|
285
|
+
assert_equal 0.9, Cash.new(9, :cents_in_whole => 10 ).to_f
|
286
|
+
assert_equal 1.0, Cash.new(10, :cents_in_whole => 10 ).to_f
|
287
|
+
assert_equal 0.99, Cash.new(99, :cents_in_whole => 100 ).to_f
|
288
|
+
assert_equal 1.0, Cash.new(100, :cents_in_whole => 100 ).to_f
|
289
|
+
assert_equal 0.999, Cash.new(999, :cents_in_whole => 1000).to_f
|
290
|
+
assert_equal 1.0, Cash.new(1000, :cents_in_whole => 1000).to_f
|
291
291
|
end
|
292
292
|
|
293
293
|
end
|
metadata
CHANGED
@@ -1,57 +1,65 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: cashrb
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0
|
3
|
+
version: !ruby/object:Gem::Version
|
5
4
|
prerelease:
|
5
|
+
version: 1.0.1
|
6
6
|
platform: ruby
|
7
|
-
authors:
|
8
|
-
- Shane Emmons
|
7
|
+
authors:
|
8
|
+
- Shane Emmons
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
|
12
|
+
|
13
|
+
date: 2011-02-23 00:00:00 -05:00
|
13
14
|
default_executable:
|
14
15
|
dependencies: []
|
16
|
+
|
15
17
|
description: Dead simple gem to work with Money/Currency without the hassle of Floats
|
16
|
-
email:
|
17
|
-
- semmons99@gmail.com
|
18
|
+
email:
|
19
|
+
- semmons99@gmail.com
|
18
20
|
executables: []
|
21
|
+
|
19
22
|
extensions: []
|
23
|
+
|
20
24
|
extra_rdoc_files: []
|
21
|
-
|
22
|
-
|
23
|
-
- lib/cash.rb
|
24
|
-
-
|
25
|
-
-
|
26
|
-
-
|
27
|
-
-
|
28
|
-
-
|
29
|
-
-
|
30
|
-
-
|
25
|
+
|
26
|
+
files:
|
27
|
+
- lib/cash.rb
|
28
|
+
- lib/cash/cash.rb
|
29
|
+
- test/test_cash.rb
|
30
|
+
- CHANGELOG.md
|
31
|
+
- LICENSE
|
32
|
+
- README.md
|
33
|
+
- Rakefile
|
34
|
+
- .gemtest
|
35
|
+
- cashrb.gemspec
|
31
36
|
has_rdoc: true
|
32
37
|
homepage: http://github.com/semmons99/cashrb
|
33
38
|
licenses: []
|
39
|
+
|
34
40
|
post_install_message:
|
35
41
|
rdoc_options: []
|
36
|
-
|
37
|
-
|
38
|
-
|
42
|
+
|
43
|
+
require_paths:
|
44
|
+
- lib
|
45
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
39
46
|
none: false
|
40
|
-
requirements:
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
47
|
+
requirements:
|
48
|
+
- - ">="
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: 1.8.7
|
51
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
45
52
|
none: false
|
46
|
-
requirements:
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
requirements:
|
51
|
-
- minitest
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: 1.3.6
|
57
|
+
requirements:
|
58
|
+
- minitest
|
52
59
|
rubyforge_project:
|
53
60
|
rubygems_version: 1.5.2
|
54
61
|
signing_key:
|
55
62
|
specification_version: 3
|
56
63
|
summary: Dead simple gem to work with Money/Currency without the hassle of Floats
|
57
64
|
test_files: []
|
65
|
+
|