minting 1.8.0 → 1.8.1
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 +6 -16
- data/Rakefile +15 -4
- data/lib/minting/mint/dsl/numeric.rb +4 -4
- data/lib/minting/mint/dsl/string.rb +1 -1
- data/lib/minting/mint/registry/zeros.rb +1 -1
- data/lib/minting/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: baca6fa666461ab6bc9f1e0ebed40d7ae0ac56af88993b5d243d25f1ad9bbad3
|
|
4
|
+
data.tar.gz: e54ad7a337df49a298e0e6236ec98d46a902ddd18b62538d395992609eca533b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: eff34626e551613b9dc312caf42698951869333aaf62440551e44eb681a8b2407e0a36ed24b02ba6f6ef03afc68dd1c7b6ac86aa85d3fafb45155f3637b70a04
|
|
7
|
+
data.tar.gz: b1d2f0f9228ef185ce8b86d4474a1d53151960d7796619ba53ff19fe0db53a9ad990e3f77f924b59c90cd984d144fb62f2fba56059f9e40dfeb5893f790e84cd
|
data/README.md
CHANGED
|
@@ -21,29 +21,19 @@ total.to_s #=> "$21.59"
|
|
|
21
21
|
total.currency_code #=> "USD"
|
|
22
22
|
```
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
| | Minting |
|
|
27
|
-
|--------------------|-------------------------------------------|
|
|
28
|
-
| **Precision** | Rational-based, zero floating-point error |
|
|
29
|
-
| **Performance** | **2× faster** (10×+ formatting) |
|
|
30
|
-
| **Ruby support** | 3.3+ (including Ruby 4.0) |
|
|
31
|
-
| **Rails** | Dedicated companion gem |
|
|
32
|
-
| **Code quality** | 100% coverage, 93/100 RubyCritic |
|
|
33
|
-
|
|
34
|
-
### 🎯 Exact precision
|
|
24
|
+
### Exact precision
|
|
35
25
|
Amounts are stored as `Rational` and rounded to the currency subunit. No floating-point surprises, ever.
|
|
36
26
|
|
|
37
|
-
###
|
|
38
|
-
Minting is
|
|
27
|
+
### Blazing performance
|
|
28
|
+
Minting is faster than the Money gem for everyday operations and **over 10× faster for formatting**. See full benchmarks in the [Performance Guide](test/performance/README.md).
|
|
39
29
|
|
|
40
|
-
###
|
|
30
|
+
### Clean, modern API
|
|
41
31
|
Intuitive interface, descriptive error messages, and sensible defaults. Works the way you expect.
|
|
42
32
|
|
|
43
|
-
###
|
|
33
|
+
### Rails-ready
|
|
44
34
|
Use with the [minting-rails](https://github.com/gferraz/minting-rails) companion gem for drop-in ActiveRecord type casting, validators, and form helpers.
|
|
45
35
|
|
|
46
|
-
###
|
|
36
|
+
### Quality code
|
|
47
37
|
- **100% test coverage** — every line exercised
|
|
48
38
|
- **93/100 RubyCritic score** — clean, maintainable code
|
|
49
39
|
- **CI-tested on Ruby 3.3 and 4.0**
|
data/Rakefile
CHANGED
|
@@ -16,7 +16,7 @@ end
|
|
|
16
16
|
|
|
17
17
|
Rake::TestTask.new('bench:all') do |t|
|
|
18
18
|
t.libs = %w[lib test]
|
|
19
|
-
t.pattern = 'test/performance
|
|
19
|
+
t.pattern = 'test/performance/{core,memory,regression,competitive/money}/*_benchmark.rb'
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
Rake::TestTask.new('bench:core') do |t|
|
|
@@ -34,9 +34,20 @@ Rake::TestTask.new('bench:regression') do |t|
|
|
|
34
34
|
t.pattern = 'test/performance/regression/*_benchmark.rb'
|
|
35
35
|
end
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
desc 'Run competitive benchmarks (Money gem)'
|
|
38
|
+
task 'bench:competitive' do
|
|
39
|
+
sh 'bundle exec ruby -Ilib -Itest -e "Dir[File.join(__dir__, \"test/performance/competitive/money/**/*_benchmark.rb\")].each { |f| require f }"'
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
desc 'Run competitive benchmarks (Shopify Money)'
|
|
43
|
+
task 'bench:competitive:shopify' do
|
|
44
|
+
sh 'BUNDLE_WITHOUT=money_bench bundle exec ruby -Ilib -Itest -e "Dir[File.join(__dir__, \"test/performance/competitive/shopify/**/*_benchmark.rb\")].each { |f| require f }"'
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
desc 'Run all competitive benchmarks (both Money and Shopify)'
|
|
48
|
+
task 'bench:competitive:all' do
|
|
49
|
+
sh 'bundle exec ruby -Ilib -Itest -e "Dir[File.join(__dir__, \"test/performance/competitive/money/**/*_benchmark.rb\")].each { |f| require f }"'
|
|
50
|
+
sh 'BUNDLE_WITHOUT=money_bench bundle exec ruby -Ilib -Itest -e "Dir[File.join(__dir__, \"test/performance/competitive/shopify/**/*_benchmark.rb\")].each { |f| require f }"'
|
|
40
51
|
end
|
|
41
52
|
|
|
42
53
|
desc 'Run core benchmarks and update the baseline'
|
|
@@ -4,17 +4,17 @@
|
|
|
4
4
|
module Mint
|
|
5
5
|
refine Numeric do
|
|
6
6
|
# @return [Money] self interpreted as BRL
|
|
7
|
-
def reais = Mint.
|
|
7
|
+
def reais = Mint::Money.from(self, 'BRL')
|
|
8
8
|
|
|
9
9
|
# @return [Money] self interpreted as USD
|
|
10
|
-
def dollars = Mint.
|
|
10
|
+
def dollars = Mint::Money.from(self, 'USD')
|
|
11
11
|
|
|
12
12
|
# @return [Money] self interpreted as EUR
|
|
13
|
-
def euros = Mint.
|
|
13
|
+
def euros = Mint::Money.from(self, 'EUR')
|
|
14
14
|
|
|
15
15
|
# @param currency [String, Symbol, Currency] target currency
|
|
16
16
|
# @return [Money] self interpreted as the given currency
|
|
17
|
-
def to_money(currency) = Mint.
|
|
17
|
+
def to_money(currency) = Mint::Money.from(self, currency)
|
|
18
18
|
|
|
19
19
|
alias_method :dollar, :dollars
|
|
20
20
|
alias_method :euro, :euros
|
data/lib/minting/version.rb
CHANGED