valid_email2 3.0.5 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/lib/valid_email2.rb +7 -3
- data/lib/valid_email2/address.rb +6 -3
- data/lib/valid_email2/version.rb +1 -1
- data/spec/valid_email2_spec.rb +11 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6b1b27babaa4cb566d2b63dc25f726f534ad05fb9364d21c52c44c775ce12218
|
4
|
+
data.tar.gz: 735df3dc625cebce4bda35547a4d3b6e8e558fc2133872c8b678e51a4891c073
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f4d6da63e2f4f1894605a1b83f0c92300d8fe3d8a558d09f670d890d38ef3efbf3f59dfdd49f1bda9696ddad73c0ee5b9fd33ca742f7293524cb29e83c96b57f
|
7
|
+
data.tar.gz: e74ea532d0510bdd0c9c8ddcc53e88aebc384d3ea4bafe475c28a754518f90103873c814134acb2cc942720a5f889ff349a142b5164e842d81bc67a08816ce1a
|
data/CHANGELOG.md
CHANGED
data/lib/valid_email2.rb
CHANGED
@@ -7,14 +7,14 @@ module ValidEmail2
|
|
7
7
|
WHITELIST_FILE = "config/whitelisted_email_domains.yml"
|
8
8
|
|
9
9
|
def self.disposable_emails
|
10
|
-
@disposable_emails ||=
|
10
|
+
@disposable_emails ||= load_file(
|
11
11
|
File.expand_path('../config/disposable_email_domains.yml', __dir__)
|
12
12
|
)
|
13
13
|
end
|
14
14
|
|
15
15
|
def self.blacklist
|
16
16
|
@blacklist ||= if File.exist?(BLACKLIST_FILE)
|
17
|
-
|
17
|
+
load_file(File.expand_path(BLACKLIST_FILE))
|
18
18
|
else
|
19
19
|
[]
|
20
20
|
end
|
@@ -22,9 +22,13 @@ module ValidEmail2
|
|
22
22
|
|
23
23
|
def self.whitelist
|
24
24
|
@whitelist ||= if File.exist?(WHITELIST_FILE)
|
25
|
-
|
25
|
+
load_file(File.expand_path(WHITELIST_FILE))
|
26
26
|
else
|
27
27
|
[]
|
28
28
|
end
|
29
29
|
end
|
30
|
+
|
31
|
+
def self.load_file(path)
|
32
|
+
Set.new(YAML.load_file(path))
|
33
|
+
end
|
30
34
|
end
|
data/lib/valid_email2/address.rb
CHANGED
@@ -72,9 +72,12 @@ module ValidEmail2
|
|
72
72
|
|
73
73
|
def domain_is_in?(domain_list)
|
74
74
|
address_domain = address.domain.downcase
|
75
|
-
domain_list.
|
76
|
-
|
77
|
-
|
75
|
+
return true if domain_list.include?(address_domain)
|
76
|
+
|
77
|
+
i = address_domain.index('.')
|
78
|
+
return false unless i
|
79
|
+
|
80
|
+
return domain_list.include?(address_domain[(i+1)..-1])
|
78
81
|
end
|
79
82
|
|
80
83
|
def mx_server_is_in?(domain_list)
|
data/lib/valid_email2/version.rb
CHANGED
data/spec/valid_email2_spec.rb
CHANGED
@@ -31,6 +31,9 @@ class TestUserMessage < TestModel
|
|
31
31
|
end
|
32
32
|
|
33
33
|
describe ValidEmail2 do
|
34
|
+
|
35
|
+
let(:disposable_domain) { ValidEmail2.disposable_emails.first }
|
36
|
+
|
34
37
|
describe "basic validation" do
|
35
38
|
subject(:user) { TestUser.new(email: "") }
|
36
39
|
|
@@ -88,13 +91,18 @@ describe ValidEmail2 do
|
|
88
91
|
expect(user.valid?).to be_truthy
|
89
92
|
end
|
90
93
|
|
94
|
+
it "is valid if it just ends with a disposable domain" do
|
95
|
+
user = TestUserDisallowDisposable.new(email: "foo@nondisposable-0-mail.com")
|
96
|
+
expect(user.valid?).to be_truthy
|
97
|
+
end
|
98
|
+
|
91
99
|
it "is invalid if it's a disposable email" do
|
92
|
-
user = TestUserDisallowDisposable.new(email: "foo@#{
|
100
|
+
user = TestUserDisallowDisposable.new(email: "foo@#{disposable_domain}")
|
93
101
|
expect(user.valid?).to be_falsey
|
94
102
|
end
|
95
103
|
|
96
104
|
it "is invalid if the domain is a subdomain of a disposable domain" do
|
97
|
-
user = TestUserDisallowDisposable.new(email: "foo@bar.#{
|
105
|
+
user = TestUserDisallowDisposable.new(email: "foo@bar.#{disposable_domain}")
|
98
106
|
expect(user.valid?).to be_falsey
|
99
107
|
end
|
100
108
|
|
@@ -119,7 +127,7 @@ describe ValidEmail2 do
|
|
119
127
|
end
|
120
128
|
|
121
129
|
describe "with whitelisted emails" do
|
122
|
-
let(:whitelist_domain) {
|
130
|
+
let(:whitelist_domain) { disposable_domain }
|
123
131
|
let(:whitelist_file_path) { "config/whitelisted_email_domains.yml" }
|
124
132
|
|
125
133
|
after do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: valid_email2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0
|
4
|
+
version: 3.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Micke Lisinge
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-10-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|