jmcnevin-money 2.0.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/money/money.rb +4 -1
- data/money.gemspec +2 -2
- data/test/money_spec.rb +10 -0
- metadata +3 -2
data/lib/money/money.rb
CHANGED
@@ -165,8 +165,11 @@ class Money
|
|
165
165
|
if rules.include?(:no_cents)
|
166
166
|
formatted = sprintf("$%d", cents.to_f / 100 )
|
167
167
|
else
|
168
|
-
formatted = sprintf("$%.2f", cents.to_f / 100 )
|
168
|
+
formatted = sprintf("$%.2f", cents.to_f / 100 )
|
169
169
|
end
|
170
|
+
|
171
|
+
# Commify
|
172
|
+
formatted = formatted.gsub(/(\d)(?=\d{3}+(?:\.|$))(\d{3}\..*)?/,'\1,\2')
|
170
173
|
|
171
174
|
if rules.include?(:with_currency)
|
172
175
|
formatted << " "
|
data/money.gemspec
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "money"
|
3
|
-
s.version = "2.0.
|
3
|
+
s.version = "2.0.1"
|
4
4
|
s.summary = "Money and currency exchange support library"
|
5
5
|
s.email = "hongli@phusion.nl"
|
6
6
|
s.homepage = "http://money.rubyforge.org/"
|
7
7
|
s.description = "Money and currency exchange support library. Modified by jmcnevin."
|
8
8
|
s.has_rdoc = true
|
9
9
|
s.rubyforge_project = "money"
|
10
|
-
s.authors = ["Tobias Luetke", "Hongli Lai"]
|
10
|
+
s.authors = ["Tobias Luetke", "Hongli Lai", "Jeremy McNevin"]
|
11
11
|
|
12
12
|
s.files = [
|
13
13
|
"README.rdoc", "MIT-LICENSE", "money.gemspec", "Rakefile",
|
data/test/money_spec.rb
CHANGED
@@ -3,6 +3,16 @@ require 'money/money'
|
|
3
3
|
|
4
4
|
describe Money do
|
5
5
|
|
6
|
+
describe "when formatted to string" do
|
7
|
+
before(:each) do
|
8
|
+
@money = Money.new(100000000000)
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should insert commas into output" do
|
12
|
+
@money.format.should == "$1,000,000,000.00"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
6
16
|
describe "with zero value" do
|
7
17
|
before(:each) do
|
8
18
|
@money = Money.new(0,'USD')
|
metadata
CHANGED
@@ -1,16 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jmcnevin-money
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tobias Luetke
|
8
8
|
- Hongli Lai
|
9
|
+
- Jeremy McNevin
|
9
10
|
autorequire:
|
10
11
|
bindir: bin
|
11
12
|
cert_chain: []
|
12
13
|
|
13
|
-
date:
|
14
|
+
date: 2009-01-11 00:00:00 -08:00
|
14
15
|
default_executable:
|
15
16
|
dependencies: []
|
16
17
|
|