money 6.16.0 → 6.18.0

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: 3de47437ec002ed24a400508cac96b2ff6812f484c666fe3db3a82e921a805c0
4
- data.tar.gz: f96755602e56ea81d734b7505e7cfc88caaa948d7a8d285eeb470801028c15b9
3
+ metadata.gz: 146c73332b26929014c71519d1a698b06aa8782651787d363c3bf6a495e5b6c5
4
+ data.tar.gz: 7dc290dc12bc060396c291d0b4f8615240d5e745d6dfb6ee493aec60296fceec
5
5
  SHA512:
6
- metadata.gz: 2f8cd71611e96a80cb733651675cb6fac59d358cb7c9576c8c264abbfec6eb1da11b8cbe2af12cdfb070e5dd01cd74f6fdc70772da16aa4c2abc5248b13fca3c
7
- data.tar.gz: '092ba5a188eb29d462431e94420e1c6d7a7f9a4a59c0895f66a4a1cf92cfaa37cbc1bc344a241f5f8cc9fc4e998189164bc2d0ab11480a589fe7bb0e341754ba'
6
+ metadata.gz: a732f1abb1cac4bfeabd12a8541ef88704da0db312ef1a93e625c738724e272ef1848eb60d5fe50910c21ab4de57937e20bc332a752daadb459865c249322892
7
+ data.tar.gz: 4351c0c06eab76fdfff48a25447606513b525bc04c0cdb478bff472816b11e5d7c9201420e79c85a1697951678a1905530ee484a8c822412c93188c2853044f4
data/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # Changelog
2
2
 
3
+ ## Upcoming
4
+
5
+ - Add second dobra (STN) from São Tomé and Príncipe
6
+ - Use euro symbol as html_entity for euro currency
7
+ - Update Georgian Lari symbol
8
+ - Add Ruby 3.1 to the CI matrix
9
+
10
+ ## 6.18.0
11
+
12
+ - Add `Money.from_dollars` alias as a more explicit initializer, it's the same as `Money.from_amount`
13
+
14
+ ## 6.17.0
15
+
16
+ - Allow true for `thousands_separator`
17
+
3
18
  ## 6.16.0
4
19
 
5
20
  - Add `Money.from_cents` alias as a more explicit initializer, it's the same as `Money.new`
data/LICENSE CHANGED
@@ -2,7 +2,7 @@ MIT License
2
2
 
3
3
  Copyright (c) 2005 Tobias Lutke
4
4
  Copyright (c) 2008 Phusion
5
- Copyright (c) 2021 Shane Emmons
5
+ Copyright (c) 2022 Shane Emmons
6
6
 
7
7
  Permission is hereby granted, free of charge, to any person obtaining a copy
8
8
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # RubyMoney - Money
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/money.svg)](https://rubygems.org/gems/money)
4
- [![Build Status](https://travis-ci.org/RubyMoney/money.svg?branch=master)](https://travis-ci.org/RubyMoney/money)
4
+ [![Ruby](https://github.com/RubyMoney/money/actions/workflows/ruby.yml/badge.svg)](https://github.com/RubyMoney/money/actions/workflows/ruby.yml)
5
5
  [![Code Climate](https://codeclimate.com/github/RubyMoney/money.svg)](https://codeclimate.com/github/RubyMoney/money)
6
6
  [![Inline docs](https://inch-ci.org/github/RubyMoney/money.svg)](https://inch-ci.org/github/RubyMoney/money)
7
7
  [![License](https://img.shields.io/github/license/RubyMoney/money.svg)](https://opensource.org/licenses/MIT)
@@ -334,6 +334,59 @@ class ExchangeRate < ApplicationRecord
334
334
  yield rate.from, rate.to, rate.rate
335
335
  end
336
336
  end
337
+
338
+ def self.marshal_dump
339
+ [self]
340
+ end
341
+ end
342
+ ```
343
+
344
+ The following example implements a `Redis` store to save exchange rates to a redis database.
345
+
346
+ ```ruby
347
+
348
+ class RedisRateStore
349
+ INDEX_KEY_SEPARATOR = '_TO_'.freeze
350
+
351
+ # Using second db of the redis instance
352
+ # because sidekiq uses the first db
353
+ REDIS_DATABASE = 1
354
+
355
+ # Using Hash to store rates data
356
+ REDIS_STORE_KEY = 'rates'
357
+
358
+ def initialize
359
+ conn_url = "#{Rails.application.credentials.redis_server}/#{REDIS_DATABASE}"
360
+ @connection = Redis.new(url: conn_url)
361
+ end
362
+
363
+ def add_rate(iso_from, iso_to, rate)
364
+ @connection.hset(REDIS_STORE_KEY, rate_key_for(iso_from, iso_to), rate)
365
+ end
366
+
367
+ def get_rate(iso_from, iso_to)
368
+ @connection.hget(REDIS_STORE_KEY, rate_key_for(iso_from, iso_to))
369
+ end
370
+
371
+ def each_rate
372
+ rates = @connection.hgetall(REDIS_STORE_KEY)
373
+ return to_enum(:each_rate) unless block_given?
374
+
375
+ rates.each do |key, rate|
376
+ iso_from, iso_to = key.split(INDEX_KEY_SEPARATOR)
377
+ yield iso_from, iso_to, rate
378
+ end
379
+ end
380
+
381
+ def transaction
382
+ yield
383
+ end
384
+
385
+ private
386
+
387
+ def rate_key_for(iso_from, iso_to)
388
+ [iso_from, iso_to].join(INDEX_KEY_SEPARATOR).upcase
389
+ end
337
390
  end
338
391
  ```
339
392
 
@@ -723,7 +723,7 @@
723
723
  "subunit": "Cent",
724
724
  "subunit_to_unit": 100,
725
725
  "symbol_first": true,
726
- "html_entity": "&#x20AC;",
726
+ "html_entity": "",
727
727
  "decimal_mark": ",",
728
728
  "thousands_separator": ".",
729
729
  "iso_numeric": "978",
@@ -782,7 +782,7 @@
782
782
  "priority": 100,
783
783
  "iso_code": "GEL",
784
784
  "name": "Georgian Lari",
785
- "symbol": "",
785
+ "symbol": "",
786
786
  "alternate_symbols": ["lari"],
787
787
  "subunit": "Tetri",
788
788
  "subunit_to_unit": 100,
@@ -1999,11 +1999,28 @@
1999
1999
  "iso_numeric": "703",
2000
2000
  "smallest_denomination": 50
2001
2001
  },
2002
+ "sle": {
2003
+ "priority": 100,
2004
+ "iso_code": "SLE",
2005
+ "name": "New Leone",
2006
+ "symbol": "Le",
2007
+ "alternate_symbols": [],
2008
+ "subunit": "Cent",
2009
+ "subunit_to_unit": 100,
2010
+ "symbol_first": false,
2011
+ "format": "%n %u",
2012
+ "html_entity": "",
2013
+ "decimal_mark": ".",
2014
+ "thousands_separator": ",",
2015
+ "iso_numeric": "925",
2016
+ "smallest_denomination": 1000
2017
+ },
2002
2018
  "sll": {
2003
2019
  "priority": 100,
2004
2020
  "iso_code": "SLL",
2005
2021
  "name": "Sierra Leonean Leone",
2006
2022
  "symbol": "Le",
2023
+ "disambiguate_symbol": "SLL",
2007
2024
  "alternate_symbols": [],
2008
2025
  "subunit": "Cent",
2009
2026
  "subunit_to_unit": 100,
@@ -2081,6 +2098,23 @@
2081
2098
  "iso_numeric": "678",
2082
2099
  "smallest_denomination": 10000
2083
2100
  },
2101
+ "stn": {
2102
+ "priority": 100,
2103
+ "iso_code": "STN",
2104
+ "name": "São Tomé and Príncipe Second Dobra",
2105
+ "symbol": "Db",
2106
+ "disambiguate_symbol": "STN",
2107
+ "alternate_symbols": [],
2108
+ "subunit": "Cêntimo",
2109
+ "subunit_to_unit": 100,
2110
+ "symbol_first": false,
2111
+ "format": "%n %u",
2112
+ "html_entity": "",
2113
+ "decimal_mark": ".",
2114
+ "thousands_separator": ",",
2115
+ "iso_numeric": "930",
2116
+ "smallest_denomination": 10
2117
+ },
2084
2118
  "svc": {
2085
2119
  "priority": 100,
2086
2120
  "iso_code": "SVC",
@@ -126,5 +126,21 @@
126
126
  "thousands_separator": ",",
127
127
  "iso_numeric": "",
128
128
  "smallest_denomination": 1
129
+ },
130
+ "usdc": {
131
+ "priority": 100,
132
+ "iso_code": "USDC",
133
+ "name": "USD Coin",
134
+ "symbol": "USDC",
135
+ "disambiguate_symbol": "USDC",
136
+ "alternate_symbols": [],
137
+ "subunit": "Cent",
138
+ "subunit_to_unit": 100,
139
+ "symbol_first": false,
140
+ "html_entity": "$",
141
+ "decimal_mark": ".",
142
+ "thousands_separator": ",",
143
+ "iso_numeric": "",
144
+ "smallest_denomination": 1
129
145
  }
130
146
  }
@@ -124,11 +124,14 @@ class Money
124
124
  # the currency should be delimited by the specified character or ','
125
125
  #
126
126
  # @example
127
- # # If false is specified, no thousands_separator is used.
127
+ # # If a falsey value is specified, no thousands_separator is used.
128
128
  # Money.new(100000, "USD").format(thousands_separator: false) #=> "1000.00"
129
129
  # Money.new(100000, "USD").format(thousands_separator: nil) #=> "1000.00"
130
130
  # Money.new(100000, "USD").format(thousands_separator: "") #=> "1000.00"
131
131
  #
132
+ # # If true is specified, the locale or default thousands_separator is used.
133
+ # Money.new(100000, "USD").format(thousands_separator: true) #=> "1,000.00"
134
+ #
132
135
  # # If a string is specified, it's value is used.
133
136
  # Money.new(100000, "USD").format(thousands_separator: ".") #=> "$1.000.00"
134
137
  #
@@ -241,7 +244,11 @@ class Money
241
244
  end
242
245
 
243
246
  def thousands_separator
244
- lookup :thousands_separator
247
+ val = lookup :thousands_separator
248
+
249
+ return val unless val == true
250
+
251
+ lookup_default :thousands_separator
245
252
  end
246
253
 
247
254
  def decimal_mark
@@ -371,6 +378,10 @@ class Money
371
378
  def lookup(key)
372
379
  return rules[key] || DEFAULTS[key] if rules.has_key?(key)
373
380
 
381
+ lookup_default key
382
+ end
383
+
384
+ def lookup_default(key)
374
385
  (Money.locale_backend && Money.locale_backend.lookup(key, currency)) || DEFAULTS[key]
375
386
  end
376
387
 
data/lib/money/money.rb CHANGED
@@ -314,6 +314,7 @@ class Money
314
314
 
315
315
  class << self
316
316
  alias_method :from_cents, :new
317
+ alias_method :from_dollars, :from_amount
317
318
  end
318
319
 
319
320
  # Creates a new Money object of value given in the
data/lib/money/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class Money
2
- VERSION = '6.16.0'
2
+ VERSION = '6.18.0'
3
3
  end
data/money.gemspec CHANGED
@@ -23,8 +23,6 @@ Gem::Specification.new do |s|
23
23
  s.add_development_dependency "kramdown", "~> 2.3"
24
24
 
25
25
  s.files = `git ls-files -z -- config/* lib/* CHANGELOG.md LICENSE money.gemspec README.md`.split("\x0")
26
- s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
27
- s.test_files = s.files.grep(%r{^(test|spec|features)/})
28
26
  s.require_paths = ["lib"]
29
27
 
30
28
  if s.respond_to?(:metadata)
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.16.0
4
+ version: 6.18.0
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: 2021-05-09 00:00:00.000000000 Z
12
+ date: 2024-03-05 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.2.3
162
+ rubygems_version: 3.5.3
163
163
  signing_key:
164
164
  specification_version: 4
165
165
  summary: A Ruby Library for dealing with money and currency conversion.