Skip to content

Commit 6bfa30f

Browse files
committed
Remove extra cents
1 parent 4a2bc2c commit 6bfa30f

File tree

3 files changed

+3
-29
lines changed

3 files changed

+3
-29
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## Unreleased
44

55
## 2.0.0
6+
- **Breaking change**: Remove deprecated `Monetize.extract_cents`.
67
- **Breaking change**: Update Money gem dependency to ~> 7.0. See the [Money 7.0 upgrading guide](https://github.com/RubyMoney/money/blob/main/UPGRADING-7.0.md)
78
- **Breaking change**: Drop support for Ruby < 3.1
89
- Fix parsing multiple delimeters in the amount, after BigDecimal updates

lib/monetize.rb

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ class << self
2121
attr_accessor :enforce_currency_delimiters
2222

2323

24-
# Where this set to true, the behavior for parsing thousands separators is changed to
25-
# expect that eg. €10.000 is EUR 10 000 and not EUR 10.000 - it's incredibly rare when parsing
24+
# Where this set to true, the behavior for parsing thousands separators is changed to
25+
# expect that eg. €10.000 is EUR 10 000 and not EUR 10.000 - it's incredibly rare when parsing
2626
# human text that we're dealing with fractions of cents.
2727
attr_accessor :expect_whole_subunits
2828

@@ -70,12 +70,5 @@ def from_numeric(value, currency = Money.default_currency)
7070
fail ArgumentError, "'value' should be a type of Numeric" unless value.is_a?(Numeric)
7171
Money.from_amount(value, currency)
7272
end
73-
74-
def extract_cents(input, currency = Money.default_currency)
75-
warn '[DEPRECATION] Monetize.extract_cents is deprecated. Use Monetize.parse().cents'
76-
77-
money = parse(input, currency)
78-
money.cents if money
79-
end
8073
end
8174
end

spec/monetize_spec.rb

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -605,26 +605,6 @@
605605
end
606606
end
607607

608-
describe '.extract_cents' do
609-
it 'is deprecated' do
610-
allow(Monetize).to receive(:warn)
611-
612-
Monetize.extract_cents('100')
613-
614-
expect(Monetize)
615-
.to have_received(:warn)
616-
.with('[DEPRECATION] Monetize.extract_cents is deprecated. Use Monetize.parse().cents')
617-
end
618-
619-
it 'extracts cents from a given string' do
620-
expect(Monetize.extract_cents('10.99')).to eq(1099)
621-
end
622-
623-
it "correctly treats pipe marks '|' in input (regression test)" do
624-
expect(Monetize.extract_cents('100|0')).to eq Monetize.extract_cents('100!0')
625-
end
626-
end
627-
628608
context 'given the same inputs to .parse and .from_*' do
629609
it 'gives the same results' do
630610
expect(4.635.to_money).to eq '4.635'.to_money

0 commit comments

Comments
 (0)