more_money 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,2 +1,3 @@
1
- 0.0.7 introduced MoreMoney::Money.curr_symbol
1
+ 0.0.9 fixed bug in to_s now if cents are nil to_s returns ''
2
2
  0.0.8 fixed the bug that was parsing invalid strings in 0 cents now maps to nil
3
+ 0.0.7 introduced MoreMoney::Money.curr_symbol
@@ -231,6 +231,7 @@ module MoreMoney
231
231
  rules = rules.flatten
232
232
  return CURRENCIES[currency][:format].call(cents, currency, CURRENCIES[currency][:symbol], rules) if CURRENCIES[currency][:format]
233
233
  return DEFAULT_FORMATS[cents] if DEFAULT_FORMATS[cents]
234
+ return '' if cents.nil?
234
235
 
235
236
 
236
237
  if rules.include?(:no_cents)
@@ -265,7 +266,7 @@ module MoreMoney
265
266
 
266
267
  # Money.new(100, 'USD').to_s => "1.00"
267
268
  def to_s
268
- sprintf("%.2f", cents.to_f / 100 )
269
+ cents.nil? ? '' : sprintf("%.2f", cents.to_f / 100 )
269
270
  end
270
271
 
271
272
  # Recieve the amount of this money object in another currency
@@ -2,7 +2,7 @@ module MoreMoney #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 0
5
- TINY = 8
5
+ TINY = 9
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -71,6 +71,8 @@ class MoreMoneyTest < Test::Unit::TestCase
71
71
  def test_nil
72
72
  a = Money.new(nil)
73
73
  assert_equal nil, a.cents
74
+ assert_equal '', a.to_s
75
+ assert_equal '', a.format
74
76
  assert_equal 'USD', a.currency
75
77
  assert_equal nil, (a * 2).cents
76
78
  assert_equal nil, (a / 2).cents
@@ -83,9 +85,6 @@ class MoreMoneyTest < Test::Unit::TestCase
83
85
  c = nil.to_money
84
86
  assert_equal nil, c.cents
85
87
  assert_equal 'USD', c.currency
86
- end
87
-
88
- def test_nil
89
88
  a = ''.to_money
90
89
  assert_equal nil, a.cents
91
90
  a = '0'.to_money
metadata CHANGED
@@ -1,10 +1,10 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.9.1
2
+ rubygems_version: 0.9.2
3
3
  specification_version: 1
4
4
  name: more_money
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.0.8
7
- date: 2007-02-05 00:00:00 +00:00
6
+ version: 0.0.9
7
+ date: 2007-02-13 00:00:00 +00:00
8
8
  summary: handles money objects in any currency using just integer as backend
9
9
  require_paths:
10
10
  - lib