has_normalized_attributes 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/has_normalized_attributes.rb +7 -7
- data/lib/version.rb +1 -1
- data/spec/has_normalized_fields_spec.rb +9 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7e37778b8ae93697c06b768b3f52735fe2b64897
|
4
|
+
data.tar.gz: 8e03c4140fb42e08d54fc997163b521ec2efbc68
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e4e44f282445e6d70d068b823fe24428db232622d2df8a3c96546a3e727493e5c39b30ca8225516246d8268f6b48f5635d08b9c9ac8a2ba87cd581186afc7f8b
|
7
|
+
data.tar.gz: b20e70e100b07c2b797037dae4d53372f33d3a4e19a126c88d88937bda337f190842733ec5f033568cfebd63c957951b742fa63c502d1836384c1af5f494639c
|
@@ -21,13 +21,13 @@ module HasNormalizedAttributes
|
|
21
21
|
}
|
22
22
|
|
23
23
|
#CONSTANT
|
24
|
-
ZIPCODE = /[
|
25
|
-
PHONE = /[
|
26
|
-
SSN = /[
|
27
|
-
TAXID = /[
|
28
|
-
DOLLAR = /[
|
29
|
-
NUMBER = /[
|
30
|
-
PERCENT = /[
|
24
|
+
ZIPCODE = /[-.\s)(,]/
|
25
|
+
PHONE = /[-.\s)(,]|(^0)/
|
26
|
+
SSN = /[-.\s)(,]/
|
27
|
+
TAXID = /[-.\s)(,]/
|
28
|
+
DOLLAR = /[$,\s]/
|
29
|
+
NUMBER = /[,\s]/
|
30
|
+
PERCENT = /[%,\s]/
|
31
31
|
SPACES = /\s/
|
32
32
|
|
33
33
|
#instance methods
|
data/lib/version.rb
CHANGED
@@ -37,6 +37,7 @@ describe "HasNormalizedAttributes" do
|
|
37
37
|
it{@resource.phone_attr = "0111-111.1111 "; @resource.phone_attr.should == "1111111111"}
|
38
38
|
it{@resource.phone_attr = "1011-111.1111 "; @resource.phone_attr.should == "10111111111"}
|
39
39
|
it{@resource.phone_attr = "111-0222.333 "; @resource.phone_attr.should == "1110222333"}
|
40
|
+
it{@resource.phone_attr = "111-0222.333\t"; @resource.phone_attr.should == "1110222333"}
|
40
41
|
it{@resource.phone_attr = ""; @resource.phone_attr.should == ""}
|
41
42
|
it{@resource.phone_attr = nil; @resource.phone_attr.should == nil}
|
42
43
|
end
|
@@ -50,6 +51,7 @@ describe "HasNormalizedAttributes" do
|
|
50
51
|
it{@resource.zipcode_attr = "111111111"; @resource.zipcode_attr.should == "111111111"}
|
51
52
|
it{@resource.zipcode_attr = "(11111) 1111"; @resource.zipcode_attr.should == "111111111"}
|
52
53
|
it{@resource.zipcode_attr = "11111) -1111"; @resource.zipcode_attr.should == "111111111"}
|
54
|
+
it{@resource.zipcode_attr = "11111\t-1111"; @resource.zipcode_attr.should == "111111111"}
|
53
55
|
it{@resource.zipcode_attr = "11111.1111"; @resource.zipcode_attr.should == "111111111"}
|
54
56
|
it{@resource.zipcode_attr = "11111 --1111"; @resource.zipcode_attr.should == "111111111"}
|
55
57
|
it{@resource.zipcode_attr = " 11111,1111 "; @resource.zipcode_attr.should == "111111111"}
|
@@ -67,6 +69,7 @@ describe "HasNormalizedAttributes" do
|
|
67
69
|
it{@resource.ssn_attr = "(111)111-1111"; @resource.ssn_attr.should == "1111111111"}
|
68
70
|
it{@resource.ssn_attr = "(111)1111111"; @resource.ssn_attr.should == "1111111111"}
|
69
71
|
it{@resource.ssn_attr = " 111-111.1111 "; @resource.ssn_attr.should == "1111111111"}
|
72
|
+
it{@resource.ssn_attr = " 111-111.1111\t"; @resource.ssn_attr.should == "1111111111"}
|
70
73
|
it{@resource.ssn_attr = ""; @resource.ssn_attr.should == ""}
|
71
74
|
it{@resource.ssn_attr = nil; @resource.ssn_attr.should == nil}
|
72
75
|
end
|
@@ -76,6 +79,8 @@ describe "HasNormalizedAttributes" do
|
|
76
79
|
it{@resource.taxid_attr = "12.345"; @resource.taxid_attr.should == "12345"}
|
77
80
|
it{@resource.taxid_attr = "1-2345"; @resource.taxid_attr.should == "12345"}
|
78
81
|
it{@resource.taxid_attr = "1,2345"; @resource.taxid_attr.should == "12345"}
|
82
|
+
it{@resource.taxid_attr = "1,2345 "; @resource.taxid_attr.should == "12345"}
|
83
|
+
it{@resource.taxid_attr = "1,2345\t"; @resource.taxid_attr.should == "12345"}
|
79
84
|
it{@resource.taxid_attr = ""; @resource.taxid_attr.should == ""}
|
80
85
|
it{@resource.taxid_attr = nil; @resource.taxid_attr.should == nil}
|
81
86
|
end
|
@@ -85,6 +90,7 @@ describe "HasNormalizedAttributes" do
|
|
85
90
|
it{@resource.dollar_attr = "111,111";@resource.dollar_attr.should == "111111"}
|
86
91
|
it{@resource.dollar_attr = "111 111 ";@resource.dollar_attr.should == "111111"}
|
87
92
|
it{@resource.dollar_attr = "$111, 111 ";@resource.dollar_attr.should == "111111"}
|
93
|
+
it{@resource.dollar_attr = "$111\t111\t";@resource.dollar_attr.should == "111111"}
|
88
94
|
it{@resource.dollar_attr = "";@resource.dollar_attr.should == ""}
|
89
95
|
it{@resource.dollar_attr = nil;@resource.dollar_attr.should == nil}
|
90
96
|
it{@resource.dollar_attr = 111111.51;@resource.dollar_attr.should == "111111.51"}
|
@@ -96,6 +102,7 @@ describe "HasNormalizedAttributes" do
|
|
96
102
|
describe "#number" do
|
97
103
|
it{@resource.number_attr = "1,23";@resource.number_attr.should == "123"}
|
98
104
|
it{@resource.number_attr = "1 23 ";@resource.number_attr.should == "123"}
|
105
|
+
it{@resource.number_attr = "1\t23\t";@resource.number_attr.should == "123"}
|
99
106
|
it{@resource.number_attr = "";@resource.number_attr.should == ""}
|
100
107
|
it{@resource.number_attr = nil;@resource.number_attr.should == nil}
|
101
108
|
it{@resource.dollar_attr = 111111.51;@resource.dollar_attr.should == "111111.51"}
|
@@ -108,12 +115,14 @@ describe "HasNormalizedAttributes" do
|
|
108
115
|
it{@resource.percent_attr = "11%";@resource.percent_attr.should == "11"}
|
109
116
|
it{@resource.percent_attr = "%11";@resource.percent_attr.should == "11"}
|
110
117
|
it{@resource.percent_attr = "1 1 % ";@resource.percent_attr.should == "11"}
|
118
|
+
it{@resource.percent_attr = "1\t1\t%\t";@resource.percent_attr.should == "11"}
|
111
119
|
it{@resource.percent_attr = "";@resource.percent_attr.should == ""}
|
112
120
|
it{@resource.percent_attr = nil;@resource.percent_attr.should == nil}
|
113
121
|
end
|
114
122
|
|
115
123
|
describe "#spaces" do
|
116
124
|
it{@resource.spaces_attr = "5 0";@resource.spaces_attr.should == "50"}
|
125
|
+
it{@resource.spaces_attr = "5\t0";@resource.spaces_attr.should == "50"}
|
117
126
|
it{@resource.spaces_attr = "";@resource.spaces_attr.should == ""}
|
118
127
|
it{@resource.spaces_attr = nil;@resource.spaces_attr.should == nil}
|
119
128
|
end
|