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.
This commit is contained in:
Jack Nagel 2013-05-25 18:31:49 -05:00
parent fafa62d1d2
commit 95ab813b35

View File

@ -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