diff options
| author | Markus Reiter | 2017-08-04 14:59:18 +0200 |
|---|---|---|
| committer | Markus Reiter | 2017-09-10 23:12:32 +0200 |
| commit | b0c98ba6319e0e53cc0a262dd08bbb339d4bd7b5 (patch) | |
| tree | 24b370322f96e962917bb356408132dc9a4dfb3d | |
| parent | 53ecdd843f6e6d6dd93e09a5394de3c31bc0e51a (diff) | |
| download | brew-b0c98ba6319e0e53cc0a262dd08bbb339d4bd7b5.tar.bz2 | |
Fix `_stanza`.
6 files changed, 43 insertions, 10 deletions
diff --git a/Library/Homebrew/cask/lib/hbc/artifact/abstract_uninstall.rb b/Library/Homebrew/cask/lib/hbc/artifact/abstract_uninstall.rb index 9499d5c03..2ce4f399d 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 64ce2d4bc..588bcabd5 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 72a6f6bb5..540699630 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 7aef66469..8c32a52d0 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 2727f95b7..018b4e9ca 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 <stanza_name> [ --table | --yaml | --inspect | --quiet ] [ <cask_token> ... ] + # brew cask _stanza <stanza_name> [ --quiet ] [ --table | --yaml ] [ <cask_token> ... ] # # 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 0dc51cb2d..00dc252fe 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 |
