lib/email_data.rb in email_data-1601711723 vs lib/email_data.rb in email_data-1602274654

- old
+ new

@@ -1,39 +1,34 @@ # frozen_string_literal: true +require "forwardable" require "pathname" -require "email_data/version" module EmailData - def self.data_dir - Pathname.new(File.expand_path("../data", __dir__)) - end + require "email_data/version" + require "email_data/source/file_system" - def self.tlds - @tlds ||= load_file("tlds.txt") - end + class << self + extend Forwardable - def self.country_tlds - @country_tlds ||= load_file("country_tlds.txt") + def_delegators :source, + :disposable_domains, + :disposable_emails, + :country_tlds, + :free_email_domains, + :tlds end - def self.disposable_emails - @disposable_emails ||= load_file("disposable_emails.txt") + def self.source=(source) + @source = source end - def self.disposable_domains - @disposable_domains ||= load_file("disposable_domains.txt") + def self.source + @source end - def self.free_email_domains - @free_email_domains ||= load_file("free_email_domains.txt") + def self.data_dir + Pathname.new(File.expand_path("../data", __dir__)) end - def self.load_file(filename) - data_dir - .join(filename) - .read - .lines - .map(&:chomp) - .reject(&:empty?) - end + self.source = EmailData::Source::FileSystem end