Merge pull request #3954 from MikeMcQuaid/cleanup-tab

tab: cleanup various methods.
This commit is contained in:
Mike McQuaid 2018-03-21 15:38:11 +00:00 committed by GitHub
commit 15f01bdd14
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -38,12 +38,12 @@ class Tab < OpenStruct
end, end,
"source" => { "source" => {
"path" => formula.specified_path.to_s, "path" => formula.specified_path.to_s,
"tap" => formula.tap ? formula.tap.name : nil, "tap" => formula.tap&.name,
"spec" => formula.active_spec_sym.to_s, "spec" => formula.active_spec_sym.to_s,
"versions" => { "versions" => {
"stable" => formula.stable ? formula.stable.version.to_s : nil, "stable" => formula.stable&.version.to_s,
"devel" => formula.devel ? formula.devel.version.to_s : nil, "devel" => formula.devel&.version.to_s,
"head" => formula.head ? formula.head.version.to_s : nil, "head" => formula.head&.version.to_s,
"version_scheme" => formula.version_scheme, "version_scheme" => formula.version_scheme,
}, },
}, },
@ -66,7 +66,7 @@ class Tab < OpenStruct
attributes["source"] ||= {} attributes["source"] ||= {}
tapped_from = attributes["tapped_from"] tapped_from = attributes["tapped_from"]
unless tapped_from.nil? || tapped_from == "path or URL" if !tapped_from.nil? && tapped_from != "path or URL"
attributes["source"]["tap"] = attributes.delete("tapped_from") attributes["source"]["tap"] = attributes.delete("tapped_from")
end end
@ -156,12 +156,12 @@ class Tab < OpenStruct
tab.unused_options = f.options.as_flags tab.unused_options = f.options.as_flags
tab.source = { tab.source = {
"path" => f.specified_path.to_s, "path" => f.specified_path.to_s,
"tap" => f.tap ? f.tap.name : f.tap, "tap" => f.tap&.name,
"spec" => f.active_spec_sym.to_s, "spec" => f.active_spec_sym.to_s,
"versions" => { "versions" => {
"stable" => f.stable ? f.stable.version.to_s : nil, "stable" => f.stable&.version.to_s,
"devel" => f.devel ? f.devel.version.to_s : nil, "devel" => f.devel&.version.to_s,
"head" => f.head ? f.head.version.to_s : nil, "head" => f.head&.version.to_s,
"version_scheme" => f.version_scheme, "version_scheme" => f.version_scheme,
}, },
} }