email_inquire 0.3.0 → 0.4.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/README.md +4 -5
- data/data/jp_tld.txt +9 -0
- data/lib/email_inquire/inquirer.rb +20 -12
- data/lib/email_inquire/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 14209d0b6b0f04fc0b236b425432cce860f0ef7f
|
4
|
+
data.tar.gz: b0a266ddf3aa51dfbb63e725fba356e6004040e9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dccb794f40ba3360c7e1b7e547ccd1a164f5e7da65e8d66690b30ccf0f67a2cb6fbf06d6e94fe48d56146a2cd8d62d2ed4165f9b1e6da7ed45e080ed9932a187
|
7
|
+
data.tar.gz: e4b418ef9e26d1b041f363fb0e8c3aedf413904db5dfffd792d453a8b944176ffb86ac438dc916059035c15785183858e12dc7ca2eb02beacaff8d10fd8fd181
|
data/README.md
CHANGED
@@ -6,13 +6,13 @@ EmailInquire is a library to validate email for common typos and one-time email
|
|
6
6
|
|
7
7
|
## Why?
|
8
8
|
|
9
|
-
Before
|
10
|
-
entering
|
11
|
-
If
|
9
|
+
Before a user is a user, they are a visitor. And they must register to be so. What if they makes a typo while
|
10
|
+
entering their email address during the registration ?
|
11
|
+
If they didn't notice, you just lost them. They won't be able to sign in next time.
|
12
12
|
|
13
13
|
Your users :
|
14
14
|
|
15
|
-
- may not be as tech
|
15
|
+
- may not be as tech savvy as you;
|
16
16
|
- may not remember exactly their email address;
|
17
17
|
- may make a typo while typing their email address (very very common on a mobile keyboard).
|
18
18
|
|
@@ -151,4 +151,3 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/maxime
|
|
151
151
|
## License
|
152
152
|
|
153
153
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
154
|
-
|
data/data/jp_tld.txt
ADDED
@@ -50,7 +50,7 @@ module EmailInquire
|
|
50
50
|
:validate_common_domains,
|
51
51
|
:validate_one_time_providers,
|
52
52
|
:validate_common_domain_mistakes,
|
53
|
-
:
|
53
|
+
:validate_cc_tld,
|
54
54
|
:validate_common_tld_mistakes,
|
55
55
|
:validate_domains_with_unique_tld,
|
56
56
|
].freeze
|
@@ -96,6 +96,7 @@ module EmailInquire
|
|
96
96
|
end
|
97
97
|
|
98
98
|
COMMON_TLD_MISTAKES = {
|
99
|
+
".cojp" => ".co.jp",
|
99
100
|
".couk" => ".co.uk",
|
100
101
|
".com.com" => ".com",
|
101
102
|
}.freeze
|
@@ -111,21 +112,28 @@ module EmailInquire
|
|
111
112
|
end
|
112
113
|
end
|
113
114
|
|
115
|
+
VALID_JP_TLD = load_data("jp_tld").freeze
|
114
116
|
VALID_UK_TLD = load_data("uk_tld").freeze
|
117
|
+
VALID_CC_TLDs = [
|
118
|
+
[".jp", ".co.jp", VALID_JP_TLD],
|
119
|
+
[".uk", ".co.uk", VALID_UK_TLD],
|
120
|
+
].freeze
|
115
121
|
|
116
|
-
def
|
117
|
-
|
118
|
-
|
119
|
-
return if VALID_UK_TLD.any? do |reference|
|
120
|
-
domain.end_with?(reference)
|
121
|
-
end
|
122
|
+
def validate_cc_tld
|
123
|
+
VALID_CC_TLDs.each do |tld, sld, valid_tld|
|
124
|
+
next unless domain.end_with?(tld)
|
122
125
|
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
new_domain.gsub!(/(?<!\.co)\.uk\z/, ".co.uk")
|
126
|
+
next if valid_tld.any? do |reference|
|
127
|
+
domain.end_with?(reference)
|
128
|
+
end
|
127
129
|
|
128
|
-
|
130
|
+
new_domain = domain.dup
|
131
|
+
tld_without_dot = tld[1..-1]
|
132
|
+
new_domain.gsub!(/\.[a-z]{2}\.#{tld_without_dot}\z/, sld)
|
133
|
+
new_domain.gsub!(/(?<!\.)co\.#{tld_without_dot}\z/, sld)
|
134
|
+
new_domain.gsub!(/(?<!\.co)\.#{tld_without_dot}\z/, sld)
|
135
|
+
response.hint!(domain: new_domain) if new_domain != domain
|
136
|
+
end
|
129
137
|
end
|
130
138
|
|
131
139
|
UNIQUE_TLD_DOMAINS = load_data("unique_domain_providers").freeze
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: email_inquire
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Maxime Garcia
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-03-
|
11
|
+
date: 2017-03-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: damerau-levenshtein
|
@@ -99,6 +99,7 @@ files:
|
|
99
99
|
- bin/console
|
100
100
|
- bin/setup
|
101
101
|
- data/common_providers.txt
|
102
|
+
- data/jp_tld.txt
|
102
103
|
- data/one_time_email_providers.txt
|
103
104
|
- data/uk_tld.txt
|
104
105
|
- data/unique_domain_providers.txt
|