Class: Homebrew::Bundle::PackageType Abstract Private

Inherits:
Object
  • Object
show all
Extended by:
T::Helpers
Defined in:
bundle/package_type.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

Brew, Cask, Extension, Tap

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

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



94
95
96
# File 'bundle/package_type.rb', line 94

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

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

This method is abstract.

Returns:



99
# File 'bundle/package_type.rb', line 99

def self.dump; end

.dump_output(describe: false, no_restart: false) ⇒ 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:

  • describe (Boolean) (defaults to: false)
  • no_restart (Boolean) (defaults to: false)

Returns:



102
103
104
105
106
107
# File 'bundle/package_type.rb', line 102

def self.dump_output(describe: false, no_restart: false)
  _ = describe
  _ = no_restart

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


32
33
34
# File 'bundle/package_type.rb', line 32

def self.dump_supported?
  true
end

.fetchable_name(name, options = {}, no_upgrade: false) ⇒ 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:



53
54
55
56
57
58
59
# File 'bundle/package_type.rb', line 53

def self.fetchable_name(name, options = {}, no_upgrade: false)
  _ = name
  _ = options
  _ = no_upgrade

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



19
20
21
22
23
24
# File 'bundle/package_type.rb', line 19

def self.inherited(subclass)
  super
  return if subclass.name == "Homebrew::Bundle::Extension"

  Homebrew::Bundle.register_package_type(subclass)
end

.install!(name, preinstall: true, no_upgrade: false, verbose: false, force: false, **options) ⇒ 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)
  • preinstall (Boolean) (defaults to: true)
  • no_upgrade (Boolean) (defaults to: false)
  • verbose (Boolean) (defaults to: false)
  • force (Boolean) (defaults to: false)
  • options (Homebrew::Bundle::EntryOption)

Returns:

  • (Boolean)


84
# File 'bundle/package_type.rb', line 84

def self.install!(name, preinstall: true, no_upgrade: false, verbose: false, force: false, **options); 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)


37
38
39
# File 'bundle/package_type.rb', line 37

def self.install_supported?
  true
end

.install_verb(_name = "", _options = {}) ⇒ 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:



42
43
44
# File 'bundle/package_type.rb', line 42

def self.install_verb(_name = "", _options = {})
  "Installing"
end

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

Returns:

  • (Boolean)


72
# File 'bundle/package_type.rb', line 72

def self.preinstall!(name, no_upgrade: false, verbose: false, **options); 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.



62
# File 'bundle/package_type.rb', line 62

def self.reset!; 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:



27
28
29
# File 'bundle/package_type.rb', line 27

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

Instance Method Details

#checkable_entries(all_entries) ⇒ 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:

Returns:



135
136
137
138
139
140
141
142
143
144
# File 'bundle/package_type.rb', line 135

def checkable_entries(all_entries)
  require "bundle/skipper"
  all_entries.filter_map do |entry|
    entry = T.cast(entry, Dsl::Entry)
    next if entry.type != self.class.const_get(:PACKAGE_TYPE)
    next if Bundle::Skipper.skip?(entry)

    entry
  end
end

#exit_early_check(packages, no_upgrade:) ⇒ 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:

Returns:



110
111
112
113
114
115
116
# File 'bundle/package_type.rb', line 110

def exit_early_check(packages, no_upgrade:)
  work_to_be_done = packages.find do |pkg|
    !installed_and_up_to_date?(pkg, no_upgrade:)
  end

  Array(work_to_be_done)
end

#failure_reason(name, 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:

  • name (Object)
  • no_upgrade (Boolean)

Returns:



119
120
121
122
123
124
125
126
# File 'bundle/package_type.rb', line 119

def failure_reason(name, no_upgrade:)
  reason = if no_upgrade && Bundle.upgrade_formulae.exclude?(name)
    "needs to be installed."
  else
    "needs to be installed or updated."
  end
  "#{self.class.const_get(:PACKAGE_TYPE_NAME)} #{name} #{reason}"
end

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



167
168
169
170
171
172
173
174
175
# File 'bundle/package_type.rb', line 167

def find_actionable(entries, exit_on_first_error: false, no_upgrade: false, verbose: false)
  requested = format_checkable(entries)

  if exit_on_first_error
    exit_early_check(requested, no_upgrade:)
  else
    full_check(requested, no_upgrade:)
  end
end

#format_checkable(entries) ⇒ 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:

Returns:



147
148
149
150
151
152
# File 'bundle/package_type.rb', line 147

def format_checkable(entries)
  checkable_entries(entries).map do |entry|
    entry = T.cast(entry, Dsl::Entry)
    entry.name
  end
end

#full_check(packages, no_upgrade:) ⇒ 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:



129
130
131
132
# File 'bundle/package_type.rb', line 129

def full_check(packages, no_upgrade:)
  packages.reject { |pkg| installed_and_up_to_date?(pkg, no_upgrade:) }
          .map { |pkg| failure_reason(pkg, no_upgrade:) }
end

#installed_and_up_to_date?(_pkg, 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:

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

Returns:

  • (Boolean)

Raises:

  • (NotImplementedError)


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

def installed_and_up_to_date?(_pkg, no_upgrade: false)
  raise NotImplementedError
end