Class: Mixlib::ShellOut::Helper::FakeShellOut

Inherits:
Object
  • Object
show all
Defined in:
lib/mixlib/shellout/helper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args, options, result) ⇒ FakeShellOut

Returns a new instance of FakeShellOut.



178
179
180
181
182
183
184
185
# File 'lib/mixlib/shellout/helper.rb', line 178

def initialize(args, options, result)
  @args = args
  @options = options
  @stdout = result.stdout
  @stderr = result.stderr
  @exitstatus = result.exit_status
  @status = OpenStruct.new(success?: ( exitstatus == 0 ))
end

Instance Attribute Details

#exitstatusObject (readonly)

Returns the value of attribute exitstatus.



176
177
178
# File 'lib/mixlib/shellout/helper.rb', line 176

def exitstatus
  @exitstatus
end

#statusObject (readonly)

Returns the value of attribute status.



176
177
178
# File 'lib/mixlib/shellout/helper.rb', line 176

def status
  @status
end

#stderrObject (readonly)

Returns the value of attribute stderr.



176
177
178
# File 'lib/mixlib/shellout/helper.rb', line 176

def stderr
  @stderr
end

#stdoutObject (readonly)

Returns the value of attribute stdout.



176
177
178
# File 'lib/mixlib/shellout/helper.rb', line 176

def stdout
  @stdout
end

Instance Method Details

#error!Object



191
192
193
# File 'lib/mixlib/shellout/helper.rb', line 191

def error!
  raise Mixlib::ShellOut::ShellCommandFailed, "Unexpected exit status of #{exitstatus} running #{@args}" if error?
end

#error?Boolean

Returns:

  • (Boolean)


187
188
189
# File 'lib/mixlib/shellout/helper.rb', line 187

def error?
  exitstatus != 0
end