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/validate/mx.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/smtp/request.rb,
lib/truemail/validate/smtp/response.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, 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'
ConfigurationError =
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
PunycodeRepresenter =
Class.new do
  require 'simpleidn'

  def self.call(email)
    return unless email.is_a?(String)
    return email if email.ascii_only?
    user, domain = email.split('@')
    "#{user}@#{SimpleIDN.to_ascii(domain.downcase)}"
  end
end
VERSION =
'1.9.0'

Class Method Summary collapse

Class Method Details

.configuration(&block) ⇒ Object


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

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

.configure(&block) ⇒ Object


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

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

.host_audit(custom_configuration: nil) ⇒ Object


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

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

.reset_configuration!Object


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

def reset_configuration!
  @configuration = nil
end

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

Returns:

  • (Boolean)

31
32
33
# File 'lib/truemail.rb', line 31

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

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


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

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