Sha256: 32907ad20a5f0f91e2a3e5175dc00ba66f1cf40254440c8523dc899fd7ab0906
Contents?: true
Size: 986 Bytes
Versions: 4
Compression:
Stored size: 986 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('@')[1..-1]&.join('@')&.downcase&.strip end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
freemail-0.8.0 | lib/freemail.rb |
freemail-0.7.0 | lib/freemail.rb |
freemail-0.6.1 | lib/freemail.rb |
freemail-0.6.0 | lib/freemail.rb |