Sha256: 3cb1b210641ba6c7c55df9cfbcaf6422d84d64647b696759a5bb1863599fce5e

Contents?: true

Size: 790 Bytes

Versions: 1

Compression:

Stored size: 790 Bytes

Contents

require "email_assessor/email_validator"

module EmailAssessor
  DISPOSABLE_DOMAINS_FILE = File.expand_path("../../vendor/disposable_domains.txt", __FILE__)
  BLACKLISTED_DOMAINS_FILE = File.expand_path("../../vendor/blacklisted_domains.txt", __FILE__)

  def self.domain_is_disposable?(domain)
    domain_in_file?(domain, DISPOSABLE_DOMAINS_FILE)
  end

  def self.domain_is_blacklisted?(domain)
    domain_in_file?(domain, BLACKLISTED_DOMAINS_FILE)
  end

  protected

  def self.domain_in_file?(domain, filename)
    return false unless File.exists?(filename)

    domain = domain.downcase
    domain_matched = false

    File.open(filename).each do |line|
      if domain.end_with?(line.chomp)
        domain_matched = true
        break
      end
    end

    domain_matched
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
email_assessor-0.1 lib/email_assessor.rb