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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/fat_fingers.rb +18 -15
  3. data/test/test_fat_fingers.rb +284 -276
  4. metadata +4 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e922507178b036835d71bd7d4c0d680c1d52f4d8
4
- data.tar.gz: 3714a5a6462e4a02146633d7a929d8f1fa90cb24
3
+ metadata.gz: 29e576d4b41299eaa24248053522b0f1ab1d2549
4
+ data.tar.gz: 8b7ce69476dd10a7276d798e2e6bfffcd2dcd8c2
5
5
  SHA512:
6
- metadata.gz: e4496124e2e942b80b98d2a6364b98b21723d6c85950148bd67b52216ab7fe70a9670ffa3ad682f687c61c10ed00f506610ab868aa127ae5c5b128ffe5c50943
7
- data.tar.gz: bc88b36848aaf18645cd916e5d42889d57c9ab8dcd93407774d0f2239306da390985f54a15016b6c04d128963600cc8d56d6326e3f5752284a78ef2719b6072b
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
- remove_period_before_at_sign.
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 remove_period_before_at_sign
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[^\.].*$/, ".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(/\.o+g*r*g*$/, ".org") # require the o, to not false-positive .gr e-mails
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(/@(g(o)*)*le(n|m)*(a|i|l)+m*(a|i|k|l)*\./,"@googlemail.")
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(n|m)*(a|i|l)+m*(a|i|k|l)*\./,"@gmail.")
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)*y*t*o*a*m*t*(a|i|k|l)*\./,"@hotmail.")
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(/@y*a*h*a*o*\./,"@yahoo.")
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*ma*cas*t\.net/,"@comcast.net").
98
- gsub(/@sbcglob(a|l)\.net/, "@sbcglobal.net").
99
- gsub(/@ver*i*z*on\.net/,"@verizon.net")
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).co$/, '\1.com')
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
@@ -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
- @good_gmail = "test@gmail.com"
9
- @bad_gmail = [
10
- "test@gmai.com",
11
- "test@gmaii.com",
12
- "test@gmal.com",
13
- "test@gmaal.com",
14
- "test@gmil.com",
15
- "test@gmial.com",
16
- "test@gmali.com",
17
- "test@gmila.com",
18
- "test@gmaill.com",
19
- "test@gamil.com",
20
- "test@gnail.com",
21
- "test@gmailc.om",
22
- "test.@gmail.com",
23
- "test.@gmail.co"
24
- ]
25
-
26
- @good_intl_gmail = "test@gmail.co.uk"
27
- @bad_intl_gmail = [
28
- "test@gmai.co.uk",
29
- "test@gmal.co.uk",
30
- "test@gmaal.co.uk",
31
- "test@gmil.co.uk",
32
- "test@gmial.co.uk",
33
- "test@gmali.co.uk",
34
- "test@gmila.co.uk",
35
- "test@gmaill.co.uk",
36
- "test@gamil.co.uk",
37
- "test@gnail.co.uk",
38
- "test@gmail.co.um",
39
- "test@gmail.o.uk",
40
- "test@gmail.couk"
41
- ]
42
-
43
- @good_googlemail = "test@googlemail.com"
44
- @bad_googlemail = [
45
- "test@googlemai.com",
46
- "test@googlemaii.com",
47
- "test@googlemal.com",
48
- "test@googlemaal.com",
49
- "test@googlemil.com",
50
- "test@googlemial.com",
51
- "test@googlemali.com",
52
- "test@googlemila.com",
53
- "test@googlemaill.com",
54
- "test@googleamil.com",
55
- "test@googlenail.com",
56
- "test@googlemailc.om",
57
- "test.@googlemail.com",
58
- "test.@googlemail.co",
59
- "test.@gogglemaii.com",
60
- "test.@gogglemail.com",
61
- "test.@gogolemail.com",
62
- "test.@goooglemail.com"
63
- ]
64
-
65
- @good_yahoo = "test@yahoo.com"
66
- @bad_yahoo = [
67
- "test@aho.com",
68
- "test@ahoo.com",
69
- "test@ahoo.com",
70
- "test@yaho.com",
71
- "test@yahooo.com",
72
- "test@yhao.com",
73
- "test@yhaoo.com",
74
- "test@yho.com",
75
- "test@yhooo.com",
76
- "test@yao.com",
77
- "test@yaooo.com",
78
- "test@yahooc.om",
79
- "test@yahoo.co"
80
- ]
81
-
82
- @good_hotmail = "test@hotmail.com"
83
- @bad_hotmail = [
84
- "test@hotamail.com",
85
- "test@htmail.com",
86
- "test@hotmaill.com",
87
- "test@hotmaik.com",
88
- "test@hoymail.com",
89
- "test@hptmail.com",
90
- "test@htomali.com",
91
- "test@homtail.com",
92
- "test@hotmail.co"
93
- ]
94
-
95
- @good_aol = "test@aol.com"
96
- @bad_aol = [
97
- "test@aol.co",
98
- "test@aol.co",
99
- "test@aol.cm",
100
- "test@ol.com"
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
- @good_com = "test@something.com"
104
- @bad_com = [
105
- "test@somethingc.om",
106
- "test@something.coom",
107
- "test@something.comm",
108
- "test@something.comme",
109
- "test@something.co,", # assume that someone entering this in *meant* to type in '.com'
110
- "test@something.co.",
111
- "test@something.co<",
112
- "test@something.co>",
113
- "test@something.cmo",
114
- "test@something.cm",
115
- "test@something.om",
116
-
117
- "test@something.c0m",
118
- "test@something.coim",
119
- "test@something.cok",
120
- "test@something.colm",
121
- "test@something.clom",
122
- "test@something.comj",
123
- "test@something.comn",
124
- "test@something.con",
125
- "test@something.conm",
126
- "test@something.coom",
127
- "test@something.copm",
128
- "test@something.cpm",
129
- "test@something.ocm",
130
- "test@something.vom",
131
- "test@something.xom",
132
-
133
- "test@something.com'",
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
- # these are actually good; mainly here to make sure
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
- i = 1
280
- cases.each do |test|
281
- eval("@bad_"+test).each do |email|
282
- unless email.clean_up_typoed_email == (processed = eval("@good_"+test))
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 test_that_good_emails_do_not_get_broken
292
- cases.each do |test|
293
- assert_equal eval("@good_"+test), eval("@good_"+test).clean_up_typoed_email
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.26
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: 2014-08-20 00:00:00.000000000 Z
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.2.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').