bd_money 0.0.11 → 0.0.12

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.11
1
+ 0.0.12
data/bd_money.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{bd_money}
8
- s.version = "0.0.11"
8
+ s.version = "0.0.12"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Adrian Madrid"]
12
- s.date = %q{2012-03-26}
12
+ s.date = %q{2012-04-05}
13
13
  s.description = %q{This library makes it easier to deal with Money values, storing them as BigDecimal to avoid floating-point math errors.}
14
14
  s.email = %q{aemadrid@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -21,7 +21,7 @@ class Money
21
21
  } unless const_defined?(:FORMATS)
22
22
 
23
23
  REMOVE_RE = %r{[$,_ ]} unless const_defined?(:REMOVE_RE)
24
- VALID_RE = %r{^(-)?(\d)+(\.\d{1,30}(e-\d{1,10})?)?$} unless const_defined?(:VALID_RE)
24
+ VALID_RE = %r{^(-)?(\d)+(\.\d*(e-\d{1,10})?)?$} unless const_defined?(:VALID_RE)
25
25
 
26
26
  YAML_TYPE_ROOT = 'npadv.com,2012-03-12' unless const_defined?(:YAML_TYPE_ROOT)
27
27
  YAML_TYPE_NAME = 'money' unless const_defined?(:YAML_TYPE_NAME)
@@ -284,6 +284,14 @@ class Money
284
284
  !!value.to_s.match(VALID_RE)
285
285
  end
286
286
 
287
+ def zero
288
+ new 0
289
+ end
290
+
291
+ def [](value)
292
+ new value
293
+ end
294
+
287
295
  end
288
296
 
289
297
  end
@@ -68,6 +68,18 @@ describe Money do
68
68
  it { Money.valid?('-.01').should_not be_true }
69
69
  it { Money.valid?('1.0e-05').should be_true }
70
70
  it { Money.valid?('-1.0e-05').should be_true }
71
+ it { Money.valid?('610.727274321917808219178082191780821917808219178082191780821917808219178082191765').should be_true }
72
+ end
73
+
74
+ describe "class zero" do
75
+ it { Money.zero.should == Money.new(0) }
76
+ end
77
+
78
+ describe "class []" do
79
+ it { Money[amt].should == Money.new(amt) }
80
+ it { Money[neg_amt].should == Money.new(neg_amt) }
81
+ it { Money[other_amt].should == Money.new(other_amt) }
82
+ it { Money[3.53].should == Money.new(3.53) }
71
83
  end
72
84
 
73
85
  describe "initialize" do
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bd_money
3
3
  version: !ruby/object:Gem::Version
4
- hash: 9
4
+ hash: 7
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 11
10
- version: 0.0.11
9
+ - 12
10
+ version: 0.0.12
11
11
  platform: ruby
12
12
  authors:
13
13
  - Adrian Madrid
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-03-26 00:00:00 -06:00
18
+ date: 2012-04-05 00:00:00 -06:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency