money 6.0.1.beta1 → 6.0.1.beta2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.coveralls.yml +1 -0
- data/Gemfile +1 -0
- data/README.md +7 -10
- data/config/currency_iso.json +1 -1
- data/lib/money/money.rb +14 -12
- data/lib/money/money/arithmetic.rb +2 -2
- data/lib/money/version.rb +1 -1
- data/money.gemspec +3 -3
- data/spec/money_spec.rb +15 -2
- data/spec/spec_helper.rb +7 -4
- metadata +25 -24
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7dbef5f1733e04f6823d0e504dbbe73112545214
|
4
|
+
data.tar.gz: 62e28891ffa15550bf323af2671a20cfa663279f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f1b30704d8098a4b7a5301775d4de24b9d8a2c0a02da1e175130319b7d177adca746203277ac7c7ee78e012ad6dd8df535333ae280fc7b235b469abe0330371f
|
7
|
+
data.tar.gz: 3de4d2fe5d9b244d7358f168b9f3fe6c5b6fb9f48b87a2be65436f95b7789bb12268dc83bb8dba0295656c28dd13cef522ef3f45c69f2f274e098f0afb1a41c4
|
data/.coveralls.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
repo_token: lUJ1iIe2hjtyIFZm413PZ38saqD5UOLXo
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,11 @@
|
|
1
1
|
# RubyMoney - Money
|
2
2
|
|
3
|
-
[![Gem Version](https://badge.fury.io/rb/money.png)](http://badge.fury.io/rb/money)
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/money.png)](http://badge.fury.io/rb/money)
|
4
|
+
[![Build Status](https://travis-ci.org/RubyMoney/money.png?branch=master)](https://travis-ci.org/RubyMoney/money)
|
5
|
+
[![Code Climate](https://codeclimate.com/github/RubyMoney/money.png)](https://codeclimate.com/github/RubyMoney/money)
|
6
|
+
[![Coverage Status](https://coveralls.io/repos/RubyMoney/money/badge.png?branch=master)](https://coveralls.io/r/RubyMoney/money?branch=master)
|
7
|
+
[![Dependency Status](https://gemnasium.com/RubyMoney/money.png)](https://gemnasium.com/RubyMoney/money)
|
8
|
+
[![License](http://img.shields.io/license/MIT.png?color=green)](http://opensource.org/licenses/MIT)
|
4
9
|
|
5
10
|
:warning: Please read the [migration notes](#migration-notes) before upgrading to a new major version.
|
6
11
|
|
@@ -12,7 +17,7 @@ See the [Contribution Guidelines](https://github.com/RubyMoney/money/blob/master
|
|
12
17
|
|
13
18
|
## Introduction
|
14
19
|
|
15
|
-
|
20
|
+
A Ruby Library for dealing with money and currency conversion.
|
16
21
|
|
17
22
|
### Features
|
18
23
|
|
@@ -25,8 +30,6 @@ This library aids one in handling money and different currencies.
|
|
25
30
|
- Represents currency as `Money::Currency` instances providing an high level of
|
26
31
|
flexibility.
|
27
32
|
- Provides APIs for exchanging money from one currency to another.
|
28
|
-
- Has the ability to parse a money and currency strings
|
29
|
-
into the corresponding Money/Currency object.
|
30
33
|
|
31
34
|
### Resources
|
32
35
|
|
@@ -75,12 +78,6 @@ Money.new(1000, "USD") - Money.new(200, "USD") == Money.new(800, "USD")
|
|
75
78
|
Money.new(1000, "USD") / 5 == Money.new(200, "USD")
|
76
79
|
Money.new(1000, "USD") * 5 == Money.new(5000, "USD")
|
77
80
|
|
78
|
-
# Assumptive Currencies
|
79
|
-
Money.assume_from_symbol = true
|
80
|
-
Money.parse("$100") == Money.new(10000, "USD")
|
81
|
-
Money.parse("€100") == Money.new(10000, "EUR")
|
82
|
-
Money.parse("£100") == Money.new(10000, "GBP")
|
83
|
-
|
84
81
|
# Currency conversions
|
85
82
|
some_code_to_setup_exchange_rates
|
86
83
|
Money.new(1000, "USD").exchange_to("EUR") == Money.new(some_value, "EUR")
|
data/config/currency_iso.json
CHANGED
data/lib/money/money.rb
CHANGED
@@ -127,6 +127,20 @@ class Money
|
|
127
127
|
#
|
128
128
|
# @return [Integer]
|
129
129
|
attr_accessor :conversion_precision
|
130
|
+
|
131
|
+
# Create a new money object with value 0.
|
132
|
+
#
|
133
|
+
# @param [Currency, String, Symbol] currency The currency to use.
|
134
|
+
#
|
135
|
+
# @return [Money]
|
136
|
+
#
|
137
|
+
# @example
|
138
|
+
# Money.empty #=> #<Money @fractional=0>
|
139
|
+
def empty(currency = default_currency)
|
140
|
+
@empty ||= {}
|
141
|
+
@empty[currency] ||= Money.new(0, currency)
|
142
|
+
end
|
143
|
+
alias_method :zero, :empty
|
130
144
|
end
|
131
145
|
|
132
146
|
def self.setup_defaults
|
@@ -179,18 +193,6 @@ class Money
|
|
179
193
|
Thread.current[:money_rounding_mode] = nil
|
180
194
|
end
|
181
195
|
|
182
|
-
# Create a new money object with value 0.
|
183
|
-
#
|
184
|
-
# @param [Currency, String, Symbol] currency The currency to use.
|
185
|
-
#
|
186
|
-
# @return [Money]
|
187
|
-
#
|
188
|
-
# @example
|
189
|
-
# Money.empty #=> #<Money @fractional=0>
|
190
|
-
def self.empty(currency = default_currency)
|
191
|
-
Money.new(0, currency)
|
192
|
-
end
|
193
|
-
|
194
196
|
# Creates a new Money object of the given value, using the Canadian
|
195
197
|
# dollar currency.
|
196
198
|
#
|
@@ -25,7 +25,7 @@ class Money
|
|
25
25
|
def ==(other_money)
|
26
26
|
if other_money.respond_to?(:to_money)
|
27
27
|
unless other_money.is_a?(Money)
|
28
|
-
Money.deprecate "as of Money 6.1.0 you must `require '
|
28
|
+
Money.deprecate "as of Money 6.1.0 you must `require 'monetize/core_extensions'` to compare Money to core classes." unless Money.silence_core_extensions_deprecations
|
29
29
|
end
|
30
30
|
other_money = other_money.to_money
|
31
31
|
fractional == other_money.fractional && currency == other_money.currency
|
@@ -48,7 +48,7 @@ class Money
|
|
48
48
|
def <=>(other_money)
|
49
49
|
if other_money.respond_to?(:to_money)
|
50
50
|
unless other_money.is_a?(Money)
|
51
|
-
Money.deprecate "as of Money 6.1.0 you must `require '
|
51
|
+
Money.deprecate "as of Money 6.1.0 you must `require 'monetize/core_extensions'` to compare Money to core classes." unless Money.silence_core_extensions_deprecations
|
52
52
|
end
|
53
53
|
other_money = other_money.to_money
|
54
54
|
if fractional == 0 || other_money.fractional == 0 || currency == other_money.currency
|
data/lib/money/version.rb
CHANGED
data/money.gemspec
CHANGED
@@ -9,9 +9,9 @@ Gem::Specification.new do |s|
|
|
9
9
|
s.platform = Gem::Platform::RUBY
|
10
10
|
s.authors = ["Shane Emmons"]
|
11
11
|
s.email = ["shane@emmons.io"]
|
12
|
-
s.homepage = "http://rubymoney.github.
|
13
|
-
s.summary = "
|
14
|
-
s.description = "
|
12
|
+
s.homepage = "http://rubymoney.github.io/money"
|
13
|
+
s.summary = "A Ruby Library for dealing with money and currency conversion."
|
14
|
+
s.description = "A Ruby Library for dealing with money and currency conversion."
|
15
15
|
s.license = "MIT"
|
16
16
|
|
17
17
|
s.post_install_message = <<MSG
|
data/spec/money_spec.rb
CHANGED
@@ -123,6 +123,19 @@ describe Money do
|
|
123
123
|
it "creates a new Money object of 0 cents" do
|
124
124
|
Money.empty.should == Money.new(0)
|
125
125
|
end
|
126
|
+
|
127
|
+
it "memoizes the result" do
|
128
|
+
Money.empty.object_id.should == Money.empty.object_id
|
129
|
+
end
|
130
|
+
|
131
|
+
it "memoizes a result for each currency" do
|
132
|
+
Money.empty(:cad).object_id.should == Money.empty(:cad).object_id
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
describe ".zero" do
|
137
|
+
subject { Money.zero }
|
138
|
+
it { should == Money.empty }
|
126
139
|
end
|
127
140
|
|
128
141
|
describe ".ca_dollar" do
|
@@ -375,11 +388,11 @@ YAML
|
|
375
388
|
it "works as documented" do
|
376
389
|
currency = Money::Currency.new("EUR")
|
377
390
|
currency.should_receive(:symbol).and_return("€")
|
378
|
-
Money.
|
391
|
+
Money.new(0, currency).symbol.should == "€"
|
379
392
|
|
380
393
|
currency = Money::Currency.new("EUR")
|
381
394
|
currency.should_receive(:symbol).and_return(nil)
|
382
|
-
Money.
|
395
|
+
Money.new(0, currency).symbol.should == "¤"
|
383
396
|
end
|
384
397
|
end
|
385
398
|
|
data/spec/spec_helper.rb
CHANGED
@@ -1,10 +1,13 @@
|
|
1
|
+
require "coveralls"
|
2
|
+
Coveralls.wear!
|
3
|
+
|
1
4
|
$LOAD_PATH.unshift File.dirname(__FILE__)
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
5
|
+
require "rspec"
|
6
|
+
require "money"
|
7
|
+
require "support/default_currency_helper"
|
5
8
|
|
6
9
|
RSpec.configure do |c|
|
7
|
-
c.order =
|
10
|
+
c.order = :random
|
8
11
|
c.include DefaultCurrencyHelper
|
9
12
|
end
|
10
13
|
|
metadata
CHANGED
@@ -1,122 +1,123 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: money
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.0.1.
|
4
|
+
version: 6.0.1.beta2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shane Emmons
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-01-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: i18n
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 0.6.4
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 0.6.4
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: monetize
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: 0.1.3
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - ~>
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 0.1.3
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - ~>
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '1.3'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - ~>
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '1.3'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rspec
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - ~>
|
73
|
+
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '2.14'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - ~>
|
80
|
+
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '2.14'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: yard
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - ~>
|
87
|
+
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '0.8'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- - ~>
|
94
|
+
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0.8'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: kramdown
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- - ~>
|
101
|
+
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: '1.1'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- - ~>
|
108
|
+
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '1.1'
|
111
|
-
description:
|
111
|
+
description: A Ruby Library for dealing with money and currency conversion.
|
112
112
|
email:
|
113
113
|
- shane@emmons.io
|
114
114
|
executables: []
|
115
115
|
extensions: []
|
116
116
|
extra_rdoc_files: []
|
117
117
|
files:
|
118
|
-
- .
|
119
|
-
- .
|
118
|
+
- ".coveralls.yml"
|
119
|
+
- ".gitignore"
|
120
|
+
- ".travis.yml"
|
120
121
|
- AUTHORS
|
121
122
|
- CHANGELOG.md
|
122
123
|
- CONTRIBUTING.md
|
@@ -158,7 +159,7 @@ files:
|
|
158
159
|
- spec/money_spec.rb
|
159
160
|
- spec/spec_helper.rb
|
160
161
|
- spec/support/default_currency_helper.rb
|
161
|
-
homepage: http://rubymoney.github.
|
162
|
+
homepage: http://rubymoney.github.io/money
|
162
163
|
licenses:
|
163
164
|
- MIT
|
164
165
|
metadata: {}
|
@@ -176,20 +177,20 @@ require_paths:
|
|
176
177
|
- lib
|
177
178
|
required_ruby_version: !ruby/object:Gem::Requirement
|
178
179
|
requirements:
|
179
|
-
- -
|
180
|
+
- - ">="
|
180
181
|
- !ruby/object:Gem::Version
|
181
182
|
version: '0'
|
182
183
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
183
184
|
requirements:
|
184
|
-
- -
|
185
|
+
- - ">"
|
185
186
|
- !ruby/object:Gem::Version
|
186
187
|
version: 1.3.1
|
187
188
|
requirements: []
|
188
189
|
rubyforge_project:
|
189
|
-
rubygems_version: 2.0
|
190
|
+
rubygems_version: 2.2.0
|
190
191
|
signing_key:
|
191
192
|
specification_version: 4
|
192
|
-
summary:
|
193
|
+
summary: A Ruby Library for dealing with money and currency conversion.
|
193
194
|
test_files:
|
194
195
|
- spec/bank/base_spec.rb
|
195
196
|
- spec/bank/single_currency_spec.rb
|