truemail 0.1.9 → 0.1.10

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 27a69f3c0536d74205f38246cdefa2b1586320b7869893791f0af5e95c343bbd
4
- data.tar.gz: 4a458c0b43cf22a8a44915d9cbb87a3c3c2b861236020e27c5f5af7a82e84078
3
+ metadata.gz: 297e4833b9652ed239d157a21f13e54495d2f88dd1fcfe72173df718a42f3c67
4
+ data.tar.gz: 9cc876220623ff3b5b19fdf005f74332975f5fb6b2ecf6afceeb2b2b852f1c01
5
5
  SHA512:
6
- metadata.gz: 3c1a271b9abca328704bcab4e25e925092f8e42a8340ad6696377381e484bc536f6be3e6668774caafbb4d68d126598c17269aca45660b0ef6b1c3bffd22d0d5
7
- data.tar.gz: 38f7aaa5eb4f01bd59f0e9bce1262a001c8e828444083cdcd2c48cf66c2e7cde430657646b6bad2624da6f58adf040a6cb7350de01b5182a9478171aa3cc4ab0
6
+ metadata.gz: e5af3df300ef218a2f10433294efd28a93b57979261f265d021b2cc25223845df28a9a2310dcda00ccfd75ac8de40e28a95d3991248f2e321934d215e1b67e88
7
+ data.tar.gz: f7d966fd95efc12b0eaf8a4208769abdf9f917a998edf80b29e2f0fe00d95cd93f292e9700bafb19dffd2112dbc304fdf75a89286a7949f848e63e92577154e7
data/.reek.yml CHANGED
@@ -27,6 +27,7 @@ detectors:
27
27
  exclude:
28
28
  - Truemail::Validate::Smtp::Request#compose_from
29
29
  - Truemail::Validator#select_validation_type
30
+ - Truemail::Validate::Base#configuration
30
31
  - Truemail::Validate::Mx#null_mx?
31
32
  - Truemail::Validate::Mx#a_record
32
33
  - Truemail::Audit::Base#verifier_domain
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- truemail (0.1.9)
4
+ truemail (0.1.10)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -114,4 +114,4 @@ DEPENDENCIES
114
114
  truemail!
115
115
 
116
116
  BUNDLED WITH
117
- 1.16.6
117
+ 1.17.3
data/README.md CHANGED
@@ -58,6 +58,9 @@ Truemail.configure do |config|
58
58
  # Optional parameter. You can override default regex pattern
59
59
  config.email_pattern = /regex_pattern/
60
60
 
61
+ # Optional parameter. You can override default regex pattern
62
+ config.smtp_error_body_pattern = /regex_pattern/
63
+
61
64
  # Optional parameter. Connection timeout is equal to 2 ms by default.
62
65
  config.connection_timeout = 1
63
66
 
@@ -92,6 +95,7 @@ Truemail.configuration
92
95
  => #<Truemail::Configuration:0x000055590cb17b40
93
96
  @connection_timeout=1,
94
97
  @email_pattern=/regex_pattern/,
98
+ @smtp_error_body_pattern=/regex_pattern/,
95
99
  @response_timeout=1,
96
100
  @connection_attempts=3,
97
101
  @validation_type_by_domain={},
@@ -114,6 +118,7 @@ Truemail.configuration
114
118
  => #<Truemail::Configuration:0x000055590cb17b40
115
119
  @connection_timeout=3,
116
120
  @email_pattern=/regex_pattern/,
121
+ @smtp_error_body_pattern=/regex_pattern/,
117
122
  @response_timeout=4,
118
123
  @connection_attempts=1,
119
124
  @validation_type_by_domain={},
@@ -270,6 +275,7 @@ Truemail.validate('email@example.com')
270
275
  #<Truemail::Configuration:0x0000000002d49930
271
276
  @connection_timeout=2,
272
277
  @email_pattern=/regex_pattern/,
278
+ @smtp_error_body_pattern=/regex_pattern/,
273
279
  @response_timeout=2,
274
280
  @connection_attempts=2,
275
281
  @smtp_safe_check=false,
@@ -323,6 +329,7 @@ Truemail.validate('email@example.com')
323
329
  #<Truemail::Configuration:0x0000000002c95b38
324
330
  @connection_timeout=2,
325
331
  @email_pattern=/regex_pattern/,
332
+ @smtp_error_body_pattern=/regex_pattern/,
326
333
  @response_timeout=2,
327
334
  @connection_attempts=2,
328
335
  @smtp_safe_check=true,
@@ -360,6 +367,7 @@ Truemail.validate('email@example.com')
360
367
  #<Truemail::Configuration:0x0000000002d49930
361
368
  @connection_timeout=2,
362
369
  @email_pattern=/regex_pattern/,
370
+ @smtp_error_body_pattern=/regex_pattern/,
363
371
  @response_timeout=2,
364
372
  @connection_attempts=2,
365
373
  @smtp_safe_check=true,
@@ -7,6 +7,7 @@ module Truemail
7
7
  DEFAULT_CONNECTION_ATTEMPTS = 2
8
8
 
9
9
  attr_reader :email_pattern,
10
+ :smtp_error_body_pattern,
10
11
  :verifier_email,
11
12
  :verifier_domain,
12
13
  :connection_timeout,
@@ -20,6 +21,7 @@ module Truemail
20
21
 
21
22
  def initialize
22
23
  @email_pattern = Truemail::RegexConstant::REGEX_EMAIL_PATTERN
24
+ @smtp_error_body_pattern = Truemail::RegexConstant::REGEX_SMTP_ERROR_BODY_PATTERN
23
25
  @connection_timeout = Truemail::Configuration::DEFAULT_CONNECTION_TIMEOUT
24
26
  @response_timeout = Truemail::Configuration::DEFAULT_RESPONSE_TIMEOUT
25
27
  @connection_attempts = Truemail::Configuration::DEFAULT_CONNECTION_ATTEMPTS
@@ -27,9 +29,11 @@ module Truemail
27
29
  @smtp_safe_check = false
28
30
  end
29
31
 
30
- def email_pattern=(regex_pattern)
31
- raise Truemail::ArgumentError.new(regex_pattern, Regexp) unless regex_pattern.is_a?(Regexp)
32
- @email_pattern = regex_pattern
32
+ %i[email_pattern smtp_error_body_pattern].each do |method|
33
+ define_method("#{method}=") do |argument|
34
+ raise Truemail::ArgumentError.new(argument, __method__) unless argument.is_a?(Regexp)
35
+ instance_variable_set(:"@#{method}", argument)
36
+ end
33
37
  end
34
38
 
35
39
  def verifier_email=(email)
data/lib/truemail/core.rb CHANGED
@@ -21,6 +21,7 @@ module Truemail
21
21
  REGEX_EMAIL_PATTERN = /(?=\A.{6,255}\z)(\A([a-zA-Z0-9]+[\w|\-|\.|\+]*)@(#{REGEX_DOMAIN})\z)/
22
22
  REGEX_DOMAIN_PATTERN = /(?=\A.{4,255}\z)(\A#{REGEX_DOMAIN}\z)/
23
23
  REGEX_DOMAIN_FROM_EMAIL = /\A.+@(.+)\z/
24
+ REGEX_SMTP_ERROR_BODY_PATTERN = /(?=.*550)(?=.*(user|account|customer|mailbox)).*/i
24
25
  end
25
26
 
26
27
  module Audit
@@ -12,6 +12,10 @@ module Truemail
12
12
  def mail_servers
13
13
  result.mail_servers
14
14
  end
15
+
16
+ def configuration
17
+ Truemail.configuration
18
+ end
15
19
  end
16
20
  end
17
21
  end
@@ -6,7 +6,7 @@ module Truemail
6
6
  ERROR = 'email does not match the regular expression'
7
7
 
8
8
  def run
9
- return true if success(Truemail.configuration.email_pattern.match?(result.email))
9
+ return true if success(configuration.email_pattern.match?(result.email))
10
10
  add_error(Truemail::Validate::Regex::ERROR)
11
11
  false
12
12
  end
@@ -4,7 +4,6 @@ module Truemail
4
4
  module Validate
5
5
  class Smtp < Truemail::Validate::Base
6
6
  ERROR = 'smtp error'
7
- ERROR_BODY = /(?=.*550)(?=.*(user|account|customer|mailbox)).*/i
8
7
 
9
8
  attr_reader :smtp_results
10
9
 
@@ -31,7 +30,7 @@ module Truemail
31
30
 
32
31
  def attempts
33
32
  @attempts ||=
34
- mail_servers.one? ? { attempts: Truemail.configuration.connection_attempts } : {}
33
+ mail_servers.one? ? { attempts: configuration.connection_attempts } : {}
35
34
  end
36
35
 
37
36
  def rcptto_error
@@ -53,11 +52,11 @@ module Truemail
53
52
  end
54
53
 
55
54
  def not_includes_user_not_found_errors?
56
- return unless Truemail.configuration.smtp_safe_check
55
+ return unless configuration.smtp_safe_check
57
56
  result.smtp_debug.map(&:response).map(&:errors).all? do |errors|
58
57
  next true unless errors.key?(:rcptto)
59
58
  errors.slice(:rcptto).values.none? do |error|
60
- Truemail::Validate::Smtp::ERROR_BODY.match?(error)
59
+ configuration.smtp_error_body_pattern.match?(error)
61
60
  end
62
61
  end
63
62
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Truemail
4
- VERSION = '0.1.9'
4
+ VERSION = '0.1.10'
5
5
  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: 0.1.9
4
+ version: 0.1.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vladislav Trotsenko
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-04-29 00:00:00.000000000 Z
11
+ date: 2019-05-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler