class Aptible::CLI::Helpers::App::GitRemoteHandleStrategy

Public Class Methods

new(options) click to toggle source
# File lib/aptible/cli/helpers/app.rb, line 57
def initialize(options)
  @remote_name = options[:remote] || ENV['APTIBLE_REMOTE'] ||
                 'aptible'
  @repo_dir = Dir.pwd
end

Public Instance Methods

app_handle() click to toggle source
# File lib/aptible/cli/helpers/app.rb, line 63
def app_handle
  handles_from_remote[:app_handle]
end
env_handle() click to toggle source
# File lib/aptible/cli/helpers/app.rb, line 67
def env_handle
  handles_from_remote[:environment_handle]
end
explain() click to toggle source
# File lib/aptible/cli/helpers/app.rb, line 75
def explain
  "(options derived from git remote #{@remote_name})"
end
usable?() click to toggle source
# File lib/aptible/cli/helpers/app.rb, line 71
def usable?
  !app_handle.nil? && !env_handle.nil?
end

Private Instance Methods

handles_from_remote() click to toggle source
# File lib/aptible/cli/helpers/app.rb, line 81
def handles_from_remote
  @handles_from_remote ||= \
    begin
      git = Git.open(@repo_dir)
      remote_url = git.remote(@remote_name).url || ''
      HandleFromGitRemote.parse(remote_url)
    rescue StandardError
      # TODO: Consider being more specific here (ArgumentError?)
      {}
    end
end