money 3.0.0 → 3.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +5 -0
- data/VERSION +1 -1
- data/lib/money/core_extensions.rb +3 -1
- data/lib/money/money.rb +5 -0
- data/money.gemspec +4 -4
- data/test/core_extensions_spec.rb +5 -0
- data/test/money_spec.rb +45 -0
- metadata +13 -4
data/CHANGELOG.rdoc
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
== Money 3.0.1
|
2
|
+
* Added #eql? method
|
3
|
+
* Updated Numeric#to_money to work with all children of Numeric
|
4
|
+
(BigDecimal, Integer, Fixnum, etc)
|
5
|
+
|
1
6
|
== Money 3.0.0
|
2
7
|
* Version Bump due to compatibility changes with ActiveRecord. See
|
3
8
|
http://github.com/FooBarWidget/money/issues#issue/4/comment/224880 for more
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.0.
|
1
|
+
3.0.1
|
@@ -4,8 +4,10 @@ class Numeric
|
|
4
4
|
#
|
5
5
|
# 100.to_money => #<Money @cents=10000>
|
6
6
|
# 100.37.to_money => #<Money @cents=10037>
|
7
|
+
# require 'bigdecimal'
|
8
|
+
# BigDecimal.new('100').to_money => #<Money @cents=10000>
|
7
9
|
def to_money
|
8
|
-
Money.new(self * 100)
|
10
|
+
Money.new((self * 100).to_int)
|
9
11
|
end
|
10
12
|
end
|
11
13
|
|
data/lib/money/money.rb
CHANGED
data/money.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{money}
|
8
|
-
s.version = "3.0.
|
8
|
+
s.version = "3.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 = ["Tobias Luetke", "Hongli Lai", "Jeremy McNevin", "Shane Emmons"]
|
12
|
-
s.date = %q{2010-05-
|
12
|
+
s.date = %q{2010-05-26}
|
13
13
|
s.description = %q{Money and currency exchange support library.}
|
14
14
|
s.email = %q{hongli@phusion.nl}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -42,7 +42,7 @@ Gem::Specification.new do |s|
|
|
42
42
|
s.rdoc_options = ["--charset=UTF-8"]
|
43
43
|
s.require_paths = ["lib"]
|
44
44
|
s.rubyforge_project = %q{money}
|
45
|
-
s.rubygems_version = %q{1.3.
|
45
|
+
s.rubygems_version = %q{1.3.7}
|
46
46
|
s.summary = %q{Money and currency exchange support library}
|
47
47
|
s.test_files = [
|
48
48
|
"test/core_extensions_spec.rb",
|
@@ -55,7 +55,7 @@ Gem::Specification.new do |s|
|
|
55
55
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
56
56
|
s.specification_version = 3
|
57
57
|
|
58
|
-
if Gem::Version.new(Gem::
|
58
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
59
59
|
s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
|
60
60
|
s.add_development_dependency(%q<hanna>, [">= 0.1.12"])
|
61
61
|
else
|
@@ -11,6 +11,11 @@ describe "Money core extensions" do
|
|
11
11
|
money = 100.37.to_money
|
12
12
|
money.cents.should == 100_37
|
13
13
|
money.currency.should == Money.default_currency
|
14
|
+
|
15
|
+
require 'bigdecimal'
|
16
|
+
money = BigDecimal.new('1234').to_money
|
17
|
+
money.cents.should == 1234_00
|
18
|
+
money.currency.should == Money.default_currency
|
14
19
|
end
|
15
20
|
|
16
21
|
specify "String#to_money works" do
|
data/test/money_spec.rb
CHANGED
@@ -102,6 +102,51 @@ describe Money do
|
|
102
102
|
Money.new(1_00, "USD").should_not == nil
|
103
103
|
end
|
104
104
|
|
105
|
+
specify "#eql? returns true if and only if their amount and currency are equal" do
|
106
|
+
Money.new(1_00, "USD").eql?(Money.new(1_00, "USD")).should be true
|
107
|
+
Money.new(1_00, "USD").eql?(Money.new(1_00, "EUR")).should be false
|
108
|
+
Money.new(1_00, "USD").eql?(Money.new(2_00, "USD")).should be false
|
109
|
+
Money.new(1_00, "USD").eql?(Money.new(99_00, "EUR")).should be false
|
110
|
+
end
|
111
|
+
|
112
|
+
specify "#eql? can be used to compare with a String money value" do
|
113
|
+
Money.new(1_00, "USD").eql?("1.00").should be true
|
114
|
+
Money.new(1_00, "USD").eql?("2.00").should be false
|
115
|
+
Money.new(1_00, "GBP").eql?("1.00").should be false
|
116
|
+
end
|
117
|
+
|
118
|
+
specify "#eql? can be used to compare with a Numeric money value" do
|
119
|
+
Money.new(1_00, "USD").eql?(1).should be true
|
120
|
+
Money.new(1_57, "USD").eql?(1.57).should be true
|
121
|
+
Money.new(1_00, "USD").eql?(2).should be false
|
122
|
+
Money.new(1_00, "GBP").eql?(1).should be false
|
123
|
+
end
|
124
|
+
|
125
|
+
specify "#eql? can be used to compare with an object that responds to #to_money" do
|
126
|
+
klass = Class.new do
|
127
|
+
def initialize(money)
|
128
|
+
@money = money
|
129
|
+
end
|
130
|
+
|
131
|
+
def to_money
|
132
|
+
@money
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
Money.new(1_00, "USD").eql?(klass.new(Money.new(1_00, "USD"))).should be true
|
137
|
+
Money.new(2_50, "USD").eql?(klass.new(Money.new(2_50, "USD"))).should be true
|
138
|
+
Money.new(2_50, "USD").eql?(klass.new(Money.new(3_00, "USD"))).should be false
|
139
|
+
Money.new(1_00, "GBP").eql?(klass.new(Money.new(1_00, "USD"))).should be false
|
140
|
+
end
|
141
|
+
|
142
|
+
specify "#eql? returns false if used to compare with an object that doesn't respond to #to_money" do
|
143
|
+
Money.new(1_00, "USD").eql?(Object.new).should be false
|
144
|
+
Money.new(1_00, "USD").eql?(Class).should be false
|
145
|
+
Money.new(1_00, "USD").eql?(Kernel).should be false
|
146
|
+
Money.new(1_00, "USD").eql?(/foo/).should be false
|
147
|
+
Money.new(1_00, "USD").eql?(nil).should be false
|
148
|
+
end
|
149
|
+
|
105
150
|
specify "#<=> can be used to compare with a String money value" do
|
106
151
|
(Money.new(1_00) <=> "1.00").should == 0
|
107
152
|
(Money.new(1_00) <=> ".99").should > 0
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: money
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 5
|
4
5
|
prerelease: false
|
5
6
|
segments:
|
6
7
|
- 3
|
7
8
|
- 0
|
8
|
-
-
|
9
|
-
version: 3.0.
|
9
|
+
- 1
|
10
|
+
version: 3.0.1
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Tobias Luetke
|
@@ -17,16 +18,18 @@ autorequire:
|
|
17
18
|
bindir: bin
|
18
19
|
cert_chain: []
|
19
20
|
|
20
|
-
date: 2010-05-
|
21
|
+
date: 2010-05-26 00:00:00 -04:00
|
21
22
|
default_executable:
|
22
23
|
dependencies:
|
23
24
|
- !ruby/object:Gem::Dependency
|
24
25
|
name: rspec
|
25
26
|
prerelease: false
|
26
27
|
requirement: &id001 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
27
29
|
requirements:
|
28
30
|
- - ">="
|
29
31
|
- !ruby/object:Gem::Version
|
32
|
+
hash: 13
|
30
33
|
segments:
|
31
34
|
- 1
|
32
35
|
- 2
|
@@ -38,9 +41,11 @@ dependencies:
|
|
38
41
|
name: hanna
|
39
42
|
prerelease: false
|
40
43
|
requirement: &id002 !ruby/object:Gem::Requirement
|
44
|
+
none: false
|
41
45
|
requirements:
|
42
46
|
- - ">="
|
43
47
|
- !ruby/object:Gem::Version
|
48
|
+
hash: 3
|
44
49
|
segments:
|
45
50
|
- 0
|
46
51
|
- 1
|
@@ -88,23 +93,27 @@ rdoc_options:
|
|
88
93
|
require_paths:
|
89
94
|
- lib
|
90
95
|
required_ruby_version: !ruby/object:Gem::Requirement
|
96
|
+
none: false
|
91
97
|
requirements:
|
92
98
|
- - ">="
|
93
99
|
- !ruby/object:Gem::Version
|
100
|
+
hash: 3
|
94
101
|
segments:
|
95
102
|
- 0
|
96
103
|
version: "0"
|
97
104
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
98
106
|
requirements:
|
99
107
|
- - ">="
|
100
108
|
- !ruby/object:Gem::Version
|
109
|
+
hash: 3
|
101
110
|
segments:
|
102
111
|
- 0
|
103
112
|
version: "0"
|
104
113
|
requirements: []
|
105
114
|
|
106
115
|
rubyforge_project: money
|
107
|
-
rubygems_version: 1.3.
|
116
|
+
rubygems_version: 1.3.7
|
108
117
|
signing_key:
|
109
118
|
specification_version: 3
|
110
119
|
summary: Money and currency exchange support library
|