Sha256: 833fdead28de805a588b54ae31e3fb30d16831c175b5485255271501d88faddc
Contents?: true
Size: 1.18 KB
Versions: 2
Compression:
Stored size: 1.18 KB
Contents
require 'aptible/api' require 'git' module Aptible module CLI module Helpers module App include Helpers::Token def ensure_app(options = {}) handle = options[:app] || handle_from_remote(options[:remote]) || ensure_default_handle app = app_from_handle(handle) return app if app fail Thor::Error, "Could not find app #{handle}" end def app_from_handle(handle) Aptible::Api::App.all(token: fetch_token).find do |a| a.handle == handle end end def ensure_default_handle return default_handle if default_handle fail Thor::Error, <<-ERR.gsub(/\s+/, ' ').strip Could not find app in current working directory, please specify with --app ERR end def default_handle handle_from_remote(:aptible) end def handle_from_remote(remote_name) git = Git.open(Dir.pwd) aptible_remote = git.remote(remote_name).url || '' aptible_remote[/:(?<name>.+)\.git/, :name] rescue nil end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
aptible-cli-0.5.7 | lib/aptible/cli/helpers/app.rb |
aptible-cli-0.5.6 | lib/aptible/cli/helpers/app.rb |