duffy 0.1.0 → 0.1.1

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: 003b573d8db477aba2c65c67b2dd55ad57748851
4
- data.tar.gz: 7508cd90aeb0a13c0c2dbddf80e7f59027b26055
3
+ metadata.gz: 1e0035fd1678d2bc2c4e6bcad1429a3fc9fc1fa9
4
+ data.tar.gz: ec504588e66ea7dfafa7090dede5b8d1e872e901
5
5
  SHA512:
6
- metadata.gz: d9eabbe19b1d5eb90e29747e4d0c7925de335132ac07f4567bbfb2a85c86279d31e8954c20e18072e0fa76e97bea63ac313607c6a05abe01a76839d718d716d0
7
- data.tar.gz: b9ec0f37134bd61a1a0793aa25b5e64bf7e840895ceb1426df4736b9d21334b09c0dd7db26de574bf62318ac200e0eb471bc314a02023f92461911745c0c1cfe
6
+ metadata.gz: c6d56016fdbc81816dc4cb753777f730d819e7dad69b80690971afdb8fc3decf85c66687c5321ba3d2f42cfc69647bd8651cebb8424bbdb5d94d145044a7273f
7
+ data.tar.gz: f67d6f42090a26e34cb25385ba6594327e68abe329fd0e04374a826e24f94efda48b589cc9363efc94ced1f0de533222f13ec421aa12dfe970488d7676b0ae15
data/lib/duffy/string.rb CHANGED
@@ -2,8 +2,7 @@
2
2
  class String
3
3
 
4
4
  def to_ssn
5
- ssn = self.to_s.gsub(/[^0-9]/, "") # now it's a string with only 0-9
6
- ssn = "%09d" % ssn.to_i # now it has leading zeros
5
+ ssn = "%09d" % self.to_numeric.to_i # strips string of non zeros, and pads leading zeros
7
6
  ssn[0..2] + "-" + ssn[3..4] + "-" + ssn[5..8] # now it's like 123-45-6789
8
7
  end
9
8
 
@@ -25,7 +24,7 @@ class String
25
24
  # serial: 0001 to 9999
26
25
  def sanitize_ssn
27
26
  begin
28
- ssn = "%09d" % self.to_numeric
27
+ ssn = "%09d" % self.to_numeric.to_i
29
28
  raise "Too Long" if ssn.length > 9
30
29
  area, group, serial = ssn[0..2], ssn[3..4], ssn[5..8]
31
30
  raise "Area Range Invalid" unless ("001" .. "665").cover?(area) or ("667" .. "899").cover?(area)
data/lib/duffy/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Duffy
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
data/spec/string_spec.rb CHANGED
@@ -42,6 +42,10 @@ describe String do
42
42
  # Invalid Area
43
43
  end
44
44
 
45
+ it "078051120 => 078051120 " do
46
+ "078051120".sanitize_ssn.should == "078051120"
47
+ end
48
+
45
49
  it "666123456 => nil" do
46
50
  "666123456".sanitize_ssn.should == nil
47
51
  # Invalid Area
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: duffy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jacob Duffy