diff --git a/Library/Homebrew/cask/lib/hbc/artifact/abstract_uninstall.rb b/Library/Homebrew/cask/lib/hbc/artifact/abstract_uninstall.rb index 9499d5c03f..2ce4f399dd 100644 --- a/Library/Homebrew/cask/lib/hbc/artifact/abstract_uninstall.rb +++ b/Library/Homebrew/cask/lib/hbc/artifact/abstract_uninstall.rb @@ -31,6 +31,10 @@ module Hbc @directives = directives end + def to_h + directives.to_h + end + private def dispatch_uninstall_directives(**options) diff --git a/Library/Homebrew/cask/lib/hbc/artifact/installer.rb b/Library/Homebrew/cask/lib/hbc/artifact/installer.rb index 64ce2d4bc5..588bcabd54 100644 --- a/Library/Homebrew/cask/lib/hbc/artifact/installer.rb +++ b/Library/Homebrew/cask/lib/hbc/artifact/installer.rb @@ -73,6 +73,12 @@ module Hbc def summarize path.relative_path_from(cask.staged_path).to_s end + + def to_h + { path: path.relative_path_from(cask.staged_path).to_s }.tap do |h| + h[:args] = args unless is_a?(ManualInstaller) + end + end end end end diff --git a/Library/Homebrew/cask/lib/hbc/artifact/relocated.rb b/Library/Homebrew/cask/lib/hbc/artifact/relocated.rb index 72a6f6bb56..540699630e 100644 --- a/Library/Homebrew/cask/lib/hbc/artifact/relocated.rb +++ b/Library/Homebrew/cask/lib/hbc/artifact/relocated.rb @@ -35,6 +35,12 @@ module Hbc @target = self.class.resolve_target(target) end + def to_a + [@source_string].tap do |ary| + ary << { target: @target_string } unless @target_string.empty? + end + end + def summarize target_string = @target_string.empty? ? "" : " -> #{@target_string}" "#{@source_string}#{target_string}" diff --git a/Library/Homebrew/cask/lib/hbc/artifact/stage_only.rb b/Library/Homebrew/cask/lib/hbc/artifact/stage_only.rb index 7aef664690..8c32a52d08 100644 --- a/Library/Homebrew/cask/lib/hbc/artifact/stage_only.rb +++ b/Library/Homebrew/cask/lib/hbc/artifact/stage_only.rb @@ -14,6 +14,10 @@ module Hbc def initialize(cask) super(cask) end + + def to_a + [true] + end end end end diff --git a/Library/Homebrew/cask/lib/hbc/cli/internal_stanza.rb b/Library/Homebrew/cask/lib/hbc/cli/internal_stanza.rb index 2727f95b70..018b4e9cae 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/internal_stanza.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/internal_stanza.rb @@ -3,7 +3,7 @@ module Hbc class InternalStanza < AbstractInternalCommand # Syntax # - # brew cask _stanza [ --table | --yaml | --inspect | --quiet ] [ ... ] + # brew cask _stanza [ --quiet ] [ --table | --yaml ] [ ... ] # # If no tokens are given, then data for all Casks is returned. # @@ -14,11 +14,11 @@ module Hbc # Examples # # brew cask _stanza appcast --table - # brew cask _stanza app --table alfred google-chrome adium voicemac logisim vagrant - # brew cask _stanza url --table alfred google-chrome adium voicemac logisim vagrant - # brew cask _stanza version --table alfred google-chrome adium voicemac logisim vagrant - # brew cask _stanza artifacts --table --inspect alfred google-chrome adium voicemac logisim vagrant - # brew cask _stanza artifacts --table --yaml alfred google-chrome adium voicemac logisim vagrant + # brew cask _stanza app --table alfred google-chrome adium vagrant + # brew cask _stanza url --table alfred google-chrome adium vagrant + # brew cask _stanza version --table alfred google-chrome adium vagrant + # brew cask _stanza artifacts --table alfred google-chrome adium vagrant + # brew cask _stanza artifacts --table --yaml alfred google-chrome adium vagrant # ARTIFACTS = @@ -43,7 +43,6 @@ module Hbc @stanza = args.shift.to_sym @format = :to_yaml if yaml? - @format = :inspect if inspect? end def run @@ -81,11 +80,25 @@ module Hbc next end - value = value.fetch(artifact_name).to_a.flatten if artifact_name + 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] + end + ] + + value = value.fetch(artifact_name) if artifact_name + end if format puts value.send(format) - elsif artifact_name || value.is_a?(Symbol) + elsif value.is_a?(Symbol) puts value.inspect else puts value.to_s diff --git a/Library/Homebrew/test/cask/conflicts_with_spec.rb b/Library/Homebrew/test/cask/conflicts_with_spec.rb index 0dc51cb2d7..00dc252fe4 100644 --- a/Library/Homebrew/test/cask/conflicts_with_spec.rb +++ b/Library/Homebrew/test/cask/conflicts_with_spec.rb @@ -8,7 +8,7 @@ describe "conflicts_with", :cask do Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-conflicts-with.rb") } - it "installs the dependency of a Cask and the Cask itself", :focus do + it "installs the dependency of a Cask and the Cask itself" do Hbc::Installer.new(local_caffeine).install expect(local_caffeine).to be_installed