Class: FormulaPin

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

Instance Method Summary collapse

Constructor Details

#initialize(f) ⇒ FormulaPin

Returns a new instance of FormulaPin



6
7
8
# File 'brew/Library/Homebrew/formula_pin.rb', line 6

def initialize(f)
  @f = f
end

Instance Method Details

#pathObject



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

def path
  HOMEBREW_PINNED_KEGS/@f.name
end

#pinObject



20
21
22
# File 'brew/Library/Homebrew/formula_pin.rb', line 20

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

#pin_at(version) ⇒ Object



14
15
16
17
18
# File 'brew/Library/Homebrew/formula_pin.rb', line 14

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)


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

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

#pinned?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'brew/Library/Homebrew/formula_pin.rb', line 29

def pinned?
  path.symlink?
end

#pinned_versionObject



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

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

#unpinObject



24
25
26
27
# File 'brew/Library/Homebrew/formula_pin.rb', line 24

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