Class: FormulaPin

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

Instance Method Summary collapse

Constructor Details

#initialize(f) ⇒ FormulaPin

Returns a new instance of FormulaPin



4
5
6
# File 'Library/Homebrew/formula_pin.rb', line 4

def initialize(f)
  @f = f
end

Instance Method Details

#pathObject



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

def path
  HOMEBREW_PINNED_KEGS/@f.name
end

#pinObject



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

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

#pin_at(version) ⇒ Object



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

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

Returns:

  • (Boolean)


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

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

#pinned?Boolean

Returns:

  • (Boolean)


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

def pinned?
  path.symlink?
end

#pinned_versionObject



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

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

#unpinObject



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

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