Explain more Tab instantiation methods
This commit is contained in:
parent
d62029f899
commit
8c3a11bca8
@ -46,10 +46,13 @@ class Tab < OpenStruct
|
||||
new(attributes)
|
||||
end
|
||||
|
||||
# Returns the Tab for an install receipt at `path`.
|
||||
# Results are cached.
|
||||
def self.from_file(path)
|
||||
CACHE.fetch(path) { |p| CACHE[p] = from_file_content(File.read(p), p) }
|
||||
end
|
||||
|
||||
# Like Tab.from_file, but bypass the cache.
|
||||
def self.from_file_content(content, path)
|
||||
attributes = Utils::JSON.load(content)
|
||||
attributes["tabfile"] = path
|
||||
@ -97,6 +100,8 @@ class Tab < OpenStruct
|
||||
end
|
||||
end
|
||||
|
||||
# Returns a tab for the named formula's installation,
|
||||
# or a fake one if the formula is not installed.
|
||||
def self.for_name(name)
|
||||
for_formula(Formulary.factory(name))
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user