Class: Truemail::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/truemail/configuration.rb

Constant Summary collapse

DEFAULT_CONNECTION_TIMEOUT =
2
DEFAULT_RESPONSE_TIMEOUT =
2
DEFAULT_CONNECTION_ATTEMPTS =
2
DEFAULT_VALIDATION_TYPE =
:smtp
DEFAULT_SMTP_PORT =
25
DEFAULT_LOGGER_OPTIONS =
{
  tracking_event: :error,
  stdout: false,
  log_absolute_path: nil
}.freeze
SETTERS =
%i[
  email_pattern
  smtp_error_body_pattern
  connection_timeout
  response_timeout
  connection_attempts
  whitelisted_emails
  blacklisted_emails
  whitelisted_domains
  blacklisted_domains
  blacklisted_mx_ip_addresses
  dns
  smtp_port
].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ Configuration

Returns a new instance of Configuration.



39
40
41
42
43
44
# File 'lib/truemail/configuration.rb', line 39

def initialize(&block)
  instance_initializer.each do |instace_variable, value|
    instance_variable_set(:"@#{instace_variable}", value)
  end
  tap(&block) if block
end

Instance Attribute Details

#not_rfc_mx_lookup_flowObject

Returns the value of attribute not_rfc_mx_lookup_flow.



37
38
39
# File 'lib/truemail/configuration.rb', line 37

def not_rfc_mx_lookup_flow
  @not_rfc_mx_lookup_flow
end

#smtp_fail_fastObject

Returns the value of attribute smtp_fail_fast.



37
38
39
# File 'lib/truemail/configuration.rb', line 37

def smtp_fail_fast
  @smtp_fail_fast
end

#smtp_safe_checkObject

Returns the value of attribute smtp_safe_check.



37
38
39
# File 'lib/truemail/configuration.rb', line 37

def smtp_safe_check
  @smtp_safe_check
end

#whitelist_validationObject

Returns the value of attribute whitelist_validation.



37
38
39
# File 'lib/truemail/configuration.rb', line 37

def whitelist_validation
  @whitelist_validation
end

Instance Method Details

#argument_consistent?(method, argument) ⇒ Boolean

Returns:

  • (Boolean)


67
68
69
70
71
72
73
# File 'lib/truemail/configuration.rb', line 67

def argument_consistent?(method, argument)
  case argument
  when ::Array then items_match_regex?(argument, regex_by_method(method))
  when ::Integer then argument.positive?
  when ::Regexp then true
  end
end

#complete?Boolean

Returns:

  • (Boolean)


87
88
89
# File 'lib/truemail/configuration.rb', line 87

def complete?
  !!verifier_email
end

#default_validation_type=(argument) ⇒ Object



57
58
59
60
# File 'lib/truemail/configuration.rb', line 57

def default_validation_type=(argument)
  raise_unless(argument, __method__, argument.is_a?(::Symbol) && Truemail::Validator::VALIDATION_TYPES.include?(argument))
  @default_validation_type = argument
end

#logger=(options) ⇒ Object



82
83
84
85
# File 'lib/truemail/configuration.rb', line 82

def logger=(options)
  raise_unless(options, __method__, options.is_a?(::Hash))
  @logger = Truemail::Logger::Builder.call(Truemail::Configuration::DEFAULT_LOGGER_OPTIONS, **options)
end

#validation_type_for=(settings) ⇒ Object



62
63
64
65
# File 'lib/truemail/configuration.rb', line 62

def validation_type_for=(settings)
  validate_validation_type(settings)
  validation_type_by_domain.merge!(settings)
end

#verifier_domain=(domain) ⇒ Object



52
53
54
55
# File 'lib/truemail/configuration.rb', line 52

def verifier_domain=(domain)
  validate_arguments(domain, __method__)
  @verifier_domain = domain.downcase
end

#verifier_email=(email) ⇒ Object



46
47
48
49
50
# File 'lib/truemail/configuration.rb', line 46

def verifier_email=(email)
  validate_arguments(email, __method__)
  @verifier_email = email.downcase
  default_verifier_domain
end