module ValidEmail2

Constants

ALLOW_LIST_FILE
DENY_LIST_FILE
DISPOSABLE_FILE
VERSION

Public Class Methods

allow_list() click to toggle source
# File lib/valid_email2.rb, line 19
def allow_list
  @allow_list ||= load_if_exists(ALLOW_LIST_FILE) || Set.new
end
deny_list() click to toggle source
# File lib/valid_email2.rb, line 15
def deny_list
  @deny_list ||= load_if_exists(DENY_LIST_FILE) || Set.new
end
disposable_emails() click to toggle source
# File lib/valid_email2.rb, line 11
def disposable_emails
  @disposable_emails ||= load_file(DISPOSABLE_FILE)
end

Private Class Methods

load_file(path) click to toggle source
# File lib/valid_email2.rb, line 29
def load_file(path)
  # This method MUST return a Set, otherwise the
  # performance will suffer!
  if path.end_with?(".yml")
    Set.new(YAML.load_file(path))
  else
    File.open(path, "r").each_line.each_with_object(Set.new) do |domain, set|
      set << domain.tap(&:chomp!)
    end
  end
end
load_if_exists(path) click to toggle source
# File lib/valid_email2.rb, line 25
def load_if_exists(path)
  load_file(path) if File.exist?(path)
end