diff --git a/lib/helpers/deprecation_helper.rb b/lib/helpers/deprecation_helper.rb deleted file mode 100644 index 85a419a..0000000 --- a/lib/helpers/deprecation_helper.rb +++ /dev/null @@ -1,14 +0,0 @@ -module DeprecationHelper - def deprecate_method(old_method, new_method) - define_method(old_method) do |*args, &block| - klass = is_a? Module - target = klass ? "#{self}." : "#{self.class}#" - warn "Warning: `#{target}#{old_method}` is deprecated and will be removed in version 6 of valid_email2; use `#{new_method}` instead." - send(new_method, *args, &block) - end - end - - def deprecation_message(old_name, new_name) - warn "Warning: `#{old_name}` is deprecated and will be removed in version 6 of valid_email2; use `#{new_name}` instead." - end -end diff --git a/lib/valid_email2.rb b/lib/valid_email2.rb index 90ed415..b711006 100644 --- a/lib/valid_email2.rb +++ b/lib/valid_email2.rb @@ -4,10 +4,7 @@ require_relative "./helpers/deprecation_helper" module ValidEmail2 - - BLACKLIST_FILE = "config/blacklisted_email_domains.yml" DENY_LIST_FILE = "config/deny_listed_email_domains.yml" - WHITELIST_FILE = "config/whitelisted_email_domains.yml" ALLOW_LIST_FILE = "config/allow_listed_email_domains.yml" DISPOSABLE_FILE = File.expand_path('../config/disposable_email_domains.txt', __dir__) @@ -19,18 +16,12 @@ def disposable_emails end def deny_list - @deny_list ||= load_if_exists(DENY_LIST_FILE) || - load_deprecated_if_exists(BLACKLIST_FILE) || - Set.new + @deny_list ||= load_if_exists(DENY_LIST_FILE) || Set.new end - deprecate_method :blacklist, :deny_list def allow_list - @allow_list ||= load_if_exists(ALLOW_LIST_FILE) || - load_deprecated_if_exists(WHITELIST_FILE) || - Set.new + @allow_list ||= load_if_exists(ALLOW_LIST_FILE) || Set.new end - deprecate_method :whitelist, :allow_list private @@ -38,16 +29,6 @@ def load_if_exists(path) load_file(path) if File.exist?(path) end - def load_deprecated_if_exists(path) - if File.exist?(path) - warn <<~WARN - Warning: The file `#{path}` used by valid_email2 is deprecated and won't be read in version 6 of valid_email2; - Rename the file to `#{path.gsub("blacklisted", "deny_listed").gsub("whitelisted", "allow_listed")}` instead." - WARN - load_file(path) - end - end - def load_file(path) # This method MUST return a Set, otherwise the # performance will suffer! diff --git a/lib/valid_email2/address.rb b/lib/valid_email2/address.rb index 3727f1d..b571fe4 100644 --- a/lib/valid_email2/address.rb +++ b/lib/valid_email2/address.rb @@ -90,12 +90,10 @@ def disposable_mx_server? def allow_listed? domain_is_in?(ValidEmail2.allow_list) end - deprecate_method :whitelisted?, :allow_listed? def deny_listed? valid? && domain_is_in?(ValidEmail2.deny_list) end - deprecate_method :blacklisted?, :deny_listed? def valid_mx? return false unless valid? diff --git a/lib/valid_email2/email_validator.rb b/lib/valid_email2/email_validator.rb index 47f9e50..e32d813 100644 --- a/lib/valid_email2/email_validator.rb +++ b/lib/valid_email2/email_validator.rb @@ -35,27 +35,15 @@ def validate_each(record, attribute, value) error(record, attribute) && return if addresses.any?(&:disposable_domain?) end - if options[:disposable_with_whitelist] - deprecation_message(:disposable_with_whitelist, :disposable_with_allow_list) - end - - if options[:disposable_with_allow_list] || options[:disposable_with_whitelist] + if options[:disposable_with_allow_list] error(record, attribute) && return if addresses.any? { |address| address.disposable? && !address.allow_listed? } end - if options[:disposable_domain_with_whitelist] - deprecation_message(:disposable_domain_with_whitelist, :disposable_domain_with_allow_list) - end - - if options[:disposable_domain_with_allow_list] || options[:disposable_domain_with_whitelist] + if options[:disposable_domain_with_allow_list] error(record, attribute) && return if addresses.any? { |address| address.disposable_domain? && !address.allow_listed? } end - if options[:blacklist] - deprecation_message(:blacklist, :deny_list) - end - - if options[:deny_list] || options[:blacklist] + if options[:deny_list] error(record, attribute) && return if addresses.any?(&:deny_listed?) end diff --git a/pull_mailchecker_emails.rb b/pull_mailchecker_emails.rb index 6edf1c0..2cfcdff 100644 --- a/pull_mailchecker_emails.rb +++ b/pull_mailchecker_emails.rb @@ -5,7 +5,7 @@ require "json" require "net/http" -whitelisted_emails = %w[ +allow_listed_emails = %w[ onet.pl poczta.onet.pl fastmail.fm hushmail.com hush.ai hush.com hushmail.me naver.com qq.com example.com yandex.net gmx.com gmx.es webdesignspecialist.com.au vp.com @@ -29,6 +29,6 @@ resp.body.split("\n").flatten end -result_emails = (existing_emails + remote_emails).map(&:strip).uniq.sort - whitelisted_emails +result_emails = (existing_emails + remote_emails).map(&:strip).uniq.sort - allow_listed_emails File.write("config/disposable_email_domains.txt", result_emails.join("\n"))