Sha256: 6557b6ddda3e68cca1d52074cee1644fee5fa605f9d8a2fd90e7036d75c9188a
Contents?: true
Size: 1.31 KB
Versions: 1
Compression:
Stored size: 1.31 KB
Contents
require "dnsaur/version" require "dnsaur/sift_3_distance" require "dnsaur/email_manipulation" class Dnsaur include EmailManipulation ARG_ERROR = "An email can not be empty or invalid" attr_reader :original_email def initialize email if Dnsaur.valid_email? email @original_email = email else raise ArgumentError, ARG_ERROR end @suggested_email = suggest @original_email end def self.open(*args) dnsaur = new(*args) return dnsaur unless block_given? begin yield dnsaur end end def original_email @original_email end def original_email= email raise ArgumentError, ARG_ERROR unless Dnsaur.valid_email? email @original_email = email @suggested_email = suggest email end def suggested_email return false unless @suggested_email @suggested_email[:full] if @suggested_email end def valid_original_dns? Dnsaur.valid_dns? @original_email end def valid_suggested_dns? return false unless @suggested_email Dnsaur.valid_dns? @suggested_email[:full] end def self.valid_dns? email email_parts = Dnsaur.split_email email mx = Resolv::DNS.open.getresources(email_parts[:domain], Resolv::DNS::Resource::IN::MX) mx.size > 0 ? true : false end def self.valid_email? email !!(Dnsaur.split_email email) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
dnsaur-0.1.0 | lib/dnsaur/dnsaur.rb |