fat_fingers 0.1.14 → 0.1.15
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/fat_fingers.rb +8 -2
- data/test/test_fat_fingers.rb +16 -2
- metadata +1 -1
data/lib/fat_fingers.rb
CHANGED
@@ -15,6 +15,7 @@ class String
|
|
15
15
|
downcase.
|
16
16
|
remove_invalid_characters.
|
17
17
|
fix_transposed_periods.
|
18
|
+
remove_period_before_at_sign.
|
18
19
|
handle_different_country_tlds.
|
19
20
|
fix_coms_with_appended_letters.
|
20
21
|
clean_up_funky_coms.
|
@@ -41,8 +42,13 @@ protected
|
|
41
42
|
# can't do "o.gr" => ".org", as ".gr" is a valid TLD
|
42
43
|
end
|
43
44
|
|
45
|
+
def remove_period_before_at_sign
|
46
|
+
gsub(/\.*@/, "@")
|
47
|
+
end
|
48
|
+
|
44
49
|
def handle_different_country_tlds
|
45
|
-
gsub(/\.couk$/, ".co.uk")
|
50
|
+
gsub(/\.(o\.uk|couk|co\.um)$/, ".co.uk").
|
51
|
+
gsub(/\.(cojp|co\.lp)$/, ".co.jp")
|
46
52
|
end
|
47
53
|
|
48
54
|
def fix_coms_with_appended_letters
|
@@ -69,7 +75,7 @@ protected
|
|
69
75
|
end
|
70
76
|
|
71
77
|
def clean_up_hotmail
|
72
|
-
gsub(/@h(o|p)*
|
78
|
+
gsub(/@h(o|p)*y*t*o*m*(a|i|k|l)*\./,"@hotmail.")
|
73
79
|
end
|
74
80
|
|
75
81
|
def clean_up_yahoo
|
data/test/test_fat_fingers.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
gem 'minitest'
|
1
2
|
require 'minitest/autorun'
|
2
3
|
#require 'fat_fingers'
|
3
4
|
require './lib/fat_fingers.rb'
|
@@ -16,7 +17,8 @@ class StringTest < MiniTest::Unit::TestCase
|
|
16
17
|
"test@gmaill.com",
|
17
18
|
"test@gamil.com",
|
18
19
|
"test@gnail.com",
|
19
|
-
"test@gmailc.om"
|
20
|
+
"test@gmailc.om",
|
21
|
+
"test.@gmail.com"
|
20
22
|
]
|
21
23
|
|
22
24
|
@good_intl_gmail = "test@gmail.co.uk"
|
@@ -31,6 +33,8 @@ class StringTest < MiniTest::Unit::TestCase
|
|
31
33
|
"test@gmaill.co.uk",
|
32
34
|
"test@gamil.co.uk",
|
33
35
|
"test@gnail.co.uk",
|
36
|
+
"test@gmail.co.um",
|
37
|
+
"test@gmail.o.uk",
|
34
38
|
"test@gmail.couk"
|
35
39
|
]
|
36
40
|
|
@@ -52,8 +56,10 @@ class StringTest < MiniTest::Unit::TestCase
|
|
52
56
|
|
53
57
|
@good_hotmail = "test@hotmail.com"
|
54
58
|
@bad_hotmail = [
|
59
|
+
"test@htmail.com",
|
55
60
|
"test@hotmaill.com",
|
56
61
|
"test@hotmaik.com",
|
62
|
+
"test@hoymail.com",
|
57
63
|
"test@hptmail.com",
|
58
64
|
"test@htomali.com"
|
59
65
|
]
|
@@ -100,9 +106,11 @@ class StringTest < MiniTest::Unit::TestCase
|
|
100
106
|
"test\#@something.com",
|
101
107
|
"test@something..com",
|
102
108
|
"test@somethingcom",
|
109
|
+
"test.@something.com",
|
103
110
|
|
104
111
|
"te st@something.com",
|
105
112
|
" test@something.com",
|
113
|
+
"test@something.com ",
|
106
114
|
"TEST@SOMETHING.COM"
|
107
115
|
]
|
108
116
|
|
@@ -159,13 +167,19 @@ class StringTest < MiniTest::Unit::TestCase
|
|
159
167
|
@good_tld_gr = "test@something.gr"
|
160
168
|
@bad_tld_gr = ["test@something.gr"]
|
161
169
|
|
170
|
+
@good_tld_jp = "test@something.co.jp"
|
171
|
+
@bad_tld_jp = [
|
172
|
+
"test@something.co.lp",
|
173
|
+
"test@something.cojp"
|
174
|
+
]
|
175
|
+
|
162
176
|
@good_tld_coop = "test@something.coop"
|
163
177
|
@bad_tld_coop = ["test@something.coop"]
|
164
178
|
|
165
179
|
end
|
166
180
|
|
167
181
|
def cases
|
168
|
-
["gmail", "intl_gmail", "yahoo", "hotmail", "com", "net", "org", "comcast", "sbcglobal", "gm", "tld_cn", "tld_co", "random_co", "tld_gr", "tld_coop", "gmail_with_dots", "gmail_with_plus"]
|
182
|
+
["gmail", "intl_gmail", "yahoo", "hotmail", "com", "net", "org", "comcast", "sbcglobal", "gm", "tld_cn", "tld_co", "random_co", "tld_gr", "tld_jp", "tld_coop", "gmail_with_dots", "gmail_with_plus"]
|
169
183
|
end
|
170
184
|
|
171
185
|
def test_that_emails_get_fixed
|