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.



718
719
720
# File 'lib/toys/utils/exec.rb', line 718

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.



710
711
712
# File 'lib/toys/utils/exec.rb', line 710

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.



738
739
740
# File 'lib/toys/utils/exec.rb', line 738

def exception
  @exception
end

#nameObject (readonly)

The subcommand's name.

Returns:

  • (Object)


702
703
704
# File 'lib/toys/utils/exec.rb', line 702

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.



728
729
730
# File 'lib/toys/utils/exec.rb', line 728

def status
  @status
end

Instance Method Details

#error?Boolean

Returns true if the subprocess terminated with a nonzero status.

Returns:

  • (Boolean)


766
767
768
# File 'lib/toys/utils/exec.rb', line 766

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)


748
749
750
# File 'lib/toys/utils/exec.rb', line 748

def exit_code
  status ? status.exitstatus : 127
end

#success?Boolean

Returns true if the subprocess terminated with a zero status.

Returns:

  • (Boolean)


757
758
759
# File 'lib/toys/utils/exec.rb', line 757

def success?
  exit_code.zero?
end