money 6.5.1 → 6.16.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +209 -5
  3. data/LICENSE +18 -16
  4. data/README.md +321 -70
  5. data/config/currency_backwards_compatible.json +65 -0
  6. data/config/currency_iso.json +280 -94
  7. data/config/currency_non_iso.json +101 -3
  8. data/lib/money/bank/base.rb +1 -3
  9. data/lib/money/bank/variable_exchange.rb +88 -96
  10. data/lib/money/currency/heuristics.rb +1 -143
  11. data/lib/money/currency/loader.rb +15 -13
  12. data/lib/money/currency.rb +98 -81
  13. data/lib/money/locale_backend/base.rb +7 -0
  14. data/lib/money/locale_backend/currency.rb +11 -0
  15. data/lib/money/locale_backend/errors.rb +6 -0
  16. data/lib/money/locale_backend/i18n.rb +25 -0
  17. data/lib/money/locale_backend/legacy.rb +28 -0
  18. data/lib/money/money/allocation.rb +46 -0
  19. data/lib/money/money/arithmetic.rb +97 -52
  20. data/lib/money/money/constructors.rb +5 -6
  21. data/lib/money/money/formatter.rb +399 -0
  22. data/lib/money/money/formatting_rules.rb +142 -0
  23. data/lib/money/money/locale_backend.rb +22 -0
  24. data/lib/money/money.rb +268 -194
  25. data/lib/money/rates_store/memory.rb +120 -0
  26. data/lib/money/version.rb +1 -1
  27. data/money.gemspec +15 -20
  28. metadata +36 -59
  29. data/.coveralls.yml +0 -1
  30. data/.gitignore +0 -22
  31. data/.travis.yml +0 -13
  32. data/AUTHORS +0 -116
  33. data/CONTRIBUTING.md +0 -17
  34. data/Gemfile +0 -7
  35. data/Rakefile +0 -17
  36. data/lib/money/money/formatting.rb +0 -386
  37. data/spec/bank/base_spec.rb +0 -77
  38. data/spec/bank/single_currency_spec.rb +0 -11
  39. data/spec/bank/variable_exchange_spec.rb +0 -275
  40. data/spec/currency/heuristics_spec.rb +0 -84
  41. data/spec/currency_spec.rb +0 -321
  42. data/spec/money/arithmetic_spec.rb +0 -568
  43. data/spec/money/constructors_spec.rb +0 -75
  44. data/spec/money/formatting_spec.rb +0 -667
  45. data/spec/money_spec.rb +0 -745
  46. data/spec/spec_helper.rb +0 -23
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 2e625dd2f1daa9df7fbe2c8c5ed8972c5bf69f9a
4
- data.tar.gz: 50addb5ca7123aff716961c6e782d43846d90c55
2
+ SHA256:
3
+ metadata.gz: 3de47437ec002ed24a400508cac96b2ff6812f484c666fe3db3a82e921a805c0
4
+ data.tar.gz: f96755602e56ea81d734b7505e7cfc88caaa948d7a8d285eeb470801028c15b9
5
5
  SHA512:
6
- metadata.gz: 51736bea340dca0e23da25018aad574380bdfea0281e20aaf0af90c306f50d48be15ffb15136daff9caac4c5c6a5f563042c6703dc6403c83ce32fee85d42e30
7
- data.tar.gz: 2b32b72aa148550d672ae639b0c9c96a13c5d3c35676fdf7649f130bd79a4d41880444d2d1b0fdbe3d442d840518fcf2e35bdb3156ddd46a8f1490f68e6ada24
6
+ metadata.gz: 2f8cd71611e96a80cb733651675cb6fac59d358cb7c9576c8c264abbfec6eb1da11b8cbe2af12cdfb070e5dd01cd74f6fdc70772da16aa4c2abc5248b13fca3c
7
+ data.tar.gz: '092ba5a188eb29d462431e94420e1c6d7a7f9a4a59c0895f66a4a1cf92cfaa37cbc1bc344a241f5f8cc9fc4e998189164bc2d0ab11480a589fe7bb0e341754ba'
data/CHANGELOG.md CHANGED
@@ -1,7 +1,200 @@
1
1
  # Changelog
2
2
 
3
- ## Next release
4
-
3
+ ## 6.16.0
4
+
5
+ - Add `Money.from_cents` alias as a more explicit initializer, it's the same as `Money.new`
6
+
7
+ ## 6.15.0
8
+
9
+ - Add :delimiter_pattern option to the Formatter
10
+
11
+ ## 6.14.1
12
+
13
+ - Fix CHF format regression introduced in v6.14.0
14
+ - Fix deprecation warning in #format_decimal_part
15
+
16
+ ## 6.14.0
17
+
18
+ - Fix Bahraini dinar symbol
19
+ - Raise exception when default currency is not set or passed as parameter
20
+ - Allow specifying default_bank as a lambda
21
+ - Allow passing a default format in currencies definition only valid without symbol_position
22
+ - Always allow comparison with zero Money
23
+ - Rename Money.infinite_precision to default_infinite_precision
24
+ - Add Currency.reset! method to reload all the default currency definitions
25
+ - Fix edgecase for Money#allocate when applying to array of all zero values
26
+
27
+ ## 6.13.8
28
+ - Update symbol for XOF
29
+ - Update UYU currency symbol
30
+ - Allow double conversion using same bank
31
+ - Warn when using unsafe serializer for rate import
32
+ - Move Icelandic symbol after the amount
33
+
34
+ ## 6.13.7
35
+ - Improve deprecation warnings for the upcoming major release
36
+
37
+ ## 6.13.6
38
+ - Fix a regression introduced in 6.13.5 that broken RatesStore::Memory subclasses
39
+
40
+ ## 6.13.5
41
+ - Raise warning on using Money.default_currency
42
+ - Raise warning on using default Money.rounding_mode
43
+ - Add Second Ouguiya MRU 929 to currency iso file
44
+ - Add symbol for UZS
45
+ - Use monitor for recursive mutual exclusion in RatesStore::Memory
46
+ - Allow passing store as a string to Money::Bank::VariableExchange (to support Rails 6)
47
+
48
+ ## 6.13.4
49
+ - Update currency config for Zambian Kwacha (ZMW)
50
+ - Do not modify options passed to FormattingRules
51
+
52
+ ## 6.13.3
53
+ - Remove specs from the packaged gem
54
+ - Use Currency::Loader directly without extending
55
+ - Add Money.with_rounding_mode as a replacement for calling Money.rounding_mode with a block
56
+ - Fix currency search for two digit ISO numbers
57
+ - Add description to TypeError raised by +/- operations
58
+
59
+ ## 6.13.2
60
+ - Prevent Money initialization with non-finite amounts
61
+ - Convert the fractional value of a Money object to BigDecimal when initializing
62
+ - Offer replacements for currency position deprecations
63
+ - Fix Peruvian Sol symbol
64
+ - Lock i18n to <= 1.2.0 for older (< 2.3) rubies
65
+ - Prevent Divide By Zero in `Money#allocate`
66
+
67
+ ## 6.13.1
68
+ - Add bolívar soberano (VES)
69
+ - Deprecate bolívar fuerte (VEF)
70
+ - Deprecate old `#format` rules passed as a symbol
71
+ - Clarify `use_i18n` deprecation
72
+ - Add `:currency` locale_backend for explicit per-currency localization
73
+
74
+ ## 6.13.0
75
+ - Add :format option to the Formatter
76
+ - Add ruby 2.6.0 support
77
+ - Performance improvement (lazy stringify currency keys)
78
+ - Add `Money.locale_backend` for translation lookups
79
+ - Deprecate `use_i18n` flag in favour of `locale_backend = :i18n`
80
+ - Deprecate old formatting rules in favour of `:format`
81
+ - LVL and LTL are no longer used
82
+ - Add `Currency#iso?` for checking if currency is iso or not
83
+ - Relax versions-lock of `i18n` and `rspec` dependencies
84
+ - Add Bitcoin Cash
85
+ - Fix incorrect behaviour of `Currency#find_by_currency_iso` when given empty input
86
+
87
+ ## 6.12.0
88
+ - Remove caching of `.empty`/`.zero`
89
+ - Preserve assigned bank when rounding
90
+ - Always round the fractional part when calling `#round`
91
+ - Wrap all amount parts when `:html_wrap` option is used
92
+ - Deprecate `#currency_as_string` and `#currency_as_string=` (in favour of `#with_currency`)
93
+ - Add `#with_currency` for swapping the currency
94
+ - Rewrite allocate/split (fixing some penny losing issues)
95
+
96
+ ## 6.11.3
97
+ - Fix regression: if enabled use i18n locales in Money#to_s
98
+
99
+ ## 6.11.2
100
+ - Fix regression: ignore formatting defaults for Money#to_s
101
+
102
+ ## 6.11.1
103
+ - Fix issue with adding non-USD money to zero (used when calling `.sum` on an array)
104
+
105
+ ## 6.11.0
106
+ - Support i18n 1.0
107
+ - Update yard dependency to 0.9.11
108
+ - Support for ruby 2.5.0
109
+ - Add inheritance for currency definitions
110
+ - Added new symbol for bitcoin denomination
111
+ - Specify custom rounding precision when using `infinite_precision`
112
+ - Allow splits with sums greater than 1
113
+ - Prevent arithmetic methods from losing reference to the bank
114
+ - Fix coerced zero numeric subtraction
115
+ - Fix south asian formatting to support whole numbers
116
+ - Refactor formatting logic
117
+
118
+ ## 6.10.1
119
+ - Fix an issue with Money.empty memoization
120
+
121
+ ## 6.10.0
122
+ - Added support for i18n version 0.9
123
+ - Disabled rounding when verifying allocation splits
124
+ - Added Chinese Yuan Offshore (CNH)
125
+ - Fixed html_entity for ARS
126
+ - Fixed KZT symbol
127
+ - Allowed comparing cross currency when both are zero
128
+ - Fixed memory rate store
129
+ - Corrected HUF subunit and thousands separator config
130
+
131
+ ## 6.9.0
132
+ - Extracted heuristics into money-heuristics gem
133
+
134
+ ## 6.8.4
135
+ - Resolving NIO ambiguity with CAD
136
+ - Display the BBD $ symbol before digits
137
+ - Symbol first for NIO and PAB currencies
138
+
139
+ ## 6.8.3
140
+ - Added support for the British Penny (GBX)
141
+ - Fixed LKR currency html_entity symbol
142
+
143
+ ## 6.8.2
144
+ - Removed subunits for HUF
145
+ - Fixed `#from_amount` accepting `nil` as currency_code
146
+ - Relaxed i18n version (< 0.9)
147
+ - Set symbol for UZS
148
+ - Added disambiguate_symbol for XFU
149
+ - Fixed Peruvian Sol name
150
+ - Fixed symbol_first for VND (now `false`)
151
+
152
+ ## 6.8.1
153
+ - Fixed issue with calling `format` on a frozen `Money` object
154
+
155
+ ## 6.8.0
156
+ - Ruby 2.4.0 support
157
+ - Fixed UZS syntax
158
+ - Fixed HUF smallest denomination
159
+ - Fixed ruby 1.9 issues
160
+ - Fixed html entity for COP
161
+ - Updated all currency decimals to ISO-4217
162
+ - Fixed money allocation for negative amounts
163
+ - Fixed symbol_first for RON
164
+ - Fixed disambiguate option when symbol is set to true
165
+ - Fixed thousands separator for CZK
166
+ - Improved formatter performance by precaching I18n calls
167
+
168
+ ## 6.7.1
169
+ - Changed DKK symbol from 'kr' to 'kr.'
170
+ - Improved Money::Formatting#format docs
171
+ - Updated VEF symbol from 'Bs F' to 'Bs'
172
+ - `Currency#exponent` now returns Fixnum
173
+ - Fixed coercion issues
174
+ - Fixed edge case with explicit override of thousands separator and decimal mark
175
+ - `Money#==` will now raise error for non-zero numeric values
176
+ - Fixed divmod
177
+ - Added disambiguation symbol to USD Dollar
178
+ - Use disambiguation symbol when both disambiguate and symbol are true in `format` method
179
+
180
+ ## 6.7.0
181
+ - Changed `Money#<=>` to return `nil` if the comparison is inappropriate. (#584)
182
+ - Remove implicit conversion of values being compared. Only accept `Money` and
183
+ subclasses of `Money` for comparisons and raise TypeError otherwise.
184
+ - When comparing fails due to `Money::Bank::UnknownRate` `Money#<=>` will now
185
+ return `nil` as `Comparable#==` will not rescue exceptions in the next release.
186
+ - Fix `Currency` specs for `#exponent` and `#decimal_places` not making assertions.
187
+ - Fix a couple of Ruby warnings found in specs.
188
+ - Fix `Money#-`,`Money#+` arithmetics for Ruby 2.3+ : check for zero value without using eql? with a Fixnum. (#577)
189
+ - Use `Money#decimal_mark` when formatting with `rounded_infinite_precision` rule
190
+ set to `true`.
191
+ - Replaced meta-defined `thousands_separator` and `decimal_mark` methods with regular methods. (#579)
192
+
193
+ ## 6.6.0
194
+ - Fixed VariableExchange#exchange_with for big numbers.
195
+ - Add Currency symbol translation support
196
+ - `Currency.all` raises a more helpful error message
197
+ (`Currency::MissingAttributeError`)if a currency has no priority
5
198
  - `Currency` implements `Enumerable`.
6
199
  - `Currency#<=>` sorts alphabetically by `id` if the `priority`s are the same,
7
200
  and no longer raises an error if one of the priorities is missing.
@@ -16,6 +209,17 @@
16
209
  `.ca_dollar`, and `.euro`.
17
210
  - Add helper methods for British pounds: `Money.pound_sterling` and
18
211
  `Money.gbp`.
212
+ - Add `Money.from_amount` to create money from a value in units instead of
213
+ fractional units.
214
+ - Changed CHF symbol from 'Fr' to 'CHF'
215
+ - Changed CLF exponent from 0 to 4
216
+ - Changed CLP subunit_to_unit from 1 to 100
217
+ - Minor fixes to prevent warnings on unused variables and the redefinition of
218
+ `Money.default_currency`
219
+ - `Money#==` changed to acknowledge that 0 in one currency is equal to 0 in any currency.
220
+ - Changed KRW subunit_to_unit from 100 to 1
221
+ - Decouple exchange rates storage from bank objects and formalize storage public API. Default is `Money::RatesStore::Memory`.
222
+ - `Currency.new` now a singleton by its id
19
223
 
20
224
  ## 6.5.1
21
225
  - Fix format for BYR currency
@@ -72,7 +276,7 @@
72
276
  - Works on Ruby 1.8.7
73
277
  - Update deps
74
278
  - Depreciate Money.parse
75
- - Passing :symbol => false when formatting 'JPY' currency in :ja locale
279
+ - Passing symbol: false when formatting 'JPY' currency in :ja locale
76
280
  will work as expected
77
281
  - Divide now obeys the specified rounding mode
78
282
  - Add Money#round method. This is helpful when working in infinite_precision mode and would like to perform rounding at specific points in your work flow.
@@ -255,7 +459,7 @@ Features
255
459
 
256
460
  Bugfixes
257
461
  --------
258
- - Fixed issue with #format(:no_cents => true) (thanks Romain & Julien)
462
+ - Fixed issue with #format(no_cents: true) (thanks Romain & Julien)
259
463
 
260
464
  Money 3.5.5
261
465
  ===========
@@ -342,7 +546,7 @@ Features
342
546
  - Deprecated `Money#format` with separate params instead of Hash. Deprecation
343
547
  target set to Money 3.5.0.
344
548
  ([#issue/31](http://github.com/RubyMoney/money/issues/31))
345
- - Deprecated `Money#new(0, :currency => "EUR")` in favor of
549
+ - Deprecated `Money#new(0, currency: "EUR")` in favor of
346
550
  `Money#new(0, "EUR")`. Deprecation target set to Money 3.5.0.
347
551
  ([#issue/31](http://github.com/RubyMoney/money/issues/31))
348
552
  - Throw ArgumentError when trying to multiply two Money objects together.
data/LICENSE CHANGED
@@ -1,21 +1,23 @@
1
+ MIT License
2
+
1
3
  Copyright (c) 2005 Tobias Lutke
2
4
  Copyright (c) 2008 Phusion
5
+ Copyright (c) 2021 Shane Emmons
3
6
 
4
- Permission is hereby granted, free of charge, to any person obtaining
5
- a copy of this software and associated documentation files (the
6
- "Software"), to deal in the Software without restriction, including
7
- without limitation the rights to use, copy, modify, merge, publish,
8
- distribute, sublicense, and/or sell copies of the Software, and to
9
- permit persons to whom the Software is furnished to do so, subject to
10
- the following conditions:
7
+ Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ of this software and associated documentation files (the "Software"), to deal
9
+ in the Software without restriction, including without limitation the rights
10
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ copies of the Software, and to permit persons to whom the Software is
12
+ furnished to do so, subject to the following conditions:
11
13
 
12
- The above copyright notice and this permission notice shall be
13
- included in all copies or substantial portions of the Software.
14
+ The above copyright notice and this permission notice shall be included in all
15
+ copies or substantial portions of the Software.
14
16
 
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ SOFTWARE.