aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorMartin Schimandl2017-10-14 08:38:46 +0200
committerMartin Schimandl2017-11-10 20:16:38 +0100
commitd03720320ad22c564cb2675d919d09677f368a9b (patch)
treed218fa03dfc995b0d95fc5310b4c6246f08032c1 /Library
parent587c5b07b326c82dc3becf4e4229861c86b1dcfa (diff)
downloadbrew-d03720320ad22c564cb2675d919d09677f368a9b.tar.bz2
adapt internal_stanza command to work with SortedSet of Artifacts
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/cask/lib/hbc/cli/internal_stanza.rb43
1 files changed, 21 insertions, 22 deletions
diff --git a/Library/Homebrew/cask/lib/hbc/cli/internal_stanza.rb b/Library/Homebrew/cask/lib/hbc/cli/internal_stanza.rb
index 1ac585673..dd7bf6e9c 100644
--- a/Library/Homebrew/cask/lib/hbc/cli/internal_stanza.rb
+++ b/Library/Homebrew/cask/lib/hbc/cli/internal_stanza.rb
@@ -24,6 +24,9 @@ module Hbc
ARTIFACTS =
DSL::ORDINARY_ARTIFACT_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 "--quiet", :quiet, false
@@ -65,33 +68,29 @@ module Hbc
next
end
- if value.nil? || (value.respond_to?(:to_a) && value.to_a.empty?) ||
- (value.respond_to?(:to_s) && value.to_s == "{}") ||
- (artifact_name && !value.include?(artifact_name))
-
- if artifact_name
- thing = artifact_name
- else
- thing = stanza
+ if stanza == :artifacts
+ result = {}
+ value.each do |e|
+ result[e.class.dsl_key] = e.summarize
end
-
- raise CaskError, "no such stanza '#{thing}' on Cask '#{cask}'"
+ value = result
end
- if stanza == :artifacts
- value = Hash[
- value.map do |k, v|
- v = v.map do |a|
- next a.to_a if a.respond_to?(:to_a)
- next a.to_h if a.respond_to?(:to_h)
- a
- end
-
- [k, v]
+ if artifact_name
+ result = nil
+ value.each do |k, v|
+ if k == artifact_name
+ result = v
+ break
end
- ]
+ end
+ value = result
+ end
+
+ if value.nil? || (value.respond_to?(:to_a) && value.to_a.empty?) ||
+ (value.respond_to?(:to_s) && value.to_s == "{}") # ||
- value = value.fetch(artifact_name) if artifact_name
+ raise CaskError, "no such stanza '#{artifact_name ? artifact_name : stanza}' on Cask '#{cask}'"
end
if format