has_money 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.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.1.0"
8
+ s.version = "0.1.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Greg Bell", "Sam Vincent", "Howard Yeh"]
12
- s.date = %q{2010-10-28}
12
+ s.date = %q{2010-11-12}
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 = [
data/lib/has_money.rb CHANGED
@@ -30,7 +30,7 @@ module HasMoney
30
30
  def calculate_cents_from_dollars(dollars)
31
31
  return nil if dollars.nil?
32
32
 
33
- dollars = dollars.to_s.gsub(/[$,]/, "")
33
+ dollars = dollars.to_s.gsub(/[$,]/, "").strip
34
34
  dollars[0] = '0.' if dollars =~ /^\.\d{1,2}/
35
35
  return nil unless dollars.match(/^\d+(\.\d+)?$/) # xx.xxx
36
36
 
@@ -64,7 +64,12 @@ describe HasMoney do
64
64
  @product.price_in_dollars = ".59"
65
65
  @product.price.should == 59
66
66
  end
67
-
67
+
68
+ it "should set the amount in dollars if it has leading and trailing spaces" do
69
+ @product.price_in_dollars = " 0.59 "
70
+ @product.price.should == 59
71
+ end
72
+
68
73
  it "should round the amount up to the nearest cent" do
69
74
  @product.price_in_dollars = '39.998'
70
75
  @product.price.should == 4000
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 0
9
- version: 0.1.0
8
+ - 1
9
+ version: 0.1.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Greg Bell
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-10-28 00:00:00 -07:00
19
+ date: 2010-11-12 00:00:00 -08:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency