Class: Toys::Utils::Exec::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/toys/utils/exec.rb

Overview

The result returned from a subcommand execution.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#captured_errString? (readonly)

The captured error string.

Returns:

  • (String)

    The string captured from stderr.

  • (nil)

    if the command was not configured to capture stderr.



809
810
811
# File 'lib/toys/utils/exec.rb', line 809

def captured_err
  @captured_err
end

#captured_outString? (readonly)

The captured output string.

Returns:

  • (String)

    The string captured from stdout.

  • (nil)

    if the command was not configured to capture stdout.



801
802
803
# File 'lib/toys/utils/exec.rb', line 801

def captured_out
  @captured_out
end

#exceptionException? (readonly)

The exception raised if a process couldn't be started.

Exactly one of exception and status will be non-nil.

Returns:

  • (Exception)

    The exception raised from process start.

  • (nil)

    if the process started successfully.



829
830
831
# File 'lib/toys/utils/exec.rb', line 829

def exception
  @exception
end

#nameObject (readonly)

The subcommand's name.

Returns:

  • (Object)


793
794
795
# File 'lib/toys/utils/exec.rb', line 793

def name
  @name
end

#statusProcess::Status? (readonly)

The status code object.

Exactly one of exception and status will be non-nil.

Returns:

  • (Process::Status)

    The status code.

  • (nil)

    if the process could not be started.



819
820
821
# File 'lib/toys/utils/exec.rb', line 819

def status
  @status
end

Instance Method Details

#error?Boolean

Returns true if the subprocess terminated with a nonzero status.

Returns:

  • (Boolean)


857
858
859
# File 'lib/toys/utils/exec.rb', line 857

def error?
  !exit_code.zero?
end

#exit_codeInteger

The numeric status code.

This will be a nonzero integer if the process failed to start. That is, exit_code will never be nil, even if status is nil.

Returns:

  • (Integer)


839
840
841
# File 'lib/toys/utils/exec.rb', line 839

def exit_code
  status ? status.exitstatus : 127
end

#success?Boolean

Returns true if the subprocess terminated with a zero status.

Returns:

  • (Boolean)


848
849
850
# File 'lib/toys/utils/exec.rb', line 848

def success?
  exit_code.zero?
end