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:



260
261
262
263
264
265
266
# File 'system_command.rb', line 260

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.



250
251
252
# File 'system_command.rb', line 250

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.



250
251
252
# File 'system_command.rb', line 250

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.



250
251
252
# File 'system_command.rb', line 250

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.



269
270
271
272
273
# File 'system_command.rb', line 269

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:



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

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)


308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
# File 'system_command.rb', line 308

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:



283
284
285
286
287
# File 'system_command.rb', line 283

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:



276
277
278
279
280
# File 'system_command.rb', line 276

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)


296
297
298
299
300
# File 'system_command.rb', line 296

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:



303
304
305
# File 'system_command.rb', line 303

def to_ary
  [stdout, stderr, status]
end