has_money 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +3 -0
- data/VERSION +1 -1
- data/has_money.gemspec +3 -2
- data/lib/has_money.rb +1 -1
- data/spec/has_money_spec.rb +5 -0
- metadata +5 -4
data/CHANGELOG.md
ADDED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.1
|
data/has_money.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{has_money}
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = [%q{Greg Bell}, %q{Sam Vincent}, %q{Philippe Creux}]
|
12
|
-
s.date = %q{2011-
|
12
|
+
s.date = %q{2011-10-11}
|
13
13
|
s.description = %q{Parsing the various ways people enter dollar amounts so you don't have to. Store values in cents as integer.}
|
14
14
|
s.email = %q{sam.vincent@mac.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -18,6 +18,7 @@ Gem::Specification.new do |s|
|
|
18
18
|
]
|
19
19
|
s.files = [
|
20
20
|
".document",
|
21
|
+
"CHANGELOG.md",
|
21
22
|
"LICENSE",
|
22
23
|
"README.rdoc",
|
23
24
|
"Rakefile",
|
data/lib/has_money.rb
CHANGED
@@ -32,7 +32,7 @@ module HasMoney
|
|
32
32
|
|
33
33
|
dollars = dollars.to_s.gsub(/[$,]/, "").strip
|
34
34
|
dollars[0] = '0.' if dollars =~ /^\.\d{1,2}/
|
35
|
-
return nil unless dollars.match(/^\d
|
35
|
+
return nil unless dollars.match(/^\d+\.?(\d+)?$/) # xx.xxx
|
36
36
|
|
37
37
|
(BigDecimal(dollars).round(2) * 100).to_i
|
38
38
|
end
|
data/spec/has_money_spec.rb
CHANGED
@@ -79,6 +79,11 @@ describe HasMoney do
|
|
79
79
|
@product.price_in_dollars = '39.992'
|
80
80
|
@product.price.should == 3999
|
81
81
|
end
|
82
|
+
|
83
|
+
it "should assume zero cents if none given after decimal point" do
|
84
|
+
@product.price_in_dollars = '39.'
|
85
|
+
@product.price.should == 3900
|
86
|
+
end
|
82
87
|
|
83
88
|
it "should set nil if nil is passed as dollars" do
|
84
89
|
@product.price_in_dollars = nil
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: has_money
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,11 +11,11 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2011-
|
14
|
+
date: 2011-10-11 00:00:00.000000000Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: rspec
|
18
|
-
requirement: &
|
18
|
+
requirement: &70191540633080 !ruby/object:Gem::Requirement
|
19
19
|
none: false
|
20
20
|
requirements:
|
21
21
|
- - ! '>='
|
@@ -23,7 +23,7 @@ dependencies:
|
|
23
23
|
version: 1.2.9
|
24
24
|
type: :development
|
25
25
|
prerelease: false
|
26
|
-
version_requirements: *
|
26
|
+
version_requirements: *70191540633080
|
27
27
|
description: Parsing the various ways people enter dollar amounts so you don't have
|
28
28
|
to. Store values in cents as integer.
|
29
29
|
email: sam.vincent@mac.com
|
@@ -34,6 +34,7 @@ extra_rdoc_files:
|
|
34
34
|
- README.rdoc
|
35
35
|
files:
|
36
36
|
- .document
|
37
|
+
- CHANGELOG.md
|
37
38
|
- LICENSE
|
38
39
|
- README.rdoc
|
39
40
|
- Rakefile
|