Class: Heroku::Command::Base

Inherits:
Object
  • Object
show all
Includes:
Helpers
Defined in:
lib/heroku/command/base.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Helpers

#action, #ask, #confirm, #confirm_billing, #confirm_command, #create_git_remote, #deprecate, #display, #display_header, #display_object, #display_row, #display_table, #error, error_with_failure, error_with_failure=, extended, extended_into, #fail, #format_bytes, #format_date, #format_error, #format_with_bang, #get_terminal_environment, #git, #has_git?, #home_directory, #host_name, #hprint, #hputs, included, included_into, #json_decode, #json_encode, #launchy, #line_formatter, #longest, #output_with_bang, #quantify, #redisplay, #retry_on_exception, #run_command, #running_on_a_mac?, #running_on_windows?, #set_buffer, #shell, #spinner, #status, #string_distance, #styled_array, #styled_error, #styled_hash, #styled_header, #suggestion, #time_ago, #truncate, #with_tty

Constructor Details

#initialize(args = [], options = {}) ⇒ Base

Returns a new instance of Base.



16
17
18
19
# File 'lib/heroku/command/base.rb', line 16

def initialize(args=[], options={})
  @args = args
  @options = options
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



13
14
15
# File 'lib/heroku/command/base.rb', line 13

def args
  @args
end

#optionsObject (readonly)

Returns the value of attribute options.



14
15
16
# File 'lib/heroku/command/base.rb', line 14

def options
  @options
end

Class Method Details

.namespaceObject



9
10
11
# File 'lib/heroku/command/base.rb', line 9

def self.namespace
  self.to_s.split("::").last.downcase
end

Instance Method Details

#apiObject



39
40
41
# File 'lib/heroku/command/base.rb', line 39

def api
  Heroku::Auth.api
end

#appObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/heroku/command/base.rb', line 21

def app
  @app ||= if options[:confirm].is_a?(String)
    if options[:app] && (options[:app] != options[:confirm])
      error("Mismatch between --app and --confirm")
    end
    options[:confirm]
  elsif options[:app].is_a?(String)
    options[:app]
  elsif ENV.has_key?('HEROKU_APP')
    ENV['HEROKU_APP']
  elsif app_from_dir = extract_app_in_dir(Dir.pwd)
    app_from_dir
  else
    # raise instead of using error command to enable rescuing when app is optional
    raise Heroku::Command::CommandFailed.new("No app specified.\nRun this command from an app folder or specify which app to use with --app APP.")
  end
end

#herokuObject



43
44
45
# File 'lib/heroku/command/base.rb', line 43

def heroku
  Heroku::Auth.client
end