Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## Current
- Fix parsing multiple delimeters in the amount, after BigDecimal updates

## 1.13.0
- **Breaking change**: check ISO currency code validity when parsing strings with `to_money`
- Adds `expect_whole_subunits` option when fractional subunits are expected
Expand Down
4 changes: 4 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,8 @@ elsif RUBY_VERSION =~ /^1/
gem 'i18n', '~> 0.9'
end

if RUBY_VERSION >= '3.4.0'
gem 'bigdecimal'
end

gemspec
6 changes: 4 additions & 2 deletions lib/monetize/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,10 @@ def regex_safe_symbols
end

def split_major_minor(num, delimiter)
major, minor = num.split(delimiter)
[major, minor || '00']
splits = num.split(delimiter)
fail ParseError, 'Invalid amount (multiple delimiters)' if splits.length > 2

[splits[0], splits[1] || '00']
end

def currency_symbol_regex
Expand Down