Closed goalaleo closed 1 year ago
@antstorm I feel this is a regression and we should accept a PR, agree?
As for your side note. We do not have an officially supported way of adding symbols. I would suggest monkey patching the constant as you have done, knowing you will need to ensure it still works after each release. An alternative would be to submit a patch that adds it as an official feature.
Malaysian ringgit, ISO code: MYR, symbol: RM. The commit that broke our code is this one which prioritises ISO code over a symbol. It makes the incorrect assumption that the first line only matches ISO codes: https://github.com/RubyMoney/monetize/blob/a0680812444181cb8eb6b1d3a288b9dbe8934d24/lib/monetize/parser.rb#L72-L73
While it's true that the regexp doesn't match any symbols in
CURRENCY_SYMBOLS
, there are a few currencies where the symbol is 2-3 capital lettersUsing version 1.9.4
In version 1.11.0, expected same result, got
I propose that if
returns a match, the code will check if
CURRENCY_SYMBOLS
contains it as a key before assuming that it's an ISO code.As a side note: what is the recommended way of "registering" symbols that are not included in the gem? In our app we've added them to the
Monetize::Parser::CURRENCY_SYMBOLS
hash, but maybe this is not recommended?