Class: FormulaPin Private
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
- #initialize(formula) ⇒ void constructor private
- #path ⇒ Pathname private
- #pin ⇒ void private
- #pinnable? ⇒ Boolean private
- #pinned? ⇒ Boolean private
- #pinned_version ⇒ PkgVersion? private
- #unpin ⇒ void private
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.
9 10 11 |
# File 'formula_pin.rb', line 9 def initialize(formula) @formula = formula end |
Instance Method Details
#path ⇒ Pathname
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.
14 15 16 17 |
# File 'formula_pin.rb', line 14 def path @formula.possible_names.map { |name| HOMEBREW_PINNED_KEGS/name }.find(&:symlink?) || (HOMEBREW_PINNED_KEGS/@formula.name) end |
#pin ⇒ 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.
20 21 22 23 24 25 |
# File 'formula_pin.rb', line 20 def pin latest_keg = @formula.installed_kegs.max_by(&:scheme_and_version) return if latest_keg.nil? || pinned? (HOMEBREW_PINNED_KEGS/latest_keg.name).make_relative_symlink(latest_keg.rack/latest_keg.version.to_s) 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.
39 40 41 |
# File 'formula_pin.rb', line 39 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.
34 35 36 |
# File 'formula_pin.rb', line 34 def pinned? path.symlink? end |
#pinned_version ⇒ PkgVersion?
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.
44 45 46 |
# File 'formula_pin.rb', line 44 def pinned_version Keg.new(Utils::Path.resolved_path(path)).version if pinned? end |
#unpin ⇒ 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.
28 29 30 31 |
# File 'formula_pin.rb', line 28 def unpin path.unlink if pinned? Utils::Path.rmdir_if_possible(HOMEBREW_PINNED_KEGS) end |