money 6.9.0 → 6.16.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +131 -3
  3. data/LICENSE +17 -17
  4. data/README.md +181 -71
  5. data/config/currency_backwards_compatible.json +65 -0
  6. data/config/currency_iso.json +119 -56
  7. data/config/currency_non_iso.json +35 -2
  8. data/lib/money/bank/variable_exchange.rb +22 -12
  9. data/lib/money/currency/loader.rb +15 -13
  10. data/lib/money/currency.rb +38 -39
  11. data/lib/money/locale_backend/base.rb +7 -0
  12. data/lib/money/locale_backend/currency.rb +11 -0
  13. data/lib/money/locale_backend/errors.rb +6 -0
  14. data/lib/money/locale_backend/i18n.rb +25 -0
  15. data/lib/money/locale_backend/legacy.rb +28 -0
  16. data/lib/money/money/allocation.rb +46 -0
  17. data/lib/money/money/arithmetic.rb +33 -15
  18. data/lib/money/money/constructors.rb +1 -2
  19. data/lib/money/money/formatter.rb +399 -0
  20. data/lib/money/money/formatting_rules.rb +142 -0
  21. data/lib/money/money/locale_backend.rb +22 -0
  22. data/lib/money/money.rb +235 -187
  23. data/lib/money/rates_store/memory.rb +24 -24
  24. data/lib/money/version.rb +1 -1
  25. data/money.gemspec +14 -8
  26. metadata +36 -56
  27. data/.coveralls.yml +0 -1
  28. data/.gitignore +0 -23
  29. data/.rspec +0 -1
  30. data/.travis.yml +0 -26
  31. data/AUTHORS +0 -126
  32. data/CONTRIBUTING.md +0 -17
  33. data/Gemfile +0 -16
  34. data/Rakefile +0 -17
  35. data/lib/money/money/formatting.rb +0 -426
  36. data/spec/bank/base_spec.rb +0 -79
  37. data/spec/bank/single_currency_spec.rb +0 -13
  38. data/spec/bank/variable_exchange_spec.rb +0 -265
  39. data/spec/currency/heuristics_spec.rb +0 -11
  40. data/spec/currency/loader_spec.rb +0 -19
  41. data/spec/currency_spec.rb +0 -359
  42. data/spec/money/arithmetic_spec.rb +0 -693
  43. data/spec/money/constructors_spec.rb +0 -103
  44. data/spec/money/formatting_spec.rb +0 -757
  45. data/spec/money_spec.rb +0 -778
  46. data/spec/rates_store/memory_spec.rb +0 -69
  47. 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