Tab: store spec of formula

This commit is contained in:
Xu Cheng 2015-07-28 15:33:07 +08:00
parent 46d45677cc
commit 808729e7ff

View File

@ -24,6 +24,7 @@ class Tab < OpenStruct
"source" => { "source" => {
"path" => formula.path.to_s, "path" => formula.path.to_s,
"tap" => formula.tap, "tap" => formula.tap,
"spec" => formula.active_spec_sym.to_s,
}, },
} }
@ -44,6 +45,15 @@ class Tab < OpenStruct
attributes["source"]["tap"] = attributes.delete("tapped_from") attributes["source"]["tap"] = attributes.delete("tapped_from")
end end
if attributes["source"]["spec"].nil?
version = PkgVersion.parse path.to_s.split("/")[-2]
if version.head?
attributes["source"]["spec"] = "head"
else
attributes["source"]["spec"] = "stable"
end
end
new(attributes) new(attributes)
end end
@ -97,7 +107,7 @@ class Tab < OpenStruct
else else
tab = empty tab = empty
tab.unused_options = f.options.as_flags tab.unused_options = f.options.as_flags
tab.source = { "path" => f.path.to_s, "tap" => f.tap } tab.source = { "path" => f.path.to_s, "tap" => f.tap, "spec" => f.active_spec_sym.to_s }
end end
tab tab
@ -116,6 +126,7 @@ class Tab < OpenStruct
"source" => { "source" => {
"path" => nil, "path" => nil,
"tap" => nil, "tap" => nil,
"spec" => nil,
}, },
} }
@ -181,6 +192,10 @@ class Tab < OpenStruct
source["tap"] = tap source["tap"] = tap
end end
def spec
source["spec"].to_sym
end
def to_json def to_json
attributes = { attributes = {
"used_options" => used_options.as_flags, "used_options" => used_options.as_flags,