money 6.13.7 → 6.13.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7423c34018e037ae7989b60e9cf22972afb7fa8f02037c253b0d3fd30e635fd0
4
- data.tar.gz: fedcca4c2a3d6918e930526e3a207c419853852604bee8268e2d8046f59ce4cc
3
+ metadata.gz: 1773172616f278d2f107e19153498c029c5f1b63f4ae68a7468ef66fbbef8991
4
+ data.tar.gz: 035cd8170e536decc4748cd8a6c2ef1b7a7d5e985e6a2ecba0c989f8cf89096c
5
5
  SHA512:
6
- metadata.gz: 53eeeb609a252d244e9d497fd3f480c317561a8b5a1889b297f96d2298bac3c2b87b5ed1af6e5c6dfbbc0264039960f4287bd6752c7090adb7923befca9ba52e
7
- data.tar.gz: 45cf7fd6f42d16a3924e515e779c283316ca204bba5dade5773f89b44118615a69736bd5231db254fb9857dc8dc5b4938343c9982cc4279d88d586f327b492e1
6
+ metadata.gz: 5636c6323a8538ccc669a2ecfd07a3108adde4f6315e43d0d2b0bb818fc31d1c230ff0ca9715a2c1ca67edcdfa7cb71c9c4d8405410f0764cc82aaad5d3af4e1
7
+ data.tar.gz: 4b2532f674ca8b665b43c745f5b8cc2beb3d7d5fda0584273bc53d8a42e8a551037758374b6864cfe4b227d61d043282394ed51b62e27f82b8f374ddb27dbe5b
@@ -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
@@ -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": true,
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": "Fr",
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
- RATE_FORMATS.include? format
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)
@@ -131,8 +131,9 @@ class Money
131
131
  #
132
132
  # @return [Integer]
133
133
  attr_accessor :default_bank, :default_formatting_rules,
134
- :use_i18n, :infinite_precision, :conversion_precision,
135
- :locale_backend
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] other_money Value to compare with.
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] other_money Other +Money+ object to add.
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] other_money Other +Money+ object to subtract.
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] rt Optional initial exchange rate data.
22
+ # @param [Hash] rates Optional initial exchange rate data.
23
23
  def initialize(opts = {}, rates = {})
24
24
  @rates = rates
25
25
  @options = opts
@@ -1,3 +1,3 @@
1
1
  class Money
2
- VERSION = '6.13.7'
2
+ VERSION = '6.13.8'
3
3
  end
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.7
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-01-05 00:00:00.000000000 Z
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.0.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.