Module: Truemail

Defined in:
lib/truemail.rb,
lib/truemail/core.rb,
lib/truemail/logger.rb,
lib/truemail/worker.rb,
lib/truemail/auditor.rb,
lib/truemail/version.rb,
lib/truemail/wrapper.rb,
lib/truemail/audit/ip.rb,
lib/truemail/executor.rb,
lib/truemail/audit/dns.rb,
lib/truemail/audit/ptr.rb,
lib/truemail/log/event.rb,
lib/truemail/validator.rb,
lib/truemail/audit/base.rb,
lib/truemail/dns/worker.rb,
lib/truemail/validate/mx.rb,
lib/truemail/dns/resolver.rb,
lib/truemail/configuration.rb,
lib/truemail/validate/base.rb,
lib/truemail/validate/smtp.rb,
lib/truemail/validate/regex.rb,
lib/truemail/log/serializer/base.rb,
lib/truemail/validate/mx_blacklist.rb,
lib/truemail/validate/smtp/request.rb,
lib/truemail/validate/smtp/response.rb,
lib/truemail/dns/punycode_representer.rb,
lib/truemail/validate/domain_list_match.rb,
lib/truemail/log/serializer/auditor_json.rb,
lib/truemail/log/serializer/validator_base.rb,
lib/truemail/log/serializer/validator_json.rb,
lib/truemail/log/serializer/validator_text.rb

Defined Under Namespace

Modules: Audit, Dns, Log, RegexConstant, Validate Classes: Auditor, Configuration, Executor, Logger, Validator, Worker, Wrapper

Constant Summary collapse

INCOMPLETE_CONFIG =
'verifier_email is required parameter'
NOT_CONFIGURED =
'use Truemail.configure before or pass custom configuration'
INVALID_TYPE =
'email should be a String'
ConfigurationError =
::Class.new(::StandardError)
TypeError =
::Class.new(::StandardError)
ArgumentError =
::Class.new(::StandardError) do
  def initialize(arg_value, arg_name)
    super("#{arg_value} is not a valid #{arg_name}")
  end
end
VERSION =
'2.7.3'

Class Method Summary collapse

Class Method Details

.configuration(&block) ⇒ Object


11
12
13
14
15
16
17
18
# File 'lib/truemail.rb', line 11

def configuration(&block)
  @configuration ||= begin
    return unless block
    configuration = Truemail::Configuration.new(&block)
    raise_unless(configuration.complete?, Truemail::INCOMPLETE_CONFIG)
    configuration
  end
end

.configure(&block) ⇒ Object


20
21
22
# File 'lib/truemail.rb', line 20

def configure(&block)
  configuration(&block)
end

.host_audit(custom_configuration: nil) ⇒ Object


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

def host_audit(custom_configuration: nil)
  Truemail::Auditor.new(configuration: determine_configuration(custom_configuration)).run
end

.reset_configuration!Object


24
25
26
# File 'lib/truemail.rb', line 24

def reset_configuration!
  @configuration = nil
end

.valid?(email, **options) ⇒ Boolean

Returns:

  • (Boolean)

33
34
35
36
# File 'lib/truemail.rb', line 33

def valid?(email, **options)
  check_argument_type(email)
  validate(email, **options).result.valid?
end

.validate(email, custom_configuration: nil, **options) ⇒ Object


28
29
30
31
# File 'lib/truemail.rb', line 28

def validate(email, custom_configuration: nil, **options)
  check_argument_type(email)
  Truemail::Validator.new(email, configuration: determine_configuration(custom_configuration), **options).run
end