Class: SystemCommand::Result Private

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
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:



290
291
292
293
294
295
296
# File 'system_command.rb', line 290

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.



280
281
282
# File 'system_command.rb', line 280

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.



280
281
282
# File 'system_command.rb', line 280

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.



280
281
282
# File 'system_command.rb', line 280

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.



299
300
301
302
303
# File 'system_command.rb', line 299

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:



320
321
322
323
# File 'system_command.rb', line 320

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:

  • (Array, Hash, nil)


338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
# File 'system_command.rb', line 338

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



313
314
315
316
317
# File 'system_command.rb', line 313

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:



306
307
308
309
310
# File 'system_command.rb', line 306

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)


326
327
328
329
330
# File 'system_command.rb', line 326

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:



333
334
335
# File 'system_command.rb', line 333

def to_ary
  [stdout, stderr, status]
end