minting 1.9.3 → 1.9.4
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 +4 -4
- data/README.md +14 -15
- data/doc/agents/api_review-2026-06-15.md +2 -2
- data/doc/agents/expired/recommendations.md +1 -1
- data/lib/minting/mint/aliases.rb +14 -8
- data/lib/minting/mint/i18n.rb +1 -1
- data/lib/minting/mint.rb +0 -1
- data/lib/minting/version.rb +1 -1
- data/lib/minting.rb +10 -0
- metadata +1 -2
- data/lib/minting/mint/dsl/top_level.rb +0 -17
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e784f15a78d9890f02c3b44c95ab975bd8a12647c27d87531059603fa0e5cab5
|
|
4
|
+
data.tar.gz: 83e28899e8e8cedcd98a93fd2b787470485d8f440ba82f63138499dc1ba33c20
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: dc823a1170e16ae3ef0751d2e35200b681e89c42d8480d7dfb6117c9f7b6dbe8b6d5cec2fa47a57755e0f52eeb0324a5dd560a359729307aa19186625490f6fc
|
|
7
|
+
data.tar.gz: a281aae01fc2e2472c0697ea02f6d68f21c64ecb9acb9c8704a70bba35a8e7dafa0523f8d6696c93c818c67488c81c6c2b3d117cc48a5f0720eeaaa31607dac1
|
data/README.md
CHANGED
|
@@ -30,7 +30,7 @@ Minting is faster than the Money gem for everyday operations and **over 10× fas
|
|
|
30
30
|
Intuitive interface, descriptive error messages, and sensible defaults. Works the way you expect.
|
|
31
31
|
|
|
32
32
|
### Rails-ready
|
|
33
|
-
Use with the [
|
|
33
|
+
Use with the [attribute-money](https://github.com/gferraz/attribute-money) companion gem for drop-in ActiveRecord type casting, validators, and form helpers.
|
|
34
34
|
|
|
35
35
|
### Quality code
|
|
36
36
|
- **100% test coverage** — every line exercised
|
|
@@ -110,7 +110,7 @@ price_in_euros.to_formatted_s(format: '%<symbol>2s%<amount>+10f') #=> " €
|
|
|
110
110
|
|
|
111
111
|
# Integral & fractional parts
|
|
112
112
|
price.to_formatted_s(format: '%<integral>d %<fractional>d/100') #=> "9 99/100"
|
|
113
|
-
Mint.money(0.99, 'USD').
|
|
113
|
+
Mint.money(0.99, 'USD').to_fs(format: '%<integral>d dollars and %<fractional>02d cents')
|
|
114
114
|
#=> "0 dollars and 99 cents"
|
|
115
115
|
|
|
116
116
|
# Per-sign Hash format (e.g. accounting parentheses for losses)
|
|
@@ -227,33 +227,32 @@ Modes: `:half_up` (default), `:half_down`, `:floor`, `:ceil`, `:truncate`, `:dow
|
|
|
227
227
|
|
|
228
228
|
## Optional top-level `Money` and `Currency`
|
|
229
229
|
|
|
230
|
-
By default,
|
|
230
|
+
By default, `require "minting"` exposes `Mint::Money` as the top-level `Money` constant, so you can write `Money.from(10, "USD")` directly:
|
|
231
231
|
|
|
232
232
|
```ruby
|
|
233
233
|
require "minting"
|
|
234
|
-
|
|
234
|
+
|
|
235
|
+
price = Money.from(10, "USD") # equivalent to Mint::Money.from
|
|
236
|
+
tax = Money.from(2.50, "USD")
|
|
235
237
|
```
|
|
236
238
|
|
|
237
|
-
|
|
239
|
+
`Currency` is **not** auto-bound, because application domain models are commonly named `Currency` (e.g. a Rails model). To opt in to the top-level `Currency` constant:
|
|
238
240
|
|
|
239
241
|
```ruby
|
|
240
|
-
|
|
242
|
+
require "minting"
|
|
243
|
+
require "minting/mint/aliases" # opt-in top-level Currency
|
|
244
|
+
|
|
245
|
+
cur = Currency.new(code: "EUR", symbol: "€", subunit: 2, priority: 0)
|
|
241
246
|
```
|
|
242
247
|
|
|
243
|
-
For Rails applications, you can enable the top-level
|
|
248
|
+
For Rails applications, you can enable the top-level `Currency` constant in an initializer:
|
|
244
249
|
|
|
245
250
|
```ruby
|
|
246
251
|
# config/initializers/minting.rb
|
|
247
|
-
require "minting/
|
|
252
|
+
require "minting/mint/aliases"
|
|
248
253
|
```
|
|
249
254
|
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
```ruby
|
|
253
|
-
price = Money.from(10, "USD") # equivalent to Mint::Money.from
|
|
254
|
-
tax = Money.from(2.50, "USD")
|
|
255
|
-
cur = Currency.new(code: "EUR", symbol: "€", subunit: 2, priority: 0)
|
|
256
|
-
```
|
|
255
|
+
If another `Money` is already defined when `require "minting"` runs (e.g. the `money` gem was loaded first), Minting warns and skips the auto-bind — use `Mint::Money` in that case. The same applies to `Currency` via `minting/mint/aliases`.
|
|
257
256
|
|
|
258
257
|
**Good fit:** Application code, especially Rails apps.
|
|
259
258
|
**Not recommended:** Reusable gems/libraries — stick to `Mint::Money` to avoid conflicts.
|
|
@@ -294,7 +294,7 @@ Your README is already strong. To push it over the top vs. `money` gem and frien
|
|
|
294
294
|
- Always-exact `Rational` amounts.
|
|
295
295
|
- Currency-agnostic zero.
|
|
296
296
|
- Faster formatting (link benchmarks).
|
|
297
|
-
- Separate `
|
|
297
|
+
- Separate `attribute-money` companion for clean Rails integration.
|
|
298
298
|
|
|
299
299
|
2. **Add “Common tasks” cheatsheet**
|
|
300
300
|
|
|
@@ -314,7 +314,7 @@ Your README is already strong. To push it over the top vs. `money` gem and frien
|
|
|
314
314
|
|
|
315
315
|
3. **Prominent “Rails” heading**
|
|
316
316
|
|
|
317
|
-
Right now you just mention `
|
|
317
|
+
Right now you just mention `attribute-money`. Make it a full section:
|
|
318
318
|
|
|
319
319
|
- How to add gem.
|
|
320
320
|
- Example migration / attribute definition (even if in the other repo, mirror one snippet here).
|
|
@@ -253,7 +253,7 @@ Multi-PR epic:
|
|
|
253
253
|
1. `Mint::Bank` interface with `#exchange(money, target)`.
|
|
254
254
|
2. `Mint::Bank::MemoryStore` (in-memory, good for tests).
|
|
255
255
|
3. `Mint::Bank::ECB` or `Mint::Bank::OpenExchangeRates` (network).
|
|
256
|
-
4. Update `
|
|
256
|
+
4. Update `attribute-money` to expose bank config in the Railtie.
|
|
257
257
|
|
|
258
258
|
### P2-3 Reek / RuboCop tightening
|
|
259
259
|
|
data/lib/minting/mint/aliases.rb
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
# Optional top
|
|
4
|
-
#
|
|
5
|
-
|
|
6
|
-
#
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
#
|
|
10
|
-
|
|
3
|
+
# Optional top-level alias for Mint::Currency.
|
|
4
|
+
#
|
|
5
|
+
# Mint::Money is auto-bound as the top-level Money constant by
|
|
6
|
+
# `require 'minting'` (see lib/minting.rb). Currency is not auto-bound
|
|
7
|
+
# because application domain models are commonly named Currency (e.g. a
|
|
8
|
+
# Rails model). Require this file to opt in:
|
|
9
|
+
#
|
|
10
|
+
# require 'minting/mint/aliases'
|
|
11
|
+
#
|
|
12
|
+
if defined?(Currency) && Currency != Mint::Currency
|
|
13
|
+
warn "minting: top-level Currency is already defined (#{Currency}); skipping alias."
|
|
14
|
+
else
|
|
15
|
+
Currency = Mint::Currency unless defined?(Currency)
|
|
16
|
+
end
|
data/lib/minting/mint/i18n.rb
CHANGED
|
@@ -13,7 +13,7 @@ module Mint
|
|
|
13
13
|
# When set, +#to_formatted_s+ and +#format+ use these values as fallbacks when the
|
|
14
14
|
# corresponding parameter is not explicitly provided.
|
|
15
15
|
#
|
|
16
|
-
# @example Rails I18n integration (in
|
|
16
|
+
# @example Rails I18n integration (in attribute-money railtie)
|
|
17
17
|
# Mint.locale_backend = -> {
|
|
18
18
|
# fmt = I18n.t('number.currency.format')
|
|
19
19
|
# {
|
data/lib/minting/mint.rb
CHANGED
|
@@ -5,7 +5,6 @@ require_relative 'currency/currency'
|
|
|
5
5
|
require_relative 'mint/dsl/numeric'
|
|
6
6
|
require_relative 'mint/dsl/range'
|
|
7
7
|
require_relative 'mint/dsl/string'
|
|
8
|
-
require_relative 'mint/dsl/top_level'
|
|
9
8
|
require_relative 'mint/i18n'
|
|
10
9
|
require_relative 'mint/mint'
|
|
11
10
|
require_relative 'mint/parser/parser'
|
data/lib/minting/version.rb
CHANGED
data/lib/minting.rb
CHANGED
|
@@ -2,3 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
require 'minting/mint'
|
|
4
4
|
require 'minting/version'
|
|
5
|
+
|
|
6
|
+
# By default, expose Mint::Money as the top-level Money constant for
|
|
7
|
+
# convenience. If Money is already defined (e.g. by the `money` gem), warn
|
|
8
|
+
# and skip so both libraries can coexist in the same process without
|
|
9
|
+
# corrupting either class.
|
|
10
|
+
if defined?(Money) && Money != Mint::Money
|
|
11
|
+
warn "minting: top-level Money is already defined (#{Money}); skipping auto-bind. Use Mint::Money."
|
|
12
|
+
else
|
|
13
|
+
Money = Mint::Money unless defined?(Money)
|
|
14
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: minting
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.9.
|
|
4
|
+
version: 1.9.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Gilson Ferraz
|
|
@@ -74,7 +74,6 @@ files:
|
|
|
74
74
|
- lib/minting/mint/dsl/numeric.rb
|
|
75
75
|
- lib/minting/mint/dsl/range.rb
|
|
76
76
|
- lib/minting/mint/dsl/string.rb
|
|
77
|
-
- lib/minting/mint/dsl/top_level.rb
|
|
78
77
|
- lib/minting/mint/i18n.rb
|
|
79
78
|
- lib/minting/mint/mint.rb
|
|
80
79
|
- lib/minting/mint/parser/parser.rb
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# Mint refinements
|
|
4
|
-
module Mint
|
|
5
|
-
# Registers top-level ::Money and ::Currency constants as aliases for Mint's classes.
|
|
6
|
-
#
|
|
7
|
-
# @raise [NameError] if ::Money or ::Currency are already defined and differ
|
|
8
|
-
def self.use_top_level_constants!
|
|
9
|
-
if !defined?(::Money) && !defined?(::Currency)
|
|
10
|
-
require 'minting/mint/aliases'
|
|
11
|
-
elsif ::Money == Mint::Money && ::Currency == Mint::Currency
|
|
12
|
-
warn 'Warning: Money and Currency already defined as Mint aliases, skipping'
|
|
13
|
-
else
|
|
14
|
-
raise NameError, 'Cannot define top-level Money or Currency constants: already defined'
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|