Module: Homebrew::Bundle::GoInstaller Private

Defined in:
bundle/go_installer.rb

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

Class Method Summary collapse

Class Method Details

.install!(name, preinstall: true, 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.

Parameters:

  • name (String)
  • preinstall (Boolean) (defaults to: true)
  • verbose (Boolean) (defaults to: false)
  • force (Boolean) (defaults to: false)
  • _options (T.anything)

Returns:

  • (Boolean)


37
38
39
40
41
42
43
44
45
46
47
# File 'bundle/go_installer.rb', line 37

def self.install!(name, preinstall: true, verbose: false, force: false, **_options)
  return true unless preinstall

  puts "Installing #{name} Go package. It is not currently installed." if verbose

  go = Bundle.which_go
  return false unless Bundle.system go.to_s, "install", "#{name}@latest", verbose: verbose

  installed_packages << name
  true
end

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



55
56
57
58
# File 'bundle/go_installer.rb', line 55

def self.installed_packages
  require "bundle/go_dumper"
  @installed_packages ||= T.let(Homebrew::Bundle::GoDumper.packages, T.nilable(T::Array[String]))
end

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


50
51
52
# File 'bundle/go_installer.rb', line 50

def self.package_installed?(package)
  installed_packages.include? package
end

.preinstall!(name, 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:

  • name (String)
  • verbose (Boolean) (defaults to: false)
  • _options (T.anything)

Returns:

  • (Boolean)


13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'bundle/go_installer.rb', line 13

def self.preinstall!(name, verbose: false, **_options)
  unless Bundle.go_installed?
    puts "Installing go. It is not currently installed." if verbose
    Bundle.brew("install", "--formula", "go", verbose:)
    raise "Unable to install #{name} package. Go installation failed." unless Bundle.go_installed?
  end

  if package_installed?(name)
    puts "Skipping install of #{name} Go package. 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.



8
9
10
# File 'bundle/go_installer.rb', line 8

def self.reset!
  @installed_packages = nil
end