Class: Chef::Mixin::ShellOut::FakeShellOut

Inherits:
Object
  • Object
show all
Defined in:
lib/chef/mixin/shell_out.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args, options, result) ⇒ FakeShellOut

Returns a new instance of FakeShellOut.



194
195
196
197
198
199
200
201
# File 'lib/chef/mixin/shell_out.rb', line 194

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.



192
193
194
# File 'lib/chef/mixin/shell_out.rb', line 192

def exitstatus
  @exitstatus
end

#statusObject (readonly)

Returns the value of attribute status.



192
193
194
# File 'lib/chef/mixin/shell_out.rb', line 192

def status
  @status
end

#stderrObject (readonly)

Returns the value of attribute stderr.



192
193
194
# File 'lib/chef/mixin/shell_out.rb', line 192

def stderr
  @stderr
end

#stdoutObject (readonly)

Returns the value of attribute stdout.



192
193
194
# File 'lib/chef/mixin/shell_out.rb', line 192

def stdout
  @stdout
end

Instance Method Details

#error!Object

Raises:

  • (Mixlib::ShellOut::ShellCommandFailed)


207
208
209
# File 'lib/chef/mixin/shell_out.rb', line 207

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

#error?Boolean

Returns:

  • (Boolean)


203
204
205
# File 'lib/chef/mixin/shell_out.rb', line 203

def error?
  exitstatus != 0
end