aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorJack Nagel2013-05-25 18:31:49 -0500
committerJack Nagel2013-05-25 19:24:08 -0500
commit95ab813b35f32314296c70d91d3c11310d9da349 (patch)
tree0be58a255613ba9b1143ccff6690c09a7d838841 /Library
parentfafa62d1d2a2bb517263f89beff9f57fa35a9753 (diff)
downloadbrew-95ab813b35f32314296c70d91d3c11310d9da349.tar.bz2
Fix Formula#installed_prefix logic
Due to the precedence of "and" relative to "||", this was not working as intended; but because #version influences #prefix, the outcome was still correct. So we can simplify this method quite a bit, and take the opportunity to share code with #prefix.
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/formula.rb16
1 files changed, 4 insertions, 12 deletions
diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb
index 34a6cf6ce..dab9726ed 100644
--- a/Library/Homebrew/formula.rb
+++ b/Library/Homebrew/formula.rb
@@ -99,17 +99,9 @@ class Formula
end
def installed_prefix
- devel_prefix = unless devel.nil?
- Pathname.new("#{HOMEBREW_CELLAR}/#{name}/#{devel.version}")
- end
-
- head_prefix = unless head.nil?
- Pathname.new("#{HOMEBREW_CELLAR}/#{name}/#{head.version}")
- end
-
- if active_spec == head || head and head_prefix.directory?
+ if head && (head_prefix = prefix(head.version)).directory?
head_prefix
- elsif active_spec == devel || devel and devel_prefix.directory?
+ elsif devel && (devel_prefix = prefix(devel.version)).directory?
devel_prefix
else
prefix
@@ -121,8 +113,8 @@ class Formula
Keg.new(installed_prefix).version
end
- def prefix
- Pathname.new("#{HOMEBREW_CELLAR}/#{name}/#{version}")
+ def prefix(v=version)
+ Pathname.new("#{HOMEBREW_CELLAR}/#{name}/#{v}")
end
def rack; prefix.parent end