minting-rails 0.3.0 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 28adcfea7e870cae7556ea935d7365e0857c3913396128ecfbc8f96087094e84
4
- data.tar.gz: f7302a98df24aa948da5e4d8043948346068717438fa5ce40f58745ce4d45897
3
+ metadata.gz: a5cbd850d0e142b296ffe9b02554317c3b240a2decea3ecd35177b83fcaab225
4
+ data.tar.gz: e1f2a8b0fc4e9d573f00e8b230773bf7e883c75ecbe134c8c611c460f3203316
5
5
  SHA512:
6
- metadata.gz: 57c6b59ebc5b927fef253e10b7755bc0e8167ce4cf7280fee6157b9df51b25b20e96149f1709a99b76cd3abba3afdb5447a3f47a739450360416caa59412139e
7
- data.tar.gz: 2a33a5dde47d0667680754b5aa4d01f51d01030ea29111408094566e72d1404234bdbb64de42e6fa58e99eee531f32c44147fadfa40ff37d08f51e576503e0b0
6
+ metadata.gz: 88b6292f0807bb62a93d04a3dc7dbd5ef6139ae215f9659c66a67428f4248d9c32a73762b8837ee69bacc3959b0922393e6d3b4c0c7b7bd13526e0d466ade436
7
+ data.tar.gz: dd0a1fcf55760156015e54a1fe86962af9271f1cb0ff9c8c134a15178e1cacef4fa5ebbd6c3d378f2dce1bdb9d650bc77fc3bffb5f4f2e81ec681f8e447c6149
@@ -1,33 +1,35 @@
1
1
  # encoding : utf-8
2
2
  # frozen_string_literal: true
3
-
4
3
  Mint.configure do |config|
5
- # Register additional currencies
4
+
5
+ # Register a custom currency
6
6
  #
7
7
  # Example:
8
8
  # config.added_currencies = [
9
- # Mint.register_currency 'CRC', subunit: 2, symbol: '₡'
10
- # Mint.register_currency 'NGN', subunit: 3, synbol: '₦'
11
- # ]
9
+ # {currency: 'CRC', subunit: 2, symbol: '₡'},
10
+ # {currency: 'NGN', subunit: 3, symbol: '₦'}
11
+ # ]
12
12
  config.added_currencies = [
13
- Mint.register_currency('CRC', subunit: 2, symbol: '₡'),
14
- Mint.register_currency('NGN', subunit: 3, symbol: '₦')
13
+ {currency: 'CRC', subunit: 2, symbol: '₡'},
14
+ {currency: 'NGN', subunit: 3, symbol: '₦'}
15
15
  ]
16
16
 
17
17
  # Enable currencies
18
18
  # Only these currencies amounts can be created
19
- # Examples:
20
- # 1. All registered currencies are enabled (default)
21
- # config.enabled_currencies = :all
22
- # 2. Some registered currencies are enabled
23
- # config.enabled_currencies = %w[BRL CRC NGN USD]
19
+ # Example:
20
+ # config.enabled_currencies = :all
21
+
22
+ config.enabled_currencies = :all
23
+
24
24
 
25
25
  # To set the default currency
26
26
  #
27
27
  # It must be a registered currency
28
- # config.default_currency = 'USD'
28
+ #
29
+ config.default_currency = 'BRL'
30
+
29
31
 
30
- # Specify a rounding mode
32
+ # Specify a rounding mode (not yet implemented)
31
33
  # Any one of:
32
34
  #
33
35
  # BigDecimal::ROUND_UP,
@@ -38,7 +40,17 @@ Mint.configure do |config|
38
40
  # BigDecimal::ROUND_CEILING,
39
41
  # BigDecimal::ROUND_FLOOR
40
42
  #
41
- # BigDecimal::ROUND_HALF_EVEN is default
43
+ # set to BigDecimal::ROUND_HALF_EVEN by default
42
44
  #
43
45
  # config.rounding_mode = BigDecimal::ROUND_HALF_UP
44
- end
46
+
47
+ # Set default money format globally.
48
+ # Default value is nil meaning "ignore this option".
49
+ # Example:
50
+ #
51
+ # config.default_format = {
52
+ # no_cents_if_whole: nil,
53
+ # symbol: nil,
54
+ # sign_before_symbol: nil
55
+ # }
56
+ end
@@ -39,7 +39,7 @@ module Mint
39
39
  end
40
40
 
41
41
  def self.parse(amount, currency)
42
- case amount
42
+ money = case amount
43
43
  when NilClass
44
44
  nil
45
45
  when Mint::Money
@@ -54,6 +54,8 @@ module Mint
54
54
  end
55
55
  end
56
56
  # puts "parse(#{amount}, #{currency.inspect}) => #{money.inspect}"
57
+ Mint.assert_valid_currency!(currency)
58
+ money
57
59
  end
58
60
  end
59
61
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Mint
4
4
  module MoneyAttribute
5
- VERSION = '0.3.0'
5
+ VERSION = '0.3.2'
6
6
  end
7
7
  end
data/lib/minting/rails.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'minting'
3
4
  require 'minting/money_attribute/core_ext'
4
5
  require 'minting/money_attribute/configuration'
5
6
  require 'minting/money_attribute/money_attribute'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minting-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gilson Ferraz