truemail 2.0.0 → 2.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.codeclimate.yml +1 -1
- data/.github/BRANCH_NAMING_CONVENTION.md +36 -0
- data/.github/ISSUE_TEMPLATE/bug_report.md +28 -0
- data/.github/ISSUE_TEMPLATE/feature_request.md +27 -0
- data/.github/{ISSUE_TEMPLATE.md → ISSUE_TEMPLATE/issue_report.md} +14 -3
- data/.github/ISSUE_TEMPLATE/question.md +22 -0
- data/.github/PULL_REQUEST_TEMPLATE.md +3 -0
- data/.reek.yml +2 -0
- data/.rubocop.yml +69 -0
- data/CHANGELOG.md +86 -15
- data/CONTRIBUTING.md +15 -14
- data/Gemfile.lock +47 -41
- data/README.md +109 -4
- data/lib/truemail.rb +1 -1
- data/lib/truemail/configuration.rb +3 -2
- data/lib/truemail/core.rb +1 -1
- data/lib/truemail/log/serializer/base.rb +1 -0
- data/lib/truemail/log/serializer/validator_base.rb +5 -1
- data/lib/truemail/validate/mx.rb +1 -1
- data/lib/truemail/validate/smtp.rb +15 -5
- data/lib/truemail/version.rb +1 -1
- data/truemail.gemspec +8 -8
- metadata +43 -27
data/lib/truemail.rb
CHANGED
@@ -10,7 +10,7 @@ module Truemail
|
|
10
10
|
class << self
|
11
11
|
def configuration(&block)
|
12
12
|
@configuration ||= begin
|
13
|
-
return unless
|
13
|
+
return unless block
|
14
14
|
configuration = Truemail::Configuration.new(&block)
|
15
15
|
raise_unless(configuration.complete?, Truemail::INCOMPLETE_CONFIG)
|
16
16
|
configuration
|
@@ -21,13 +21,13 @@ module Truemail
|
|
21
21
|
:blacklisted_domains,
|
22
22
|
:logger
|
23
23
|
|
24
|
-
attr_accessor :whitelist_validation, :not_rfc_mx_lookup_flow, :smtp_safe_check
|
24
|
+
attr_accessor :whitelist_validation, :not_rfc_mx_lookup_flow, :smtp_fail_fast, :smtp_safe_check
|
25
25
|
|
26
26
|
def initialize(&block)
|
27
27
|
instance_initializer.each do |instace_variable, value|
|
28
28
|
instance_variable_set(:"@#{instace_variable}", value)
|
29
29
|
end
|
30
|
-
tap(&block) if
|
30
|
+
tap(&block) if block
|
31
31
|
end
|
32
32
|
|
33
33
|
%i[email_pattern smtp_error_body_pattern].each do |method|
|
@@ -102,6 +102,7 @@ module Truemail
|
|
102
102
|
whitelist_validation: false,
|
103
103
|
blacklisted_domains: [],
|
104
104
|
not_rfc_mx_lookup_flow: false,
|
105
|
+
smtp_fail_fast: false,
|
105
106
|
smtp_safe_check: false
|
106
107
|
}
|
107
108
|
end
|
data/lib/truemail/core.rb
CHANGED
@@ -32,7 +32,7 @@ module Truemail
|
|
32
32
|
|
33
33
|
module RegexConstant
|
34
34
|
REGEX_DOMAIN = /[\p{L}0-9]+([\-.]{1}[\p{L}0-9]+)*\.\p{L}{2,63}/i.freeze
|
35
|
-
REGEX_EMAIL_PATTERN = /(?=\A.{6,255}\z)(\A([\p{L}0-9]+[\w
|
35
|
+
REGEX_EMAIL_PATTERN = /(?=\A.{6,255}\z)(\A([\p{L}0-9]+[\w|\-.+]*)@(#{REGEX_DOMAIN})\z)/.freeze
|
36
36
|
REGEX_DOMAIN_PATTERN = /(?=\A.{4,255}\z)(\A#{REGEX_DOMAIN}\z)/.freeze
|
37
37
|
REGEX_DOMAIN_FROM_EMAIL = /\A.+@(.+)\z/.freeze
|
38
38
|
REGEX_SMTP_ERROR_BODY_PATTERN = /(?=.*550)(?=.*(user|account|customer|mailbox)).*/i.freeze
|
@@ -56,6 +56,7 @@ module Truemail
|
|
56
56
|
whitelisted_domains: whitelisted_domains,
|
57
57
|
blacklisted_domains: blacklisted_domains,
|
58
58
|
not_rfc_mx_lookup_flow: executor_configuration.not_rfc_mx_lookup_flow,
|
59
|
+
smtp_fail_fast: executor_configuration.smtp_fail_fast,
|
59
60
|
smtp_safe_check: executor_configuration.smtp_safe_check,
|
60
61
|
email_pattern: email_pattern,
|
61
62
|
smtp_error_body_pattern: smtp_error_body_pattern
|
@@ -13,6 +13,10 @@ module Truemail
|
|
13
13
|
|
14
14
|
attr_reader :validation_type
|
15
15
|
|
16
|
+
def replace_invalid_chars
|
17
|
+
->(value) { value.encode('UTF-8', invalid: :replace) }
|
18
|
+
end
|
19
|
+
|
16
20
|
def smtp_debug
|
17
21
|
validation_smtp_debug = executor_result.smtp_debug
|
18
22
|
return unless validation_smtp_debug
|
@@ -22,7 +26,7 @@ module Truemail
|
|
22
26
|
mail_host: smtp_request.host,
|
23
27
|
port_opened: smtp_response.port_opened,
|
24
28
|
connection: smtp_response.connection,
|
25
|
-
errors: smtp_response.errors
|
29
|
+
errors: smtp_response.errors.transform_values(&replace_invalid_chars)
|
26
30
|
}
|
27
31
|
end
|
28
32
|
end
|
data/lib/truemail/validate/mx.rb
CHANGED
@@ -24,13 +24,23 @@ module Truemail
|
|
24
24
|
|
25
25
|
private
|
26
26
|
|
27
|
-
def
|
28
|
-
|
27
|
+
def fail_fast?
|
28
|
+
configuration.smtp_fail_fast
|
29
|
+
end
|
30
|
+
|
31
|
+
def filtered_mail_servers_by_fail_fast_scenario
|
32
|
+
fail_fast? ? mail_servers.first(1) : mail_servers
|
29
33
|
end
|
30
34
|
|
31
35
|
def attempts
|
32
|
-
@attempts ||=
|
33
|
-
|
36
|
+
@attempts ||= begin
|
37
|
+
return {} if fail_fast? || !mail_servers.one?
|
38
|
+
{ attempts: configuration.connection_attempts }
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def request
|
43
|
+
smtp_results.last
|
34
44
|
end
|
35
45
|
|
36
46
|
def rcptto_error
|
@@ -38,7 +48,7 @@ module Truemail
|
|
38
48
|
end
|
39
49
|
|
40
50
|
def establish_smtp_connection
|
41
|
-
|
51
|
+
filtered_mail_servers_by_fail_fast_scenario.each do |mail_server|
|
42
52
|
smtp_results << Truemail::Validate::Smtp::Request.new(
|
43
53
|
configuration: configuration, host: mail_server, email: result.punycode_email, **attempts
|
44
54
|
)
|
data/lib/truemail/version.rb
CHANGED
data/truemail.gemspec
CHANGED
@@ -35,17 +35,17 @@ Gem::Specification.new do |spec|
|
|
35
35
|
|
36
36
|
spec.add_development_dependency 'bundler', '~> 1.16'
|
37
37
|
spec.add_development_dependency 'bundler-audit', '~> 0.7.0.1'
|
38
|
+
spec.add_development_dependency 'faker', '~> 2.15', '>= 2.15.1'
|
38
39
|
spec.add_development_dependency 'fasterer', '~> 0.8.3'
|
39
|
-
spec.add_development_dependency 'ffaker', '~> 2.17'
|
40
40
|
spec.add_development_dependency 'json_matchers', '~> 0.11.1'
|
41
|
-
spec.add_development_dependency 'overcommit', '~> 0.
|
41
|
+
spec.add_development_dependency 'overcommit', '~> 0.57.0'
|
42
42
|
spec.add_development_dependency 'pry-byebug', '~> 3.9'
|
43
43
|
spec.add_development_dependency 'rake', '~> 13.0', '>= 13.0.1'
|
44
|
-
spec.add_development_dependency 'reek', '~> 6.0', '>= 6.0.
|
45
|
-
spec.add_development_dependency 'rspec', '~> 3.
|
46
|
-
spec.add_development_dependency 'rubocop', '~>
|
47
|
-
spec.add_development_dependency 'rubocop-performance', '~> 1.
|
48
|
-
spec.add_development_dependency 'rubocop-rspec', '~>
|
44
|
+
spec.add_development_dependency 'reek', '~> 6.0', '>= 6.0.2'
|
45
|
+
spec.add_development_dependency 'rspec', '~> 3.10'
|
46
|
+
spec.add_development_dependency 'rubocop', '~> 1.5', '>= 1.5.2'
|
47
|
+
spec.add_development_dependency 'rubocop-performance', '~> 1.9', '>= 1.9.1'
|
48
|
+
spec.add_development_dependency 'rubocop-rspec', '~> 2.0', '>= 2.0.1'
|
49
49
|
spec.add_development_dependency 'simplecov', '~> 0.17.1'
|
50
|
-
spec.add_development_dependency 'truemail-rspec', '~> 0.
|
50
|
+
spec.add_development_dependency 'truemail-rspec', '~> 0.3.3'
|
51
51
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: truemail
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vladislav Trotsenko
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-12-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: simpleidn
|
@@ -53,33 +53,39 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 0.7.0.1
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: faker
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: '2.15'
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: 2.15.1
|
62
65
|
type: :development
|
63
66
|
prerelease: false
|
64
67
|
version_requirements: !ruby/object:Gem::Requirement
|
65
68
|
requirements:
|
66
69
|
- - "~>"
|
67
70
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
71
|
+
version: '2.15'
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: 2.15.1
|
69
75
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
76
|
+
name: fasterer
|
71
77
|
requirement: !ruby/object:Gem::Requirement
|
72
78
|
requirements:
|
73
79
|
- - "~>"
|
74
80
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
81
|
+
version: 0.8.3
|
76
82
|
type: :development
|
77
83
|
prerelease: false
|
78
84
|
version_requirements: !ruby/object:Gem::Requirement
|
79
85
|
requirements:
|
80
86
|
- - "~>"
|
81
87
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
88
|
+
version: 0.8.3
|
83
89
|
- !ruby/object:Gem::Dependency
|
84
90
|
name: json_matchers
|
85
91
|
requirement: !ruby/object:Gem::Requirement
|
@@ -100,14 +106,14 @@ dependencies:
|
|
100
106
|
requirements:
|
101
107
|
- - "~>"
|
102
108
|
- !ruby/object:Gem::Version
|
103
|
-
version: 0.
|
109
|
+
version: 0.57.0
|
104
110
|
type: :development
|
105
111
|
prerelease: false
|
106
112
|
version_requirements: !ruby/object:Gem::Requirement
|
107
113
|
requirements:
|
108
114
|
- - "~>"
|
109
115
|
- !ruby/object:Gem::Version
|
110
|
-
version: 0.
|
116
|
+
version: 0.57.0
|
111
117
|
- !ruby/object:Gem::Dependency
|
112
118
|
name: pry-byebug
|
113
119
|
requirement: !ruby/object:Gem::Requirement
|
@@ -151,7 +157,7 @@ dependencies:
|
|
151
157
|
version: '6.0'
|
152
158
|
- - ">="
|
153
159
|
- !ruby/object:Gem::Version
|
154
|
-
version: 6.0.
|
160
|
+
version: 6.0.2
|
155
161
|
type: :development
|
156
162
|
prerelease: false
|
157
163
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -161,75 +167,81 @@ dependencies:
|
|
161
167
|
version: '6.0'
|
162
168
|
- - ">="
|
163
169
|
- !ruby/object:Gem::Version
|
164
|
-
version: 6.0.
|
170
|
+
version: 6.0.2
|
165
171
|
- !ruby/object:Gem::Dependency
|
166
172
|
name: rspec
|
167
173
|
requirement: !ruby/object:Gem::Requirement
|
168
174
|
requirements:
|
169
175
|
- - "~>"
|
170
176
|
- !ruby/object:Gem::Version
|
171
|
-
version: '3.
|
177
|
+
version: '3.10'
|
172
178
|
type: :development
|
173
179
|
prerelease: false
|
174
180
|
version_requirements: !ruby/object:Gem::Requirement
|
175
181
|
requirements:
|
176
182
|
- - "~>"
|
177
183
|
- !ruby/object:Gem::Version
|
178
|
-
version: '3.
|
184
|
+
version: '3.10'
|
179
185
|
- !ruby/object:Gem::Dependency
|
180
186
|
name: rubocop
|
181
187
|
requirement: !ruby/object:Gem::Requirement
|
182
188
|
requirements:
|
183
189
|
- - "~>"
|
184
190
|
- !ruby/object:Gem::Version
|
185
|
-
version:
|
191
|
+
version: '1.5'
|
192
|
+
- - ">="
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: 1.5.2
|
186
195
|
type: :development
|
187
196
|
prerelease: false
|
188
197
|
version_requirements: !ruby/object:Gem::Requirement
|
189
198
|
requirements:
|
190
199
|
- - "~>"
|
191
200
|
- !ruby/object:Gem::Version
|
192
|
-
version:
|
201
|
+
version: '1.5'
|
202
|
+
- - ">="
|
203
|
+
- !ruby/object:Gem::Version
|
204
|
+
version: 1.5.2
|
193
205
|
- !ruby/object:Gem::Dependency
|
194
206
|
name: rubocop-performance
|
195
207
|
requirement: !ruby/object:Gem::Requirement
|
196
208
|
requirements:
|
197
209
|
- - "~>"
|
198
210
|
- !ruby/object:Gem::Version
|
199
|
-
version: '1.
|
211
|
+
version: '1.9'
|
200
212
|
- - ">="
|
201
213
|
- !ruby/object:Gem::Version
|
202
|
-
version: 1.
|
214
|
+
version: 1.9.1
|
203
215
|
type: :development
|
204
216
|
prerelease: false
|
205
217
|
version_requirements: !ruby/object:Gem::Requirement
|
206
218
|
requirements:
|
207
219
|
- - "~>"
|
208
220
|
- !ruby/object:Gem::Version
|
209
|
-
version: '1.
|
221
|
+
version: '1.9'
|
210
222
|
- - ">="
|
211
223
|
- !ruby/object:Gem::Version
|
212
|
-
version: 1.
|
224
|
+
version: 1.9.1
|
213
225
|
- !ruby/object:Gem::Dependency
|
214
226
|
name: rubocop-rspec
|
215
227
|
requirement: !ruby/object:Gem::Requirement
|
216
228
|
requirements:
|
217
229
|
- - "~>"
|
218
230
|
- !ruby/object:Gem::Version
|
219
|
-
version: '
|
231
|
+
version: '2.0'
|
220
232
|
- - ">="
|
221
233
|
- !ruby/object:Gem::Version
|
222
|
-
version:
|
234
|
+
version: 2.0.1
|
223
235
|
type: :development
|
224
236
|
prerelease: false
|
225
237
|
version_requirements: !ruby/object:Gem::Requirement
|
226
238
|
requirements:
|
227
239
|
- - "~>"
|
228
240
|
- !ruby/object:Gem::Version
|
229
|
-
version: '
|
241
|
+
version: '2.0'
|
230
242
|
- - ">="
|
231
243
|
- !ruby/object:Gem::Version
|
232
|
-
version:
|
244
|
+
version: 2.0.1
|
233
245
|
- !ruby/object:Gem::Dependency
|
234
246
|
name: simplecov
|
235
247
|
requirement: !ruby/object:Gem::Requirement
|
@@ -250,14 +262,14 @@ dependencies:
|
|
250
262
|
requirements:
|
251
263
|
- - "~>"
|
252
264
|
- !ruby/object:Gem::Version
|
253
|
-
version: 0.
|
265
|
+
version: 0.3.3
|
254
266
|
type: :development
|
255
267
|
prerelease: false
|
256
268
|
version_requirements: !ruby/object:Gem::Requirement
|
257
269
|
requirements:
|
258
270
|
- - "~>"
|
259
271
|
- !ruby/object:Gem::Version
|
260
|
-
version: 0.
|
272
|
+
version: 0.3.3
|
261
273
|
description: Configurable framework agnostic plain Ruby email validator. Verify email
|
262
274
|
via Regex, DNS and SMTP.
|
263
275
|
email:
|
@@ -268,7 +280,11 @@ extra_rdoc_files: []
|
|
268
280
|
files:
|
269
281
|
- ".circleci/config.yml"
|
270
282
|
- ".codeclimate.yml"
|
271
|
-
- ".github/
|
283
|
+
- ".github/BRANCH_NAMING_CONVENTION.md"
|
284
|
+
- ".github/ISSUE_TEMPLATE/bug_report.md"
|
285
|
+
- ".github/ISSUE_TEMPLATE/feature_request.md"
|
286
|
+
- ".github/ISSUE_TEMPLATE/issue_report.md"
|
287
|
+
- ".github/ISSUE_TEMPLATE/question.md"
|
272
288
|
- ".github/PULL_REQUEST_TEMPLATE.md"
|
273
289
|
- ".gitignore"
|
274
290
|
- ".overcommit.yml"
|