tab: allow retrieving tabs from arbitrary kegs
This will be useful in places where we need information about things other than the currently linked keg, such as `brew info`. Signed-off-by: Jack Nagel <jacknagel@gmail.com>
This commit is contained in:
parent
07b7dd7a7a
commit
dc1be896d8
@ -27,6 +27,16 @@ class Tab < OpenStruct
|
|||||||
return tab
|
return tab
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.for_keg keg
|
||||||
|
path = keg+'INSTALL_RECEIPT.json'
|
||||||
|
|
||||||
|
if path.exist?
|
||||||
|
self.from_file path
|
||||||
|
else
|
||||||
|
self.dummy_tab Formula.factory(keg.parent.basename)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def self.for_formula f
|
def self.for_formula f
|
||||||
f = Formula.factory f unless f.kind_of? Formula
|
f = Formula.factory f unless f.kind_of? Formula
|
||||||
path = HOMEBREW_REPOSITORY + 'Library' + 'LinkedKegs' + f.name + 'INSTALL_RECEIPT.json'
|
path = HOMEBREW_REPOSITORY + 'Library' + 'LinkedKegs' + f.name + 'INSTALL_RECEIPT.json'
|
||||||
@ -42,10 +52,14 @@ class Tab < OpenStruct
|
|||||||
# TODO:
|
# TODO:
|
||||||
# This isn't the best behavior---perhaps a future version of Homebrew can
|
# This isn't the best behavior---perhaps a future version of Homebrew can
|
||||||
# treat missing Tabs as errors.
|
# treat missing Tabs as errors.
|
||||||
|
self.dummy_tab f
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.dummy_tab f
|
||||||
Tab.new :used_options => [],
|
Tab.new :used_options => [],
|
||||||
:unused_options => f.options.map { |o, _| o}
|
:unused_options => f.options.map { |o, _| o}
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def installed_with? opt
|
def installed_with? opt
|
||||||
used_options.include? opt
|
used_options.include? opt
|
||||||
|
Loading…
x
Reference in New Issue
Block a user