Class: Homebrew::Bundle::Tap Private

Inherits:
PackageType show all
Defined in:
bundle/tap.rb

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.

Constant Summary collapse

PACKAGE_TYPE =

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.

:tap
PACKAGE_TYPE_NAME =

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.

"Tap"

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from PackageType

check, #checkable_entries, dump_supported?, #exit_early_check, #failure_reason, fetchable_name, #format_checkable, #full_check, inherited, install_supported?, type

Class Method Details

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



83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'bundle/tap.rb', line 83

def dump
  taps.map do |tap|
    remote = if tap.custom_remote? && (tap_remote = tap.remote)
      if (api_token = ENV.fetch("HOMEBREW_GITHUB_API_TOKEN", false).presence)
        # Replace the API token in the remote URL with interpolation.
        # Keep the interpolation unevaluated until the Brewfile is evaluated.
        tap_remote = tap_remote.gsub api_token, "\#{ENV.fetch(\"HOMEBREW_GITHUB_API_TOKEN\")}"
      end
      ", \"#{tap_remote}\""
    end
    "tap \"#{tap.name}\"#{remote}"
  end.sort.uniq.join("\n")
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:



98
99
100
101
102
103
# File 'bundle/tap.rb', line 98

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

  dump
end

.install!(name, preinstall: true, no_upgrade: false, verbose: false, force: false, clone_target: nil, **_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.

Parameters:

  • name (String)
  • preinstall (Boolean) (defaults to: true)
  • no_upgrade (Boolean) (defaults to: false)
  • verbose (Boolean) (defaults to: false)
  • force (Boolean) (defaults to: false)
  • clone_target (String, nil) (defaults to: nil)
  • _options (Homebrew::Bundle::EntryOption)

Returns:

  • (Boolean)


50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'bundle/tap.rb', line 50

def install!(name, preinstall: true, no_upgrade: false, verbose: false, force: false, clone_target: nil,
             **_options)
  _ = no_upgrade

  return true unless preinstall

  puts "Installing #{name} tap. It is not currently installed." if verbose
  args = []
  official_tap = name.downcase.start_with? "homebrew/"
  args << "--force" if force || (official_tap && Homebrew::EnvConfig.developer?)

  success = if clone_target
    Bundle.brew("tap", name, clone_target, *args, verbose:)
  else
    Bundle.brew("tap", name, *args, verbose:)
  end

  unless success
    require "bundle/skipper"
    Homebrew::Bundle::Skipper.tap_failed!(name)
    return false
  end

  installed_taps << name
  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:



78
79
80
# File 'bundle/tap.rb', line 78

def install_verb(_name = "", _options = {})
  "Tapping"
end

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

Returns:



111
112
113
# File 'bundle/tap.rb', line 111

def installed_taps
  @installed_taps ||= T.let(tap_names, T.nilable(T::Array[String]))
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.

Parameters:

Returns:

  • (Boolean)


28
29
30
31
32
33
34
35
36
37
# File 'bundle/tap.rb', line 28

def preinstall!(name, no_upgrade: false, verbose: false, **_options)
  _ = no_upgrade

  if installed_taps.include? name
    puts "Skipping install of #{name} tap. It is already installed." if verbose
    return false
  end

  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 returns an undefined value.



15
16
17
18
# File 'bundle/tap.rb', line 15

def reset!
  @taps = T.let(nil, T.nilable(T::Array[::Tap]))
  @installed_taps = T.let(nil, T.nilable(T::Array[String]))
end

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

Returns:



106
107
108
# File 'bundle/tap.rb', line 106

def tap_names
  taps.map(&:name)
end

.tapsArray<::Tap>

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:



116
117
118
119
120
121
# File 'bundle/tap.rb', line 116

def taps
  @taps ||= begin
    require "tap"
    ::Tap.select(&:installed?).to_a
  end
end

Instance Method Details

#find_actionable(entries, exit_on_first_error: false, no_upgrade: false, verbose: false) ⇒ 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:

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

Returns:



129
130
131
132
133
134
135
136
137
138
139
# File 'bundle/tap.rb', line 129

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

  requested_taps = format_checkable(entries)
  return [] if requested_taps.empty?

  current_taps = self.class.tap_names
  (requested_taps - current_taps).map { |entry| "Tap #{entry} needs to be tapped." }
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)


142
143
144
145
146
# File 'bundle/tap.rb', line 142

def installed_and_up_to_date?(package, no_upgrade: false)
  _ = no_upgrade

  self.class.installed_taps.include?(T.cast(package, String))
end