monetize 1.4.0 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7f96f9f99c2fc04ab625a2977f370eff77d33696
4
- data.tar.gz: 75817ce67a91ae35019f6ef3a3b290b937b64749
3
+ metadata.gz: f097cc5d74682b06292fd1f13a33f02b2f7559f0
4
+ data.tar.gz: fad265ffdc0fa112f1116ea78974b20c865719bf
5
5
  SHA512:
6
- metadata.gz: 657c4f4be74370f9a8b2b1f4fcb91e60a013e9d2e01f39f95258a48c47710c5418767770af32ca61c19d52b0a94ccaa875fd3a4b7d8f21023ff7f4b036700c90
7
- data.tar.gz: 4cb6265937f209b0797cc4c0d2e78b4fa27a9f27f9f045cfac8d00812dcb2ccb86072672897b7fb36f7337dab52cbb62c3e58739b9cdcdc9ec32b73393bedd9a
6
+ metadata.gz: 7a7bee5359f9c717b01434c2e95f7bb8a58116fd629971e04c44453a96d26e2a7a7bc1d7088873eba4628769ad2d79476bdf669199d02f19de6e51d7a211e456
7
+ data.tar.gz: c831f37f346f27ad1d44e6757c7afbc2ab845380c5fa5ca9874029f9a507f208d7401c32d5de9113a8667832035fd14fdd6c6294cb5185ac4713a2c79128e5ec
@@ -1,8 +1,12 @@
1
+ sudo: false
1
2
  language: ruby
2
3
  rvm:
3
4
  - 1.9.3
4
5
  - 2.0.0
5
- - 2.1.2
6
+ - 2.1.9
7
+ - 2.2.5
8
+ - 2.3.1
9
+ - jruby-9.0.5.0
6
10
  script: bundle exec rspec spec
7
11
  notifications:
8
12
  recipients:
@@ -1,5 +1,29 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.5.0
4
+ - Add extra currencies:
5
+ - Azerbaijani manat
6
+ - Chinese yuan
7
+ - Czech koruna
8
+ - Hungarian forint
9
+ - Indinan rupee
10
+ - Russian ruble
11
+ - Turkish Lira
12
+ - Ukrainian Hryvnia
13
+ - Swiss Frank
14
+ - Polish Zloty
15
+ - Kazakhstani Tenge
16
+ - Parsing a Money object returns it unchanged
17
+ - Fix issue with loosing precision on BigDecimal input
18
+ - Add Swedish krona
19
+ - Exclud ambiguous kr symbol from parsing
20
+ - Fix JPY parsing
21
+ - Sublcass all errors to Monetize::Error
22
+ - Fix ruby 1.9.3 compatibility
23
+ - Suppress errors when using parse. Use `parse!` instead
24
+ - Strip currency symbol prefix when parsing input
25
+
26
+
3
27
  ## 1.4.0
4
28
  - Required Forwardable on Collection to resolve NameError [\#44](https://github.com/RubyMoney/monetize/issues/44)
5
29
  - Add capability to parse currency amounts given with suffixes (K, M, B, and T)
@@ -19,3 +43,5 @@
19
43
  - Reformat code to adapt to Rubocop guidelines
20
44
  - Add config setting to always enforce currency delimiters
21
45
  - Add rake console task
46
+ - Fix issue where parsing a Money object resulted in a Money object with its currency set to `Money.default_currency`,
47
+ rather than the currency that it was sent in as.
data/Gemfile CHANGED
@@ -2,4 +2,13 @@ source 'https://rubygems.org'
2
2
 
3
3
  gem 'coveralls', require: false
4
4
 
5
+ # JSON gem no longer supports ruby < 2.0.0
6
+ if defined?(JRUBY_VERSION)
7
+ gem 'json'
8
+ elsif RUBY_VERSION =~ /^1/
9
+ gem 'json', '~> 1.8.3'
10
+ gem 'tins', '~> 1.6.0'
11
+ gem 'term-ansicolor', '~> 1.3.0'
12
+ end
13
+
5
14
  gemspec
data/README.md CHANGED
@@ -1,11 +1,11 @@
1
1
  # Monetize
2
2
 
3
- [![Gem Version](https://badge.fury.io/rb/monetize.png)](http://badge.fury.io/rb/monetize)
4
- [![Build Status](https://travis-ci.org/RubyMoney/monetize.png?branch=master)](https://travis-ci.org/RubyMoney/monetize)
5
- [![Code Climate](https://codeclimate.com/github/RubyMoney/monetize.png)](https://codeclimate.com/github/RubyMoney/monetize)
6
- [![Coverage Status](https://coveralls.io/repos/RubyMoney/monetize/badge.png)](https://coveralls.io/r/RubyMoney/monetize)
7
- [![Dependency Status](https://gemnasium.com/RubyMoney/monetize.png)](https://gemnasium.com/RubyMoney/monetize)
8
- [![License](http://img.shields.io/license/MIT.png?color=green)](http://opensource.org/licenses/MIT)
3
+ [![Gem Version](https://badge.fury.io/rb/monetize.svg)](http://badge.fury.io/rb/monetize)
4
+ [![Build Status](https://travis-ci.org/RubyMoney/monetize.svg?branch=master)](https://travis-ci.org/RubyMoney/monetize)
5
+ [![Code Climate](https://codeclimate.com/github/RubyMoney/monetize.svg)](https://codeclimate.com/github/RubyMoney/monetize)
6
+ [![Coverage Status](https://coveralls.io/repos/RubyMoney/monetize/badge.svg)](https://coveralls.io/r/RubyMoney/monetize)
7
+ [![Dependency Status](https://gemnasium.com/RubyMoney/monetize.svg)](https://gemnasium.com/RubyMoney/monetize)
8
+ [![License](https://img.shields.io/badge/license-MIT-green.svg)](http://opensource.org/licenses/MIT)
9
9
 
10
10
  A library for converting various objects into `Money` objects.
11
11
 
@@ -33,6 +33,16 @@ Monetize.parse("GBP 100") == Money.new(100_00, "GBP")
33
33
  "100".to_money == Money.new(100_00, "USD")
34
34
  ```
35
35
 
36
+ `parse` will return `nil` if it is unable to parse the input. Use `parse!` instead if you want a `Monetize::Error` (or one of the subclasses) to be raised instead:
37
+
38
+ ```ruby
39
+ >> Monetize.parse('OMG 100')
40
+ => nil
41
+
42
+ >> Monetize.parse!('OMG 100')
43
+ Monetize::ParseError: Unknown currency 'omg'
44
+ ```
45
+
36
46
  Optionally, enable the ability to assume the currency from a passed symbol. Otherwise, currency symbols will be ignored, and USD used as the default currency:
37
47
 
38
48
  ```ruby
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'money'
4
4
  require 'monetize/core_extensions'
5
+ require 'monetize/errors'
5
6
  require 'monetize/version'
6
7
  require 'collection'
7
8
 
@@ -14,7 +15,18 @@ module Monetize
14
15
  'R$' => 'BRL',
15
16
  'R' => 'ZAR',
16
17
  '¥' => 'JPY',
17
- 'C$' => 'CAD'
18
+ 'C$' => 'CAD',
19
+ '₼' => 'AZN',
20
+ '元' => 'CNY',
21
+ 'Kč' => 'CZK',
22
+ 'Ft' => 'HUF',
23
+ '₹' => 'INR',
24
+ '₽' => 'RUB',
25
+ '₺' => 'TRY',
26
+ '₴' => 'UAH',
27
+ 'Fr' => 'CHF',
28
+ 'zł' => 'PLN',
29
+ '₸' => 'KZT',
18
30
  }
19
31
 
20
32
  MULTIPLIER_SUFFIXES = {
@@ -40,6 +52,15 @@ module Monetize
40
52
  end
41
53
 
42
54
  def self.parse(input, currency = Money.default_currency, options = {})
55
+ parse! input, currency, options
56
+ rescue Error
57
+ nil
58
+ end
59
+
60
+ def self.parse!(input, currency = Money.default_currency, options = {})
61
+ return input if input.is_a?(Money)
62
+ return from_numeric(input, currency) if input.is_a?(Numeric)
63
+
43
64
  input = input.to_s.strip
44
65
 
45
66
  computed_currency = if options.fetch(:assume_from_symbol) { assume_from_symbol }
@@ -53,6 +74,8 @@ module Monetize
53
74
 
54
75
  fractional = extract_cents(input, currency)
55
76
  Money.new(fractional, currency)
77
+ rescue Money::Currency::UnknownCurrency => e
78
+ fail ParseError, e.message
56
79
  end
57
80
 
58
81
  def self.parse_collection(input, currency = Money.default_currency, options = {})
@@ -97,7 +120,7 @@ module Monetize
97
120
  def self.extract_cents(input, currency = Money.default_currency)
98
121
  multiplier_exp, input = extract_multiplier(input)
99
122
 
100
- num = input.gsub(/[^\d.,'-]/, '')
123
+ num = input.gsub(/(?:^#{currency.symbol}|[^\d.,'-]+)/, '')
101
124
 
102
125
  negative, num = extract_sign(num)
103
126
 
@@ -105,9 +128,9 @@ module Monetize
105
128
 
106
129
  major, minor = extract_major_minor(num, currency)
107
130
 
108
- cents = major.to_i * currency.subunit_to_unit
131
+ major, minor = apply_multiplier(multiplier_exp, major.to_i, minor)
109
132
 
110
- cents, minor = apply_multiplier(multiplier_exp, cents, minor)
133
+ cents = major.to_i * currency.subunit_to_unit
111
134
 
112
135
  cents += set_minor_precision(minor, currency)
113
136
 
@@ -116,13 +139,13 @@ module Monetize
116
139
 
117
140
  private
118
141
 
119
- def self.apply_multiplier(multiplier_exp, cents, minor)
120
- cents *= (10**multiplier_exp)
142
+ def self.apply_multiplier(multiplier_exp, major, minor)
143
+ major *= 10**multiplier_exp
121
144
  minor = minor.to_s + ('0' * multiplier_exp)
122
- shift = minor[0...multiplier_exp].to_i * 100
123
- cents += shift
145
+ shift = minor[0...multiplier_exp].to_i
146
+ major += shift
124
147
  minor = (minor[multiplier_exp..-1] || '')
125
- [cents, minor]
148
+ [major, minor]
126
149
  end
127
150
 
128
151
  def self.apply_sign(negative, cents)
@@ -154,7 +177,7 @@ module Monetize
154
177
  when 1
155
178
  extract_major_minor_with_single_delimiter(num, currency, used_delimiters.first)
156
179
  else
157
- fail ArgumentError, 'Invalid currency amount'
180
+ fail ParseError, 'Invalid amount'
158
181
  end
159
182
  end
160
183
 
@@ -195,7 +218,7 @@ module Monetize
195
218
 
196
219
  def self.extract_sign(input)
197
220
  result = (input =~ /^-+(.*)$/ or input =~ /^(.*)-+$/) ? [true, $1] : [false, input]
198
- fail ArgumentError, 'Invalid currency amount (hyphen)' if result[1].include?('-')
221
+ fail ParseError, 'Invalid amount (hyphen)' if result[1].include?('-')
199
222
  result
200
223
  end
201
224
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  class String
4
4
  def to_money(currency = nil)
5
- Monetize.parse(self, currency)
5
+ Monetize.parse!(self, currency)
6
6
  end
7
7
 
8
8
  def to_currency
@@ -0,0 +1,6 @@
1
+ module Monetize
2
+ class Error < StandardError; end
3
+
4
+ class ParseError < Error; end
5
+ class ArgumentError < Error; end
6
+ end
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module Monetize
4
- VERSION = '1.4.0'
4
+ VERSION = '1.5.0'
5
5
  end
@@ -23,5 +23,5 @@ Gem::Specification.new do |spec|
23
23
 
24
24
  spec.add_development_dependency 'bundler', '~> 1.3'
25
25
  spec.add_development_dependency 'rake'
26
- spec.add_development_dependency 'rspec', '~> 3.0.0.beta1'
26
+ spec.add_development_dependency 'rspec', '~> 3.0'
27
27
  end
@@ -56,76 +56,69 @@ describe Monetize do
56
56
  Monetize.assume_from_symbol = false
57
57
  end
58
58
 
59
- it 'parses formatted inputs with Euros passed as a symbol' do
60
- expect(Monetize.parse('€5.95')).to eq Money.new(595, 'EUR')
61
- end
62
-
63
- it 'parses formatted inputs with Euros passed as a symbol with surrounding space' do
64
- expect(Monetize.parse(' €5.95 ')).to eq Money.new(595, 'EUR')
65
- end
66
-
67
- it 'parses formatted inputs with British Pounds Sterling passed as a symbol' do
68
- expect(Monetize.parse('£9.99')).to eq Money.new(999, 'GBP')
69
- end
70
-
71
- it 'parses formatted inputs with British Pounds Sterling passed as a lira sign symbol' do
72
- expect(Monetize.parse('₤9.99')).to eq Money.new(999, 'GBP')
73
- end
74
-
75
- it 'parses formatted inputs with South African Rand passed as a symbol' do
76
- expect(Monetize.parse('R9.99')).to eq Money.new(999, 'ZAR')
77
- end
78
-
79
- it 'parses formatted inputs with Brazilian real passed as a symbol' do
80
- expect(Monetize.parse('R$R9.99')).to eq Money.new(999, 'BRL')
81
- end
82
-
83
- it 'parses formatted inputs with Japanese Yen passed as a symbol' do
84
- expect(Monetize.parse('¥999')).to eq Money.new(999, 'JPY')
85
- end
86
-
87
- it 'parses formatted inputs with Canadian Dollar passed as a symbol' do
88
- expect(Monetize.parse('C$9.99')).to eq Money.new(999, 'CAD')
59
+ Monetize::CURRENCY_SYMBOLS.each_pair do |symbol, iso_code|
60
+ context iso_code do
61
+ let(:currency) { Money::Currency.find(iso_code) }
62
+ let(:amount) { 5_95 }
63
+ let(:amount_in_units) { amount.to_f / currency.subunit_to_unit }
64
+
65
+ it 'ensures correct amount calculations for test' do
66
+ expect(amount_in_units * currency.subunit_to_unit).to eq(amount)
67
+ end
68
+
69
+ it "parses formatted inputs with #{iso_code} passed as a symbol" do
70
+ expect(Monetize.parse("#{symbol}#{amount_in_units}")).to eq Money.new(amount, iso_code)
71
+ end
72
+
73
+ context 'prefix' do
74
+ it 'parses formatted inputs with plus sign and currency as a symbol' do
75
+ expect(Monetize.parse("+#{symbol}#{amount_in_units}")).to eq Money.new(amount, iso_code)
76
+ end
77
+
78
+ it 'parses formatted inputs with minus sign and currency as a symbol' do
79
+ expect(Monetize.parse("-#{symbol}#{amount_in_units}")).to eq Money.new(-amount, iso_code)
80
+ end
81
+ end
82
+
83
+ context 'postfix' do
84
+ it 'parses formatted inputs with currency symbol and postfix minus sign' do
85
+ expect(Monetize.parse("#{symbol}#{amount_in_units}-")).to eq Money.new(-amount, iso_code)
86
+ end
87
+
88
+ it 'parses formatted inputs with currency symbol and postfix plus sign' do
89
+ expect(Monetize.parse("#{symbol}#{amount_in_units}+")).to eq Money.new(amount, iso_code)
90
+ end
91
+ end
92
+
93
+ context 'amount suffixes' do
94
+ it 'parses formatted inputs with amounts given with suffixes' do
95
+ expect(Monetize.parse("#{symbol}1.26K")).to eq Money.new(1_260 * currency.subunit_to_unit, iso_code)
96
+ expect(Monetize.parse("#{symbol}126.36M")).to eq Money.new(126_360_000 * currency.subunit_to_unit, iso_code)
97
+ expect(Monetize.parse("#{symbol}.45B")).to eq Money.new(450_000_000 * currency.subunit_to_unit, iso_code)
98
+ expect(Monetize.parse("-#{symbol}2.45B")).to eq Money.new(-2_450_000_000 * currency.subunit_to_unit, iso_code)
99
+ expect(Monetize.parse("#{symbol}1.65T")).to eq Money.new(1_650_000_000_000 * currency.subunit_to_unit, iso_code)
100
+ end
101
+ end
102
+
103
+ it 'parses formatted inputs with symbol and surrounding spaces' do
104
+ expect(Monetize.parse(" #{symbol}#{amount_in_units} ")).to eq Money.new(amount, iso_code)
105
+ end
106
+
107
+ it 'parses formatted inputs without currency detection when overridden' do
108
+ expect(Monetize.parse("#{symbol}5.95", nil, assume_from_symbol: false)).to eq Money.new(amount, 'USD')
109
+ end
110
+ end
89
111
  end
90
112
 
91
113
  it 'should assume default currency if not a recognised symbol' do
92
114
  expect(Monetize.parse('L9.99')).to eq Money.new(999, 'USD')
93
115
  end
94
116
 
95
- it 'parses formatted inputs without currency detection when overridden' do
96
- expect(Monetize.parse('£9.99', nil, assume_from_symbol: false)).to eq Money.new(999, 'USD')
97
- end
98
-
99
- it 'parses formatted inputs with minus sign and currency symbol' do
100
- expect(Monetize.parse('-€9.99')).to eq Money.new(-999, 'EUR')
101
- expect(Monetize.parse('-£9.99')).to eq Money.new(-999, 'GBP')
102
- expect(Monetize.parse('-R$R9.99')).to eq Money.new(-999, 'BRL')
103
- expect(Monetize.parse('-¥999')).to eq Money.new(-999, 'JPY')
104
- expect(Monetize.parse('-C$9.99')).to eq Money.new(-999, 'CAD')
105
- end
106
-
107
- it 'parses formatted inputs with plus and GBP passed as symbol' do
108
- expect(Monetize.parse('+€9.99')).to eq Money.new(999, 'EUR')
109
- expect(Monetize.parse('+£9.99')).to eq Money.new(999, 'GBP')
110
- expect(Monetize.parse('+R$R9.99')).to eq Money.new(999, 'BRL')
111
- expect(Monetize.parse('+¥999')).to eq Money.new(999, 'JPY')
112
- expect(Monetize.parse('+C$9.99')).to eq Money.new(999, 'CAD')
113
- end
114
-
115
- it 'parses formatted inputs with currency symbol and postfix minus sign' do
116
- expect(Monetize.parse('€9.99-')).to eq Money.new(-999, 'EUR')
117
- end
118
-
119
- it 'parses formatted inputs with currency symbol and postfix plus sign' do
120
- expect(Monetize.parse('€9.99+')).to eq Money.new(999, 'EUR')
121
- end
122
-
123
- it 'parses formatted inputs with amounts given with suffixes' do
124
- expect(Monetize.parse('$1.26K')).to eq Money.new(1_260_00, 'USD')
125
- expect(Monetize.parse('$126.36M')).to eq Money.new(126_360_000_00, 'USD')
126
- expect(Monetize.parse('€.45B')).to eq Money.new(450_000_000_00, 'EUR')
127
- expect(Monetize.parse('-$2.45B')).to eq Money.new(-2_450_000_000_00, 'USD')
128
- expect(Monetize.parse('€1.65T')).to eq Money.new(1_650_000_000_000_00, 'EUR')
117
+ context 'negatives' do
118
+ it 'ignores the ambiguous kr symbol' do
119
+ # Could mean either of DKK, EEK, ISK, NOK, SEK
120
+ expect(Monetize.parse('kr9.99')).to eq Money.new(999, 'USD')
121
+ end
129
122
  end
130
123
  end
131
124
 
@@ -158,6 +151,18 @@ describe Monetize do
158
151
  it 'should opt out by default' do
159
152
  expect(Monetize.assume_from_symbol).to be_falsy
160
153
  end
154
+
155
+ context 'ISO code' do
156
+ it 'parses currency given as ISO code' do
157
+ expect('20.00 USD'.to_money).to eq Money.new(20_00, 'USD')
158
+ expect('20.00 EUR'.to_money).to eq Money.new(20_00, 'EUR')
159
+ expect('20.00 GBP'.to_money).to eq Money.new(20_00, 'GBP')
160
+ end
161
+
162
+ it 'raises an error if currency code is invalid' do
163
+ expect { '20.00 OMG'.to_money }.to raise_error Monetize::ParseError
164
+ end
165
+ end
161
166
  end
162
167
 
163
168
  it 'parses USD-formatted inputs under $10' do
@@ -177,10 +182,16 @@ describe Monetize do
177
182
  expect(Monetize.parse('1,111,234,567.89')).to eq Money.new(1_111_234_567_89, 'USD')
178
183
  end
179
184
 
180
- it 'does not return a price if there is a price range' do
181
- expect { Monetize.parse('$5.95-10.95') }.to raise_error ArgumentError
182
- expect { Monetize.parse('$5.95 - 10.95') }.to raise_error ArgumentError
183
- expect { Monetize.parse('$5.95 - $10.95') }.to raise_error ArgumentError
185
+ it 'parses DKK-formatted inputs' do
186
+ expect(Monetize.parse('kr.123,45', 'DKK')).to eq Money.new(123_45, 'DKK')
187
+ expect(Monetize.parse('kr.123.45', 'DKK')).to eq Money.new(123_45, 'DKK')
188
+ expect(Monetize.parse('kr.45k', 'DKK')).to eq Money.new(45_000_00, 'DKK')
189
+ end
190
+
191
+ it 'returns nil if input is a price range' do
192
+ expect(Monetize.parse('$5.95-10.95')).to be_nil
193
+ expect(Monetize.parse('$5.95 - 10.95')).to be_nil
194
+ expect(Monetize.parse('$5.95 - $10.95')).to be_nil
184
195
  end
185
196
 
186
197
  it 'does not return a price for completely invalid input' do
@@ -197,8 +208,8 @@ describe Monetize do
197
208
  expect(Monetize.parse('$5.95-')).to eq five_ninety_five
198
209
  end
199
210
 
200
- it 'raises ArgumentError when unable to detect polarity' do
201
- expect { Monetize.parse('-$5.95-') }.to raise_error ArgumentError
211
+ it 'returns nil when unable to detect polarity' do
212
+ expect(Monetize.parse('-$5.95-')).to be_nil
202
213
  end
203
214
 
204
215
  it 'parses correctly strings with exactly 3 decimal digits' do
@@ -210,6 +221,32 @@ describe Monetize do
210
221
  Monetize.enforce_currency_delimiters = false
211
222
  end
212
223
 
224
+ context 'Money object attempting to be parsed' do
225
+ let(:money) { Money.new(595, 'GBP') }
226
+
227
+ it 'returns the original Money object' do
228
+ expect(Monetize.parse(money)).to eq money
229
+ expect(Monetize.parse(money).currency).to eq 'GBP'
230
+ expect(Monetize.parse(money).cents).to eq 595
231
+ end
232
+ end
233
+
234
+ context 'parsing an instance of Numeric class' do
235
+ let(:fixnum) { 10 }
236
+ let(:float) { 10.0 }
237
+ let(:big_decimal) { BigDecimal.new('10') }
238
+
239
+ [:fixnum, :float, :big_decimal].each do |type|
240
+ it "returns a new Money object based on the #{type} input" do
241
+ money = Monetize.parse(send(type), 'USD')
242
+
243
+ expect(money).to be_instance_of(Money)
244
+ expect(money.currency).to eq('USD')
245
+ expect(money.cents).to eq(10_00)
246
+ end
247
+ end
248
+ end
249
+
213
250
  context 'custom currencies with 4 decimal places' do
214
251
  before :each do
215
252
  Money::Currency.register(JSON.parse(bar, symbolize_names: true))
@@ -265,6 +302,18 @@ describe Monetize do
265
302
  end
266
303
  end
267
304
 
305
+ describe '.parse!' do
306
+ it 'does not return a price if there is a price range' do
307
+ expect { Monetize.parse!('$5.95-10.95') }.to raise_error Monetize::ParseError
308
+ expect { Monetize.parse!('$5.95 - 10.95') }.to raise_error Monetize::ParseError
309
+ expect { Monetize.parse!('$5.95 - $10.95') }.to raise_error Monetize::ParseError
310
+ end
311
+
312
+ it 'raises ArgumentError when unable to detect polarity' do
313
+ expect { Monetize.parse!('-$5.95-') }.to raise_error Monetize::ParseError
314
+ end
315
+ end
316
+
268
317
  describe '.parse_collection' do
269
318
  it 'parses into a Money::Collection' do
270
319
  expect(Monetize.parse_collection('$7')).to be_a Monetize::Collection
@@ -421,7 +470,7 @@ describe Monetize do
421
470
  end
422
471
 
423
472
  it 'raises ArgumentError with unsupported argument' do
424
- expect { Monetize.from_numeric('100') }.to raise_error(ArgumentError)
473
+ expect { Monetize.from_numeric('100') }.to raise_error(Monetize::ArgumentError)
425
474
  end
426
475
 
427
476
  it 'optimizes workload' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: monetize
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shane Emmons
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-15 00:00:00.000000000 Z
11
+ date: 2016-12-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: money
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 3.0.0.beta1
61
+ version: '3.0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 3.0.0.beta1
68
+ version: '3.0'
69
69
  description: A library for converting various objects into `Money` objects.
70
70
  email:
71
71
  - shane@emmons.io
@@ -91,6 +91,7 @@ files:
91
91
  - lib/monetize/core_extensions/numeric.rb
92
92
  - lib/monetize/core_extensions/string.rb
93
93
  - lib/monetize/core_extensions/symbol.rb
94
+ - lib/monetize/errors.rb
94
95
  - lib/monetize/version.rb
95
96
  - monetize.gemspec
96
97
  - spec/core_extensions_spec.rb
@@ -116,7 +117,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
116
117
  version: '0'
117
118
  requirements: []
118
119
  rubyforge_project:
119
- rubygems_version: 2.4.5.1
120
+ rubygems_version: 2.5.1
120
121
  signing_key:
121
122
  specification_version: 4
122
123
  summary: A library for converting various objects into `Money` objects.
@@ -124,4 +125,3 @@ test_files:
124
125
  - spec/core_extensions_spec.rb
125
126
  - spec/monetize_spec.rb
126
127
  - spec/spec_helper.rb
127
- has_rdoc: