Class: AngryShell::Shell::ShellResult

Inherits:
Struct
  • Object
show all
Defined in:
lib/angry_shell.rb

Overview

We encapsulate the shell’s result, including the Process::Status, stdout and stderr.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#optionsObject

Returns the value of attribute options

Returns:

  • (Object)

    the current value of options



90
91
92
# File 'lib/angry_shell.rb', line 90

def options
  @options
end

#process_resultObject

Returns the value of attribute process_result

Returns:

  • (Object)

    the current value of process_result



90
91
92
# File 'lib/angry_shell.rb', line 90

def process_result
  @process_result
end

#stderrObject

Returns the value of attribute stderr

Returns:

  • (Object)

    the current value of stderr



90
91
92
# File 'lib/angry_shell.rb', line 90

def stderr
  @stderr
end

#stdoutObject

Returns the value of attribute stdout

Returns:

  • (Object)

    the current value of stdout



90
91
92
# File 'lib/angry_shell.rb', line 90

def stdout
  @stdout
end

Instance Method Details

#ensure_ok!Object



95
96
97
98
99
# File 'lib/angry_shell.rb', line 95

def ensure_ok!
  unless ok?
    raise ShellError.new("unable to run command\ncommand=#{options[:cmd]}\noptions=#{options.pretty_inspect}\noutput=#{stdout}\nerror=#{stderr}",self)
  end
end

#ok?Boolean

Returns:

  • (Boolean)


91
92
93
# File 'lib/angry_shell.rb', line 91

def ok?
  process_result.success?
end