fat_fingers 0.1.11 → 0.1.12

Sign up to get free protection for your applications and to get access to all the features.
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
+ handle_different_country_tlds.
18
19
  fix_coms_with_appended_letters.
19
20
  clean_up_funky_coms.
20
21
  clean_up_funky_nets.
@@ -40,9 +41,13 @@ protected
40
41
  # can't do "o.gr" => ".org", as ".gr" is a valid TLD
41
42
  end
42
43
 
44
+ def handle_different_country_tlds
45
+ gsub(/\.couk$/, ".co.uk")
46
+ end
47
+
43
48
  def fix_coms_with_appended_letters
44
- gsub(/\.couk$/, ".co.uk").
45
- gsub(/\.com(.)*$/, ".com").
49
+ gsub(/\.com\.$/, ".com").
50
+ gsub(/\.com[^\.].*$/, ".com").
46
51
  gsub(/\.co[^op]$/, ".com")
47
52
  end
48
53
 
@@ -63,34 +63,34 @@ class StringTest < MiniTest::Unit::TestCase
63
63
  "test@something.coom",
64
64
  "test@something.comm",
65
65
  "test@something.comme",
66
- "test@something.co,",
66
+ "test@something.co,", # assume that someone entering this in *meant* to type in '.com'
67
+ "test@something.co.",
67
68
  "test@something.co<",
69
+ "test@something.co>",
68
70
  "test@something.cmo",
69
71
  "test@something.cm",
70
72
  "test@something.om",
71
73
 
72
- "test@something.ocm",
73
- "test@something.con",
74
- "test@something.cmo",
75
- "test@something.copm",
76
- "test@something.xom",
77
- "test@something.vom",
78
- "test@something.cok",
79
- "test@something.comn",
80
- "test@something.comj",
74
+ "test@something.c0m",
81
75
  "test@something.coim",
82
- "test@something.cpm",
76
+ "test@something.cok",
83
77
  "test@something.colm",
78
+ "test@something.comj",
79
+ "test@something.comn",
80
+ "test@something.con",
84
81
  "test@something.conm",
85
82
  "test@something.coom",
86
- "test@something.c0m",
83
+ "test@something.copm",
84
+ "test@something.cpm",
85
+ "test@something.ocm",
86
+ "test@something.vom",
87
+ "test@something.xom",
87
88
 
88
89
  "test@something.com'",
89
90
  "te'st@something.com",
90
91
  "test@something.com\"",
91
92
  "test@something.com\\",
92
93
  "test@something.com,",
93
- "test@something.co,",
94
94
  "test@something.com.",
95
95
  "test@something,com",
96
96
  "test@\#something.com",
@@ -149,8 +149,11 @@ class StringTest < MiniTest::Unit::TestCase
149
149
  @good_tld_cn = "test@something.cn"
150
150
  @bad_tld_cn = ["test@something.cn"]
151
151
 
152
- @good_tld_co = "test@something.co"
153
- @bad_tld_co = ["test@something.co"]
152
+ @good_tld_co = "test@something.com.co"
153
+ @bad_tld_co = ["test@something.com.co"]
154
+
155
+ @good_random_co = "test@something.co"
156
+ @bad_random_co = ["test@something.co"]
154
157
 
155
158
  @good_tld_gr = "test@something.gr"
156
159
  @bad_tld_gr = ["test@something.gr"]
@@ -161,13 +164,18 @@ class StringTest < MiniTest::Unit::TestCase
161
164
  end
162
165
 
163
166
  def cases
164
- ["gmail", "intl_gmail", "yahoo", "hotmail", "com", "net", "org", "comcast", "sbcglobal", "gm", "tld_cn", "tld_co", "tld_gr", "tld_coop", "gmail_with_dots", "gmail_with_plus"]
167
+ ["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"]
165
168
  end
166
169
 
167
170
  def test_that_emails_get_fixed
171
+ i = 1
168
172
  cases.each do |test|
169
173
  eval("@bad_"+test).each do |email|
174
+ unless email.clean_up_typoed_email == (processed = eval("@good_"+test))
175
+ puts "#{i} - Failed on '#{email}'"
176
+ end
170
177
  assert_equal eval("@good_"+test), email.clean_up_typoed_email
178
+ i += 1
171
179
  end
172
180
  end
173
181
  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.11
4
+ version: 0.1.12
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: