Class: SystemCommand::Result Private

Inherits:
Object
  • Object
show all
Includes:
Context
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 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:



384
385
386
387
388
389
390
# File 'system_command.rb', line 384

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

Instance Attribute Details

#commandObject

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.



374
375
376
# File 'system_command.rb', line 374

def command
  @command
end

#exit_statusObject

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.



374
375
376
# File 'system_command.rb', line 374

def exit_status
  @exit_status
end

#statusObject

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.



374
375
376
# File 'system_command.rb', line 374

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.



393
394
395
396
397
# File 'system_command.rb', line 393

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:



414
415
416
417
# File 'system_command.rb', line 414

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

#plistArray, ...

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:



432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
# File 'system_command.rb', line 432

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

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



407
408
409
410
411
# File 'system_command.rb', line 407

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



400
401
402
403
404
# File 'system_command.rb', line 400

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)


420
421
422
423
424
# File 'system_command.rb', line 420

def success?
  return false if @exit_status.nil?

  @exit_status.zero?
end

#to_aryArray<(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.

Returns:



427
428
429
# File 'system_command.rb', line 427

def to_ary
  [stdout, stderr, status]
end