Skip to content

Commit

Permalink
Merge pull request #64 from mexxxxx/extra-currencies
Browse files Browse the repository at this point in the history
Extra currencies
  • Loading branch information
antstorm committed Jun 12, 2016
2 parents 752f45e + c229c4c commit 08a3296
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 1 deletion.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# Changelog

## 1.5.0
- Added extra currencies:
- Azerbaijani manat
- Chinese yuan
- Czech koruna
- Hungarian forint
- Indinan rupee
- Russian ruble
- Turkish Lira
- Ukrainian Hryvnia
- Swiss Frank
- Polish Zloty
- Kazakhstani Tenge


## 1.4.0
- Required Forwardable on Collection to resolve NameError [\#44](https://github.com/RubyMoney/monetize/issues/44)
- Add capability to parse currency amounts given with suffixes (K, M, B, and T)
Expand Down
13 changes: 12 additions & 1 deletion lib/monetize.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,18 @@ module Monetize
'R$' => 'BRL',
'R' => 'ZAR',
'¥' => 'JPY',
'C$' => 'CAD'
'C$' => 'CAD',
'₼' => 'AZN',
'元' => 'CNY',
'Kč' => 'CZK',
'Ft' => 'HUF',
'₹' => 'INR',
'₽' => 'RUB',
'₺' => 'TRY',
'₴' => 'UAH',
'Fr' => 'CHF',
'zł' => 'PLN',
'₸' => 'KZT'
}

MULTIPLIER_SUFFIXES = {
Expand Down
68 changes: 68 additions & 0 deletions spec/monetize_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,51 @@
expect(Monetize.parse('C$9.99')).to eq Money.new(999, 'CAD')
end

it 'parses formatted inputs with Azerbaijani Manat passed as a symbol' do
expect(Monetize.parse('₼9.99')).to eq Money.new(999, 'AZN')
end

it 'parses formatted inputs with Chinese Yuan passed as a symbol' do
expect(Monetize.parse('元9.99')).to eq Money.new(999, 'CNY')
end

it 'parses formatted inputs with Czech Koruna passed as a symbol' do
expect(Monetize.parse('Kč9.99')).to eq Money.new(999, 'CZK')
end

it 'parses formatted inputs with Hungarian Forint passed as a symbol' do
expect(Monetize.parse('Ft9.99')).to eq Money.new(999, 'HUF')
end

it 'parses formatted inputs with Indinan Rupee passed as a symbol' do
expect(Monetize.parse('₹9.99')).to eq Money.new(999, 'INR')
end

it 'parses formatted inputs with Russian rubl passed as a symbol' do
expect(Monetize.parse('₽9.99')).to eq Money.new(999, 'RUB')
end

it 'parses formatted inputs with Turkish Lira passed as a symbol' do
expect(Monetize.parse('₺9.99')).to eq Money.new(999, 'TRY')
end

it 'parses formatted inputs with Ukrainian Hryvnia passed as a symbol' do
expect(Monetize.parse('₴9.99')).to eq Money.new(999, 'UAH')
end

it 'parses formatted inputs with Swiss Frank passed as a symbol' do
expect(Monetize.parse('Fr9.99')).to eq Money.new(999, 'CHF')
end

it 'parses formatted inputs with Polish Zloty passed as a symbol' do
expect(Monetize.parse('zł9.99')).to eq Money.new(999, 'PLN')
end

it 'parses formatted inputs with Kazakhstani Tenge passed as a symbol' do
expect(Monetize.parse('₸9.99')).to eq Money.new(999, 'KZT')
end


it 'should assume default currency if not a recognised symbol' do
expect(Monetize.parse('L9.99')).to eq Money.new(999, 'USD')
end
Expand All @@ -102,6 +147,18 @@
expect(Monetize.parse('-R$R9.99')).to eq Money.new(-999, 'BRL')
expect(Monetize.parse('-¥999')).to eq Money.new(-999, 'JPY')
expect(Monetize.parse('-C$9.99')).to eq Money.new(-999, 'CAD')
expect(Monetize.parse('-₼9.99')).to eq Money.new(-999, 'AZN')
expect(Monetize.parse('-元9.99')).to eq Money.new(-999, 'CNY')
expect(Monetize.parse('-Kč9.99')).to eq Money.new(-999, 'CZK')
expect(Monetize.parse('-Ft9.99')).to eq Money.new(-999, 'HUF')
expect(Monetize.parse('-₹9.99')).to eq Money.new(-999, 'INR')
expect(Monetize.parse('-₽9.99')).to eq Money.new(-999, 'RUB')
expect(Monetize.parse('-₺9.99')).to eq Money.new(-999, 'TRY')
expect(Monetize.parse('-₴9.99')).to eq Money.new(-999, 'UAH')
expect(Monetize.parse('-Fr9.99')).to eq Money.new(-999, 'CHF')
expect(Monetize.parse('-zł9.99')).to eq Money.new(-999, 'PLN')
expect(Monetize.parse('-₸9.99')).to eq Money.new(-999, 'KZT')

end

it 'parses formatted inputs with plus and GBP passed as symbol' do
Expand All @@ -110,6 +167,17 @@
expect(Monetize.parse('+R$R9.99')).to eq Money.new(999, 'BRL')
expect(Monetize.parse('+¥999')).to eq Money.new(999, 'JPY')
expect(Monetize.parse('+C$9.99')).to eq Money.new(999, 'CAD')
expect(Monetize.parse('+₼9.99')).to eq Money.new(999, 'AZN')
expect(Monetize.parse('+元9.99')).to eq Money.new(999, 'CNY')
expect(Monetize.parse('+Kč9.99')).to eq Money.new(999, 'CZK')
expect(Monetize.parse('+Ft9.99')).to eq Money.new(999, 'HUF')
expect(Monetize.parse('+₹9.99')).to eq Money.new(999, 'INR')
expect(Monetize.parse('+₽9.99')).to eq Money.new(999, 'RUB')
expect(Monetize.parse('+₺9.99')).to eq Money.new(999, 'TRY')
expect(Monetize.parse('+₴9.99')).to eq Money.new(999, 'UAH')
expect(Monetize.parse('+Fr9.99')).to eq Money.new(999, 'CHF')
expect(Monetize.parse('+zł9.99')).to eq Money.new(999, 'PLN')
expect(Monetize.parse('+₸9.99')).to eq Money.new(999, 'KZT')
end

it 'parses formatted inputs with currency symbol and postfix minus sign' do
Expand Down

0 comments on commit 08a3296

Please sign in to comment.