email_repair 0.2.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/email_repair/mechanic.rb +7 -7
- data/lib/email_repair/version.rb +1 -1
- data/spec/lib/email_repair/mechanic_spec.rb +6 -8
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a87714cd558a4ce9a5ffe176b2dcfc379f2b771b
|
4
|
+
data.tar.gz: 8322e71366d7e121483b368cdfa83e235d413560
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8771c5ce3aa48dec34961e30285df05f14b1d99711772248f94306b23d573c5f5d4bc00ca8c1f9a5d50a2fa927b3504f55656176fb8664937a26249ecc6e93f7
|
7
|
+
data.tar.gz: 1c8f55a9e3e83df59cbb22d1994977455d904645701c2b685b48107985654e14a4a592d6ae3e518b04e56f5161334f6de279bd8cd1a89dd0c28be20d3dc153d5
|
@@ -42,10 +42,10 @@ module EmailRepair
|
|
42
42
|
class CommonMistakeRepair
|
43
43
|
def self.repair(email)
|
44
44
|
email.downcase
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
45
|
+
.gsub(/\s/, '')
|
46
|
+
.sub(/@+/, '@')
|
47
|
+
.sub(/\.c0m$/, '.com')
|
48
|
+
.sub(/,[a-z]{2,24}$/) { |m| m.sub(',', '.') }
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
@@ -58,7 +58,7 @@ module EmailRepair
|
|
58
58
|
|
59
59
|
class CommonDomainRepair
|
60
60
|
def self.repair(*)
|
61
|
-
|
61
|
+
raise 'not implemented'
|
62
62
|
end
|
63
63
|
|
64
64
|
def self.common_domains
|
@@ -78,7 +78,7 @@ module EmailRepair
|
|
78
78
|
class CommonDomainSuffixRepair < CommonDomainRepair
|
79
79
|
def self.repair(email)
|
80
80
|
common_domains.each do |name, suffix|
|
81
|
-
email = "#{email}.#{suffix}" if email.match(/#{name}$/)
|
81
|
+
email = "#{email}.#{suffix}" if email.match?(/#{name}$/)
|
82
82
|
end
|
83
83
|
email
|
84
84
|
end
|
@@ -100,7 +100,7 @@ module EmailRepair
|
|
100
100
|
punc_regex = /[.#-]#{name}.#{suffix}$/
|
101
101
|
if email.match(punc_regex)
|
102
102
|
email = email.sub(punc_regex, "@#{name}.#{suffix}")
|
103
|
-
elsif email.match(/[^@]#{name}.#{suffix}$/)
|
103
|
+
elsif email.match?(/[^@]#{name}.#{suffix}$/)
|
104
104
|
email = email.sub(/#{name}.#{suffix}$/, "@#{name}.#{suffix}")
|
105
105
|
end
|
106
106
|
end
|
data/lib/email_repair/version.rb
CHANGED
@@ -2,12 +2,11 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
module EmailRepair
|
4
4
|
describe Mechanic, '#repair_all' do
|
5
|
-
|
6
5
|
it 'sanitizes an array of emails and returns bulk results' do
|
7
6
|
mechanic = Mechanic.new
|
8
|
-
salvageable_emails = %w
|
9
|
-
sanitized_emails = %w
|
10
|
-
bad_emails = %w
|
7
|
+
salvageable_emails = %w[One@@two.com three@four.com one@twO.com]
|
8
|
+
sanitized_emails = %w[one@two.com three@four.com]
|
9
|
+
bad_emails = %w[bleep@blop plooooooop plooOOooop]
|
11
10
|
|
12
11
|
result = mechanic.repair_all(salvageable_emails + bad_emails)
|
13
12
|
expect(result.sanitized_emails).to match_array sanitized_emails
|
@@ -23,7 +22,6 @@ module EmailRepair
|
|
23
22
|
expect(result.sanitized_emails).to eq ['bleep@bloop.com']
|
24
23
|
expect(result.invalid_emails).to eq []
|
25
24
|
end
|
26
|
-
|
27
25
|
end
|
28
26
|
|
29
27
|
describe Mechanic, '#repair' do
|
@@ -34,7 +32,7 @@ module EmailRepair
|
|
34
32
|
# http://www.stuffaboutcode.com/2013/02/validating-email-address-bloody.html
|
35
33
|
# List of longest TLDs
|
36
34
|
# https://jasontucker.blog/8945/what-is-the-longest-tld-you-can-get-for-a-domain-name
|
37
|
-
good_emails = %w
|
35
|
+
good_emails = %w[
|
38
36
|
b@b.com
|
39
37
|
lobatifricha@gmail.com
|
40
38
|
mrspicy+whocares@whatevs.com
|
@@ -43,7 +41,7 @@ module EmailRepair
|
|
43
41
|
b@mps.school
|
44
42
|
b@kickstarter.engineering
|
45
43
|
b@joyful.christmas
|
46
|
-
|
44
|
+
]
|
47
45
|
|
48
46
|
good_emails.each do |good_email|
|
49
47
|
expect(mechanic.repair(good_email)).to eq good_email
|
@@ -73,7 +71,7 @@ module EmailRepair
|
|
73
71
|
end
|
74
72
|
|
75
73
|
it 'adds missing .com' do
|
76
|
-
no_com_mails = %w
|
74
|
+
no_com_mails = %w[blah@gmail bloo@yahoo blee@hotmail]
|
77
75
|
no_com_mails.each do |no_com_mail|
|
78
76
|
expect(mechanic.repair(no_com_mail)).to eq "#{no_com_mail}.com"
|
79
77
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: email_repair
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Holman Gao
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2018-03-28 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description:
|
15
15
|
email:
|
@@ -47,7 +47,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
47
47
|
version: '0'
|
48
48
|
requirements: []
|
49
49
|
rubyforge_project:
|
50
|
-
rubygems_version: 2.6.
|
50
|
+
rubygems_version: 2.6.14
|
51
51
|
signing_key:
|
52
52
|
specification_version: 4
|
53
53
|
summary: Library to fix invalid emails
|