normalizr 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/normalizr/normalizers.rb +17 -12
- data/lib/normalizr/version.rb +1 -1
- 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: 001866efe62b5690380583e71cd63a7db0f8b50e
|
4
|
+
data.tar.gz: 5569ab0e1c9379bfae5bb5c5a3f085839dffd4dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dd87e9aa36aa9da01e264b5097e00fdc6af7f576c116c5d640078eaa40de6e57127e838b0f8bc1e1773fb3dcd5c928c4dc238aa5c4d9627fb117a1a417311168
|
7
|
+
data.tar.gz: 54a92ab8ec8a31523f8eb8bbf8b3322aefaf58b2d5b999659258dcaf35dbe36bff3bbe7cfe9f5783393f2dda079366a1ead640c6649670bec5edd4f27abd282b
|
data/CHANGELOG.md
CHANGED
@@ -16,13 +16,16 @@ Normalizr.configure do
|
|
16
16
|
end
|
17
17
|
|
18
18
|
add :control_chars do |value|
|
19
|
-
|
20
|
-
|
19
|
+
if String === value
|
20
|
+
value.gsub(/[[:cntrl:]&&[^[:space:]]]/, '')
|
21
|
+
else
|
22
|
+
value
|
23
|
+
end
|
21
24
|
end
|
22
25
|
|
23
26
|
add :phone do |value|
|
24
27
|
if String === value
|
25
|
-
value.gsub
|
28
|
+
value = value.gsub(/[^0-9]+/, '')
|
26
29
|
value unless value.empty?
|
27
30
|
else
|
28
31
|
value
|
@@ -31,25 +34,27 @@ Normalizr.configure do
|
|
31
34
|
|
32
35
|
add :squish do |value|
|
33
36
|
if String === value
|
34
|
-
value.strip
|
35
|
-
|
37
|
+
value.strip.gsub(/\s+/, ' ')
|
38
|
+
else
|
39
|
+
value
|
36
40
|
end
|
37
|
-
value
|
38
41
|
end
|
39
42
|
|
40
43
|
add :whitespace do |value|
|
41
44
|
if String === value
|
42
|
-
value.gsub
|
43
|
-
|
44
|
-
value
|
45
|
+
value.gsub(/[^\S\n]+/, ' ').gsub(/\s?\n\s?/, "\n").strip
|
46
|
+
else
|
47
|
+
value
|
45
48
|
end
|
46
|
-
value
|
47
49
|
end
|
48
50
|
|
49
51
|
[:capitalize, :downcase, :strip, :upcase].each do |name|
|
50
52
|
add name do |value|
|
51
|
-
|
52
|
-
|
53
|
+
if String === value
|
54
|
+
value.send(:"#{name}")
|
55
|
+
else
|
56
|
+
value
|
57
|
+
end
|
53
58
|
end
|
54
59
|
end
|
55
60
|
end
|
data/lib/normalizr/version.rb
CHANGED