money 6.0.0 → 6.0.1.beta1
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.
- checksums.yaml +7 -0
- data/.gitignore +19 -0
- data/.travis.yml +11 -0
- data/AUTHORS +101 -0
- data/CHANGELOG.md +6 -0
- data/CONTRIBUTING.md +17 -0
- data/Gemfile +5 -0
- data/README.md +2 -0
- data/Rakefile +4 -45
- data/lib/money.rb +11 -1
- data/lib/money/core_extensions.rb +5 -78
- data/lib/money/core_extensions/numeric.rb +9 -0
- data/lib/money/core_extensions/string.rb +15 -0
- data/lib/money/core_extensions/symbol.rb +9 -0
- data/lib/money/currency.rb +29 -0
- data/lib/money/deprecations.rb +4 -1
- data/lib/money/money.rb +25 -3
- data/lib/money/money/arithmetic.rb +6 -3
- data/lib/money/money/parsing.rb +14 -344
- data/lib/money/version.rb +3 -0
- data/money.gemspec +21 -19
- data/spec/core_extensions_spec.rb +2 -2
- data/spec/currency_spec.rb +16 -0
- data/spec/money/deprecations_spec.rb +17 -0
- data/spec/money/parsing_spec.rb +3 -6
- data/spec/money_spec.rb +21 -5
- metadata +109 -55
@@ -110,8 +110,8 @@ describe Money, "core extensions" do
|
|
110
110
|
"10.10 USD".to_money('USD').should == Money.new(1010, 'USD')
|
111
111
|
end
|
112
112
|
|
113
|
-
it "
|
114
|
-
expect
|
113
|
+
it "uses the parsed currency even if a currency was specified by the method" do
|
114
|
+
expect("10.10 USD".to_money("EUR")).to eq Money.new(1010, "USD")
|
115
115
|
end
|
116
116
|
|
117
117
|
it "ignores unrecognized data" do
|
data/spec/currency_spec.rb
CHANGED
@@ -112,6 +112,8 @@ describe Money::Currency do
|
|
112
112
|
|
113
113
|
it "allows direct comparison of currencies and symbols/strings" do
|
114
114
|
Money::Currency.new(:eur).should == 'eur'
|
115
|
+
Money::Currency.new(:eur).should == 'EUR'
|
116
|
+
Money::Currency.new(:eur).should == :eur
|
115
117
|
Money::Currency.new(:eur).should == :EUR
|
116
118
|
Money::Currency.new(:eur).should_not == 'usd'
|
117
119
|
end
|
@@ -154,6 +156,20 @@ describe Money::Currency do
|
|
154
156
|
end
|
155
157
|
end
|
156
158
|
|
159
|
+
describe "#to_str" do
|
160
|
+
it "works as documented" do
|
161
|
+
Money::Currency.new(:usd).to_str.should == "USD"
|
162
|
+
Money::Currency.new(:eur).to_str.should == "EUR"
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
describe "#to_sym" do
|
167
|
+
it "works as documented" do
|
168
|
+
Money::Currency.new(:usd).to_sym.should == :USD
|
169
|
+
Money::Currency.new(:eur).to_sym.should == :EUR
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
157
173
|
describe "#to_currency" do
|
158
174
|
it "works as documented" do
|
159
175
|
usd = Money::Currency.new(:usd)
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require "spec_helper"
|
4
|
+
|
5
|
+
describe Money do
|
6
|
+
describe "#deprecate" do
|
7
|
+
let(:error_message) { "Deprecated method triggered here" }
|
8
|
+
|
9
|
+
it "should send a deprecation message with caller" do
|
10
|
+
Money.should_receive(:warn).with do |message|
|
11
|
+
message.should =~ /DEPRECATION WARNING: #{error_message} \(called from:.*:\d+\)/
|
12
|
+
end
|
13
|
+
|
14
|
+
Money.deprecate(error_message)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/spec/money/parsing_spec.rb
CHANGED
@@ -8,7 +8,7 @@ describe Money, "parsing" do
|
|
8
8
|
eu4 = '{ "priority": 1, "iso_code": "EU4", "iso_numeric": "841", "name": "Euro with 4 decimal places", "symbol": "€", "subunit": "Cent", "subunit_to_unit": 10000, "symbol_first": true, "html_entity": "€", "decimal_mark": ",", "thousands_separator": "." }'
|
9
9
|
|
10
10
|
describe ".parse" do
|
11
|
-
it "is
|
11
|
+
it "is deprecated" do
|
12
12
|
Money.should_receive(:deprecate).at_least(1).times
|
13
13
|
Money.parse("1.95")
|
14
14
|
end
|
@@ -17,9 +17,6 @@ describe Money, "parsing" do
|
|
17
17
|
five_ninety_five = Money.new(595, 'EUR')
|
18
18
|
|
19
19
|
Money.parse('EUR 5,95').should == five_ninety_five
|
20
|
-
#TODO: try and handle these
|
21
|
-
#Money.parse('€5,95').should == five_ninety_five
|
22
|
-
#Money.parse('$5.95').should == five_ninety_five
|
23
20
|
end
|
24
21
|
|
25
22
|
it "parses european-formatted inputs with multiple thousands-seperators" do
|
@@ -291,9 +288,9 @@ describe Money, "parsing" do
|
|
291
288
|
end
|
292
289
|
|
293
290
|
it "optimizes workload" do
|
294
|
-
|
291
|
+
Monetize.should_receive(:from_fixnum).with(1, "USD").and_return(Money.new(1_00, "USD"))
|
295
292
|
Money.from_numeric(1, "USD").should == Money.new(1_00, "USD")
|
296
|
-
|
293
|
+
Monetize.should_receive(:from_bigdecimal).with(BigDecimal.new("1.0"), "USD").and_return(Money.new(1_00, "USD"))
|
297
294
|
Money.from_numeric(1.0, "USD").should == Money.new(1_00, "USD")
|
298
295
|
end
|
299
296
|
|
data/spec/money_spec.rb
CHANGED
@@ -250,12 +250,28 @@ YAML
|
|
250
250
|
Money.rounding_mode = BigDecimal::ROUND_HALF_EVEN
|
251
251
|
end
|
252
252
|
|
253
|
-
|
254
|
-
|
255
|
-
|
253
|
+
context "with the setter" do
|
254
|
+
it "respects the rounding_mode" do
|
255
|
+
Money.rounding_mode = BigDecimal::ROUND_DOWN
|
256
|
+
Money.new(1.9).fractional.should == 1
|
256
257
|
|
257
|
-
|
258
|
-
|
258
|
+
Money.rounding_mode = BigDecimal::ROUND_UP
|
259
|
+
Money.new(1.1).fractional.should == 2
|
260
|
+
end
|
261
|
+
end
|
262
|
+
|
263
|
+
context "with a block" do
|
264
|
+
it "respects the rounding_mode" do
|
265
|
+
Money.rounding_mode(BigDecimal::ROUND_DOWN) do
|
266
|
+
Money.new(1.9).fractional
|
267
|
+
end.should == 1
|
268
|
+
|
269
|
+
Money.rounding_mode(BigDecimal::ROUND_UP) do
|
270
|
+
Money.new(1.1).fractional
|
271
|
+
end.should == 2
|
272
|
+
|
273
|
+
Money.rounding_mode.should == BigDecimal::ROUND_HALF_EVEN
|
274
|
+
end
|
259
275
|
end
|
260
276
|
end
|
261
277
|
|
metadata
CHANGED
@@ -1,24 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: money
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.0.
|
5
|
-
prerelease:
|
4
|
+
version: 6.0.1.beta1
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
|
-
- Tobias Luetke
|
9
|
-
- Hongli Lai
|
10
|
-
- Jeremy McNevin
|
11
7
|
- Shane Emmons
|
12
|
-
- Simone Carletti
|
13
8
|
autorequire:
|
14
9
|
bindir: bin
|
15
10
|
cert_chain: []
|
16
|
-
date: 2013-
|
11
|
+
date: 2013-12-29 00:00:00.000000000 Z
|
17
12
|
dependencies:
|
18
13
|
- !ruby/object:Gem::Dependency
|
19
14
|
name: i18n
|
20
15
|
requirement: !ruby/object:Gem::Requirement
|
21
|
-
none: false
|
22
16
|
requirements:
|
23
17
|
- - ~>
|
24
18
|
- !ruby/object:Gem::Version
|
@@ -26,15 +20,55 @@ dependencies:
|
|
26
20
|
type: :runtime
|
27
21
|
prerelease: false
|
28
22
|
version_requirements: !ruby/object:Gem::Requirement
|
29
|
-
none: false
|
30
23
|
requirements:
|
31
24
|
- - ~>
|
32
25
|
- !ruby/object:Gem::Version
|
33
26
|
version: 0.6.4
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: monetize
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.1.3
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.1.3
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.3'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.3'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
34
69
|
- !ruby/object:Gem::Dependency
|
35
70
|
name: rspec
|
36
71
|
requirement: !ruby/object:Gem::Requirement
|
37
|
-
none: false
|
38
72
|
requirements:
|
39
73
|
- - ~>
|
40
74
|
- !ruby/object:Gem::Version
|
@@ -42,7 +76,6 @@ dependencies:
|
|
42
76
|
type: :development
|
43
77
|
prerelease: false
|
44
78
|
version_requirements: !ruby/object:Gem::Requirement
|
45
|
-
none: false
|
46
79
|
requirements:
|
47
80
|
- - ~>
|
48
81
|
- !ruby/object:Gem::Version
|
@@ -50,7 +83,6 @@ dependencies:
|
|
50
83
|
- !ruby/object:Gem::Dependency
|
51
84
|
name: yard
|
52
85
|
requirement: !ruby/object:Gem::Requirement
|
53
|
-
none: false
|
54
86
|
requirements:
|
55
87
|
- - ~>
|
56
88
|
- !ruby/object:Gem::Version
|
@@ -58,7 +90,6 @@ dependencies:
|
|
58
90
|
type: :development
|
59
91
|
prerelease: false
|
60
92
|
version_requirements: !ruby/object:Gem::Requirement
|
61
|
-
none: false
|
62
93
|
requirements:
|
63
94
|
- - ~>
|
64
95
|
- !ruby/object:Gem::Version
|
@@ -66,7 +97,6 @@ dependencies:
|
|
66
97
|
- !ruby/object:Gem::Dependency
|
67
98
|
name: kramdown
|
68
99
|
requirement: !ruby/object:Gem::Requirement
|
69
|
-
none: false
|
70
100
|
requirements:
|
71
101
|
- - ~>
|
72
102
|
- !ruby/object:Gem::Version
|
@@ -74,80 +104,104 @@ dependencies:
|
|
74
104
|
type: :development
|
75
105
|
prerelease: false
|
76
106
|
version_requirements: !ruby/object:Gem::Requirement
|
77
|
-
none: false
|
78
107
|
requirements:
|
79
108
|
- - ~>
|
80
109
|
- !ruby/object:Gem::Version
|
81
110
|
version: '1.1'
|
82
111
|
description: This library aids one in handling money and different currencies.
|
83
112
|
email:
|
84
|
-
-
|
113
|
+
- shane@emmons.io
|
85
114
|
executables: []
|
86
115
|
extensions: []
|
87
116
|
extra_rdoc_files: []
|
88
117
|
files:
|
89
|
-
-
|
118
|
+
- .gitignore
|
119
|
+
- .travis.yml
|
120
|
+
- AUTHORS
|
121
|
+
- CHANGELOG.md
|
122
|
+
- CONTRIBUTING.md
|
123
|
+
- Gemfile
|
124
|
+
- LICENSE
|
125
|
+
- README.md
|
126
|
+
- Rakefile
|
90
127
|
- config/currency_backwards_compatible.json
|
128
|
+
- config/currency_iso.json
|
91
129
|
- config/currency_non_iso.json
|
92
|
-
- lib/money
|
93
|
-
- lib/money/money/arithmetic.rb
|
94
|
-
- lib/money/money/parsing.rb
|
95
|
-
- lib/money/money/formatting.rb
|
96
|
-
- lib/money/core_extensions.rb
|
97
|
-
- lib/money/deprecations.rb
|
98
|
-
- lib/money/currency/loader.rb
|
99
|
-
- lib/money/currency/heuristics.rb
|
100
|
-
- lib/money/bank/variable_exchange.rb
|
130
|
+
- lib/money.rb
|
101
131
|
- lib/money/bank/base.rb
|
102
132
|
- lib/money/bank/single_currency.rb
|
133
|
+
- lib/money/bank/variable_exchange.rb
|
134
|
+
- lib/money/core_extensions.rb
|
135
|
+
- lib/money/core_extensions/numeric.rb
|
136
|
+
- lib/money/core_extensions/string.rb
|
137
|
+
- lib/money/core_extensions/symbol.rb
|
138
|
+
- lib/money/currency.rb
|
139
|
+
- lib/money/currency/heuristics.rb
|
140
|
+
- lib/money/currency/loader.rb
|
141
|
+
- lib/money/deprecations.rb
|
103
142
|
- lib/money/money.rb
|
104
|
-
- lib/money.rb
|
105
|
-
-
|
106
|
-
-
|
143
|
+
- lib/money/money/arithmetic.rb
|
144
|
+
- lib/money/money/formatting.rb
|
145
|
+
- lib/money/money/parsing.rb
|
146
|
+
- lib/money/version.rb
|
147
|
+
- money.gemspec
|
148
|
+
- spec/bank/base_spec.rb
|
149
|
+
- spec/bank/single_currency_spec.rb
|
150
|
+
- spec/bank/variable_exchange_spec.rb
|
107
151
|
- spec/core_extensions_spec.rb
|
108
|
-
- spec/
|
152
|
+
- spec/currency/heuristics_spec.rb
|
153
|
+
- spec/currency_spec.rb
|
109
154
|
- spec/money/arithmetic_spec.rb
|
155
|
+
- spec/money/deprecations_spec.rb
|
110
156
|
- spec/money/formatting_spec.rb
|
157
|
+
- spec/money/parsing_spec.rb
|
111
158
|
- spec/money_spec.rb
|
112
|
-
- spec/currency/heuristics_spec.rb
|
113
159
|
- spec/spec_helper.rb
|
114
|
-
- spec/
|
115
|
-
- spec/bank/variable_exchange_spec.rb
|
116
|
-
- spec/bank/base_spec.rb
|
117
|
-
- CHANGELOG.md
|
118
|
-
- LICENSE
|
119
|
-
- README.md
|
120
|
-
- Rakefile
|
121
|
-
- money.gemspec
|
160
|
+
- spec/support/default_currency_helper.rb
|
122
161
|
homepage: http://rubymoney.github.com/money
|
123
162
|
licenses:
|
124
163
|
- MIT
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
164
|
+
metadata: {}
|
165
|
+
post_install_message: |
|
166
|
+
Please note the following API changes in Money version 6
|
167
|
+
|
168
|
+
- Money#amount, Money#dollars methods now return instances of BigDecimal (rather than Float).
|
169
|
+
|
170
|
+
Please read the migration notes at https://github.com/RubyMoney/money#migration-notes
|
171
|
+
and choose the migration that best suits your application.
|
172
|
+
|
173
|
+
Test responsibly :-)
|
129
174
|
rdoc_options: []
|
130
175
|
require_paths:
|
131
176
|
- lib
|
132
177
|
required_ruby_version: !ruby/object:Gem::Requirement
|
133
|
-
none: false
|
134
178
|
requirements:
|
135
|
-
- -
|
179
|
+
- - '>='
|
136
180
|
- !ruby/object:Gem::Version
|
137
|
-
version:
|
181
|
+
version: '0'
|
138
182
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
139
|
-
none: false
|
140
183
|
requirements:
|
141
|
-
- -
|
184
|
+
- - '>'
|
142
185
|
- !ruby/object:Gem::Version
|
143
|
-
version:
|
144
|
-
segments:
|
145
|
-
- 0
|
146
|
-
hash: 2830931323134829129
|
186
|
+
version: 1.3.1
|
147
187
|
requirements: []
|
148
188
|
rubyforge_project:
|
149
|
-
rubygems_version:
|
189
|
+
rubygems_version: 2.0.14
|
150
190
|
signing_key:
|
151
|
-
specification_version:
|
191
|
+
specification_version: 4
|
152
192
|
summary: Money and currency exchange support library.
|
153
|
-
test_files:
|
193
|
+
test_files:
|
194
|
+
- spec/bank/base_spec.rb
|
195
|
+
- spec/bank/single_currency_spec.rb
|
196
|
+
- spec/bank/variable_exchange_spec.rb
|
197
|
+
- spec/core_extensions_spec.rb
|
198
|
+
- spec/currency/heuristics_spec.rb
|
199
|
+
- spec/currency_spec.rb
|
200
|
+
- spec/money/arithmetic_spec.rb
|
201
|
+
- spec/money/deprecations_spec.rb
|
202
|
+
- spec/money/formatting_spec.rb
|
203
|
+
- spec/money/parsing_spec.rb
|
204
|
+
- spec/money_spec.rb
|
205
|
+
- spec/spec_helper.rb
|
206
|
+
- spec/support/default_currency_helper.rb
|
207
|
+
has_rdoc:
|