Sha256: 80a0d969089cfef46275888ece85aef5489d64012823a7505899cb5af84696e8
Contents?: true
Size: 1.04 KB
Versions: 23
Compression:
Stored size: 1.04 KB
Contents
require "email/provider" module Imap::Backup class Setup; end class Setup::Email attr_reader :account attr_reader :config def initialize(account:, config:) @account = account @config = config end def run username = Setup::Asker.email(account.username) other_accounts = config.accounts.reject { |a| a == account } others = other_accounts.map(&:username) if others.include?(username) Kernel.puts( "There is already an account set up with that email address" ) else account.username = username if account.server.nil? || (account.server == "") default = default_server(username) account.server = default if default end end end private def default_server(username) provider = Email::Provider.for_address(username) if provider.is_a?(Email::Provider::Unknown) Kernel.puts "Can't decide provider for email address '#{username}'" return nil end provider.host end end end
Version data entries
23 entries across 23 versions & 1 rubygems