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