class Doc::Command

Attributes

command[R]
status[R]

Public Class Methods

new(*command) click to toggle source
# File lib/doc/command.rb, line 10
def initialize(*command)
  @command = command
end
run(*command) click to toggle source
# File lib/doc/command.rb, line 5
def self.run(*command)
  new(*command).run
end

Public Instance Methods

add(*arguments) click to toggle source
# File lib/doc/command.rb, line 14
def add(*arguments)
  @command.concat(arguments)
end
run() click to toggle source
# File lib/doc/command.rb, line 18
def run
  command_string = command.length == 1 ? command.first : command.map(&:to_s).shelljoin
  output = IO.popen("#{command_string} 2>&1", &:read)
  @status = $?
  status.success? || begin
    $stderr.puts "cd #{Dir.pwd.shellescape}; #{command_string}\n#{output}"
    case
    when status.signaled?
      if status.termsig == 2
        raise Interrupt.new
      else
        raise SignalException.new(status.termsig)
      end
    when status.exited?
      raise SystemExit.new(status.exitstatus)
    else
      raise status.inspect
    end
  end
end