fat_fingers 0.1.15 → 0.1.16

Sign up to get free protection for your applications and to get access to all the features.
data/lib/fat_fingers.rb CHANGED
@@ -58,12 +58,12 @@ protected
58
58
  end
59
59
 
60
60
  def clean_up_funky_coms
61
- gsub(/\.c*(c|i|l|m|n|o|p|0)*m+o*$/,".com").
61
+ gsub(/\.c*(c|ci|coi|l|m|n|o|op|cp|0)*m+o*$/,".com").
62
62
  gsub(/\.(c|v|x)o+(m|n)$/,".com")
63
63
  end
64
64
 
65
65
  def clean_up_funky_nets
66
- gsub(/\.n*t*e*t*$/, ".net")
66
+ gsub(/\.(nte*|n*et*)$/, ".net")
67
67
  end
68
68
 
69
69
  def clean_up_funky_orgs
@@ -75,7 +75,7 @@ protected
75
75
  end
76
76
 
77
77
  def clean_up_hotmail
78
- gsub(/@h(o|p)*y*t*o*m*(a|i|k|l)*\./,"@hotmail.")
78
+ gsub(/@h(o|p)*y*t*o*a*m*(a|i|k|l)*\./,"@hotmail.")
79
79
  end
80
80
 
81
81
  def clean_up_yahoo
@@ -83,8 +83,8 @@ protected
83
83
  end
84
84
 
85
85
  def clean_up_other_providers
86
- gsub(/@coma*cas*t.net/,"@comcast.net").
87
- gsub(/@sbcgloba.net/, "@sbcglobal.net")
86
+ gsub(/@co*ma*cas*t\.net/,"@comcast.net").
87
+ gsub(/@sbcglob(a|l)\.net/, "@sbcglobal.net")
88
88
  end
89
89
 
90
90
  def add_a_period_if_they_forgot_it
@@ -56,6 +56,7 @@ class StringTest < MiniTest::Unit::TestCase
56
56
 
57
57
  @good_hotmail = "test@hotmail.com"
58
58
  @bad_hotmail = [
59
+ "test@hotamail.com",
59
60
  "test@htmail.com",
60
61
  "test@hotmaill.com",
61
62
  "test@hotmaik.com",
@@ -138,12 +139,14 @@ class StringTest < MiniTest::Unit::TestCase
138
139
  @bad_comcast = [
139
140
  "test@comacast.net",
140
141
  "test@comcastn.et",
141
- "test@comcat.net"
142
+ "test@comcat.net",
143
+ "test@cmcast.net"
142
144
  ]
143
145
 
144
146
  @good_sbcglobal = "test@sbcglobal.net"
145
147
  @bad_sbcglobal = [
146
- "test@sbcgloba.net"
148
+ "test@sbcgloba.net",
149
+ "test@sbcglobl.net"
147
150
  ]
148
151
 
149
152
  @good_gm = "test@gm.com"
@@ -173,13 +176,67 @@ class StringTest < MiniTest::Unit::TestCase
173
176
  "test@something.cojp"
174
177
  ]
175
178
 
179
+ # these are actually good; mainly here to make sure
180
+ # that they don't trip as false-positives
181
+
176
182
  @good_tld_coop = "test@something.coop"
177
183
  @bad_tld_coop = ["test@something.coop"]
178
184
 
185
+ @good_aol_com = "test@aol.com"
186
+ @bad_aol_com = ["test@aol.com"]
187
+
188
+ @good_att_net = "test@att.net"
189
+ @bad_att_net = ["test@att.net"]
190
+
191
+ @good_facebook_com = "test@facebook.com"
192
+ @bad_facebook_com = ["test@facebook.com"]
193
+
194
+ @good_gmx_com = "test@gmx.com"
195
+ @bad_gmx_com = ["test@gmx.com"]
196
+
197
+ @good_googlemail_com = "test@googlemail.com"
198
+ @bad_googlemail_com = ["test@googlemail.com"]
199
+
200
+ @good_hotmail_co_uk = "test@hotmail.co.uk"
201
+ @bad_hotmail_co_uk = ["test@hotmail.co.uk"]
202
+
203
+ @good_live_com = "test@live.com"
204
+ @bad_live_com = ["test@live.com"]
205
+
206
+ @good_mac_com = "test@mac.com"
207
+ @bad_mac_com = ["test@mac.com"]
208
+
209
+ @good_mail_com = "test@mail.com"
210
+ @bad_mail_com = ["test@mail.com"]
211
+
212
+ @good_me_com = "test@me.com"
213
+ @bad_me_com = ["test@me.com"]
214
+
215
+ @good_msn_com = "test@msn.com"
216
+ @bad_msn_com = ["test@msn.com"]
217
+
218
+ @good_verizon_net = "test@verizon.net"
219
+ @bad_verizon_net = ["test@verizon.net"]
220
+
221
+ @good_yahoo_co_uk = "test@yahoo.co.uk"
222
+ @bad_yahoo_co_uk = ["test@yahoo.co.uk"]
223
+
224
+ @good_ymail_com = "test@ymail.com"
225
+ @bad_ymail_com = ["test@ymail.com"]
226
+
227
+ @good_mil = "test@army.mil"
228
+ @bad_mil = ["test@army.mil"]
229
+
230
+ @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)
231
+ @tlds_fat_fingers_gets_tripped_on = %w(cm et ne om)
232
+
179
233
  end
180
234
 
181
235
  def cases
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"]
236
+ [ "gmail", "intl_gmail", "yahoo", "hotmail", "com", "net", "org", "comcast", "sbcglobal", "gm", "tld_cn", "tld_co",
237
+ "random_co", "tld_gr", "tld_jp", "tld_coop", "gmail_with_dots", "gmail_with_plus", "aol_com", "att_net", "facebook_com",
238
+ "gmx_com", "googlemail_com", "hotmail_co_uk", "live_com", "mac_com", "mail_com", "me_com", "msn_com", "verizon_net",
239
+ "yahoo_co_uk", "ymail_com", "mil"]
183
240
  end
184
241
 
185
242
  def test_that_emails_get_fixed
@@ -200,4 +257,11 @@ class StringTest < MiniTest::Unit::TestCase
200
257
  assert_equal eval("@good_"+test), eval("@good_"+test).clean_up_typoed_email
201
258
  end
202
259
  end
260
+
261
+ def test_that_tlds_do_not_get_broken
262
+ @all_tlds_fat_fingers_works_with.each do |tld|
263
+ assert_equal "test@something.#{tld}", "test@something.#{tld}".clean_up_typoed_email
264
+ end
265
+ end
266
+
203
267
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fat_fingers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.15
4
+ version: 0.1.16
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: