fat_fingers 0.1.22 → 0.1.23

Sign up to get free protection for your applications and to get access to all the features.
data/lib/fat_fingers.rb CHANGED
@@ -22,6 +22,7 @@ class String
22
22
  clean_up_funky_nets.
23
23
  clean_up_funky_orgs.
24
24
  clean_up_gmail.
25
+ clean_up_googlemail.
25
26
  clean_up_hotmail.
26
27
  clean_up_yahoo.
27
28
  clean_up_other_providers.
@@ -71,8 +72,12 @@ protected
71
72
  gsub(/\.o+g*r*g*$/, ".org") # require the o, to not false-positive .gr e-mails
72
73
  end
73
74
 
75
+ def clean_up_googlemail
76
+ gsub(/@(g(o)*)*le(n|m)*(a|i|l)+m*(a|i|k|l)*\./,"@googlemail.")
77
+ end
78
+
74
79
  def clean_up_gmail
75
- gsub(/@g(n|m)*(a|i|l)+m*(a|i|l)*\./,"@gmail.")
80
+ gsub(/@g(n|m)*(a|i|l)+m*(a|i|k|l)*\./,"@gmail.")
76
81
  end
77
82
 
78
83
  def clean_up_hotmail
@@ -90,7 +95,7 @@ protected
90
95
  end
91
96
 
92
97
  def clean_up_known_coms
93
- gsub(/(aol|gmail|hotmail|yahoo).co$/, '\1.com')
98
+ gsub(/(aol|googlemail|gmail|hotmail|yahoo).co$/, '\1.com')
94
99
  end
95
100
 
96
101
  def add_a_period_if_they_forgot_it
@@ -8,6 +8,7 @@ class StringTest < MiniTest::Unit::TestCase
8
8
  @good_gmail = "test@gmail.com"
9
9
  @bad_gmail = [
10
10
  "test@gmai.com",
11
+ "test@gmaii.com",
11
12
  "test@gmal.com",
12
13
  "test@gmaal.com",
13
14
  "test@gmil.com",
@@ -39,6 +40,28 @@ class StringTest < MiniTest::Unit::TestCase
39
40
  "test@gmail.couk"
40
41
  ]
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
+
42
65
  @good_yahoo = "test@yahoo.com"
43
66
  @bad_yahoo = [
44
67
  "test@aho.com",
@@ -245,10 +268,10 @@ class StringTest < MiniTest::Unit::TestCase
245
268
  end
246
269
 
247
270
  def cases
248
- [ "gmail", "intl_gmail", "yahoo", "hotmail", "aol", "com", "net", "org", "comcast", "sbcglobal", "gm", "tld_cn", "tld_co",
249
- "random_co", "tld_gr", "tld_jp", "tld_coop", "gmail_with_dots", "gmail_with_plus", "aol_com", "att_net", "facebook_com",
250
- "gmx_com", "googlemail_com", "hotmail_co_uk", "live_com", "mac_com", "mail_com", "me_com", "msn_com", "verizon_net",
251
- "yahoo_co_uk", "ymail_com", "mil"]
271
+ [ "aol", "aol_com", "att_net", "com", "comcast", "facebook_com", "googlemail", "gm", "gmail", "gmail_with_dots", "gmail_with_plus",
272
+ "gmx_com", "googlemail_com", "hotmail", "hotmail_co_uk", "intl_gmail", "live_com", "mac_com", "mail_com", "me_com",
273
+ "mil", "msn_com", "net", "org", "random_co", "sbcglobal", "tld_cn", "tld_co", "tld_coop", "tld_gr", "tld_jp",
274
+ "verizon_net", "yahoo", "yahoo_co_uk", "ymail_com" ]
252
275
  end
253
276
 
254
277
  def test_that_emails_get_fixed
@@ -276,4 +299,10 @@ class StringTest < MiniTest::Unit::TestCase
276
299
  end
277
300
  end
278
301
 
302
+ def test_the_four_obscure_tlds_fat_fingers_doesnt_work_with
303
+ @tlds_fat_fingers_gets_tripped_on.each do |tld|
304
+ refute_equal "test@something.#{tld}", "test@something.#{tld}".clean_up_typoed_email
305
+ end
306
+ end
307
+
279
308
  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.22
4
+ version: 0.1.23
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-12-12 00:00:00.000000000 Z
12
+ date: 2014-02-16 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Makes sure users don't accidentally create an account for the wrong e-mail
15
15
  address. Because 'gmial' isn't actually what they meant to type. Similarly, 'yaho.com',