money 6.16.0 → 6.18.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +15 -0
- data/LICENSE +1 -1
- data/README.md +54 -1
- data/config/currency_iso.json +36 -2
- data/config/currency_non_iso.json +16 -0
- data/lib/money/money/formatter.rb +13 -2
- data/lib/money/money.rb +1 -0
- data/lib/money/version.rb +1 -1
- data/money.gemspec +0 -2
- 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: 146c73332b26929014c71519d1a698b06aa8782651787d363c3bf6a495e5b6c5
|
4
|
+
data.tar.gz: 7dc290dc12bc060396c291d0b4f8615240d5e745d6dfb6ee493aec60296fceec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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)
|
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
|
-
[![
|
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
|
|
data/config/currency_iso.json
CHANGED
@@ -723,7 +723,7 @@
|
|
723
723
|
"subunit": "Cent",
|
724
724
|
"subunit_to_unit": 100,
|
725
725
|
"symbol_first": true,
|
726
|
-
"html_entity": "
|
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
|
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
data/lib/money/version.rb
CHANGED
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.
|
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:
|
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.
|
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.
|