minting 1.3.0 → 1.4.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 +4 -4
- data/README.md +17 -2
- data/Rakefile +3 -3
- data/doc/Mint/Currency.html +816 -0
- data/doc/Mint/Money.html +3471 -0
- data/doc/Mint.html +953 -0
- data/doc/Minting.html +142 -0
- data/doc/_index.html +136 -0
- data/doc/agents/AGENTS.md +25 -0
- data/doc/agents/copilot-instructions.md +75 -0
- data/doc/agents/gemini_gem_evaluation.md +245 -0
- data/doc/agents/recommendations.md +335 -0
- data/doc/class_list.html +54 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +206 -0
- data/doc/css/style.css +1089 -0
- data/doc/file.README.html +379 -0
- data/doc/file_list.html +59 -0
- data/doc/frames.html +22 -0
- data/doc/index.html +379 -0
- data/doc/js/app.js +801 -0
- data/doc/js/full_list.js +334 -0
- data/doc/js/jquery.js +4 -0
- data/doc/method_list.html +470 -0
- data/doc/top-level-namespace.html +112 -0
- data/lib/minting/mint/currency.rb +1 -1
- data/lib/minting/mint/registry.rb +9 -18
- data/lib/minting/money/conversion.rb +5 -16
- data/lib/minting/money/formatting.rb +34 -1
- data/lib/minting/money/money.rb +83 -5
- data/lib/minting/version.rb +1 -1
- data/minting.gemspec +1 -0
- metadata +38 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 55db3e9b61e8ee1c813e313789222cc2e083f59c1070c12801cd3afd5eaf6fe6
|
|
4
|
+
data.tar.gz: d2d4420c40bd39e551a79a9b1ad42386f8d8ab4e9560ad8ad287909fc1a5633a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7aa9f93ea36aeef350308adcec126812a8e5438a95d5e305d79ca6e993f27ffbf7f27908fd4ead9fa0b3659f10f29db263b31b97c5a86fb1f689c401913401eb
|
|
7
|
+
data.tar.gz: c9267d2eb5e5329d7af59eca2507663bf85e4716f2dda4089946c86bd0da8f2848e4069e298e4a9a58eba4a89da203fd7116226f546ab2bf531ad0cc04ce3526
|
data/README.md
CHANGED
|
@@ -8,7 +8,7 @@ Fast, precise, and developer-friendly money handling for Ruby.
|
|
|
8
8
|
|
|
9
9
|
**Tired of floating-point errors in financial calculations?** Minting uses Rational numbers for perfect precision.
|
|
10
10
|
|
|
11
|
-
**Need performance?** Minting is
|
|
11
|
+
**Need performance?** Minting is 2× faster than alternatives for high-volume operations (often 10×+ for formatting). See the [Performance](#performance) section for full benchmarks.
|
|
12
12
|
|
|
13
13
|
**Want a clean API?** Minting provides an intuitive interface with helpful error messages.
|
|
14
14
|
|
|
@@ -87,15 +87,30 @@ price.to_s(format: ' %<amount>10f %<currency>s') #=> " 9.99 USD"
|
|
|
87
87
|
|
|
88
88
|
price_in_euros.to_s(format: '%<symbol>2s%<amount>+10f') #=> " € +12.34"
|
|
89
89
|
|
|
90
|
+
# Per-sign Hash format (e.g. accounting parentheses for losses)
|
|
91
|
+
loss = Mint.money(-1234.56, 'USD')
|
|
92
|
+
loss.to_s(format: { negative: '(%<symbol>s%<amount>f)' }) #=> "($1,234.56)"
|
|
93
|
+
Mint.money(0, 'BRL').to_s(format: { zero: '--' }) #=> "--"
|
|
94
|
+
# All three keys at once:
|
|
95
|
+
fmt = { positive: '%<symbol>s%<amount>f', negative: '(%<symbol>s%<amount>f)', zero: '--' }
|
|
96
|
+
Mint.money(1234.56, 'USD').to_s(format: fmt) #=> "$1,234.56"
|
|
97
|
+
|
|
90
98
|
# Json serialization
|
|
91
99
|
|
|
92
|
-
price.to_json # => "{
|
|
100
|
+
price.to_json # => "{\"currency\": \"USD\", \"amount\": \"9.99\"}"
|
|
93
101
|
|
|
94
102
|
# Hash conversion
|
|
95
103
|
|
|
96
104
|
price.to_hash #=> {currency: "USD", amount: "9.99"}
|
|
97
105
|
|
|
98
106
|
|
|
107
|
+
# Fractional units (inverse of #fractional) - exact integer arithmetic
|
|
108
|
+
|
|
109
|
+
price.fractional #=> 999
|
|
110
|
+
Mint::Money.from_fractional(999, 'USD') #=> [USD 9.99]
|
|
111
|
+
Mint::Money.from_fractional(1234, 'JPY') #=> [JPY 1234] # subunit 0 -> no scaling
|
|
112
|
+
|
|
113
|
+
|
|
99
114
|
# Proportional allocation and split
|
|
100
115
|
|
|
101
116
|
ten.split(3) #=> [[USD 3.34], [USD 3.33], [USD 3.33]]
|
data/Rakefile
CHANGED
|
@@ -44,9 +44,9 @@ end
|
|
|
44
44
|
RuboCop::RakeTask.new(:cop)
|
|
45
45
|
|
|
46
46
|
YARD::Rake::YardocTask.new do |t|
|
|
47
|
-
t.files = ['lib/**/*.rb']
|
|
48
|
-
t.options = [] #
|
|
49
|
-
t.stats_options = ['--list-undoc']
|
|
47
|
+
t.files = ['lib/**/*.rb']
|
|
48
|
+
t.options = ['-o doc/api'] # Place the documentos in doc/api
|
|
49
|
+
t.stats_options = ['--list-undoc']
|
|
50
50
|
end
|
|
51
51
|
|
|
52
52
|
task default: :test
|