money 6.13.7 → 6.13.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/README.md +10 -0
- data/config/currency_iso.json +5 -5
- data/lib/money/bank/variable_exchange.rb +9 -5
- data/lib/money/money.rb +3 -2
- data/lib/money/money/arithmetic.rb +3 -3
- data/lib/money/rates_store/memory.rb +1 -1
- data/lib/money/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1773172616f278d2f107e19153498c029c5f1b63f4ae68a7468ef66fbbef8991
|
4
|
+
data.tar.gz: 035cd8170e536decc4748cd8a6c2ef1b7a7d5e985e6a2ecba0c989f8cf89096c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5636c6323a8538ccc669a2ecfd07a3108adde4f6315e43d0d2b0bb818fc31d1c230ff0ca9715a2c1ca67edcdfa7cb71c9c4d8405410f0764cc82aaad5d3af4e1
|
7
|
+
data.tar.gz: 4b2532f674ca8b665b43c745f5b8cc2beb3d7d5fda0584273bc53d8a42e8a551037758374b6864cfe4b227d61d043282394ed51b62e27f82b8f374ddb27dbe5b
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 6.13.8
|
4
|
+
- Update symbol for XOF
|
5
|
+
- Update UYU currency symbol
|
6
|
+
- Allow double conversion using same bank
|
7
|
+
- Warn when using unsafe serializer for rate import
|
8
|
+
- Move Icelandic symbol after the amount
|
9
|
+
|
3
10
|
## 6.13.7
|
4
11
|
- Improve deprecation warnings for the upcoming major release
|
5
12
|
|
data/README.md
CHANGED
@@ -493,6 +493,16 @@ Money.new(10_000_00, 'USD').format # => $10.000,00
|
|
493
493
|
Money.new(10_000_00, 'EUR').format # => €10.000,00
|
494
494
|
```
|
495
495
|
|
496
|
+
If you need to localize the position of the currency symbol, you
|
497
|
+
have to pass it manually. *Note: this will become the default formatting
|
498
|
+
behavior in the next version.*
|
499
|
+
|
500
|
+
```ruby
|
501
|
+
I18n.locale = :fr
|
502
|
+
format = I18n.t :format, scope: 'number.currency.format'
|
503
|
+
Money.new(10_00, 'EUR').format(format: format) # => 10,00 €
|
504
|
+
```
|
505
|
+
|
496
506
|
For the legacy behaviour of "per currency" localization (formatting depends only on currency):
|
497
507
|
|
498
508
|
```ruby
|
data/config/currency_iso.json
CHANGED
@@ -1019,11 +1019,11 @@
|
|
1019
1019
|
"priority": 100,
|
1020
1020
|
"iso_code": "ISK",
|
1021
1021
|
"name": "Icelandic Króna",
|
1022
|
-
"symbol": "kr",
|
1022
|
+
"symbol": "kr.",
|
1023
1023
|
"alternate_symbols": ["Íkr"],
|
1024
1024
|
"subunit": null,
|
1025
1025
|
"subunit_to_unit": 1,
|
1026
|
-
"symbol_first":
|
1026
|
+
"symbol_first": false,
|
1027
1027
|
"html_entity": "",
|
1028
1028
|
"decimal_mark": ",",
|
1029
1029
|
"thousands_separator": ".",
|
@@ -2245,12 +2245,12 @@
|
|
2245
2245
|
"priority": 100,
|
2246
2246
|
"iso_code": "UYU",
|
2247
2247
|
"name": "Uruguayan Peso",
|
2248
|
-
"symbol": "$",
|
2248
|
+
"symbol": "$U",
|
2249
2249
|
"alternate_symbols": ["$U"],
|
2250
2250
|
"subunit": "Centésimo",
|
2251
2251
|
"subunit_to_unit": 100,
|
2252
2252
|
"symbol_first": true,
|
2253
|
-
"html_entity": "
|
2253
|
+
"html_entity": "$U",
|
2254
2254
|
"decimal_mark": ",",
|
2255
2255
|
"thousands_separator": ".",
|
2256
2256
|
"iso_numeric": "858",
|
@@ -2336,7 +2336,7 @@
|
|
2336
2336
|
"priority": 100,
|
2337
2337
|
"iso_code": "XAF",
|
2338
2338
|
"name": "Central African Cfa Franc",
|
2339
|
-
"symbol": "
|
2339
|
+
"symbol": "CFA",
|
2340
2340
|
"disambiguate_symbol": "FCFA",
|
2341
2341
|
"alternate_symbols": ["FCFA"],
|
2342
2342
|
"subunit": "Centime",
|
@@ -114,7 +114,7 @@ class Money
|
|
114
114
|
if rate = get_rate(from.currency, to_currency)
|
115
115
|
fractional = calculate_fractional(from, to_currency)
|
116
116
|
from.class.new(
|
117
|
-
exchange(fractional, rate, &block), to_currency
|
117
|
+
exchange(fractional, rate, &block), to_currency, self
|
118
118
|
)
|
119
119
|
else
|
120
120
|
raise UnknownRate, "No conversion rate known for '#{from.currency.iso_code}' -> '#{to_currency}'"
|
@@ -217,8 +217,7 @@ class Money
|
|
217
217
|
# s = bank.export_rates(:json)
|
218
218
|
# s #=> "{\"USD_TO_CAD\":1.24515,\"CAD_TO_USD\":0.803115}"
|
219
219
|
def export_rates(format, file = nil, opts = {})
|
220
|
-
raise Money::Bank::UnknownRateFormat unless
|
221
|
-
RATE_FORMATS.include? format
|
220
|
+
raise Money::Bank::UnknownRateFormat unless RATE_FORMATS.include?(format)
|
222
221
|
|
223
222
|
store.transaction do
|
224
223
|
s = FORMAT_SERIALIZERS[format].dump(rates)
|
@@ -258,8 +257,13 @@ class Money
|
|
258
257
|
# bank.get_rate("USD", "CAD") #=> 1.24515
|
259
258
|
# bank.get_rate("CAD", "USD") #=> 0.803115
|
260
259
|
def import_rates(format, s, opts = {})
|
261
|
-
raise Money::Bank::UnknownRateFormat unless
|
262
|
-
|
260
|
+
raise Money::Bank::UnknownRateFormat unless RATE_FORMATS.include?(format)
|
261
|
+
|
262
|
+
if format == :ruby
|
263
|
+
warn '[WARNING] Using :ruby format when importing rates is potentially unsafe and ' \
|
264
|
+
'might lead to remote code execution via Marshal.load deserializer. Consider using ' \
|
265
|
+
'safe alternatives such as :json and :yaml.'
|
266
|
+
end
|
263
267
|
|
264
268
|
store.transaction do
|
265
269
|
data = FORMAT_SERIALIZERS[format].load(s)
|
data/lib/money/money.rb
CHANGED
@@ -131,8 +131,9 @@ class Money
|
|
131
131
|
#
|
132
132
|
# @return [Integer]
|
133
133
|
attr_accessor :default_bank, :default_formatting_rules,
|
134
|
-
:
|
135
|
-
|
134
|
+
:infinite_precision, :conversion_precision
|
135
|
+
|
136
|
+
attr_reader :use_i18n, :locale_backend
|
136
137
|
end
|
137
138
|
|
138
139
|
# @!attribute default_currency
|
@@ -46,7 +46,7 @@ class Money
|
|
46
46
|
# Compares two Money objects. If money objects have a different currency it
|
47
47
|
# will attempt to convert the currency.
|
48
48
|
#
|
49
|
-
# @param [Money]
|
49
|
+
# @param [Money] other Value to compare with.
|
50
50
|
#
|
51
51
|
# @return [Integer]
|
52
52
|
#
|
@@ -103,7 +103,7 @@ class Money
|
|
103
103
|
# values. If +other_money+ has a different currency then its monetary value
|
104
104
|
# is automatically exchanged to this object's currency using +exchange_to+.
|
105
105
|
#
|
106
|
-
# @param [Money]
|
106
|
+
# @param [Money] other Other +Money+ object to add.
|
107
107
|
#
|
108
108
|
# @return [Money]
|
109
109
|
#
|
@@ -116,7 +116,7 @@ class Money
|
|
116
116
|
# its monetary value is automatically exchanged to this object's currency
|
117
117
|
# using +exchange_to+.
|
118
118
|
#
|
119
|
-
# @param [Money]
|
119
|
+
# @param [Money] other Other +Money+ object to subtract.
|
120
120
|
#
|
121
121
|
# @return [Money]
|
122
122
|
#
|
@@ -19,7 +19,7 @@ class Money
|
|
19
19
|
#
|
20
20
|
# @param [Hash] opts Optional store options.
|
21
21
|
# @option opts [Boolean] :without_mutex disables the usage of a mutex
|
22
|
-
# @param [Hash]
|
22
|
+
# @param [Hash] rates Optional initial exchange rate data.
|
23
23
|
def initialize(opts = {}, rates = {})
|
24
24
|
@rates = rates
|
25
25
|
@options = opts
|
data/lib/money/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: money
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.13.
|
4
|
+
version: 6.13.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shane Emmons
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2020-
|
12
|
+
date: 2020-07-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: i18n
|
@@ -159,7 +159,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
159
159
|
- !ruby/object:Gem::Version
|
160
160
|
version: '0'
|
161
161
|
requirements: []
|
162
|
-
rubygems_version: 3.
|
162
|
+
rubygems_version: 3.1.2
|
163
163
|
signing_key:
|
164
164
|
specification_version: 4
|
165
165
|
summary: A Ruby Library for dealing with money and currency conversion.
|