class Rvm2::Shell::Command::Base

Attributes

command[R]
status[R]

Public Class Methods

new(*args) click to toggle source
# File lib/rvm2/shell/command/base.rb, line 11
def initialize(*args)
  @command = args
end

Public Instance Methods

aborted?() click to toggle source
# File lib/rvm2/shell/command/base.rb, line 42
def aborted?
  @status.nil?
end
duration() click to toggle source
# File lib/rvm2/shell/command/base.rb, line 27
def duration
  return nil if @started.nil? || @finished.nil?
  @finished - @started
end
execute(runner) click to toggle source
# File lib/rvm2/shell/command/base.rb, line 32
def execute(runner)
  start
  status = runner.execute(to_s) do |out, err|
    run_hook(:on_stdout, out) if out
    run_hook(:on_stderr, err) if err
  end
ensure
  finish(status) # nil if not called
end
failed?() click to toggle source
# File lib/rvm2/shell/command/base.rb, line 50
def failed?
  !aborted? && !success?
end
finish(status) click to toggle source
# File lib/rvm2/shell/command/base.rb, line 20
def finish(status)
  @finished = Time.now
  @status   = status
  run_hook(:on_finish, @finished, @status)
  @status
end
start() click to toggle source
# File lib/rvm2/shell/command/base.rb, line 15
def start
  @started = Time.now
  run_hook(:on_start, @started)
end
success?() click to toggle source
# File lib/rvm2/shell/command/base.rb, line 46
def success?
  @status == 0
end
to_s() click to toggle source
# File lib/rvm2/shell/command/base.rb, line 54
def to_s
  args.map{|a| "\"#{a}\""}.join(" ")
end