Class: SystemCommand::Result Private
- 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
- #command ⇒ Array<String> private
- #exit_status ⇒ Integer? private
- #status ⇒ Process::Status private
Instance Method Summary collapse
- #assert_success! ⇒ void private
- #initialize(command, output, status, secrets:) ⇒ void constructor private
- #merged_output ⇒ String private
- #plist ⇒ T.untyped private
- #stderr ⇒ String private
- #stdout ⇒ String private
- #success? ⇒ Boolean private
- #to_ary ⇒ Array<(String, String, Process::Status)> (also: #to_a) private
Methods included from Utils::Output::Mixin
#issue_reporting_message, #odebug, #odeprecated, #odie, #odisabled, #ofail, #oh1, #oh1_title, #ohai, #ohai_title, #onoe, #opoo, #opoo_outside_github_actions, #opoo_without_github_actions_annotation, #pretty_deprecated, #pretty_disabled, #pretty_duration, #pretty_install_status, #pretty_installed, #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.
511 512 513 514 515 516 517 |
# File 'system_command.rb', line 511 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
#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.
495 496 497 |
# File 'system_command.rb', line 495 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.
501 502 503 |
# File 'system_command.rb', line 501 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.
498 499 500 |
# File 'system_command.rb', line 498 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.
520 521 522 523 524 |
# File 'system_command.rb', line 520 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.
541 542 543 |
# File 'system_command.rb', line 541 def merged_output @merged_output ||= T.let(@output.map { |_, line| line }.join, T.nilable(String)) 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.
559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 |
# File 'system_command.rb', line 559 def plist require "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 |
#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.
534 535 536 537 538 |
# File 'system_command.rb', line 534 def stderr @stderr ||= T.let(@output.select { |type,| type == :stderr } .map { |_, line| line } .join, T.nilable(String)) 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.
527 528 529 530 531 |
# File 'system_command.rb', line 527 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.
546 547 548 549 550 |
# File 'system_command.rb', line 546 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.
553 554 555 |
# File 'system_command.rb', line 553 def to_ary [stdout, stderr, status] end |