Class: FormulaPin Private

Inherits:
Object
  • Object
show all
Defined in:
Library/Homebrew/formula_pin.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Helper functions for pinning a formula.

Instance Method Summary collapse

Constructor Details

#initialize(f) ⇒ FormulaPin

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of FormulaPin.


9
10
11
# File 'Library/Homebrew/formula_pin.rb', line 9

def initialize(f)
  @f = f
end

Instance Method Details

#pathObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


13
14
15
# File 'Library/Homebrew/formula_pin.rb', line 13

def path
  HOMEBREW_PINNED_KEGS/@f.name
end

#pinObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


23
24
25
# File 'Library/Homebrew/formula_pin.rb', line 23

def pin
  pin_at(@f.installed_kegs.map(&:version).max)
end

#pin_at(version) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


17
18
19
20
21
# File 'Library/Homebrew/formula_pin.rb', line 17

def pin_at(version)
  HOMEBREW_PINNED_KEGS.mkpath
  version_path = @f.rack/version
  path.make_relative_symlink(version_path) unless pinned? || !version_path.exist?
end

#pinnable?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)

36
37
38
# File 'Library/Homebrew/formula_pin.rb', line 36

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

#pinned?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)

32
33
34
# File 'Library/Homebrew/formula_pin.rb', line 32

def pinned?
  path.symlink?
end

#pinned_versionObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


40
41
42
# File 'Library/Homebrew/formula_pin.rb', line 40

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

#unpinObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


27
28
29
30
# File 'Library/Homebrew/formula_pin.rb', line 27

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