truemail 1.7.1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +1 -1
- data/.codeclimate.yml +1 -1
- data/.github/ISSUE_TEMPLATE.md +3 -3
- data/.github/PULL_REQUEST_TEMPLATE.md +1 -1
- data/.reek.yml +4 -0
- data/.rubocop.yml +177 -6
- data/CHANGELOG.md +149 -22
- data/Gemfile.lock +44 -38
- data/LICENSE.txt +1 -1
- data/README.md +162 -102
- data/lib/truemail.rb +10 -3
- data/lib/truemail/audit/base.rb +8 -0
- data/lib/truemail/audit/dns.rb +26 -0
- data/lib/truemail/audit/ip.rb +28 -0
- data/lib/truemail/audit/ptr.rb +8 -37
- data/lib/truemail/auditor.rb +7 -5
- data/lib/truemail/configuration.rb +8 -2
- data/lib/truemail/core.rb +28 -22
- data/lib/truemail/executor.rb +11 -0
- data/lib/truemail/log/serializer/auditor_json.rb +25 -0
- data/lib/truemail/log/serializer/base.rb +17 -42
- data/lib/truemail/log/serializer/validator_base.rb +45 -0
- data/lib/truemail/log/serializer/{json.rb → validator_json.rb} +1 -1
- data/lib/truemail/log/serializer/{text.rb → validator_text.rb} +2 -2
- data/lib/truemail/logger.rb +1 -1
- data/lib/truemail/validate/smtp/request.rb +2 -3
- data/lib/truemail/validator.rb +4 -4
- data/lib/truemail/version.rb +1 -1
- data/truemail.gemspec +17 -9
- metadata +49 -27
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Truemail
|
4
|
+
module Log
|
5
|
+
module Serializer
|
6
|
+
class ValidatorBase < Truemail::Log::Serializer::Base
|
7
|
+
def initialize(executor_instance)
|
8
|
+
@validation_type = executor_instance.validation_type
|
9
|
+
super
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
attr_reader :validation_type
|
15
|
+
|
16
|
+
def smtp_debug
|
17
|
+
validation_smtp_debug = executor_result.smtp_debug
|
18
|
+
return unless validation_smtp_debug
|
19
|
+
validation_smtp_debug.map do |smtp_request|
|
20
|
+
smtp_response = smtp_request.response
|
21
|
+
{
|
22
|
+
mail_host: smtp_request.host,
|
23
|
+
port_opened: smtp_response.port_opened,
|
24
|
+
connection: smtp_response.connection,
|
25
|
+
errors: smtp_response.errors
|
26
|
+
}
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def result
|
31
|
+
@result ||=
|
32
|
+
{
|
33
|
+
date: Time.now,
|
34
|
+
email: executor_result.email,
|
35
|
+
validation_type: validation_type,
|
36
|
+
success: executor_result.success,
|
37
|
+
errors: errors(executor_result.errors),
|
38
|
+
smtp_debug: smtp_debug,
|
39
|
+
configuration: configuration
|
40
|
+
}
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module Truemail
|
4
4
|
module Log
|
5
5
|
module Serializer
|
6
|
-
class
|
6
|
+
class ValidatorText < Truemail::Log::Serializer::ValidatorBase
|
7
7
|
ATTEMPT = 'ATTEMPT #'
|
8
8
|
|
9
9
|
def serialize
|
@@ -30,7 +30,7 @@ module Truemail
|
|
30
30
|
|
31
31
|
def collection_printer(collection)
|
32
32
|
collection.inject([]) { |array, hash| array << printer(hash) }.map.with_index do |item, index|
|
33
|
-
"\n#{Truemail::Log::Serializer::
|
33
|
+
"\n#{Truemail::Log::Serializer::ValidatorText::ATTEMPT}#{index + 1}:\n#{item}\n"
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
data/lib/truemail/logger.rb
CHANGED
@@ -15,7 +15,7 @@ module Truemail
|
|
15
15
|
def push(validator_instance)
|
16
16
|
current_event = Truemail::Log::Event.new(event, validator_instance)
|
17
17
|
return unless current_event.valid?
|
18
|
-
create_logs(current_event.log_level, Truemail::Log::Serializer::
|
18
|
+
create_logs(current_event.log_level, Truemail::Log::Serializer::ValidatorText.call(validator_instance))
|
19
19
|
end
|
20
20
|
|
21
21
|
private
|
@@ -31,8 +31,8 @@ module Truemail
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def run
|
34
|
-
session.start do |smtp_request|
|
35
|
-
response.connection = true
|
34
|
+
session.start(configuration.verifier_domain) do |smtp_request|
|
35
|
+
response.connection = response.helo = true
|
36
36
|
smtp_handshakes(smtp_request, response)
|
37
37
|
end
|
38
38
|
rescue => error
|
@@ -83,7 +83,6 @@ module Truemail
|
|
83
83
|
|
84
84
|
def session_data
|
85
85
|
{
|
86
|
-
helo: configuration.verifier_domain,
|
87
86
|
mailfrom: configuration.verifier_email,
|
88
87
|
rcptto: email
|
89
88
|
}
|
data/lib/truemail/validator.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Truemail
|
4
|
-
class Validator
|
4
|
+
class Validator < Truemail::Executor
|
5
5
|
RESULT_ATTRS = %i[success email domain mail_servers errors smtp_debug configuration].freeze
|
6
6
|
VALIDATION_TYPES = %i[regex mx smtp].freeze
|
7
7
|
|
@@ -16,9 +16,9 @@ module Truemail
|
|
16
16
|
alias_method :valid?, :success
|
17
17
|
end
|
18
18
|
|
19
|
-
attr_reader :validation_type
|
19
|
+
attr_reader :validation_type
|
20
20
|
|
21
|
-
def initialize(email, with: nil
|
21
|
+
def initialize(email, configuration:, with: nil)
|
22
22
|
with ||= configuration.default_validation_type
|
23
23
|
raise Truemail::ArgumentError.new(with, :argument) unless Truemail::Validator::VALIDATION_TYPES.include?(with)
|
24
24
|
@result = Truemail::Validator::Result.new(email: email, configuration: configuration)
|
@@ -33,7 +33,7 @@ module Truemail
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def as_json
|
36
|
-
Truemail::Log::Serializer::
|
36
|
+
Truemail::Log::Serializer::ValidatorJson.call(self)
|
37
37
|
end
|
38
38
|
|
39
39
|
private
|
data/lib/truemail/version.rb
CHANGED
data/truemail.gemspec
CHANGED
@@ -13,9 +13,17 @@ Gem::Specification.new do |spec|
|
|
13
13
|
spec.summary = %(truemail)
|
14
14
|
spec.description = %(Configurable framework agnostic plain Ruby email validator. Verify email via Regex, DNS and SMTP.)
|
15
15
|
|
16
|
-
spec.homepage = 'https://github.com/
|
16
|
+
spec.homepage = 'https://github.com/truemail-rb/truemail'
|
17
17
|
spec.license = 'MIT'
|
18
18
|
|
19
|
+
spec.metadata = {
|
20
|
+
'homepage_uri' => 'https://truemail-rb.org',
|
21
|
+
'changelog_uri' => 'https://github.com/truemail-rb/truemail/blob/master/CHANGELOG.md',
|
22
|
+
'source_code_uri' => 'https://github.com/truemail-rb/truemail',
|
23
|
+
'documentation_uri' => 'https://truemail-rb.org/truemail-gem',
|
24
|
+
'bug_tracker_uri' => 'https://github.com/truemail-rb/truemail/issues'
|
25
|
+
}
|
26
|
+
|
19
27
|
spec.required_ruby_version = '>= 2.5.0'
|
20
28
|
|
21
29
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
@@ -26,18 +34,18 @@ Gem::Specification.new do |spec|
|
|
26
34
|
spec.add_runtime_dependency 'simpleidn', '~> 0.1.1'
|
27
35
|
|
28
36
|
spec.add_development_dependency 'bundler', '~> 1.16'
|
29
|
-
spec.add_development_dependency 'bundler-audit', '~> 0.
|
37
|
+
spec.add_development_dependency 'bundler-audit', '~> 0.7.0.1'
|
30
38
|
spec.add_development_dependency 'fasterer', '~> 0.8.3'
|
31
|
-
spec.add_development_dependency 'ffaker', '~> 2.
|
39
|
+
spec.add_development_dependency 'ffaker', '~> 2.17'
|
32
40
|
spec.add_development_dependency 'json_matchers', '~> 0.11.1'
|
33
|
-
spec.add_development_dependency 'overcommit', '~> 0.
|
41
|
+
spec.add_development_dependency 'overcommit', '~> 0.55.0'
|
34
42
|
spec.add_development_dependency 'pry-byebug', '~> 3.9'
|
35
43
|
spec.add_development_dependency 'rake', '~> 13.0', '>= 13.0.1'
|
36
|
-
spec.add_development_dependency 'reek', '~> 6.0'
|
44
|
+
spec.add_development_dependency 'reek', '~> 6.0', '>= 6.0.1'
|
37
45
|
spec.add_development_dependency 'rspec', '~> 3.9'
|
38
|
-
spec.add_development_dependency 'rubocop', '~> 0.
|
39
|
-
spec.add_development_dependency 'rubocop-performance', '~> 1.
|
40
|
-
spec.add_development_dependency 'rubocop-rspec', '~> 1.
|
46
|
+
spec.add_development_dependency 'rubocop', '~> 0.91.0'
|
47
|
+
spec.add_development_dependency 'rubocop-performance', '~> 1.8', '>= 1.8.1'
|
48
|
+
spec.add_development_dependency 'rubocop-rspec', '~> 1.43', '>= 1.43.2'
|
41
49
|
spec.add_development_dependency 'simplecov', '~> 0.17.1'
|
42
|
-
spec.add_development_dependency 'truemail-rspec', '~> 0.1
|
50
|
+
spec.add_development_dependency 'truemail-rspec', '~> 0.2.1'
|
43
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:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vladislav Trotsenko
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-10-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: simpleidn
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0.
|
47
|
+
version: 0.7.0.1
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0.
|
54
|
+
version: 0.7.0.1
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: fasterer
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -72,14 +72,14 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '2.
|
75
|
+
version: '2.17'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '2.
|
82
|
+
version: '2.17'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: json_matchers
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -100,14 +100,14 @@ dependencies:
|
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: 0.
|
103
|
+
version: 0.55.0
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: 0.
|
110
|
+
version: 0.55.0
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: pry-byebug
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -149,6 +149,9 @@ dependencies:
|
|
149
149
|
- - "~>"
|
150
150
|
- !ruby/object:Gem::Version
|
151
151
|
version: '6.0'
|
152
|
+
- - ">="
|
153
|
+
- !ruby/object:Gem::Version
|
154
|
+
version: 6.0.1
|
152
155
|
type: :development
|
153
156
|
prerelease: false
|
154
157
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -156,6 +159,9 @@ dependencies:
|
|
156
159
|
- - "~>"
|
157
160
|
- !ruby/object:Gem::Version
|
158
161
|
version: '6.0'
|
162
|
+
- - ">="
|
163
|
+
- !ruby/object:Gem::Version
|
164
|
+
version: 6.0.1
|
159
165
|
- !ruby/object:Gem::Dependency
|
160
166
|
name: rspec
|
161
167
|
requirement: !ruby/object:Gem::Requirement
|
@@ -176,48 +182,54 @@ dependencies:
|
|
176
182
|
requirements:
|
177
183
|
- - "~>"
|
178
184
|
- !ruby/object:Gem::Version
|
179
|
-
version: 0.
|
185
|
+
version: 0.91.0
|
180
186
|
type: :development
|
181
187
|
prerelease: false
|
182
188
|
version_requirements: !ruby/object:Gem::Requirement
|
183
189
|
requirements:
|
184
190
|
- - "~>"
|
185
191
|
- !ruby/object:Gem::Version
|
186
|
-
version: 0.
|
192
|
+
version: 0.91.0
|
187
193
|
- !ruby/object:Gem::Dependency
|
188
194
|
name: rubocop-performance
|
189
195
|
requirement: !ruby/object:Gem::Requirement
|
190
196
|
requirements:
|
191
197
|
- - "~>"
|
192
198
|
- !ruby/object:Gem::Version
|
193
|
-
version: '1.
|
199
|
+
version: '1.8'
|
194
200
|
- - ">="
|
195
201
|
- !ruby/object:Gem::Version
|
196
|
-
version: 1.
|
202
|
+
version: 1.8.1
|
197
203
|
type: :development
|
198
204
|
prerelease: false
|
199
205
|
version_requirements: !ruby/object:Gem::Requirement
|
200
206
|
requirements:
|
201
207
|
- - "~>"
|
202
208
|
- !ruby/object:Gem::Version
|
203
|
-
version: '1.
|
209
|
+
version: '1.8'
|
204
210
|
- - ">="
|
205
211
|
- !ruby/object:Gem::Version
|
206
|
-
version: 1.
|
212
|
+
version: 1.8.1
|
207
213
|
- !ruby/object:Gem::Dependency
|
208
214
|
name: rubocop-rspec
|
209
215
|
requirement: !ruby/object:Gem::Requirement
|
210
216
|
requirements:
|
211
217
|
- - "~>"
|
212
218
|
- !ruby/object:Gem::Version
|
213
|
-
version: '1.
|
219
|
+
version: '1.43'
|
220
|
+
- - ">="
|
221
|
+
- !ruby/object:Gem::Version
|
222
|
+
version: 1.43.2
|
214
223
|
type: :development
|
215
224
|
prerelease: false
|
216
225
|
version_requirements: !ruby/object:Gem::Requirement
|
217
226
|
requirements:
|
218
227
|
- - "~>"
|
219
228
|
- !ruby/object:Gem::Version
|
220
|
-
version: '1.
|
229
|
+
version: '1.43'
|
230
|
+
- - ">="
|
231
|
+
- !ruby/object:Gem::Version
|
232
|
+
version: 1.43.2
|
221
233
|
- !ruby/object:Gem::Dependency
|
222
234
|
name: simplecov
|
223
235
|
requirement: !ruby/object:Gem::Requirement
|
@@ -238,14 +250,14 @@ dependencies:
|
|
238
250
|
requirements:
|
239
251
|
- - "~>"
|
240
252
|
- !ruby/object:Gem::Version
|
241
|
-
version: 0.1
|
253
|
+
version: 0.2.1
|
242
254
|
type: :development
|
243
255
|
prerelease: false
|
244
256
|
version_requirements: !ruby/object:Gem::Requirement
|
245
257
|
requirements:
|
246
258
|
- - "~>"
|
247
259
|
- !ruby/object:Gem::Version
|
248
|
-
version: 0.1
|
260
|
+
version: 0.2.1
|
249
261
|
description: Configurable framework agnostic plain Ruby email validator. Verify email
|
250
262
|
via Regex, DNS and SMTP.
|
251
263
|
email:
|
@@ -277,14 +289,19 @@ files:
|
|
277
289
|
- bin/setup
|
278
290
|
- lib/truemail.rb
|
279
291
|
- lib/truemail/audit/base.rb
|
292
|
+
- lib/truemail/audit/dns.rb
|
293
|
+
- lib/truemail/audit/ip.rb
|
280
294
|
- lib/truemail/audit/ptr.rb
|
281
295
|
- lib/truemail/auditor.rb
|
282
296
|
- lib/truemail/configuration.rb
|
283
297
|
- lib/truemail/core.rb
|
298
|
+
- lib/truemail/executor.rb
|
284
299
|
- lib/truemail/log/event.rb
|
300
|
+
- lib/truemail/log/serializer/auditor_json.rb
|
285
301
|
- lib/truemail/log/serializer/base.rb
|
286
|
-
- lib/truemail/log/serializer/
|
287
|
-
- lib/truemail/log/serializer/
|
302
|
+
- lib/truemail/log/serializer/validator_base.rb
|
303
|
+
- lib/truemail/log/serializer/validator_json.rb
|
304
|
+
- lib/truemail/log/serializer/validator_text.rb
|
288
305
|
- lib/truemail/logger.rb
|
289
306
|
- lib/truemail/validate/base.rb
|
290
307
|
- lib/truemail/validate/domain_list_match.rb
|
@@ -298,11 +315,16 @@ files:
|
|
298
315
|
- lib/truemail/worker.rb
|
299
316
|
- lib/truemail/wrapper.rb
|
300
317
|
- truemail.gemspec
|
301
|
-
homepage: https://github.com/
|
318
|
+
homepage: https://github.com/truemail-rb/truemail
|
302
319
|
licenses:
|
303
320
|
- MIT
|
304
|
-
metadata:
|
305
|
-
|
321
|
+
metadata:
|
322
|
+
homepage_uri: https://truemail-rb.org
|
323
|
+
changelog_uri: https://github.com/truemail-rb/truemail/blob/master/CHANGELOG.md
|
324
|
+
source_code_uri: https://github.com/truemail-rb/truemail
|
325
|
+
documentation_uri: https://truemail-rb.org/truemail-gem
|
326
|
+
bug_tracker_uri: https://github.com/truemail-rb/truemail/issues
|
327
|
+
post_install_message:
|
306
328
|
rdoc_options: []
|
307
329
|
require_paths:
|
308
330
|
- lib
|
@@ -317,9 +339,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
317
339
|
- !ruby/object:Gem::Version
|
318
340
|
version: '0'
|
319
341
|
requirements: []
|
320
|
-
rubyforge_project:
|
321
|
-
rubygems_version: 2.7.
|
322
|
-
signing_key:
|
342
|
+
rubyforge_project:
|
343
|
+
rubygems_version: 2.7.3
|
344
|
+
signing_key:
|
323
345
|
specification_version: 4
|
324
346
|
summary: truemail
|
325
347
|
test_files: []
|