email_inquire 0.9.0 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "email_inquire/validator/base"
4
+
5
+ module EmailInquire
6
+ module Validator
7
+ class CustomInvalidDomain < Base
8
+
9
+ def validate
10
+ response.invalid! if EmailInquire.custom_invalid_domains.include?(domain)
11
+ end
12
+
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "email_inquire/validator/base"
4
+
5
+ module EmailInquire
6
+ module Validator
7
+ class CustomValidDomain < Base
8
+
9
+ def validate
10
+ response.valid! if EmailInquire.custom_valid_domains.include?(domain)
11
+ end
12
+
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "email_inquire/validator/base"
4
+
5
+ module EmailInquire
6
+ module Validator
7
+ class EmailFormat < Base
8
+
9
+ # Relevant literature:
10
+ # http://emailregex.com/email-validation-summary/
11
+ # http://www.regular-expressions.info/email.html
12
+
13
+ def validate
14
+ response.invalid! if !email || email.length > 255 || !name_valid? || !domain_valid?
15
+ end
16
+
17
+ private
18
+
19
+ def domain_valid?
20
+ domain =~ DOMAIN_REGEXP
21
+ end
22
+
23
+ def name_valid?
24
+ name =~ NAME_REGEXP
25
+ end
26
+
27
+ DOMAIN_REGEXP = /
28
+ \A
29
+ (?:
30
+ (?=
31
+ [a-z0-9-]{1,63}
32
+ \.
33
+ )
34
+ [a-z0-9]+
35
+ (?:
36
+ -
37
+ [a-z0-9]+
38
+ )*
39
+ \.
40
+ ){1,8}
41
+ [a-z]{2,63}
42
+ \z
43
+ /x.freeze
44
+
45
+ NAME_REGEXP = /
46
+ \A
47
+ [a-z0-9]
48
+ [a-z0-9._%+-]{0,63}
49
+ \z
50
+ /x.freeze
51
+
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "email_inquire/validator/base"
4
+
5
+ module EmailInquire
6
+ module Validator
7
+ class KnownInvalidDomain < Base
8
+
9
+ DOMAINS = load_data("known_invalid_domains").freeze
10
+
11
+ def validate
12
+ response.invalid! if DOMAINS.include?(domain)
13
+ end
14
+
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "email_inquire/validator/base"
4
+
5
+ module EmailInquire
6
+ module Validator
7
+ class OneTimeProvider < Base
8
+
9
+ DOMAINS = load_data("one_time_providers").freeze
10
+
11
+ def validate
12
+ response.invalid! if DOMAINS.include?(domain)
13
+ end
14
+
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "email_inquire/validator/base"
4
+
5
+ module EmailInquire
6
+ module Validator
7
+ class UniqueDomainProvider < Base
8
+
9
+ DOMAINS = load_data("unique_domain_providers").freeze
10
+
11
+ def validate
12
+ return response.valid! if DOMAINS.include?(domain)
13
+
14
+ base, _tld = domain.split(".", 2)
15
+
16
+ replacement_domain =
17
+ DOMAINS.find do |reference|
18
+ reference_base, _reference_tld = reference.split(".")
19
+
20
+ reference_base.eql?(base)
21
+ end
22
+
23
+ response.hint!(domain: replacement_domain) if replacement_domain
24
+ end
25
+
26
+ end
27
+ end
28
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module EmailInquire
4
4
 
5
- VERSION = "0.9.0"
5
+ VERSION = "0.10.0"
6
6
 
7
7
  end
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.9.0
4
+ version: 0.10.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: 2019-01-04 00:00:00.000000000 Z
11
+ date: 2019-01-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: damerau-levenshtein
@@ -103,18 +103,30 @@ files:
103
103
  - bin/console
104
104
  - bin/setup
105
105
  - codecov.yml
106
- - data/br_tld.txt
107
106
  - data/common_providers.txt
108
- - data/jp_tld.txt
107
+ - data/country_code_tld/br.txt
108
+ - data/country_code_tld/jp.txt
109
+ - data/country_code_tld/uk.txt
109
110
  - data/known_invalid_domains.txt
110
- - data/one_time_email_providers.txt
111
- - data/uk_tld.txt
111
+ - data/one_time_providers.txt
112
112
  - data/unique_domain_providers.txt
113
113
  - email_inquire.gemspec
114
114
  - lib/email_inquire.rb
115
- - lib/email_inquire/email_validator.rb
115
+ - lib/email_inquire/helper.rb
116
116
  - lib/email_inquire/inquirer.rb
117
117
  - lib/email_inquire/response.rb
118
+ - lib/email_inquire/validator/base.rb
119
+ - lib/email_inquire/validator/common_provider.rb
120
+ - lib/email_inquire/validator/common_provider_mistake.rb
121
+ - lib/email_inquire/validator/commonly_mistaken_domain.rb
122
+ - lib/email_inquire/validator/commonly_mistaken_tld.rb
123
+ - lib/email_inquire/validator/country_code_tld.rb
124
+ - lib/email_inquire/validator/custom_invalid_domain.rb
125
+ - lib/email_inquire/validator/custom_valid_domain.rb
126
+ - lib/email_inquire/validator/email_format.rb
127
+ - lib/email_inquire/validator/known_invalid_domain.rb
128
+ - lib/email_inquire/validator/one_time_provider.rb
129
+ - lib/email_inquire/validator/unique_domain_provider.rb
118
130
  - lib/email_inquire/version.rb
119
131
  homepage: https://github.com/maximeg/email_inquire
120
132
  licenses:
data/data/br_tld.txt DELETED
@@ -1,72 +0,0 @@
1
- .adm.br
2
- .adv.br
3
- .agr.br
4
- .am.br
5
- .arq.br
6
- .art.br
7
- .ato.br
8
- .b.br
9
- .bio.br
10
- .blog.br
11
- .bmd.br
12
- .cim.br
13
- .cng.br
14
- .cnt.br
15
- .com.br
16
- .coop.br
17
- .cri.br
18
- .def.br
19
- .ecn.br
20
- .eco.br
21
- .edu.br
22
- .emp.br
23
- .eng.br
24
- .esp.br
25
- .etc.br
26
- .eti.br
27
- .far.br
28
- .flog.br
29
- .fm.br
30
- .fnd.br
31
- .fot.br
32
- .fst.br
33
- .g12.br
34
- .ggf.br
35
- .gov.br
36
- .imb.br
37
- .ind.br
38
- .inf.br
39
- .jor.br
40
- .jus.br
41
- .leg.br
42
- .lel.br
43
- .mat.br
44
- .med.br
45
- .mil.br
46
- .mp.br
47
- .mus.br
48
- .net.br
49
- .nom.br
50
- .not.br
51
- .ntr.br
52
- .odo.br
53
- .org.br
54
- .ppg.br
55
- .pro.br
56
- .psc.br
57
- .psi.br
58
- .qsl.br
59
- .radio.br
60
- .rec.br
61
- .slg.br
62
- .srv.br
63
- .taxi.br
64
- .teo.br
65
- .tmp.br
66
- .trd.br
67
- .tur.br
68
- .tv.br
69
- .vet.br
70
- .vlog.br
71
- .wiki.br
72
- .zlg.br
data/data/jp_tld.txt DELETED
@@ -1,9 +0,0 @@
1
- .ac.jp
2
- .ad.jp
3
- .co.jp
4
- .ed.jp
5
- .go.jp
6
- .gr.jp
7
- .lg.jp
8
- .ne.jp
9
- .or.jp
data/data/uk_tld.txt DELETED
@@ -1,15 +0,0 @@
1
- .ac.uk
2
- .co.uk
3
- .gov.uk
4
- .judiciary.uk
5
- .ltd.uk
6
- .me.uk
7
- .mod.uk
8
- .net.uk
9
- .nhs.uk
10
- .nic.uk
11
- .org.uk
12
- .parliament.uk
13
- .plc.uk
14
- .police.uk
15
- .sch.uk
@@ -1,67 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module EmailInquire
4
- # Relevant literature:
5
- # http://emailregex.com/email-validation-summary/
6
- # http://www.regular-expressions.info/email.html
7
- class EmailValidator
8
-
9
- def initialize(email)
10
- @email = email.downcase
11
- end
12
-
13
- attr_reader :email
14
-
15
- def valid?
16
- return false unless email.count("@") == 1
17
- return false if email.length > 255
18
-
19
- name, domain = email.split("@", 2)
20
-
21
- name_valid?(name) && domain_valid?(domain)
22
- end
23
-
24
- private
25
-
26
- DOMAIN_REGEXP = /
27
- \A
28
- (?:
29
- (?=
30
- [a-z0-9-]{1,63}
31
- \.
32
- )
33
- [a-z0-9]+
34
- (?:
35
- -
36
- [a-z0-9]+
37
- )*
38
- \.
39
- ){1,8}
40
- [a-z]{2,63}
41
- \z
42
- /x.freeze
43
-
44
- def domain_valid?(domain)
45
- return false if domain == ""
46
- return false unless domain =~ DOMAIN_REGEXP
47
-
48
- true
49
- end
50
-
51
- NAME_REGEXP = /
52
- \A
53
- [a-z0-9]
54
- [a-z0-9._%+-]{0,63}
55
- \z
56
- /x.freeze
57
-
58
- def name_valid?(name)
59
- return false if name == ""
60
- return false if name.length > 64
61
- return false unless name =~ NAME_REGEXP
62
-
63
- true
64
- end
65
-
66
- end
67
- end