diff options
| author | Uladzislau Shablinski | 2016-11-01 03:53:20 +0300 |
|---|---|---|
| committer | Uladzislau Shablinski | 2016-12-03 04:42:04 +0300 |
| commit | 52526c962b235e16da03415dd78cf911afcf8106 (patch) | |
| tree | 12c91e045276fe4425d1e588ee62eec6b16cc482 /Library/Homebrew | |
| parent | 7b24d1d2d1c5e32b29bce772df37c970764e9d39 (diff) | |
| download | brew-52526c962b235e16da03415dd78cf911afcf8106.tar.bz2 | |
formula: add new methods
* `Formula#linked?` returns true if formula linked
* `Formula#optlinked?` returns true if formula linked to opt
formula installed to the Cellar
* `Formula#prefix_linked?` returns true if linked keg points to the prefix
passed as an argument
* `Formula#linked_version` to get linked version of the formula
Diffstat (limited to 'Library/Homebrew')
| -rw-r--r-- | Library/Homebrew/formula.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index bae2e3314..0c19805a3 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -553,6 +553,28 @@ class Formula Pathname.new("#{HOMEBREW_CELLAR}/#{name}/#{v}") end + # Is the formula linked? + def linked? + linked_keg.symlink? + end + + # Is the formula linked to opt? + def optlinked? + opt_prefix.symlink? + end + + # Is formula's linked keg points to the prefix. + def prefix_linked?(v = pkg_version) + return false unless linked? + linked_keg.resolved_path == prefix(v) + end + + # {PkgVersion} of the linked keg for the formula. + def linked_version + return unless linked? + Keg.for(linked_keg).version + end + # The parent of the prefix; the named directory in the cellar containing all # installed versions of this software # @private |
