truemail 1.0.1 → 1.1.0

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: d6ae9e8559f02e6dc3c192d25b68299d710b0f725d6415dcce94291b67cfedec
4
- data.tar.gz: ca8150d40f29c19424c75203ebc8725a158f9ab211e31fed6139258f850f061e
3
+ metadata.gz: 20487757313dd1f93984687a1bb9190b5a8e7a9f619d41a5ae0b550230de63a5
4
+ data.tar.gz: fc67f8aaa93041388ff21a9dfb3cbeee16581929cd8217cb2101de64ef2c5af7
5
5
  SHA512:
6
- metadata.gz: 756ac97059a71e39fff2161c9d484ac5c916061403d7165fb1afd45c1d363928c10330fc0175ed33fe0915eedc503b237e8c796fe1cdfd4c80a7dc7c2fc4d6f5
7
- data.tar.gz: 565ab89967301f5f8b9cd5cd6c230ee6c1a6e908776532f1346131850afccfe72063bb2acc05b573b806c8cd8be13b0f085eaadf136de9165ace3a6ee232651e
6
+ metadata.gz: 2f4551903201185b354ec56c919fba276633da90546a8de1c4a3e57d0f4b786de6b1d7c667be61af5a46414569f9d00c98d19e0cc9e3bfa23c80c807fc38ba1e
7
+ data.tar.gz: 27873755f8df550ce1b2be550b8ad6650a3b4dbbeb1f5d0ee7bade7588d2d7a0b3eb1fe539a596ab05ecf220391006f6d10bfb95dfb312ce05653b2c59bf5c7a
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- truemail (1.0.1)
4
+ truemail (1.1.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -74,6 +74,11 @@ Truemail.configure do |config|
74
74
  # there is one mx server).
75
75
  config.connection_attempts = 3
76
76
 
77
+ # Optional parameter. You can predefine default validation type for
78
+ # Truemail.validate('email@email.com') call without with-parameter
79
+ # Available validation types: :regex, :mx, :smtp
80
+ config.default_validation_type = :mx
81
+
77
82
  # Optional parameter. You can predefine which type of validation will be used for domains.
78
83
  # Also you can skip validation by domain. Available validation types: :regex, :mx, :smtp
79
84
  # This configuration will be used over current or default validation type parameter
@@ -5,6 +5,7 @@ module Truemail
5
5
  DEFAULT_CONNECTION_TIMEOUT = 2
6
6
  DEFAULT_RESPONSE_TIMEOUT = 2
7
7
  DEFAULT_CONNECTION_ATTEMPTS = 2
8
+ DEFAULT_VALIDATION_TYPE = :smtp
8
9
 
9
10
  attr_reader :email_pattern,
10
11
  :smtp_error_body_pattern,
@@ -13,6 +14,7 @@ module Truemail
13
14
  :connection_timeout,
14
15
  :response_timeout,
15
16
  :connection_attempts,
17
+ :default_validation_type,
16
18
  :validation_type_by_domain,
17
19
  :whitelisted_domains,
18
20
  :blacklisted_domains
@@ -27,6 +29,7 @@ module Truemail
27
29
  @connection_timeout = Truemail::Configuration::DEFAULT_CONNECTION_TIMEOUT
28
30
  @response_timeout = Truemail::Configuration::DEFAULT_RESPONSE_TIMEOUT
29
31
  @connection_attempts = Truemail::Configuration::DEFAULT_CONNECTION_ATTEMPTS
32
+ @default_validation_type = Truemail::Configuration::DEFAULT_VALIDATION_TYPE
30
33
  @validation_type_by_domain = {}
31
34
  @whitelisted_domains = []
32
35
  @blacklisted_domains = []
@@ -58,6 +61,11 @@ module Truemail
58
61
  end
59
62
  end
60
63
 
64
+ def default_validation_type=(argument)
65
+ raise_unless(argument, __method__, argument.is_a?(Symbol) && Truemail::Validator::VALIDATION_TYPES.include?(argument))
66
+ @default_validation_type = argument
67
+ end
68
+
61
69
  def validation_type_for=(settings)
62
70
  validate_validation_type(settings)
63
71
  validation_type_by_domain.merge!(settings)
@@ -14,8 +14,8 @@ module Truemail
14
14
 
15
15
  attr_reader :validation_type, :result
16
16
 
17
- def initialize(email, with: :smtp)
18
- raise ArgumentError.new(with, :argument) unless VALIDATION_TYPES.include?(with)
17
+ def initialize(email, with: Truemail.configuration.default_validation_type)
18
+ raise Truemail::ArgumentError.new(with, :argument) unless Truemail::Validator::VALIDATION_TYPES.include?(with)
19
19
  @validation_type = select_validation_type(email, with)
20
20
  @result = Truemail::Validator::Result.new(email: email)
21
21
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Truemail
4
- VERSION = '1.0.1'
4
+ VERSION = '1.1.0'
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: 1.0.1
4
+ version: 1.1.0
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-06-08 00:00:00.000000000 Z
11
+ date: 2019-06-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler