Class: FormulaPin Private

Inherits:
Object show all
Defined in:
formula_pin.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.

Helper functions for pinning a formula.

Instance Method Summary collapse

Constructor Details

#initialize(formula) ⇒ 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:



9
10
11
# File 'formula_pin.rb', line 9

def initialize(formula)
  @formula = formula
end

Instance Method Details

#pathPathname

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:



14
15
16
# File 'formula_pin.rb', line 14

def path
  HOMEBREW_PINNED_KEGS/@formula.name
end

#pinvoid

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.



26
27
28
29
30
31
# File 'formula_pin.rb', line 26

def pin
  latest_keg = @formula.installed_kegs.max_by(&:scheme_and_version)
  return if latest_keg.nil?

  pin_at(latest_keg.version)
end

#pin_at(version) ⇒ 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
# File 'formula_pin.rb', line 19

def pin_at(version)
  HOMEBREW_PINNED_KEGS.mkpath
  version_path = @formula.rack/version.to_s
  path.make_relative_symlink(version_path) if !pinned? && version_path.exist?
end

#pinnable?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)


45
46
47
# File 'formula_pin.rb', line 45

def pinnable?
  !@formula.installed_prefixes.empty?
end

#pinned?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)


40
41
42
# File 'formula_pin.rb', line 40

def pinned?
  path.symlink?
end

#pinned_versionPkgVersion?

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:



50
51
52
# File 'formula_pin.rb', line 50

def pinned_version
  Keg.new(path.resolved_path).version if pinned?
end

#unpinvoid

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.



34
35
36
37
# File 'formula_pin.rb', line 34

def unpin
  path.unlink if pinned?
  HOMEBREW_PINNED_KEGS.rmdir_if_possible
end