rrod 1.0.0.alpha.4 → 1.0.0.alpha.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 73a47a1b2feaa5f8ca345afab9b483e5755d710b
4
- data.tar.gz: 000a4429b93fe6a68df919e3a1295abc27a71a0b
3
+ metadata.gz: 06754ed204ad9ff8a477fdeffa4d06434dea7e67
4
+ data.tar.gz: 9ae55842b97ccec524f8b5ca164f847dd5988a1a
5
5
  SHA512:
6
- metadata.gz: 4267a72e45678a7f60eb7fbd756d7fd88bdfb552a38eb596dcf768d59aa99dece04a297151e31d6dfb70f59c5d231b1d635e2dec80278724d2c930b8ea6ba4d7
7
- data.tar.gz: 74ef9e7c3c8d511e080fbc143c62ff6dc9813902cbe427bb6de738672d213ab0eb58f305fa6202f9ba6f33a815ddc9162917d387403e99d6474d084368ce40de
6
+ metadata.gz: 642a5471ed9e3b49d879846c7744ebc88052662c9c52eddc5a27b0c077c3426865b6ac365dbaed0df9996536a57d1ce24e73fdc227343d83fd1b23b96c4e23aa
7
+ data.tar.gz: e85b9b3e8a854b1eed52ccdf1713d5560992baffb22bda02eb27947353f55f4464dbbb79df1fe52292a5cbbca66e34eb5abcec54e01288d70f04454698617f42
data/lib/rrod/caster.rb CHANGED
@@ -20,11 +20,11 @@ module Rrod
20
20
  BigDecimal = new { |value| ::BigDecimal.new(value.to_s) }
21
21
  Date = new { |value| value.to_date }
22
22
  DateTime = new { |value| value.to_datetime }
23
- Float = new { |value| value.to_f }
24
- Integer = new { |value| value.to_i }
23
+ Float = new { |value| value.respond_to?(:gsub) ? value.gsub(',', '').to_f : value.to_f }
24
+ Integer = new { |value| value.respond_to?(:gsub) ? value.gsub(',', '').to_i : value.to_i }
25
25
  Numeric = new { |value|
26
- float_value = value.to_f
27
- int_value = value.to_i
26
+ float_value = value.respond_to?(:gsub) ? value.gsub(',', '').to_f : value.to_f
27
+ int_value = value.respond_to?(:gsub) ? value.gsub(',', '').to_i : value.to_i
28
28
  float_value == int_value ? int_value : float_value
29
29
  }
30
30
  String = new { |value| value.to_s }
data/lib/rrod/version.rb CHANGED
@@ -1,2 +1,2 @@
1
1
  Rrod = Module.new unless defined? Rrod
2
- Rrod::VERSION = '1.0.0.alpha.4'
2
+ Rrod::VERSION = '1.0.0.alpha.5'
@@ -74,6 +74,9 @@ describe Rrod::Caster do
74
74
  it "converts to floating point" do
75
75
  expect(caster.rrod_cast("3.142")).to eq floater
76
76
  end
77
+ it "suppresses commas in otherwise-clean input" do
78
+ expect(caster.rrod_cast('3,333.142')).to eq 3333.142
79
+ end
77
80
  end
78
81
 
79
82
  describe "Integer" do
@@ -81,6 +84,9 @@ describe Rrod::Caster do
81
84
  it "converts to integer" do
82
85
  expect(caster.rrod_cast('4')).to eq 4
83
86
  end
87
+ it "suppresses commas in otherwise-clean input" do
88
+ expect(caster.rrod_cast('1,234,567')).to eq 1234567
89
+ end
84
90
  end
85
91
 
86
92
  describe "Numeric" do
@@ -91,6 +97,12 @@ describe Rrod::Caster do
91
97
  it "converts to integer" do
92
98
  expect(caster.rrod_cast("3")).to eq 3
93
99
  end
100
+ it "suppresses commas in integer input" do
101
+ expect(caster.rrod_cast("3,012")).to eq 3012
102
+ end
103
+ it "suppresses commas in float input" do
104
+ expect(caster.rrod_cast("3,333.142")).to eq 3333.142
105
+ end
94
106
  end
95
107
 
96
108
  describe "String" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rrod
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.alpha.4
4
+ version: 1.0.0.alpha.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Hunter
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-19 00:00:00.000000000 Z
11
+ date: 2015-02-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: riak-client