Improve format of git cask info --json output

This commit is contained in:
alexbostock 2018-07-02 10:13:25 +01:00
parent 2d5ae645d9
commit 0bfc6bd490
2 changed files with 11 additions and 5 deletions

View File

@ -26,6 +26,10 @@ module Hbc
abstract_phase(self.class.uninstall_dsl_key) abstract_phase(self.class.uninstall_dsl_key)
end end
def summarize
directives.keys.map(&:to_s).join(", ")
end
private private
def class_for_dsl_key(dsl_key) def class_for_dsl_key(dsl_key)
@ -37,10 +41,6 @@ module Hbc
return if (block = directives[dsl_key]).nil? return if (block = directives[dsl_key]).nil?
class_for_dsl_key(dsl_key).new(cask).instance_eval(&block) class_for_dsl_key(dsl_key).new(cask).instance_eval(&block)
end end
def summarize
directives.keys.map(&:to_s).join(", ")
end
end end
end end
end end

View File

@ -138,7 +138,7 @@ module Hbc
"appcast" => appcast, "appcast" => appcast,
"version" => version, "version" => version,
"sha256" => sha256, "sha256" => sha256,
"artifacts" => artifacts, "artifacts" => {},
"caveats" => caveats, "caveats" => caveats,
"depends_on" => depends_on, "depends_on" => depends_on,
"conflicts_with" => conflicts_with, "conflicts_with" => conflicts_with,
@ -148,6 +148,12 @@ module Hbc
"auto_updates" => auto_updates "auto_updates" => auto_updates
} }
artifacts.each do |a|
hsh["artifacts"][a.class.english_name] = a.summarize
end
hsh["conflicts_with"] = [] if hsh["conflicts_with"] == nil
hsh hsh
end end
end end