diff options
| author | Jack Nagel | 2012-01-01 15:22:36 -0600 |
|---|---|---|
| committer | Jack Nagel | 2012-01-03 19:50:19 -0600 |
| commit | dc1be896d8edb63cf1afd168a331a86b6fe2f289 (patch) | |
| tree | d816524eced41488b62b4c1b3627411879f40c33 /Library/Homebrew/tab.rb | |
| parent | 07b7dd7a7aa1bc2f1628a1081006845374426bc4 (diff) | |
| download | brew-dc1be896d8edb63cf1afd168a331a86b6fe2f289.tar.bz2 | |
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>
Diffstat (limited to 'Library/Homebrew/tab.rb')
| -rw-r--r-- | Library/Homebrew/tab.rb | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/Library/Homebrew/tab.rb b/Library/Homebrew/tab.rb index 9eb9a34a9..ec80b0204 100644 --- a/Library/Homebrew/tab.rb +++ b/Library/Homebrew/tab.rb @@ -27,6 +27,16 @@ class Tab < OpenStruct return tab 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 f = Formula.factory f unless f.kind_of? Formula path = HOMEBREW_REPOSITORY + 'Library' + 'LinkedKegs' + f.name + 'INSTALL_RECEIPT.json' @@ -42,11 +52,15 @@ class Tab < OpenStruct # TODO: # This isn't the best behavior---perhaps a future version of Homebrew can # treat missing Tabs as errors. - Tab.new :used_options => [], - :unused_options => f.options.map { |o, _| o} + self.dummy_tab f end end + def self.dummy_tab f + Tab.new :used_options => [], + :unused_options => f.options.map { |o, _| o} + end + def installed_with? opt used_options.include? opt end |
