email_repair 0.0.3 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/email_repair/mechanic.rb +4 -2
- data/lib/email_repair/version.rb +1 -1
- data/spec/lib/email_repair/mechanic_spec.rb +12 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b4b69fd1e249e2e22790e3d2c4a1b504f2152bb9
|
4
|
+
data.tar.gz: b95be782fe298e8a3ec18cf89c6c89ac5a9f808a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7ad8b2396bc3dc7d7be9ac80ff29491dbe20f2cfe965a3bfdfe5a2c80980c945fce5f08c53e3b3af1c9effde8fc792a9df50127bd119df24b6aadebfc1351ef0
|
7
|
+
data.tar.gz: 4600961f8e96f3e06e6712fddb8a917212ec485699a30286272b4738373135d06df29b5273256bd33c836da06a854696d5b4ddd4eada8baacd944ae7365c64a3
|
@@ -12,6 +12,8 @@ module EmailRepair
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def repair_all(emails)
|
15
|
+
emails = emails.reject(&:nil?).map(&:strip).reject { |email| email == '' }
|
16
|
+
|
15
17
|
sanitized_emails = []
|
16
18
|
invalid_emails = []
|
17
19
|
|
@@ -26,8 +28,8 @@ module EmailRepair
|
|
26
28
|
end
|
27
29
|
|
28
30
|
OpenStruct.new(
|
29
|
-
sanitized_emails: sanitized_emails,
|
30
|
-
invalid_emails: invalid_emails,
|
31
|
+
sanitized_emails: sanitized_emails.uniq,
|
32
|
+
invalid_emails: invalid_emails.uniq,
|
31
33
|
)
|
32
34
|
end
|
33
35
|
|
data/lib/email_repair/version.rb
CHANGED
@@ -5,15 +5,25 @@ module EmailRepair
|
|
5
5
|
|
6
6
|
it 'sanitizes an array of emails and returns bulk results' do
|
7
7
|
mechanic = Mechanic.new
|
8
|
-
salvageable_emails = %w(One@@two.com three@four.com)
|
8
|
+
salvageable_emails = %w(One@@two.com three@four.com one@twO.com)
|
9
9
|
sanitized_emails = %w(one@two.com three@four.com)
|
10
|
-
bad_emails = %w(bleep@blop plooooooop)
|
10
|
+
bad_emails = %w(bleep@blop plooooooop plooOOooop)
|
11
11
|
|
12
12
|
result = mechanic.repair_all(salvageable_emails + bad_emails)
|
13
13
|
expect(result.sanitized_emails).to match_array sanitized_emails
|
14
14
|
expect(result.invalid_emails).to match_array bad_emails
|
15
15
|
end
|
16
16
|
|
17
|
+
it 'filters out nil and empty string emails before processing results' do
|
18
|
+
mechanic = Mechanic.new
|
19
|
+
emails = [nil, '', ' ', 'bleep@bloop.com']
|
20
|
+
|
21
|
+
result = mechanic.repair_all(emails)
|
22
|
+
|
23
|
+
expect(result.sanitized_emails).to eq ['bleep@bloop.com']
|
24
|
+
expect(result.invalid_emails).to eq []
|
25
|
+
end
|
26
|
+
|
17
27
|
end
|
18
28
|
|
19
29
|
describe Mechanic, '#repair' do
|
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.0
|
4
|
+
version: 0.1.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: 2016-06-
|
12
|
+
date: 2016-06-29 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description:
|
15
15
|
email:
|