aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJack Nagel2012-01-01 15:22:36 -0600
committerJack Nagel2012-01-03 19:50:19 -0600
commit913b8c4d608fb6b84b71b09ffdcbb438d27c7484 (patch)
treea34987358301f646589acb59421b2457d3b3e5a9
parentb3fafa3ff18919734386ed5f2187853ca8088cb4 (diff)
downloadhomebrew-913b8c4d608fb6b84b71b09ffdcbb438d27c7484.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>
-rw-r--r--Library/Homebrew/tab.rb18
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