fat_fingers 0.1.26 → 0.1.27
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/fat_fingers.rb +18 -15
- data/test/test_fat_fingers.rb +284 -276
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 29e576d4b41299eaa24248053522b0f1ab1d2549
|
4
|
+
data.tar.gz: 8b7ce69476dd10a7276d798e2e6bfffcd2dcd8c2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: baacf5758ad7bdcbdffaa2f0a32d1c8725c17ba89cc64deac4617496e57e0b26a16d5e8f610dc52bb16055719b1f14fc137583064bd5054e5cc64145be938a2b
|
7
|
+
data.tar.gz: a03a219aea2d5fd7aca5664c2d7b9d51459c37af9cfabd3043a53512e4b911473eb0b923c10931de629b97f8f7a4ab4b200310d08f2743d47c90575f175a6f24
|
data/lib/fat_fingers.rb
CHANGED
@@ -15,7 +15,7 @@ class String
|
|
15
15
|
downcase.
|
16
16
|
remove_invalid_characters.
|
17
17
|
fix_transposed_periods.
|
18
|
-
|
18
|
+
remove_period_around_at_sign.
|
19
19
|
handle_different_country_tlds.
|
20
20
|
fix_coms_with_appended_letters.
|
21
21
|
clean_up_funky_coms.
|
@@ -24,8 +24,8 @@ class String
|
|
24
24
|
clean_up_gmail.
|
25
25
|
clean_up_googlemail.
|
26
26
|
clean_up_hotmail.
|
27
|
-
clean_up_yahoo.
|
28
27
|
clean_up_aol.
|
28
|
+
clean_up_yahoo.
|
29
29
|
clean_up_other_providers.
|
30
30
|
clean_up_known_coms.
|
31
31
|
add_a_period_if_they_forgot_it
|
@@ -45,8 +45,8 @@ protected
|
|
45
45
|
# can't do "o.gr" => ".org", as ".gr" is a valid TLD
|
46
46
|
end
|
47
47
|
|
48
|
-
def
|
49
|
-
gsub(
|
48
|
+
def remove_period_around_at_sign
|
49
|
+
gsub(/(\.@|@\.)/, "@")
|
50
50
|
end
|
51
51
|
|
52
52
|
def handle_different_country_tlds
|
@@ -55,8 +55,9 @@ protected
|
|
55
55
|
end
|
56
56
|
|
57
57
|
def fix_coms_with_appended_letters
|
58
|
+
gsub(/\.co[mn]\.com/, ".com").
|
58
59
|
gsub(/\.com\.$/, ".com").
|
59
|
-
gsub(/\.com
|
60
|
+
gsub(/\.com(?!cast|\.|@).{1,3}$/, ".com"). # fix up to three extra letters after .com as long as they're not .comcast or .com.* (and as long as they're not before the @)
|
60
61
|
gsub(/\.co[^op]$/, ".com")
|
61
62
|
end
|
62
63
|
|
@@ -70,37 +71,39 @@ protected
|
|
70
71
|
end
|
71
72
|
|
72
73
|
def clean_up_funky_orgs
|
73
|
-
gsub(/\.
|
74
|
+
gsub(/\.og?r?g{0,2}$/, ".org") # require the o, to not false-positive .gr e-mails
|
74
75
|
end
|
75
76
|
|
76
77
|
def clean_up_googlemail
|
77
|
-
gsub(/@
|
78
|
+
gsub(/@go{0,3}g{0,2}o?le?[mn]?[ail]{1,2}m?[aikl]{0,3}\./,"@googlemail.")
|
78
79
|
end
|
79
80
|
|
80
81
|
def clean_up_gmail
|
81
|
-
gsub(/@g(
|
82
|
+
gsub(/@g[nm]{0,2}s?[ail]{1,2}[aiklmou]{0,3}\.(?!gov)/,"@gmail.") # match a broad variety of mispellings of gmail, but not if it's .gov
|
82
83
|
end
|
83
84
|
|
84
85
|
def clean_up_hotmail
|
85
|
-
gsub(/@h(o|p)
|
86
|
+
gsub(/@h(i|o|p)?y?t?o?a?m?n?t?[aikl]{1,3}l?\./,"@hotmail.")
|
86
87
|
end
|
87
88
|
|
88
89
|
def clean_up_yahoo
|
89
|
-
gsub(/@
|
90
|
+
gsub(/@(ya|yh|ua|ah)+h*a*o+\./,"@yahoo.")
|
90
91
|
end
|
91
92
|
|
92
93
|
def clean_up_aol
|
93
|
-
gsub(/@ol\./,"@aol.")
|
94
|
+
gsub(/@(ol|ao|ail)\./,"@aol.")
|
94
95
|
end
|
95
96
|
|
96
97
|
def clean_up_other_providers
|
97
|
-
gsub(/@co
|
98
|
-
gsub(/@
|
99
|
-
gsub(/@ver
|
98
|
+
gsub(/@co?(m|n)a?cas?t{0,2}\./,"@comcast.").
|
99
|
+
gsub(/@sbc?gl?ob[al]{0,2}l?\./, "@sbcglobal.").
|
100
|
+
gsub(/@ver?i?z?on\./,"@verizon.").
|
101
|
+
gsub(/@icl{0,2}oud\./,"@icloud.").
|
102
|
+
gsub(/@outl?ook?\./,"@outlook.")
|
100
103
|
end
|
101
104
|
|
102
105
|
def clean_up_known_coms
|
103
|
-
gsub(/(aol|googlemail|gmail|hotmail|yahoo)
|
106
|
+
gsub(/(aol|googlemail|gmail|hotmail|yahoo|icloud|outlook)\.(co|net|org)$/, '\1.com')
|
104
107
|
end
|
105
108
|
|
106
109
|
def add_a_period_if_they_forgot_it
|
data/test/test_fat_fingers.rb
CHANGED
@@ -1,296 +1,305 @@
|
|
1
1
|
gem 'minitest'
|
2
2
|
require 'minitest/autorun'
|
3
|
-
#require 'fat_fingers'
|
4
3
|
require './lib/fat_fingers.rb'
|
5
4
|
|
6
5
|
class StringTest < MiniTest::Unit::TestCase
|
7
6
|
def setup
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
"test@
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
"test@
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
"test@
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
"test@
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
"test@
|
98
|
-
|
99
|
-
|
100
|
-
|
7
|
+
|
8
|
+
# examples of email typos that should be fixed
|
9
|
+
@replacement_examples = [
|
10
|
+
# gmail.com
|
11
|
+
{ good: "test@gmail.com",
|
12
|
+
bad: [
|
13
|
+
"test@gmai.com",
|
14
|
+
"test@gmaii.com",
|
15
|
+
"test@gmal.com",
|
16
|
+
"test@gmaal.com",
|
17
|
+
"test@gmaol.com",
|
18
|
+
"test@gmaul.com",
|
19
|
+
"test@gmil.com",
|
20
|
+
"test@gmsil.com",
|
21
|
+
"test@gmial.com",
|
22
|
+
"test@gmali.com",
|
23
|
+
"test@gmila.com",
|
24
|
+
"test@gmaill.com",
|
25
|
+
"test@gamil.com",
|
26
|
+
"test@gnail.com",
|
27
|
+
"test@gmailc.om",
|
28
|
+
"test.@gmail.com",
|
29
|
+
"test.@gmail.co",
|
30
|
+
"test@gmail.net"
|
31
|
+
]
|
32
|
+
},
|
33
|
+
# gmail.co.uk
|
34
|
+
{ good: "test@gmail.co.uk",
|
35
|
+
bad: [
|
36
|
+
"test@gmai.co.uk",
|
37
|
+
"test@gmal.co.uk",
|
38
|
+
"test@gmaal.co.uk",
|
39
|
+
"test@gmil.co.uk",
|
40
|
+
"test@gmial.co.uk",
|
41
|
+
"test@gmali.co.uk",
|
42
|
+
"test@gmila.co.uk",
|
43
|
+
"test@gmaill.co.uk",
|
44
|
+
"test@gamil.co.uk",
|
45
|
+
"test@gnail.co.uk",
|
46
|
+
"test@gmail.co.um",
|
47
|
+
"test@gmail.o.uk",
|
48
|
+
"test@gmail.couk"
|
49
|
+
]
|
50
|
+
},
|
51
|
+
# googlemail.com
|
52
|
+
{ good: "test@googlemail.com",
|
53
|
+
bad: [
|
54
|
+
"test@googlemai.com",
|
55
|
+
"test@googlemaii.com",
|
56
|
+
"test@googlemal.com",
|
57
|
+
"test@googlemaal.com",
|
58
|
+
"test@googlemil.com",
|
59
|
+
"test@googlemial.com",
|
60
|
+
"test@googlemali.com",
|
61
|
+
"test@googlemila.com",
|
62
|
+
"test@googlemaill.com",
|
63
|
+
"test@googleamil.com",
|
64
|
+
"test@googlenail.com",
|
65
|
+
"test@googlemailc.om",
|
66
|
+
"test.@googlemail.com",
|
67
|
+
"test.@googlemail.co",
|
68
|
+
"test.@gogglemaii.com",
|
69
|
+
"test.@gogglemail.com",
|
70
|
+
"test.@gogolemail.com",
|
71
|
+
"test.@goooglemail.com",
|
72
|
+
"test@goooglemail.net"
|
73
|
+
]
|
74
|
+
},
|
75
|
+
# yahoo.com
|
76
|
+
{ good: "test@yahoo.com",
|
77
|
+
bad: [
|
78
|
+
"test@aho.com",
|
79
|
+
"test@ahoo.com",
|
80
|
+
"test@ahoo.com",
|
81
|
+
"test@uahoo.com",
|
82
|
+
"test@yaho.com",
|
83
|
+
"test@yahooo.com",
|
84
|
+
"test@yhao.com",
|
85
|
+
"test@yhaoo.com",
|
86
|
+
"test@yho.com",
|
87
|
+
"test@yhooo.com",
|
88
|
+
"test@yao.com",
|
89
|
+
"test@yaooo.com",
|
90
|
+
"test@yahooc.om",
|
91
|
+
"test@yahoo.co",
|
92
|
+
"test@yahoo.net"
|
93
|
+
]
|
94
|
+
},
|
95
|
+
# hotmail.com
|
96
|
+
{ good: "test@hotmail.com",
|
97
|
+
bad: [
|
98
|
+
"test@hotamail.com",
|
99
|
+
"test@htmail.com",
|
100
|
+
"test@hotmaill.com",
|
101
|
+
"test@hotmaik.com",
|
102
|
+
"test@hoymail.com",
|
103
|
+
"test@hptmail.com",
|
104
|
+
"test@hitmail.com",
|
105
|
+
"test@hotnail.com",
|
106
|
+
"test@htomali.com",
|
107
|
+
"test@homtail.com",
|
108
|
+
"test@hotmail.co",
|
109
|
+
"test@hotmail.net"
|
110
|
+
]
|
111
|
+
},
|
112
|
+
# aol.com
|
113
|
+
{ good: "test@aol.com",
|
114
|
+
bad: [
|
115
|
+
"test@aol.cm",
|
116
|
+
"test@ail.cm",
|
117
|
+
"test@ol.com",
|
118
|
+
"test@ao.com",
|
119
|
+
"test@aol.co",
|
120
|
+
"test@aol.net"
|
121
|
+
]
|
122
|
+
},
|
123
|
+
# comcast.net
|
124
|
+
{ good: "test@comcast.net",
|
125
|
+
bad: [
|
126
|
+
"test@comacast.net",
|
127
|
+
"test@comcastn.et",
|
128
|
+
"test@comcastt.net",
|
129
|
+
"test@comcat.net",
|
130
|
+
"test@concast.net",
|
131
|
+
"test@cmcast.net"
|
132
|
+
]
|
133
|
+
},
|
134
|
+
# sbcglobal.net
|
135
|
+
{ good: "test@sbcglobal.net",
|
136
|
+
bad: [
|
137
|
+
"test@sbcgloball.net",
|
138
|
+
"test@sbcgloba.net",
|
139
|
+
"test@sbcglobl.net",
|
140
|
+
"test@sbcgobal.net",
|
141
|
+
"test@sbglobal.net"
|
142
|
+
]
|
143
|
+
},
|
144
|
+
# icloud.com
|
145
|
+
{ good: "test@icloud.com",
|
146
|
+
bad: [
|
147
|
+
"test@icoud.com",
|
148
|
+
"test@icloud.co",
|
149
|
+
"test@icloud.net"
|
150
|
+
]
|
151
|
+
},
|
152
|
+
# outlook.com
|
153
|
+
{ good: "test@outlook.com",
|
154
|
+
bad: [
|
155
|
+
"test@outloo.com",
|
156
|
+
"test@outlook.co",
|
157
|
+
"test@outlook.net"
|
158
|
+
]
|
159
|
+
},
|
160
|
+
# verizon.net
|
161
|
+
{ good: "test@verizon.net",
|
162
|
+
bad: [
|
163
|
+
"test@verizon.net",
|
164
|
+
"test@veizon.net",
|
165
|
+
"test@verion.net",
|
166
|
+
"test@verzon.net"
|
167
|
+
]
|
168
|
+
},
|
169
|
+
# generic .com
|
170
|
+
{ good: "test@something.com",
|
171
|
+
bad: [
|
172
|
+
"test@somethingc.om",
|
173
|
+
"test@something.coom",
|
174
|
+
"test@something.comm",
|
175
|
+
"test@something.comme",
|
176
|
+
"test@something.co,", # assume that someone entering this in *meant* to type in '.com'
|
177
|
+
"test@something.co.",
|
178
|
+
"test@something.co<",
|
179
|
+
"test@something.co>",
|
180
|
+
"test@something.cmo",
|
181
|
+
"test@something.cm",
|
182
|
+
"test@something.om",
|
183
|
+
"test@something.c0m",
|
184
|
+
"test@something.coim",
|
185
|
+
"test@something.cok",
|
186
|
+
"test@something.colm",
|
187
|
+
"test@something.clom",
|
188
|
+
"test@something.comj",
|
189
|
+
"test@something.comn",
|
190
|
+
"test@something.con",
|
191
|
+
"test@something.conm",
|
192
|
+
"test@something.coom",
|
193
|
+
"test@something.copm",
|
194
|
+
"test@something.cpm",
|
195
|
+
"test@something.ocm",
|
196
|
+
"test@something.vom",
|
197
|
+
"test@something.xom",
|
198
|
+
"test@something.con.com",
|
199
|
+
"test@something.com.com",
|
200
|
+
"test@something.com'",
|
201
|
+
"te'st@something.com",
|
202
|
+
"test@something.com\"",
|
203
|
+
"test@something.com\\",
|
204
|
+
"test@something.com,",
|
205
|
+
"test@something.com.",
|
206
|
+
"test@something,com",
|
207
|
+
"test@\#something.com",
|
208
|
+
"test@#something.com",
|
209
|
+
"test@@something.com",
|
210
|
+
"test\#@something.com",
|
211
|
+
"test@something..com",
|
212
|
+
"test@somethingcom",
|
213
|
+
"test.@something.com",
|
214
|
+
"test@.something.com",
|
215
|
+
"te st@something.com",
|
216
|
+
" test@something.com",
|
217
|
+
"test@something.com ",
|
218
|
+
"TEST@SOMETHING.COM"
|
219
|
+
]
|
220
|
+
},
|
221
|
+
# generic .net
|
222
|
+
{ good: "test@something.net",
|
223
|
+
bad: [
|
224
|
+
"test@something.nt",
|
225
|
+
"test@something.ne",
|
226
|
+
"test@something.et",
|
227
|
+
"test@something.nte",
|
228
|
+
"test@something.nett",
|
229
|
+
"test@something.net",
|
230
|
+
"test@somethingnet"
|
231
|
+
]
|
232
|
+
},
|
233
|
+
# generic .org
|
234
|
+
{ good: "test@something.org",
|
235
|
+
bad: [
|
236
|
+
"test@something.or",
|
237
|
+
"test@something.og",
|
238
|
+
"test@something.ogr",
|
239
|
+
"test@something.orgg",
|
240
|
+
"test@somethingorg"
|
241
|
+
]
|
242
|
+
},
|
243
|
+
# generic .co.jp
|
244
|
+
{ good: "test@something.co.jp",
|
245
|
+
bad: [
|
246
|
+
"test@something.co.lp",
|
247
|
+
"test@something.cojp"
|
248
|
+
]
|
249
|
+
}
|
101
250
|
]
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
"test@
|
107
|
-
"
|
108
|
-
"test@
|
109
|
-
"test@
|
110
|
-
"test@
|
111
|
-
"test@something.
|
112
|
-
"test@something.co
|
113
|
-
"test@something.
|
114
|
-
"test@something.
|
115
|
-
"test@something.
|
116
|
-
|
117
|
-
"test@
|
118
|
-
"test@
|
119
|
-
"test@
|
120
|
-
"test@
|
121
|
-
"test@
|
122
|
-
"test@
|
123
|
-
"test@
|
124
|
-
"test@
|
125
|
-
"test@
|
126
|
-
"test@
|
127
|
-
"test@
|
128
|
-
"test@
|
129
|
-
"test@
|
130
|
-
"test@
|
131
|
-
"test@
|
132
|
-
|
133
|
-
"test@
|
134
|
-
"te'st@something.com",
|
135
|
-
"test@something.com\"",
|
136
|
-
"test@something.com\\",
|
137
|
-
"test@something.com,",
|
138
|
-
"test@something.com.",
|
139
|
-
"test@something,com",
|
140
|
-
"test@\#something.com",
|
141
|
-
"test@#something.com",
|
142
|
-
"test@@something.com",
|
143
|
-
"test\#@something.com",
|
144
|
-
"test@something..com",
|
145
|
-
"test@somethingcom",
|
146
|
-
"test.@something.com",
|
147
|
-
|
148
|
-
"te st@something.com",
|
149
|
-
" test@something.com",
|
150
|
-
"test@something.com ",
|
151
|
-
"TEST@SOMETHING.COM"
|
152
|
-
]
|
153
|
-
|
154
|
-
@good_net = "test@something.net"
|
155
|
-
@bad_net = [
|
156
|
-
"test@something.nt",
|
157
|
-
"test@something.ne",
|
158
|
-
"test@something.et",
|
159
|
-
"test@something.nte",
|
160
|
-
"test@something.nett",
|
161
|
-
"test@something.net",
|
162
|
-
"test@somethingnet"
|
163
|
-
]
|
164
|
-
|
165
|
-
@good_org = "test@something.org"
|
166
|
-
@bad_org = [
|
167
|
-
"test@something.or",
|
168
|
-
"test@something.og",
|
169
|
-
"test@something.ogr",
|
170
|
-
"test@something.orgg",
|
171
|
-
"test@somethingorg"
|
172
|
-
]
|
173
|
-
|
174
|
-
@good_comcast = "test@comcast.net"
|
175
|
-
@bad_comcast = [
|
176
|
-
"test@comacast.net",
|
177
|
-
"test@comcastn.et",
|
178
|
-
"test@comcat.net",
|
179
|
-
"test@cmcast.net"
|
180
|
-
]
|
181
|
-
|
182
|
-
@good_sbcglobal = "test@sbcglobal.net"
|
183
|
-
@bad_sbcglobal = [
|
184
|
-
"test@sbcgloba.net",
|
185
|
-
"test@sbcglobl.net"
|
186
|
-
]
|
187
|
-
|
188
|
-
@good_gm = "test@gm.com"
|
189
|
-
@bad_gm = ["test@gm.com"]
|
190
|
-
|
191
|
-
@good_gmail_with_dots = "te.st@gmail.com"
|
192
|
-
@bad_gmail_with_dots = ["te.st@gmail.com"]
|
193
|
-
|
194
|
-
@good_gmail_with_plus = "test+spamfilter@gmail.com"
|
195
|
-
@bad_gmail_with_plus = ["test+spamfilter@gmail.com"]
|
196
|
-
|
197
|
-
@good_tld_cn = "test@something.cn"
|
198
|
-
@bad_tld_cn = ["test@something.cn"]
|
199
|
-
|
200
|
-
@good_tld_co = "test@something.com.co"
|
201
|
-
@bad_tld_co = ["test@something.com.co"]
|
202
|
-
|
203
|
-
@good_random_co = "test@something.co"
|
204
|
-
@bad_random_co = ["test@something.co"]
|
205
|
-
|
206
|
-
@good_tld_gr = "test@something.gr"
|
207
|
-
@bad_tld_gr = ["test@something.gr"]
|
208
|
-
|
209
|
-
@good_tld_jp = "test@something.co.jp"
|
210
|
-
@bad_tld_jp = [
|
211
|
-
"test@something.co.lp",
|
212
|
-
"test@something.cojp"
|
251
|
+
|
252
|
+
|
253
|
+
# test that good address don't trip as false-positives
|
254
|
+
@good_examples = [
|
255
|
+
"test@gm.com",
|
256
|
+
"te.st@gmail.com",
|
257
|
+
"test.com@gmail.com",
|
258
|
+
"test.comisky@gmail.com",
|
259
|
+
"test+spamfilter@gmail.com",
|
260
|
+
"test@something.cn",
|
261
|
+
"test@something.com.co",
|
262
|
+
"test@something.co",
|
263
|
+
"test@something.gr",
|
264
|
+
"test@something.coop",
|
265
|
+
"test@aol.com",
|
266
|
+
"test@att.net",
|
267
|
+
"test@facebook.com",
|
268
|
+
"test@gmx.com",
|
269
|
+
"test@gao.gov",
|
270
|
+
"test@googlemail.com",
|
271
|
+
"test@hotmail.co.uk",
|
272
|
+
"test@live.com",
|
273
|
+
"test@mac.com",
|
274
|
+
"test@mail.com",
|
275
|
+
"test@me.com",
|
276
|
+
"test@msn.com",
|
277
|
+
"test@yahoo.co.uk",
|
278
|
+
"test@ya.ru",
|
279
|
+
"test@ymail.com",
|
280
|
+
"test@army.mil",
|
281
|
+
"test@anything.comcast.com",
|
282
|
+
"test@anything.comcastbiz.net"
|
213
283
|
]
|
214
|
-
|
215
|
-
|
216
|
-
# that they don't trip as false-positives
|
217
|
-
|
218
|
-
@good_tld_coop = "test@something.coop"
|
219
|
-
@bad_tld_coop = ["test@something.coop"]
|
220
|
-
|
221
|
-
@good_aol_com = "test@aol.com"
|
222
|
-
@bad_aol_com = ["test@aol.com"]
|
223
|
-
|
224
|
-
@good_att_net = "test@att.net"
|
225
|
-
@bad_att_net = ["test@att.net"]
|
226
|
-
|
227
|
-
@good_facebook_com = "test@facebook.com"
|
228
|
-
@bad_facebook_com = ["test@facebook.com"]
|
229
|
-
|
230
|
-
@good_gmx_com = "test@gmx.com"
|
231
|
-
@bad_gmx_com = ["test@gmx.com"]
|
232
|
-
|
233
|
-
@good_googlemail_com = "test@googlemail.com"
|
234
|
-
@bad_googlemail_com = ["test@googlemail.com"]
|
235
|
-
|
236
|
-
@good_hotmail_co_uk = "test@hotmail.co.uk"
|
237
|
-
@bad_hotmail_co_uk = ["test@hotmail.co.uk"]
|
238
|
-
|
239
|
-
@good_live_com = "test@live.com"
|
240
|
-
@bad_live_com = ["test@live.com"]
|
241
|
-
|
242
|
-
@good_mac_com = "test@mac.com"
|
243
|
-
@bad_mac_com = ["test@mac.com"]
|
244
|
-
|
245
|
-
@good_mail_com = "test@mail.com"
|
246
|
-
@bad_mail_com = ["test@mail.com"]
|
247
|
-
|
248
|
-
@good_me_com = "test@me.com"
|
249
|
-
@bad_me_com = ["test@me.com"]
|
250
|
-
|
251
|
-
@good_msn_com = "test@msn.com"
|
252
|
-
@bad_msn_com = ["test@msn.com"]
|
253
|
-
|
254
|
-
@good_verizon_net = "test@verizon.net"
|
255
|
-
@bad_verizon_net = ["test@verizon.net", "test@veizon.net", "test@verion.net", "test@verzon.net"]
|
256
|
-
|
257
|
-
@good_yahoo_co_uk = "test@yahoo.co.uk"
|
258
|
-
@bad_yahoo_co_uk = ["test@yahoo.co.uk"]
|
259
|
-
|
260
|
-
@good_ymail_com = "test@ymail.com"
|
261
|
-
@bad_ymail_com = ["test@ymail.com"]
|
262
|
-
|
263
|
-
@good_mil = "test@army.mil"
|
264
|
-
@bad_mil = ["test@army.mil"]
|
265
|
-
|
284
|
+
|
285
|
+
|
266
286
|
@all_tlds_fat_fingers_works_with = %w(ac ad ae af ag ai al am an ao aq ar as at au aw ax az ba bb bd be bf bg bh bi bj bm bn bo br bs bt bv bw by bz ca cc cd cf cg ch ci ck cl cn co cr cs cu cv cx cy cz dd de dj dk dm do dz ec ee eg eh er es eu fi fjfk fm fo fr ga gb gd ge gf gg gh gi gl gm gn gp gq gr gs gt gu gw gy hk hm hn hr ht hu id ie il im in io iq ir is it je jm jo jp ke kg kh ki km kn kp kr kw ky kz la lb lc li lk lr ls lt lu lv ly ma mc md me mg mh mk ml mn mp mq mr ms mt mu mv mw mx my mz na nc nf ng ni nl no np nr nu nz pa pe pf pg ph pk pl pm pn pr ps pt pw py qa re ro rs ru rw sa sb sc sd se sg sh si sj sk sl sm sn so sr ss st su sv sx sy sz tc td tf tg th tj tk tl tm tn to tp tr tt tv tw tz ua ug uk us uy uz va vc ve vg vi vn vu wf ws ye yt yu za zm zw aero asia biz cat com coop info int jobs mobi museum name net org post pro tel travel xxx edu gov mil)
|
267
287
|
@tlds_fat_fingers_gets_tripped_on = %w(cm et ne om)
|
268
|
-
|
269
288
|
end
|
270
289
|
|
271
|
-
def cases
|
272
|
-
[ "aol", "aol_com", "att_net", "com", "comcast", "facebook_com", "googlemail", "gm", "gmail", "gmail_with_dots", "gmail_with_plus",
|
273
|
-
"gmx_com", "googlemail_com", "hotmail", "hotmail_co_uk", "intl_gmail", "live_com", "mac_com", "mail_com", "me_com",
|
274
|
-
"mil", "msn_com", "net", "org", "random_co", "sbcglobal", "tld_cn", "tld_co", "tld_coop", "tld_gr", "tld_jp",
|
275
|
-
"verizon_net", "yahoo", "yahoo_co_uk", "ymail_com" ]
|
276
|
-
end
|
277
290
|
|
278
291
|
def test_that_emails_get_fixed
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
puts "#{i} - Failed on '#{email}'"
|
284
|
-
end
|
285
|
-
assert_equal eval("@good_"+test), email.clean_up_typoed_email
|
286
|
-
i += 1
|
292
|
+
@replacement_examples.each do |example|
|
293
|
+
example[:bad].each do |email|
|
294
|
+
# puts "- Failed on '#{email}'. Expected #{example[:good]}" if example[:good] != email.clean_up_typoed_email
|
295
|
+
assert_equal example[:good], email.clean_up_typoed_email
|
287
296
|
end
|
288
297
|
end
|
289
298
|
end
|
290
299
|
|
291
|
-
def
|
292
|
-
|
293
|
-
assert_equal
|
300
|
+
def test_that_false_positives_dont_get_tripped
|
301
|
+
@good_examples.each do |email|
|
302
|
+
assert_equal email, email.clean_up_typoed_email
|
294
303
|
end
|
295
304
|
end
|
296
305
|
|
@@ -305,5 +314,4 @@ class StringTest < MiniTest::Unit::TestCase
|
|
305
314
|
refute_equal "test@something.#{tld}", "test@something.#{tld}".clean_up_typoed_email
|
306
315
|
end
|
307
316
|
end
|
308
|
-
|
309
317
|
end
|
metadata
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fat_fingers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.27
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Charlie Park
|
8
|
+
- Ben Rugg
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date:
|
12
|
+
date: 2017-06-20 00:00:00.000000000 Z
|
12
13
|
dependencies: []
|
13
14
|
description: Makes sure users don't accidentally create an account for the wrong e-mail
|
14
15
|
address. Because 'gmial' isn't actually what they meant to type. Similarly, 'yaho.com',
|
@@ -42,7 +43,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
42
43
|
version: '0'
|
43
44
|
requirements: []
|
44
45
|
rubyforge_project:
|
45
|
-
rubygems_version: 2.
|
46
|
+
rubygems_version: 2.6.12
|
46
47
|
signing_key:
|
47
48
|
specification_version: 4
|
48
49
|
summary: Clean up e-mail strings when the user's made a typo (like 'gmail.cmo').
|