Class: Homebrew::Bundle::Extension Abstract Private

Inherits:
Checker::Base show all
Extended by:
T::Helpers
Defined in:
bundle/extensions/extension.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.

This class is abstract.

It cannot be directly instantiated. Subclasses must implement the abstract methods below.

Direct Known Subclasses

Go, Uv

Constant Summary collapse

EntryOptions =

This constant is part of a private API. This constant may only be used in the Homebrew/brew repository. Third parties should avoid using this constant if possible, as it may be removed or changed without warning.

T.type_alias { T::Hash[Symbol, Object] }

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Checker::Base

#checkable_entries, #exit_early_check, #find_actionable, #format_checkable, #full_check

Class Method Details

.add_supported?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)


180
181
182
# File 'bundle/extensions/extension.rb', line 180

def self.add_supported?
  true
end

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:



110
111
112
# File 'bundle/extensions/extension.rb', line 110

def self.banner_name
  T.cast(const_get(:BANNER_NAME), String)
end

.check(entries, exit_on_first_error: false, no_upgrade: false, verbose: false) ⇒ Array<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.

Parameters:

  • entries (Array<Object>)
  • exit_on_first_error (Boolean) (defaults to: false)
  • no_upgrade (Boolean) (defaults to: false)
  • verbose (Boolean) (defaults to: false)

Returns:



253
254
255
# File 'bundle/extensions/extension.rb', line 253

def self.check(entries, exit_on_first_error: false, no_upgrade: false, verbose: false)
  new.find_actionable(entries, exit_on_first_error:, no_upgrade:, verbose:)
end

.check_labelString

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:



105
106
107
# File 'bundle/extensions/extension.rb', line 105

def self.check_label
  T.cast(const_get(:PACKAGE_TYPE_NAME), String)
end

.cleanup!(_items) ⇒ 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.

Parameters:



263
# File 'bundle/extensions/extension.rb', line 263

def self.cleanup!(_items); end

.cleanup_headingString?

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:



195
196
197
# File 'bundle/extensions/extension.rb', line 195

def self.cleanup_heading
  nil
end

.cleanup_items(_entries) ⇒ 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.

Parameters:

Returns:



258
259
260
# File 'bundle/extensions/extension.rb', line 258

def self.cleanup_items(_entries)
  []
end

.cleanup_supported?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)


200
201
202
# File 'bundle/extensions/extension.rb', line 200

def self.cleanup_supported?
  !cleanup_heading.nil?
end

.dumpString

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:



241
242
243
# File 'bundle/extensions/extension.rb', line 241

def self.dump
  packages.map { |package| dump_entry(package) }.join("\n")
end

.dump_disable_descriptionString

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:



160
161
162
# File 'bundle/extensions/extension.rb', line 160

def self.dump_disable_description
  "`dump` without #{banner_name}."
end

.dump_disable_envSymbol

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:



165
166
167
# File 'bundle/extensions/extension.rb', line 165

def self.dump_disable_env
  :"bundle_dump_no_#{type}"
end

.dump_disable_predicate_methodSymbol

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:



175
176
177
# File 'bundle/extensions/extension.rb', line 175

def self.dump_disable_predicate_method
  :"no_#{type}?"
end

.dump_disable_supported?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)


170
171
172
# File 'bundle/extensions/extension.rb', line 170

def self.dump_disable_supported?
  true
end

.dump_entry(package) ⇒ 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.

Parameters:

Returns:



216
217
218
219
220
221
222
223
# File 'bundle/extensions/extension.rb', line 216

def self.dump_entry(package)
  line = "#{type} #{quote(dump_name(package))}"
  with = dump_with(package)
  return line if with.blank?

  formatted_with = with.map { |requirement| quote(requirement) }.join(", ")
  "#{line}, with: [#{formatted_with}]"
end

.dump_name(package) ⇒ 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.

Parameters:

Returns:



231
232
233
# File 'bundle/extensions/extension.rb', line 231

def self.dump_name(package)
  package.to_s
end

.dump_supported?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)


155
156
157
# File 'bundle/extensions/extension.rb', line 155

def self.dump_supported?
  true
end

.dump_with(_package) ⇒ 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.

Parameters:

Returns:



236
237
238
# File 'bundle/extensions/extension.rb', line 236

def self.dump_with(_package)
  nil
end

.entry(name, options = {}) ⇒ Dsl::Entry

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 is abstract.

Parameters:

Returns:



120
# File 'bundle/extensions/extension.rb', line 120

def self.entry(name, options = {}); end

.flagString

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:



123
124
125
# File 'bundle/extensions/extension.rb', line 123

def self.flag
  type.to_s.tr("_", "-")
end

.inherited(subclass) ⇒ 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.

Parameters:



94
95
96
97
# File 'bundle/extensions/extension.rb', line 94

def self.inherited(subclass)
  super
  Homebrew::Bundle.register_extension(subclass)
end

.install!(name, with: nil, preinstall: true, no_upgrade: false, verbose: false, force: false) ⇒ 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.

Parameters:

  • name (String)
  • with (Array<String>, nil) (defaults to: nil)
  • preinstall (Boolean) (defaults to: true)
  • no_upgrade (Boolean) (defaults to: false)
  • verbose (Boolean) (defaults to: false)
  • force (Boolean) (defaults to: false)

Returns:

  • (Boolean)


318
319
320
321
322
323
324
325
326
327
328
329
330
331
# File 'bundle/extensions/extension.rb', line 318

def self.install!(name, with: nil, preinstall: true, no_upgrade: false, verbose: false, force: false)
  _ = no_upgrade
  _ = force

  return true unless preinstall

  puts "Installing #{name} #{package_description}. It is not currently installed." if verbose
  return false unless install_package!(name, with:, verbose:)

  package = package_record(name, with:)
  installed_packages << package unless installed_packages.include?(package)
  packages << package unless packages.include?(package)
  true
end

.install_package!(name, with: nil, verbose: false) ⇒ 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.

This method is abstract.

Parameters:

  • name (String)
  • with (Array<String>, nil) (defaults to: nil)
  • verbose (Boolean) (defaults to: false)

Returns:

  • (Boolean)


350
# File 'bundle/extensions/extension.rb', line 350

def self.install_package!(name, with: nil, verbose: false); end

.install_supported?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)


190
191
192
# File 'bundle/extensions/extension.rb', line 190

def self.install_supported?
  true
end

.installed_packagesArray<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.

This method is abstract.

Returns:



213
# File 'bundle/extensions/extension.rb', line 213

def self.installed_packages; end

.package_descriptionString

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:



150
151
152
# File 'bundle/extensions/extension.rb', line 150

def self.package_description
  check_label.downcase
end

.package_installed?(name, with: nil) ⇒ 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.

Parameters:

Returns:

  • (Boolean)


273
274
275
# File 'bundle/extensions/extension.rb', line 273

def self.package_installed?(name, with: nil)
  installed_packages.include?(package_record(name, with:))
end

.package_manager_executablePathname?

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:



145
146
147
# File 'bundle/extensions/extension.rb', line 145

def self.package_manager_executable
  Bundle.public_send(:"which_#{type}")
end

.package_manager_installed?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.

TODO:

Route these through each extension once the go/uv specs stop

stubbing Homebrew::Bundle.which_* and *_installed? directly.

Returns:

  • (Boolean)


140
141
142
# File 'bundle/extensions/extension.rb', line 140

def self.package_manager_installed?
  Bundle.public_send(:"#{type}_installed?")
end

.package_manager_nameString

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:



133
134
135
# File 'bundle/extensions/extension.rb', line 133

def self.package_manager_name
  flag
end

.package_record(name, with: nil) ⇒ 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.

Parameters:

Returns:



266
267
268
269
270
# File 'bundle/extensions/extension.rb', line 266

def self.package_record(name, with: nil)
  _ = with

  name
end

.packagesArray<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.

This method is abstract.
TODO:

Replace these T.untyped package collections once extensions can

share a typed package interface without breaking Sorbet override checks.

Returns:



210
# File 'bundle/extensions/extension.rb', line 210

def self.packages; end

.predicate_methodSymbol

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:



128
129
130
# File 'bundle/extensions/extension.rb', line 128

def self.predicate_method
  :"#{type}?"
end

.preinstall!(name, with: nil, no_upgrade: false, verbose: false) ⇒ 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.

Parameters:

  • name (String)
  • with (Array<String>, nil) (defaults to: nil)
  • no_upgrade (Boolean) (defaults to: false)
  • verbose (Boolean) (defaults to: false)

Returns:

  • (Boolean)


285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
# File 'bundle/extensions/extension.rb', line 285

def self.preinstall!(name, with: nil, no_upgrade: false, verbose: false)
  _ = no_upgrade

  unless package_manager_installed?
    puts "Installing #{package_manager_name}. It is not currently installed." if verbose
    Bundle.brew("install", "--formula", package_manager_name, verbose:)
    upgrade_formulae = Bundle.upgrade_formulae
    Bundle.reset!
    Bundle.upgrade_formulae = upgrade_formulae.join(",")
    unless package_manager_installed?
      raise "Unable to install #{name} #{package_description}. " \
            "#{package_manager_name} installation failed."
    end
  end

  if package_installed?(name, with:)
    puts "Skipping install of #{name} #{package_description}. It is already installed." if verbose
    return false
  end

  true
end

.quote(value) ⇒ 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.

Parameters:

Returns:



226
227
228
# File 'bundle/extensions/extension.rb', line 226

def self.quote(value)
  value.inspect
end

.remove_supported?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)


185
186
187
# File 'bundle/extensions/extension.rb', line 185

def self.remove_supported?
  true
end

.reset!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 is abstract.

This method returns an undefined value.



205
# File 'bundle/extensions/extension.rb', line 205

def self.reset!; end

.switch_descriptionString

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:



115
116
117
# File 'bundle/extensions/extension.rb', line 115

def self.switch_description
  "`list` or `dump` #{banner_name}."
end

.typeSymbol

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:



100
101
102
# File 'bundle/extensions/extension.rb', line 100

def self.type
  T.cast(const_get(:PACKAGE_TYPE), Symbol)
end

Instance Method Details

#failure_reason(package, no_upgrade:) ⇒ 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.

Parameters:

  • package (Object)
  • no_upgrade (Boolean)

Returns:



334
335
336
# File 'bundle/extensions/extension.rb', line 334

def failure_reason(package, no_upgrade:)
  "#{self.class.check_label} #{self.class.dump_name(package)} needs to be installed."
end

#installed_and_up_to_date?(package, no_upgrade: false) ⇒ 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.

Parameters:

  • package (Object)
  • no_upgrade (Boolean) (defaults to: false)

Returns:

  • (Boolean)


339
340
341
# File 'bundle/extensions/extension.rb', line 339

def installed_and_up_to_date?(package, no_upgrade: false)
  self.class.package_installed?(self.class.dump_name(package), with: self.class.dump_with(package))
end