module PostyClient::Command::FinderConcerns

Public Instance Methods

find_domain_alias_by_domain_and_name(domain_name, name) click to toggle source
# File lib/posty_client/command/finder_concerns.rb, line 40
def find_domain_alias_by_domain_and_name(domain_name, name)
  domain = find_domain_by_name(domain_name)
  
  DomainAlias.new(domain, name)
end
find_domain_by_name(name) click to toggle source
# File lib/posty_client/command/finder_concerns.rb, line 17
def find_domain_by_name(name)
  domain = Domain.new(name)
  if domain.new_resource?
    say("Unknown domain #{name}", :red)
    exit 1
  end

  domain        
end
find_user_alias_by_email_and_name(email, name) click to toggle source
# File lib/posty_client/command/finder_concerns.rb, line 34
def find_user_alias_by_email_and_name(email, name)
  user = find_user_by_email(email)
  
  UserAlias.new(user, name)
end
find_user_by_email(name) click to toggle source
# File lib/posty_client/command/finder_concerns.rb, line 27
def find_user_by_email(name)
  user_name, domain_name = user_and_domain_from_email(name)
  domain = find_domain_by_name(domain_name)

  User.new(domain, user_name)
end
user_and_domain_from_email(email) click to toggle source
# File lib/posty_client/command/finder_concerns.rb, line 6
def user_and_domain_from_email(email)
  parts = email.split("\@")

  unless parts.size == 2
    say("#{email} not an email address", :red)
    exit 1
  end

  return *parts
end