sanitizing_bigdecimal 0.0.2 → 0.0.3
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.
- checksums.yaml +4 -4
- data/lib/sanitizing_bigdecimal.rb +2 -1
- data/spec/unit/sanitizing_bigdecimal_spec.rb +4 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 856c83b4b24ddaec565ac91dbdd6fb5bcf06bd8d
|
4
|
+
data.tar.gz: 27f95ec60d338f2e293d43897c5a304ad80ac6a3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7553c432d8251e0c682fec26251ae7fb0a4244983438142f38881e7cb8ae4b96f81994e279824def2b4b91ea4607c26e1551a50024759c44a446224c239f6921
|
7
|
+
data.tar.gz: 3002eb0555602d7642ad33c8c0ac054f572006eac6db38636bd127a6db1eebd4cb4c20a9105d1be16a65ec1a5fbcb29e3b1d28d691aae65a5277351e1999d32d
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'bigdecimal'
|
2
2
|
|
3
3
|
class SanitizingBigDecimal
|
4
|
-
VERSION = "0.0.
|
4
|
+
VERSION = "0.0.3"
|
5
5
|
|
6
6
|
def self.get_bigdecimal(input)
|
7
7
|
return input if input.is_a?(BigDecimal)
|
@@ -9,6 +9,7 @@ class SanitizingBigDecimal
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def self.sanitize(input)
|
12
|
+
return nil.to_s if input.nil?
|
12
13
|
input.gsub(/[^.0-9]/, '')
|
13
14
|
end
|
14
15
|
end
|
@@ -9,6 +9,10 @@ describe SanitizingBigDecimal do
|
|
9
9
|
expect(SanitizingBigDecimal("$1,000.23")).to eq(BigDecimal("1000.23"))
|
10
10
|
end
|
11
11
|
|
12
|
+
it "should not blow up with nil" do
|
13
|
+
expect{SanitizingBigDecimal(nil)}.to_not raise_error
|
14
|
+
end
|
15
|
+
|
12
16
|
it "returns what it's passed, if it is passed a BigDecimal" do
|
13
17
|
input = BigDecimal("1000.13")
|
14
18
|
expect(SanitizingBigDecimal(input)).to equal(input)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sanitizing_bigdecimal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josh Adams
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2014-04-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|