Sha256: 137fb2390d3172fdf0824c25a7e7a377589149d6be959f30ccb27902a1d97fd8
Contents?: true
Size: 1.71 KB
Versions: 5
Compression:
Stored size: 1.71 KB
Contents
# frozen_string_literal: true require_relative 'truemail/core' module Truemail INCOMPLETE_CONFIG = 'verifier_email is required parameter' NOT_CONFIGURED = 'use Truemail.configure before or pass custom configuration' INVALID_TYPE = 'email should be a String' class << self def configuration(&block) @configuration ||= begin return unless block configuration = Truemail::Configuration.new(&block) raise_unless(configuration.complete?, Truemail::INCOMPLETE_CONFIG) configuration end end def configure(&block) configuration(&block) end def reset_configuration! @configuration = nil end def validate(email, custom_configuration: nil, **options) check_argument_type(email) Truemail::Validator.new(email, configuration: determine_configuration(custom_configuration), **options).run end def valid?(email, **options) validate(email, **options).result.valid? end def host_audit(custom_configuration: nil) Truemail::Auditor.new(configuration: determine_configuration(custom_configuration)).run end private def raise_unless(condition, message, error_class = Truemail::ConfigurationError) raise error_class, message unless condition end def check_argument_type(argument) raise_unless(argument.is_a?(::String), Truemail::INVALID_TYPE, Truemail::TypeError) end def determine_configuration(custom_configuration) current_configuration = custom_configuration || configuration raise_unless(current_configuration, Truemail::NOT_CONFIGURED) raise_unless(current_configuration.complete?, Truemail::INCOMPLETE_CONFIG) current_configuration.dup.freeze end end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
truemail-3.3.1 | lib/truemail.rb |
truemail-3.3.0 | lib/truemail.rb |
truemail-3.2.0 | lib/truemail.rb |
truemail-3.1.2 | lib/truemail.rb |
truemail-3.1.1 | lib/truemail.rb |