money 6.9.0 → 6.16.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +131 -3
- data/LICENSE +17 -17
- data/README.md +181 -71
- data/config/currency_backwards_compatible.json +65 -0
- data/config/currency_iso.json +119 -56
- data/config/currency_non_iso.json +35 -2
- data/lib/money/bank/variable_exchange.rb +22 -12
- data/lib/money/currency/loader.rb +15 -13
- data/lib/money/currency.rb +38 -39
- data/lib/money/locale_backend/base.rb +7 -0
- data/lib/money/locale_backend/currency.rb +11 -0
- data/lib/money/locale_backend/errors.rb +6 -0
- data/lib/money/locale_backend/i18n.rb +25 -0
- data/lib/money/locale_backend/legacy.rb +28 -0
- data/lib/money/money/allocation.rb +46 -0
- data/lib/money/money/arithmetic.rb +33 -15
- data/lib/money/money/constructors.rb +1 -2
- data/lib/money/money/formatter.rb +399 -0
- data/lib/money/money/formatting_rules.rb +142 -0
- data/lib/money/money/locale_backend.rb +22 -0
- data/lib/money/money.rb +235 -187
- data/lib/money/rates_store/memory.rb +24 -24
- data/lib/money/version.rb +1 -1
- data/money.gemspec +14 -8
- metadata +36 -56
- data/.coveralls.yml +0 -1
- data/.gitignore +0 -23
- data/.rspec +0 -1
- data/.travis.yml +0 -26
- data/AUTHORS +0 -126
- data/CONTRIBUTING.md +0 -17
- data/Gemfile +0 -16
- data/Rakefile +0 -17
- data/lib/money/money/formatting.rb +0 -426
- data/spec/bank/base_spec.rb +0 -79
- data/spec/bank/single_currency_spec.rb +0 -13
- data/spec/bank/variable_exchange_spec.rb +0 -265
- data/spec/currency/heuristics_spec.rb +0 -11
- data/spec/currency/loader_spec.rb +0 -19
- data/spec/currency_spec.rb +0 -359
- data/spec/money/arithmetic_spec.rb +0 -693
- data/spec/money/constructors_spec.rb +0 -103
- data/spec/money/formatting_spec.rb +0 -757
- data/spec/money_spec.rb +0 -778
- data/spec/rates_store/memory_spec.rb +0 -69
- data/spec/spec_helper.rb +0 -28
@@ -1,69 +0,0 @@
|
|
1
|
-
describe Money::RatesStore::Memory do
|
2
|
-
let(:subject) { described_class.new }
|
3
|
-
|
4
|
-
describe '#add_rate and #get_rate' do
|
5
|
-
it 'stores rate in memory' do
|
6
|
-
expect(subject.add_rate('USD', 'CAD', 0.9)).to eql 0.9
|
7
|
-
expect(subject.get_rate('USD', 'CAD')).to eql 0.9
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
describe 'add_rate' do
|
12
|
-
it "uses a mutex by default" do
|
13
|
-
expect(subject.instance_variable_get(:@mutex)).to receive(:synchronize)
|
14
|
-
subject.add_rate('USD', 'EUR', 1.25)
|
15
|
-
end
|
16
|
-
|
17
|
-
context ':without_mutex' do
|
18
|
-
let(:subject) { Money::RatesStore::Memory.new(:without_mutex => true) }
|
19
|
-
|
20
|
-
it "doesn't use mutex if requested not to" do
|
21
|
-
expect(subject.instance_variable_get(:@mutex)).not_to receive(:synchronize)
|
22
|
-
subject.add_rate('USD', 'EUR', 1.25)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
describe '#each_rate' do
|
28
|
-
before do
|
29
|
-
subject.add_rate('USD', 'CAD', 0.9)
|
30
|
-
subject.add_rate('CAD', 'USD', 1.1)
|
31
|
-
end
|
32
|
-
|
33
|
-
it 'iterates over rates' do
|
34
|
-
expect{|b| subject.each_rate(&b)}.to yield_successive_args(['USD', 'CAD', 0.9], ['CAD', 'USD', 1.1])
|
35
|
-
end
|
36
|
-
|
37
|
-
it 'is an Enumeator' do
|
38
|
-
expect(subject.each_rate).to be_kind_of(Enumerator)
|
39
|
-
result = subject.each_rate.each_with_object({}){|(from, to, rate),m| m[[from,to].join] = rate}
|
40
|
-
expect(result).to match({'USDCAD' => 0.9, 'CADUSD' => 1.1})
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
describe '#transaction' do
|
45
|
-
context 'mutex' do
|
46
|
-
it 'uses mutex' do
|
47
|
-
expect(subject.instance_variable_get('@mutex')).to receive(:synchronize)
|
48
|
-
subject.transaction{ 1 + 1 }
|
49
|
-
end
|
50
|
-
|
51
|
-
it 'wraps block in mutex transaction only once' do
|
52
|
-
expect{
|
53
|
-
subject.transaction do
|
54
|
-
subject.add_rate('USD', 'CAD', 1)
|
55
|
-
end
|
56
|
-
}.not_to raise_error
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
context 'no mutex' do
|
61
|
-
let(:subject) { Money::RatesStore::Memory.new(:without_mutex => true) }
|
62
|
-
|
63
|
-
it 'does not use mutex' do
|
64
|
-
expect(subject.instance_variable_get('@mutex')).not_to receive(:synchronize)
|
65
|
-
subject.transaction{ 1 + 1 }
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
require "coveralls"
|
2
|
-
Coveralls.wear!
|
3
|
-
|
4
|
-
$LOAD_PATH.unshift File.dirname(__FILE__)
|
5
|
-
require "rspec"
|
6
|
-
require "money"
|
7
|
-
|
8
|
-
I18n.enforce_available_locales = false
|
9
|
-
|
10
|
-
RSpec.configure do |c|
|
11
|
-
c.order = :random
|
12
|
-
c.filter_run :focus
|
13
|
-
c.run_all_when_everything_filtered = true
|
14
|
-
end
|
15
|
-
|
16
|
-
def reset_i18n
|
17
|
-
I18n.backend = I18n::Backend::Simple.new
|
18
|
-
end
|
19
|
-
|
20
|
-
RSpec.shared_context "with infinite precision", :infinite_precision do
|
21
|
-
before do
|
22
|
-
Money.infinite_precision = true
|
23
|
-
end
|
24
|
-
|
25
|
-
after do
|
26
|
-
Money.infinite_precision = false
|
27
|
-
end
|
28
|
-
end
|