meplato-money 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,11 @@
1
+ # 0.2.1, released 2012-09-14
2
+
3
+ * Allow both string and symbol for `locale` parameter,
4
+ both when formatting and parsing.
5
+ This allows to use `m.format(locale: I18n.locale)`
6
+ in Rails instead of `m.format(locale: I18n.locale.to_s)`.
7
+ Same with `Money.parse("123,56", "EUR", :locale => :de)`.
8
+
1
9
  # 0.2.0, released 2012-08-01
2
10
 
3
11
  * Thread safety (remove autoload and class variables)
@@ -139,11 +139,11 @@ module Money
139
139
  :bank => default_bank,
140
140
  :currency => currency || default_currency
141
141
  }.merge(options)
142
- format = FORMATS[opts[:locale]]
142
+ format = FORMATS[opts[:locale].to_s]
143
143
  # TODO there's a special case e.g. "($12,345,678.90)" that has to be converted to -12345678.90
144
144
  s = value.gsub(/[^0-9\-#{format[:decimal_sep]}]/, '')
145
145
  s.gsub!(format[:decimal_sep], '.')
146
- Money.new(s.to_f, opts[:currency], opts)
146
+ Money.new(s.to_f, opts[:currency].to_s, opts)
147
147
  end
148
148
  end
149
149
  end
@@ -21,7 +21,7 @@ module Money
21
21
 
22
22
  def initialize(money, options = {})
23
23
  @money = money
24
- @locale = options[:locale] || Money.default_locale
24
+ @locale = (options[:locale] || Money.default_locale).to_s
25
25
  @locale.gsub!(/_/, '-')
26
26
  @bank = options[:bank] || Money.default_bank
27
27
  @format = FORMATS[@locale]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: meplato-money
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-02 00:00:00.000000000 Z
12
+ date: 2012-09-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler