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 ⇒ Object private
- #exit_status ⇒ Object private
- #status ⇒ Object private
Instance Method Summary collapse
- #assert_success! ⇒ void private
- #initialize(command, output, status, secrets:) ⇒ void constructor private
- #merged_output ⇒ String private
- #plist ⇒ Array, ... private
- #stderr ⇒ String private
- #stdout ⇒ String private
- #success? ⇒ Boolean private
- #to_ary ⇒ Array<(String, String, Process::Status)> private
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.
396 397 398 399 400 401 402 |
# File 'system_command.rb', line 396 def initialize(command, output, status, secrets:) @command = command @output = output @status = status @exit_status = status.exitstatus @secrets = secrets end |
Instance Attribute Details
#command ⇒ Object
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.
386 387 388 |
# File 'system_command.rb', line 386 def command @command end |
#exit_status ⇒ Object
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.
386 387 388 |
# File 'system_command.rb', line 386 def exit_status @exit_status end |
#status ⇒ Object
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.
386 387 388 |
# File 'system_command.rb', line 386 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.
405 406 407 408 409 |
# File 'system_command.rb', line 405 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.
426 427 428 429 |
# File 'system_command.rb', line 426 def merged_output @merged_output ||= @output.map { |_, line| line } .join end |
#plist ⇒ Array, ...
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.
444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 |
# File 'system_command.rb', line 444 def plist @plist ||= 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 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.
419 420 421 422 423 |
# File 'system_command.rb', line 419 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.
412 413 414 415 416 |
# File 'system_command.rb', line 412 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.
432 433 434 435 436 |
# File 'system_command.rb', line 432 def success? return false if @exit_status.nil? @exit_status.zero? end |
#to_ary ⇒ Array<(String, String, 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.
439 440 441 |
# File 'system_command.rb', line 439 def to_ary [stdout, stderr, status] end |