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

#issue_reporting_message, #odebug, #odeprecated, #odie, #odisabled, #ofail, #oh1, #oh1_title, #ohai, #ohai_title, #onoe, #opoo, #opoo_once, #opoo_outside_github_actions, #opoo_without_github_actions_annotation, #pretty_cannot_install, #pretty_deprecated, #pretty_disabled, #pretty_duration, #pretty_incompatible, #pretty_install_status, #pretty_installed, #pretty_removed, #pretty_uninstalled, #pretty_unmarked, #pretty_upgradable, #pretty_warning

Methods included from Context

current, current=, #debug?, #deferred_environment_expansion?, #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:



648
649
650
651
652
653
654
655
656
657
658
# File 'system_command.rb', line 648

def initialize(command, output, status, secrets:)
  @stdout = T.let(nil, T.nilable(String))
  @stderr = T.let(nil, T.nilable(String))
  @merged_output = T.let(nil, T.nilable(String))

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

Instance Attribute Details

#command ⇒ Array<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:



632
633
634
# File 'system_command.rb', line 632

def command
  @command
end

#exit_status ⇒ Integer?

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:



638
639
640
# File 'system_command.rb', line 638

def exit_status
  @exit_status
end

#status ⇒ Process::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)


635
636
637
# File 'system_command.rb', line 635

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.



661
662
663
664
665
# File 'system_command.rb', line 661

def assert_success!
  return if @status.success?

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

#merged_output ⇒ 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:



682
683
684
# File 'system_command.rb', line 682

def merged_output
  @merged_output ||= @output.map { |_, line| line }.join
end

#plist ⇒ T.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)


700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
# File 'system_command.rb', line 700

def plist
  require "plist"
  return @plist if @plist

  output = stdout

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

  output = output.sub(%r{(<\s*/\s*plist\s*>\s*)(.*?)\Z}m) do
    warn_plist_garbage(Regexp.last_match(2))
    Regexp.last_match(1)
  end
  resolved_plist = Plist.parse_xml(output, marshal: false)
  @plist = T.let(resolved_plist, T.untyped)
end

#stderr ⇒ 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:



675
676
677
678
679
# File 'system_command.rb', line 675

def stderr
  @stderr ||= @output.select { |type,| type == :stderr }
                     .map { |_, line| line }
                     .join
end

#stdout ⇒ 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:



668
669
670
671
672
# File 'system_command.rb', line 668

def stdout
  @stdout ||= @output.select { |type,| type == :stdout }
                     .map { |_, line| line }
                     .join
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)


687
688
689
690
691
# File 'system_command.rb', line 687

def success?
  return false if @exit_status.nil?

  @exit_status.zero?
end

#to_ary ⇒ Array<(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:



694
695
696
# File 'system_command.rb', line 694

def to_ary
  [stdout, stderr, status]
end