minting 1.6.2 → 1.7.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: 0af1a3786bbef7fd2c9d3614ccd5076e0ad6f77fb35bd0d34e636355bafd4714
4
- data.tar.gz: 520dfe15e4a3ddcd180a898769266d27502af54e3ad70503ed734ad351564639
3
+ metadata.gz: 005a740f595e3f1b579b2108feb4cd742706588a75b1df41179775d311fb002e
4
+ data.tar.gz: b1c2d55e378cca46adde3e6edd7253bb0914707768c19fd00e568288921540ff
5
5
  SHA512:
6
- metadata.gz: bd835b1ff970861a98dff3f056feb8903e2cb5145f0b60e52372d754daa65d60461e5200cc07de954963c0f31d954f8a8f54faf0a4f16746119e1195dc3c206e
7
- data.tar.gz: 5f4e58dea85c7129e00aeef897810053136ba8d30cd49a4f199376b0e4f45885680bf1225b518dd479174e473da6e538efe30831e834e2ce41b3fdaf0a81235c
6
+ metadata.gz: 48f40d6cceeb16d9ffc357297dae0961ba0473f4d9ed1271ac6e144a0a468b42dd8a553b661485317eba56d88665b08b1302c4620af1a58bb6f07ab9aa996da3
7
+ data.tar.gz: bc77e69b3e39d3bde0ebb47e60bb1225d0a9062e2a1f201924c3e32924ad65711c28ef492ac4c5d63b06bb376510d07e7d2d69a3efbc17805e89d703c3c15812
data/README.md CHANGED
@@ -16,6 +16,11 @@ Fast, precise, and developer-friendly money handling for Ruby.
16
16
 
17
17
  **Rails**? Use the [minting-rails](https://github.com/gferraz/minting-rails) companion gem
18
18
 
19
+ ## Resources
20
+
21
+ - [API Documentation](https://www.rubydoc.info/gems/minting/frames)
22
+ - [Git Repository](https://github.com/gferraz/minting)
23
+
19
24
  ## Quick start
20
25
 
21
26
  ```ruby
@@ -185,6 +190,49 @@ Option 3: Install it yourself with:
185
190
  gem install minting
186
191
  ```
187
192
 
193
+ ## Configuration
194
+
195
+ ### Optional top‑level `Money` and `Currency`
196
+
197
+ By default, Minting keeps everything namespaced under `Mint`:
198
+
199
+ ```ruby
200
+ price = Mint::Money.create(10, "USD")
201
+ currency = Mint::Currency.new(code: "USD", symbol: "$", subunit: 2, priority: 0)
202
+ ```
203
+
204
+ To avoid polluting the global namespace (and to coexist nicely with other gems), **Minting dont automatically defines `Money` or `Currency` at the top level automatically**.
205
+
206
+ If you prefer the shorter `Money` / `Currency` constants in your application code, you can opt in explicitly.
207
+
208
+ There are two ways to enable shorter constants:
209
+
210
+ 1. Require dsl in your app
211
+
212
+ ```ruby
213
+ require "minting"
214
+ require "minting/dsl" # opt‑in top‑level Money / Currency
215
+ ```
216
+
217
+ 2. Call a configuration method
218
+
219
+ ```ruby
220
+ Minting.use_top_level_constants!
221
+ ```
222
+
223
+ After this, you can use:
224
+
225
+ ```ruby
226
+ price = Money.create(10, "USD") # equivalent to Mint::Money.create
227
+ tax = Money.money(2.50, "USD") # via Mint.money, still available
228
+ cur = Currency.new(code: "EUR", symbol: "€", subunit: 2, priority: 0)
229
+ ```
230
+
231
+ #### When to use this
232
+
233
+ - **Good fit:** application code, especially in Rails apps, where `Money` reads nicely in models and views.
234
+ - **Not recommended:** reusable gems/libraries. In that case, stick to the namespaced API (`Mint::Money`, `Mint::Currency`) to avoid conflicts with other libraries.
235
+
188
236
  ## Parsing strings
189
237
 
190
238
  ```ruby
@@ -202,9 +250,9 @@ Mint.parse('USD 1,234.56') #=> [USD 1234.56]
202
250
 
203
251
  ## Roadmap
204
252
 
205
- - Improve formatting features
253
+ - Add support to configure thousand and decimal separators in parse (evaluating)
206
254
  - Localization (I18n-aware formatting)
207
- - Basic exchange-rate conversions
255
+ - Basic exchange-rate conversions - infrastructure only, not integrations yet
208
256
 
209
257
  ## Contributing
210
258
 
data/Rakefile CHANGED
@@ -1,6 +1,8 @@
1
+ require 'bundler/audit/task'
1
2
  require 'bundler/gem_tasks'
2
- require 'rubocop/rake_task'
3
3
  require 'rake/testtask'
4
+ require 'rubocop/rake_task'
5
+ require 'rubycritic/rake_task'
4
6
  require 'yard'
5
7
 
6
8
  CLOBBER.include %w[doc/css doc/js doc/Mint doc/*.html tmp .yardoc]
@@ -37,11 +39,19 @@ Rake::TestTask.new('bench:competitive') do |t|
37
39
  t.pattern = 'test/performance/competitive/**/*_benchmark.rb'
38
40
  end
39
41
 
40
- RuboCop::RakeTask.new(:cop)
42
+ Bundler::Audit::Task.new
43
+
44
+ RuboCop::RakeTask.new(:cop) do |task|
45
+ task.patterns = ['lib']
46
+ end
47
+
48
+ RubyCritic::RakeTask.new do |task|
49
+ task.name = 'critic'
50
+ end
41
51
 
42
52
  YARD::Rake::YardocTask.new do |t|
43
53
  t.files = ['lib/**/*.rb']
44
- t.options = ['-o doc/api'] # Place the documentos in doc/api
54
+ #t.options = ['-o doc'] # Place the documentos in doc/api
45
55
  t.stats_options = ['--list-undoc']
46
56
  end
47
57