class Shelly::User

Public Class Methods

guess_email() click to toggle source
# File lib/shelly/user.rb, line 58
def self.guess_email
  @@guess_email ||= IO.popen("git config --get user.email").read.strip
end

Public Instance Methods

apps() click to toggle source
# File lib/shelly/user.rb, line 5
def apps
  shelly.apps.map do |attributes|
    Shelly::App.from_attributes(attributes)
  end
end
authorize!() click to toggle source
# File lib/shelly/user.rb, line 25
def authorize!
  if credentials_exists?
    email, password = File.read(credentials_path).split("\n")
    shelly.authorize_with_email_and_password(email, password)
    delete_credentials
  else
    shelly.authorize!
  end
end
config_dir() click to toggle source
# File lib/shelly/user.rb, line 62
def config_dir
  File.expand_path("~/.shelly")
end
delete_credentials() click to toggle source
# File lib/shelly/user.rb, line 54
def delete_credentials
  File.delete(credentials_path) if credentials_exists?
end
email() click to toggle source
# File lib/shelly/user.rb, line 17
def email
  shelly.user_email
end
login(email, password) click to toggle source
# File lib/shelly/user.rb, line 35
def login(email, password)
  delete_credentials # clean up previous auth storage

  shelly.authorize_with_email_and_password(email, password)
end
logout() click to toggle source
# File lib/shelly/user.rb, line 41
def logout
  delete_credentials # clean up previous auth storage
  shelly.forget_authorization
end
organizations() click to toggle source
# File lib/shelly/user.rb, line 11
def organizations
  shelly.organizations.map do |attributes|
    Shelly::Organization.new(attributes)
  end
end
register(email, password) click to toggle source
# File lib/shelly/user.rb, line 21
def register(email, password)
  shelly.register_user(email, password)
end
ssh_key() click to toggle source
# File lib/shelly/user.rb, line 50
def ssh_key
  ssh_keys.prefered_key
end
ssh_keys() click to toggle source
# File lib/shelly/user.rb, line 46
def ssh_keys
  @keys ||= SshKeys.new
end

Protected Instance Methods

credentials_exists?() click to toggle source
# File lib/shelly/user.rb, line 71
def credentials_exists?
  File.exists?(credentials_path)
end
credentials_path() click to toggle source
# File lib/shelly/user.rb, line 67
def credentials_path
  File.join(config_dir, "credentials")
end