email_repair 1.0.0 → 2.0.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 +5 -5
- data/README.md +68 -2
- data/lib/email_repair/constants.rb +2 -2
- data/lib/email_repair/version.rb +1 -1
- data/spec/lib/email_repair/constants_spec.rb +10 -0
- metadata +63 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 5ee85877aa4e7df7d05e7084df4553209c6de6f4d555fe16ddd13070628f5ca5
|
4
|
+
data.tar.gz: e1ace67bbe8264421ae9c73dd77a7dde04097d694a90fcfae608b21e49d8e3be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 58d21040563feed012c9218fb37f94173b895718ba103ff7d626e4dc3edb9c3c2c76f1f4395462522045b8eb88ad2ba393c81e995e709daaf663657a617c6e17
|
7
|
+
data.tar.gz: 66a4f543f9db2cf547dacfdb4eed8d55d1e9a98a9d6a9b7a2d5ca3ad9461769857458ccf18f02ff3faedc9b508634e0b36e4db13e681ea6f3444786d0fa133fe
|
data/README.md
CHANGED
@@ -4,7 +4,8 @@
|
|
4
4
|
[](https://travis-ci.org/ChalkSchools/email-repair)
|
5
5
|
[](https://coveralls.io/r/ChalkSchools/email-repair?branch=master)
|
6
6
|
|
7
|
-
|
7
|
+
Email Repair is a utility for sanitizing and validating user-provided email
|
8
|
+
address.
|
8
9
|
|
9
10
|
## Installation
|
10
11
|
|
@@ -22,7 +23,72 @@ Or install it yourself as:
|
|
22
23
|
|
23
24
|
## Usage
|
24
25
|
|
25
|
-
|
26
|
+
```ruby
|
27
|
+
require 'email_repair'
|
28
|
+
require 'ostruct'
|
29
|
+
|
30
|
+
EmailRepair::Mechanic.new.repair('blah@gmail')
|
31
|
+
# "blah@gmail.com"
|
32
|
+
|
33
|
+
EmailRepair::Mechanic.new.repair_all(%w[One@@two.com bleep@blop plooooooop])
|
34
|
+
# <OpenStruct sanitized_emails=["one@two.com"], invalid_emails=["bleep@blop", "plooooooop"]>
|
35
|
+
```
|
36
|
+
|
37
|
+
### Public Methods
|
38
|
+
|
39
|
+
#### EmailRepair::Mechanic#repair(email)
|
40
|
+
|
41
|
+
Takes a single email address, applies the available repairs to it and returns
|
42
|
+
the repaired email. If the email cannot be repaired, `nil` is returned instead.
|
43
|
+
|
44
|
+
#### EmailRepair::Mechanic#repair_all(emails)
|
45
|
+
|
46
|
+
Takes an array of emails, applies available repairs to each email and returns an
|
47
|
+
`OpenStruct` containing keys `sanitized_emails:` with a unique array of the
|
48
|
+
emails that were able to be repaired, and `invalid_emails:` with unique array of
|
49
|
+
the emails that were unable to be repaired
|
50
|
+
|
51
|
+
#### EmailRepair::Constants::email_regex
|
52
|
+
|
53
|
+
Returns a regular expression to be used to validate user-supplied email
|
54
|
+
addresses.
|
55
|
+
|
56
|
+
### Available Repairs
|
57
|
+
|
58
|
+
#### CommonMistakeRepair
|
59
|
+
|
60
|
+
Repairs common email typos:
|
61
|
+
* downcases the email
|
62
|
+
* removes white space
|
63
|
+
* removes duplicate @ symbols
|
64
|
+
* replaces `.c0m` with `.com`
|
65
|
+
* replaces commas with periods
|
66
|
+
|
67
|
+
#### CommonDomainSuffixRepair
|
68
|
+
|
69
|
+
Adds missing top-level domain for common email domains. For example, it replaces
|
70
|
+
`blah@gmail` with `blah@gmail.com`.
|
71
|
+
|
72
|
+
#### CommonDomainPeriodAdder
|
73
|
+
|
74
|
+
Adds missing period between the domain and top-level domain for common email
|
75
|
+
domains. For example, it replaces `blah@gmailcom` with `blah@gmail.com`.
|
76
|
+
|
77
|
+
#### CommonDomainAtAdder
|
78
|
+
|
79
|
+
Replaces '#', '.', or '-', with '@', or adds missing @ symbol for common
|
80
|
+
domains. For example, it replaces `blahgmail.com` and `blah#gmail.com` with
|
81
|
+
`blah@gmail.com`.
|
82
|
+
|
83
|
+
#### CommonDomainSwapRepair
|
84
|
+
|
85
|
+
Fixes swapped letters ('ia' instead of 'ai') in common domains. For example, it
|
86
|
+
replaces `blah@gmial.com` with `blah@gmail.com`.
|
87
|
+
|
88
|
+
#### EmailRegexRepair
|
89
|
+
|
90
|
+
Extracts the email address from strings that contain other text. For example, it
|
91
|
+
replaces `blah <blah@email.com>` with `blah@email.com`.
|
26
92
|
|
27
93
|
## Contributing
|
28
94
|
|
@@ -4,7 +4,7 @@ module EmailRepair
|
|
4
4
|
def email_regex
|
5
5
|
local_part_regex = "[#{valid_chars}]" \
|
6
6
|
"([#{valid_chars_with_dot}]*[#{valid_chars}])?"
|
7
|
-
/#{local_part_regex}@(?:[a-
|
7
|
+
/#{local_part_regex}@(?:[a-zA-Z0-9\-]+\.)+(?:[a-zA-Z]{2,24})/
|
8
8
|
end
|
9
9
|
|
10
10
|
private
|
@@ -14,7 +14,7 @@ module EmailRepair
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def valid_chars
|
17
|
-
'a-
|
17
|
+
'a-zA-Z0-9_%\+\-\''
|
18
18
|
end
|
19
19
|
end
|
20
20
|
end
|
data/lib/email_repair/version.rb
CHANGED
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:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Holman Gao
|
@@ -9,8 +9,64 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
13
|
-
dependencies:
|
12
|
+
date: 2023-05-01 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: coveralls
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: 0.8.23
|
21
|
+
type: :development
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: 0.8.23
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: rake
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - "~>"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 13.0.6
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: 13.0.6
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: rspec
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: 3.12.0
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - "~>"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: 3.12.0
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: rubocop
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 1.50.2
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 1.50.2
|
14
70
|
description:
|
15
71
|
email:
|
16
72
|
- holman@golmansax.com
|
@@ -25,6 +81,7 @@ files:
|
|
25
81
|
- lib/email_repair/constants.rb
|
26
82
|
- lib/email_repair/mechanic.rb
|
27
83
|
- lib/email_repair/version.rb
|
84
|
+
- spec/lib/email_repair/constants_spec.rb
|
28
85
|
- spec/lib/email_repair/mechanic_spec.rb
|
29
86
|
- spec/spec_helper.rb
|
30
87
|
homepage: https://github.com/ChalkSchools/email-repair
|
@@ -46,11 +103,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
46
103
|
- !ruby/object:Gem::Version
|
47
104
|
version: '0'
|
48
105
|
requirements: []
|
49
|
-
|
50
|
-
rubygems_version: 2.6.14
|
106
|
+
rubygems_version: 3.4.2
|
51
107
|
signing_key:
|
52
108
|
specification_version: 4
|
53
109
|
summary: Library to fix invalid emails
|
54
110
|
test_files:
|
55
|
-
- spec/
|
111
|
+
- spec/lib/email_repair/constants_spec.rb
|
56
112
|
- spec/lib/email_repair/mechanic_spec.rb
|
113
|
+
- spec/spec_helper.rb
|