lib/email_inquire/inquirer.rb in email_inquire-0.6.0 vs lib/email_inquire/inquirer.rb in email_inquire-0.7.0
- old
+ new
@@ -2,11 +2,10 @@
require "damerau-levenshtein"
require "set"
module EmailInquire
-
class Inquirer
class << self
private
@@ -30,10 +29,11 @@
attr_reader :domain, :email, :name
VALIDATORS = %i[
validate_common_domains
validate_one_time_providers
+ validate_known_invalid_domains
validate_common_domain_mistakes
validate_cc_tld
validate_common_tld_mistakes
validate_domains_with_unique_tld
].freeze
@@ -61,13 +61,14 @@
def parse_email
@name, @domain = email.split("@")
end
def response
- @response ||= Response.new.tap do |response|
- response.email = email
- end
+ @response ||=
+ Response.new.tap do |response|
+ response.email = email
+ end
end
COMMON_DOMAIN_MISTAKES = {
/google(?!mail)/ => "gmail.com",
/windows.*\.com/ => "live.com",
@@ -159,8 +160,13 @@
def validate_one_time_providers
response.invalid! if ONE_TIME_EMAIL_PROVIDERS.include?(domain)
end
- end
+ KNOWN_INVALID_DOMAINS = load_data("known_invalid_domains").freeze
+ def validate_known_invalid_domains
+ response.invalid! if KNOWN_INVALID_DOMAINS.include?(domain)
+ end
+
+ end
end