Initialize linked_keg_record in the Keg constructor

This commit is contained in:
Jack Nagel 2014-06-23 22:52:41 -05:00
parent 76e86891e4
commit 892e763b0b

View File

@ -88,10 +88,13 @@ class Keg < Pathname
raise NotAKegError, "#{path} is not inside a keg" raise NotAKegError, "#{path} is not inside a keg"
end end
attr_reader :linked_keg_record
def initialize path def initialize path
super path super path
raise "#{to_s} is not a valid keg" unless parent.parent.realpath == HOMEBREW_CELLAR.realpath raise "#{to_s} is not a valid keg" unless parent.parent.realpath == HOMEBREW_CELLAR.realpath
raise "#{to_s} is not a directory" unless directory? raise "#{to_s} is not a directory" unless directory?
@linked_keg_record = HOMEBREW_LIBRARY.join("LinkedKegs", fname)
end end
def uninstall def uninstall
@ -145,10 +148,6 @@ class Keg < Pathname
FormulaLock.new(fname).with_lock { yield } FormulaLock.new(fname).with_lock { yield }
end end
def linked_keg_record
@linked_keg_record ||= HOMEBREW_REPOSITORY/"Library/LinkedKegs"/fname
end
def linked? def linked?
linked_keg_record.directory? && self == linked_keg_record.resolved_path linked_keg_record.directory? && self == linked_keg_record.resolved_path
end end