Class: SystemCommand::Result Private

Inherits:
Object
  • Object
show all
Includes:
Context, Utils::Output::Mixin
Defined in:
system_command.rb

Overview

This class is part of a private API. This class may only be used in the Homebrew/brew repository. Third parties should avoid using this class if possible, as it may be removed or changed without warning.

Result containing the output and exit status of a finished sub-process.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Utils::Output::Mixin

#odebug, #odeprecated, #odie, #odisabled, #ofail, #oh1, #oh1_title, #ohai, #ohai_title, #onoe, #opoo, #opoo_outside_github_actions, #pretty_duration, #pretty_installed, #pretty_outdated, #pretty_uninstalled

Methods included from Context

current, current=, #debug?, #quiet?, #verbose?, #with_context

Constructor Details

#initialize(command, output, status, secrets:) ⇒ void

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Parameters:



488
489
490
491
492
493
494
# File 'system_command.rb', line 488

def initialize(command, output, status, secrets:)
  @command       = command
  @output        = output
  @status        = status
  @exit_status   = T.let(status.exitstatus, T.nilable(Integer))
  @secrets       = secrets
end

Instance Attribute Details

#commandArray<String>

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns:



472
473
474
# File 'system_command.rb', line 472

def command
  @command
end

#exit_statusInteger?

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns:

  • (Integer, nil)


478
479
480
# File 'system_command.rb', line 478

def exit_status
  @exit_status
end

#statusProcess::Status

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns:

  • (Process::Status)


475
476
477
# File 'system_command.rb', line 475

def status
  @status
end

Instance Method Details

#assert_success!void

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

This method returns an undefined value.



497
498
499
500
501
# File 'system_command.rb', line 497

def assert_success!
  return if @status.success?

  raise ErrorDuringExecution.new(command, status: @status, output: @output, secrets: @secrets)
end

#merged_outputString

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns:



518
519
520
# File 'system_command.rb', line 518

def merged_output
  @merged_output ||= T.let(@output.map { |_, line| line }.join, T.nilable(String))
end

#plistT.untyped

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns:

  • (T.untyped)


536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
# File 'system_command.rb', line 536

def plist
  @plist ||= T.let(begin
    output = stdout

    output = output.sub(/\A(.*?)(\s*<\?\s*xml)/m) do
      warn_plist_garbage(T.must(Regexp.last_match(1)))
      Regexp.last_match(2)
    end

    output = output.sub(%r{(<\s*/\s*plist\s*>\s*)(.*?)\Z}m) do
      warn_plist_garbage(T.must(Regexp.last_match(2)))
      Regexp.last_match(1)
    end

    Plist.parse_xml(output, marshal: false)
  end, T.untyped)
end

#stderrString

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns:



511
512
513
514
515
# File 'system_command.rb', line 511

def stderr
  @stderr ||= T.let(@output.select { |type,| type == :stderr }
                           .map { |_, line| line }
                           .join, T.nilable(String))
end

#stdoutString

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns:



504
505
506
507
508
# File 'system_command.rb', line 504

def stdout
  @stdout ||= T.let(@output.select { |type,| type == :stdout }
                           .map { |_, line| line }
                           .join, T.nilable(String))
end

#success?Boolean

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns:

  • (Boolean)


523
524
525
526
527
# File 'system_command.rb', line 523

def success?
  return false if @exit_status.nil?

  @exit_status.zero?
end

#to_aryArray<(String, String, Process::Status)> Also known as: to_a

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns:



530
531
532
# File 'system_command.rb', line 530

def to_ary
  [stdout, stderr, status]
end