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.



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

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.



730
731
732
# File 'lib/toys/utils/exec.rb', line 730

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.



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

def exception
  @exception
end

#nameObject (readonly)

The subcommand's name.

Returns:

  • (Object)


722
723
724
# File 'lib/toys/utils/exec.rb', line 722

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.



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

def status
  @status
end

Instance Method Details

#error?Boolean

Returns true if the subprocess terminated with a nonzero status.

Returns:

  • (Boolean)


786
787
788
# File 'lib/toys/utils/exec.rb', line 786

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)


768
769
770
# File 'lib/toys/utils/exec.rb', line 768

def exit_code
  status ? status.exitstatus : 127
end

#success?Boolean

Returns true if the subprocess terminated with a zero status.

Returns:

  • (Boolean)


777
778
779
# File 'lib/toys/utils/exec.rb', line 777

def success?
  exit_code.zero?
end