Sha256: ed45d73b75e72cb208fff2536e34fb1f5b48acf26b3841f2b14166f472dd71d6
Contents?: true
Size: 971 Bytes
Versions: 4
Compression:
Stored size: 971 Bytes
Contents
require 'freemail/version' module Freemail ROOT = File.join(File.dirname(File.expand_path(__FILE__)), '../') DISPOSABLE = Hash[File.readlines("#{ROOT}/data/disposable.txt").map { |d| [d.strip.downcase] }] FREE = Hash[File.readlines("#{ROOT}/data/free.txt").map { |d| [d.strip.downcase] }] def self.add_disposable_domains(custom_domains) custom_domains = [custom_domains] unless custom_domains.is_a? Array custom_domains.each { |domain| DISPOSABLE[domain] = nil } end def self.add_free_domains(custom_domains) custom_domains = [custom_domains] unless custom_domains.is_a? Array custom_domains.each { |domain| FREE[domain] = nil } end def self.free?(email) FREE.key?(get_domain(email)) end def self.disposable?(email) DISPOSABLE.key?(get_domain(email)) end def self.free_or_disposable?(email) free?(email) || disposable?(email) end def self.get_domain(email) email.split('@').last.downcase.strip end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
freemail-0.5.0 | lib/freemail.rb |
freemail-0.4.0 | lib/freemail.rb |
freemail-0.3.0 | lib/freemail.rb |
freemail-0.2.3 | lib/freemail.rb |