class Truemail::Log::Serializer::ValidatorText

Constants

ATTEMPT

Public Instance Methods

serialize() click to toggle source
# File lib/truemail/log/serializer/validator_text.rb, line 9
        def serialize
          <<~VALIDATION_LOGGER_INFO
            #{txt_info_title}
            #{txt_info_debug}
            #{txt_info_configuration}
          VALIDATION_LOGGER_INFO
        end

Private Instance Methods

collection_printer(collection) click to toggle source
# File lib/truemail/log/serializer/validator_text.rb, line 31
def collection_printer(collection)
  collection.inject([]) { |array, hash| array << printer(hash) }.map.with_index do |item, index|
    "\n#{Truemail::Log::Serializer::ValidatorText::ATTEMPT}#{index + 1}:\n#{item}\n"
  end
end
data_composer(enumerable_object) click to toggle source
# File lib/truemail/log/serializer/validator_text.rb, line 19
def data_composer(enumerable_object)
  enumerable_object.inject([]) do |formatted_data, (key, value)|
    data =
      case value
      when ::Hash then "\n#{printer(value)}"
      when ::Array then value.join(', ')
      else value
      end
    formatted_data << "#{key.to_s.tr('_', ' ')}: #{data}".chomp << "\n"
  end
end
error_info() click to toggle source
# File lib/truemail/log/serializer/validator_text.rb, line 45
def error_info
  validation_errors = result[:errors]
  validation_errors ? " (#{printer(validation_errors).tr("\n", ', ')})" : validation_errors
end
printer(enumerable_object) click to toggle source
# File lib/truemail/log/serializer/validator_text.rb, line 37
def printer(enumerable_object)
  if enumerable_object.is_a?(Hash)
    data_composer(enumerable_object)
  else
    collection_printer(enumerable_object)
  end.join.chomp
end
txt_info_configuration() click to toggle source
# File lib/truemail/log/serializer/validator_text.rb, line 60
def txt_info_configuration
  "CONFIGURATION SETTINGS:\n#{printer(result[:configuration].compact)}"
end
txt_info_debug() click to toggle source
# File lib/truemail/log/serializer/validator_text.rb, line 55
def txt_info_debug
  result_smtp_debug = result[:smtp_debug]
  "#{printer(result_smtp_debug)}\n" if result_smtp_debug
end
txt_info_title() click to toggle source
# File lib/truemail/log/serializer/validator_text.rb, line 50
def txt_info_title
  validation_result = result[:success] ? 'was successful' : 'failed'
  "Truemail #{result[:validation_type]} validation for #{result[:email]} #{validation_result}#{error_info}"
end