more_money 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,2 @@
1
+ 0.0.7 introduced MoreMoney::Money.curr_symbol
2
+ 0.0.8 fixed the bug that was parsing invalid strings in 0 cents now maps to nil
@@ -19,7 +19,7 @@ class String
19
19
 
20
20
  # Get the cents amount
21
21
  matches = scan(/(\-?\d+(\.(\d+))?)/)
22
- cents = matches[0] ? (matches[0][0].to_f * 100) : 0
22
+ cents = matches[0] ? (matches[0][0].to_f * 100) : nil
23
23
 
24
24
  MoreMoney::Money.new(cents, currency)
25
25
  end
@@ -113,6 +113,12 @@ module MoreMoney
113
113
  raise MoneyInvalidCurrency, "#{currency} is not defined as a currency" unless CURRENCIES.key?(currency)
114
114
  end
115
115
 
116
+ #returns the symbol for the given currency code
117
+ #
118
+ # MoreMoney::Money.curr_symbol('USD')
119
+ #
120
+ # => '$'
121
+ #
116
122
  def self.curr_symbol(currency = Money.default_currency)
117
123
  check_currency(currency)
118
124
  CURRENCIES[currency][:symbol]
@@ -2,7 +2,7 @@ module MoreMoney #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 0
5
- TINY = 7
5
+ TINY = 8
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -85,6 +85,15 @@ class MoreMoneyTest < Test::Unit::TestCase
85
85
  assert_equal 'USD', c.currency
86
86
  end
87
87
 
88
+ def test_nil
89
+ a = ''.to_money
90
+ assert_equal nil, a.cents
91
+ a = '0'.to_money
92
+ assert_equal 0, a.cents
93
+ a = 'a'.to_money
94
+ assert_equal nil, a.cents
95
+ end
96
+
88
97
  def test_symbol
89
98
  assert_equal '$', Money.curr_symbol
90
99
  assert_equal '£', Money.curr_symbol('GBP')
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.1
3
3
  specification_version: 1
4
4
  name: more_money
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.0.7
7
- date: 2007-01-21 00:00:00 +00:00
6
+ version: 0.0.8
7
+ date: 2007-02-05 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