adapt internal_stanza command to work with SortedSet of Artifacts

This commit is contained in:
Martin Schimandl 2017-10-14 08:38:46 +02:00
parent 587c5b07b3
commit d03720320a

View File

@ -24,6 +24,9 @@ module Hbc
ARTIFACTS = ARTIFACTS =
DSL::ORDINARY_ARTIFACT_CLASSES.map(&:dsl_key) + DSL::ORDINARY_ARTIFACT_CLASSES.map(&:dsl_key) +
DSL::ARTIFACT_BLOCK_CLASSES.map(&:dsl_key) DSL::ARTIFACT_BLOCK_CLASSES.map(&:dsl_key)
ARTIFACTS_CLASSES =
DSL::ORDINARY_ARTIFACT_CLASSES +
DSL::ARTIFACT_BLOCK_CLASSES
option "--table", :table, false option "--table", :table, false
option "--quiet", :quiet, false option "--quiet", :quiet, false
@ -65,33 +68,29 @@ module Hbc
next next
end end
if value.nil? || (value.respond_to?(:to_a) && value.to_a.empty?) || if stanza == :artifacts
(value.respond_to?(:to_s) && value.to_s == "{}") || result = {}
(artifact_name && !value.include?(artifact_name)) value.each do |e|
result[e.class.dsl_key] = e.summarize
if artifact_name
thing = artifact_name
else
thing = stanza
end end
value = result
raise CaskError, "no such stanza '#{thing}' on Cask '#{cask}'"
end end
if stanza == :artifacts if artifact_name
value = Hash[ result = nil
value.map do |k, v| value.each do |k, v|
v = v.map do |a| if k == artifact_name
next a.to_a if a.respond_to?(:to_a) result = v
next a.to_h if a.respond_to?(:to_h) break
a
end
[k, v]
end end
] end
value = result
end
value = value.fetch(artifact_name) if artifact_name if value.nil? || (value.respond_to?(:to_a) && value.to_a.empty?) ||
(value.respond_to?(:to_s) && value.to_s == "{}") # ||
raise CaskError, "no such stanza '#{artifact_name ? artifact_name : stanza}' on Cask '#{cask}'"
end end
if format if format