money 6.17.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: a77a263720ab3ec11aa09efafd92db24699bb94a6c1dbde3ef4091919d4d9f6f
4
- data.tar.gz: 740a688dd466867db5b75a12f6f937401097bfb3961a6767238cab977b6a6e18
3
+ metadata.gz: 146c73332b26929014c71519d1a698b06aa8782651787d363c3bf6a495e5b6c5
4
+ data.tar.gz: 7dc290dc12bc060396c291d0b4f8615240d5e745d6dfb6ee493aec60296fceec
5
5
  SHA512:
6
- metadata.gz: ea34a12312f4dc1c356dd2feef065c282e0c4a6452ad9c85cb594dead220bd2cdd7fbe2294e9252f8ab4805f1c75f652572012ff28b93d3fccdf5f7738eeb0b7
7
- data.tar.gz: cb819df21f0b5177c3f28ad20adc831dff9e153e51efb1077725eaa1f80e67446de8eb4bcb8e20600c52cde575c776cb6858b50d794874b955cac558d3de8896
6
+ metadata.gz: a732f1abb1cac4bfeabd12a8541ef88704da0db312ef1a93e625c738724e272ef1848eb60d5fe50910c21ab4de57937e20bc332a752daadb459865c249322892
7
+ data.tar.gz: 4351c0c06eab76fdfff48a25447606513b525bc04c0cdb478bff472816b11e5d7c9201420e79c85a1697951678a1905530ee484a8c822412c93188c2853044f4
data/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
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
+
3
14
  ## 6.17.0
4
15
 
5
16
  - Allow true for `thousands_separator`
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
  }
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.17.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.17.0
4
+ version: 6.18.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shane Emmons