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.



208
209
210
211
212
213
214
215
216
# File 'lib/mixlib/shellout/helper.rb', line 208

def initialize(args, options, result)
  @args = args
  @options = options
  @stdout = result.stdout
  @stderr = result.stderr
  @exitstatus = result.exit_status
  @valid_exit_codes = Array(options[:returns] || 0)
  @status = OpenStruct.new(success?: (@valid_exit_codes.include? exitstatus))
end

Instance Attribute Details

#exitstatusObject (readonly)

Returns the value of attribute exitstatus.



206
207
208
# File 'lib/mixlib/shellout/helper.rb', line 206

def exitstatus
  @exitstatus
end

#statusObject (readonly)

Returns the value of attribute status.



206
207
208
# File 'lib/mixlib/shellout/helper.rb', line 206

def status
  @status
end

#stderrObject (readonly)

Returns the value of attribute stderr.



206
207
208
# File 'lib/mixlib/shellout/helper.rb', line 206

def stderr
  @stderr
end

#stdoutObject (readonly)

Returns the value of attribute stdout.



206
207
208
# File 'lib/mixlib/shellout/helper.rb', line 206

def stdout
  @stdout
end

Instance Method Details

#error!Object



222
223
224
# File 'lib/mixlib/shellout/helper.rb', line 222

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

#error?Boolean

Returns:

  • (Boolean)


218
219
220
# File 'lib/mixlib/shellout/helper.rb', line 218

def error?
  @valid_exit_codes.none?(exitstatus)
end