shopify-money 3.1.0 → 3.1.2

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: 020a26aff536b7d54d8c1b06b3018b52eda8c4085e87817f9a40f5245ed59d74
4
- data.tar.gz: efe3d99e59baeda27fef40583b2e13fdcfb7608771aee5091a6a1663977fe1f9
3
+ metadata.gz: 03fea29a7733cd7ac14493fff381a197b42a16de9369c8a15b0bba9905f7a8a0
4
+ data.tar.gz: '025213910adf2f5090dfb7afaa85f715f05515094e15f14c25b5805eaef569eb'
5
5
  SHA512:
6
- metadata.gz: 356eba9a2f547cc8c65f8f9fc0c5464fecc23670fa4bfdb6ed4ae39bd5080e89ec4be947f4ce6a04da51676e89bfbfdf4adefe590566b97993025b496274e145
7
- data.tar.gz: d9cea15b3214c263d8318c13355c9c08fc6d38d86bb265a7f2d68cd91ee29284c41814882230f6e87891cba00e6e7e486a9505ef1373af878363689c9048963b
6
+ metadata.gz: dad64b959edcde085fc92904dd442babdc33122c7b2c30b91e204e597fd38e547ccf62c3e6881d78d1a2b2005581d27dcad1177b1d64ae066d2bfbafabe89cb5
7
+ data.tar.gz: 2047c647afe7e4a9b373997184bde9c1a84e47e410571531266fc60075a99da1a65ec4de685c6e79fd852e7de61af427a40440e317ad8a13014a8cc4ccd4f372
@@ -9,7 +9,7 @@ jobs:
9
9
 
10
10
  strategy:
11
11
  matrix:
12
- ruby: ['3.1', '3.2', '3.3']
12
+ ruby: ['3.1', '3.2', '3.3', '3.4']
13
13
 
14
14
  name: Ruby ${{ matrix.ruby }}
15
15
  steps:
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 3.3.5
1
+ 3.4.2
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- shopify-money (3.1.0)
4
+ shopify-money (3.1.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -295,4 +295,4 @@ DEPENDENCIES
295
295
  sqlite3
296
296
 
297
297
  BUNDLED WITH
298
- 2.5.3
298
+ 2.6.7
data/lib/money/config.rb CHANGED
@@ -16,6 +16,10 @@ class Money
16
16
  @legacy_json_format = true
17
17
  end
18
18
 
19
+ def experimental_crypto_currencies!
20
+ @experimental_crypto_currencies = true
21
+ end
22
+
19
23
  def initialize
20
24
  @default_currency = nil
21
25
  @legacy_json_format = false
data/lib/money/helpers.rb CHANGED
@@ -12,6 +12,7 @@ class Money
12
12
  STRIPE_SUBUNIT_OVERRIDE = {
13
13
  'ISK' => 100,
14
14
  'UGX' => 100,
15
+ 'USDC' => 1_000_000,
15
16
  }.freeze
16
17
 
17
18
  def value_to_decimal(num)
data/lib/money/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Money
4
- VERSION = "3.1.0"
4
+ VERSION = "3.1.2"
5
5
  end
data/spec/config_spec.rb CHANGED
@@ -72,7 +72,25 @@ RSpec.describe "Money::Config" do
72
72
  it 'can be set to true' do
73
73
  config = Money::Config.new
74
74
  config.experimental_crypto_currencies = true
75
+ expect(config.experimental_crypto_currencies).to be(true)
76
+ end
77
+
78
+ it 'can be set to true using the bang method' do
79
+ config = Money::Config.new
80
+ config.experimental_crypto_currencies!
75
81
  expect(config.experimental_crypto_currencies).to eq(true)
76
82
  end
77
83
  end
84
+
85
+ describe 'legacy_json_format' do
86
+ it 'defaults to false' do
87
+ expect(Money::Config.new.legacy_json_format).to eq(false)
88
+ end
89
+
90
+ it 'can be set to true using the bang method' do
91
+ config = Money::Config.new
92
+ config.legacy_json_format!
93
+ expect(config.legacy_json_format).to eq(true)
94
+ end
95
+ end
78
96
  end
data/spec/money_spec.rb CHANGED
@@ -457,6 +457,12 @@ RSpec.describe "Money" do
457
457
  expect(Money.from_subunits(100, 'UGX', format: :stripe)).to eq(Money.new(1, 'UGX'))
458
458
  end
459
459
 
460
+ it 'overrides the subunit_to_unit amount for USDC' do
461
+ configure(experimental_crypto_currencies: true) do
462
+ expect(Money.from_subunits(500000, "USDC", format: :stripe)).to eq(Money.new(0.50, 'USDC'))
463
+ end
464
+ end
465
+
460
466
  it 'fallbacks to the default subunit_to_unit amount if no override is specified' do
461
467
  expect(Money.from_subunits(100, 'USD', format: :stripe)).to eq(Money.new(1, 'USD'))
462
468
  end
data/spec/spec_helper.rb CHANGED
@@ -81,7 +81,7 @@ def configure(default_currency: nil, legacy_json_format: nil, legacy_deprecation
81
81
  config.legacy_json_format! if legacy_json_format
82
82
  config.legacy_deprecations! if legacy_deprecations
83
83
  config.legacy_default_currency! if legacy_default_currency
84
- config.experimental_crypto_currencies = experimental_crypto_currencies unless experimental_crypto_currencies.nil?
84
+ config.experimental_crypto_currencies! if experimental_crypto_currencies
85
85
  end
86
86
  yield
87
87
  ensure
@@ -48,6 +48,12 @@ RSpec.describe "Money::Splitter" do
48
48
  expect(moneys[2].value).to eq(33)
49
49
  end
50
50
 
51
+ specify "#spit results behaves like an array" do
52
+ moneys = Money.new(100, 'JPY').split(3)
53
+ expect(moneys.size).to eq(3)
54
+ expect(moneys[3]).to eq(nil)
55
+ end
56
+
51
57
  specify "#split return respond to #first" do
52
58
  expect(Money.new(100).split(3).first).to eq(Money.new(33.34))
53
59
  expect(Money.new(100).split(3).first(2)).to eq([Money.new(33.34), Money.new(33.33)])
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shopify-money
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.0
4
+ version: 3.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shopify Inc