Include dsl key in cask artifact hash
This commit is contained in:
		
							parent
							
								
									4de680688e
								
							
						
					
					
						commit
						90d22bc7b1
					
				@ -1,6 +1,8 @@
 | 
			
		||||
# typed: false
 | 
			
		||||
# frozen_string_literal: true
 | 
			
		||||
 | 
			
		||||
require "active_support/core_ext/object/deep_dup"
 | 
			
		||||
 | 
			
		||||
module Cask
 | 
			
		||||
  module Artifact
 | 
			
		||||
    # Abstract superclass for all artifacts.
 | 
			
		||||
@ -127,8 +129,9 @@ module Cask
 | 
			
		||||
 | 
			
		||||
      attr_reader :cask
 | 
			
		||||
 | 
			
		||||
      def initialize(cask)
 | 
			
		||||
      def initialize(cask, *dsl_args)
 | 
			
		||||
        @cask = cask
 | 
			
		||||
        @dsl_args = dsl_args.deep_dup
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      def config
 | 
			
		||||
@ -139,6 +142,10 @@ module Cask
 | 
			
		||||
      def to_s
 | 
			
		||||
        "#{summarize} (#{self.class.english_name})"
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      def to_args
 | 
			
		||||
        @dsl_args.reject(&:blank?)
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
@ -32,6 +32,10 @@ module Cask
 | 
			
		||||
        abstract_phase(self.class.uninstall_dsl_key)
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      def summarize
 | 
			
		||||
        directives.keys.map(&:to_s).join(", ")
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      private
 | 
			
		||||
 | 
			
		||||
      def class_for_dsl_key(dsl_key)
 | 
			
		||||
@ -44,10 +48,6 @@ module Cask
 | 
			
		||||
 | 
			
		||||
        class_for_dsl_key(dsl_key).new(cask).instance_eval(&block)
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      def summarize
 | 
			
		||||
        directives.keys.map(&:to_s).join(", ")
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
@ -40,7 +40,7 @@ module Cask
 | 
			
		||||
      def initialize(cask, directives)
 | 
			
		||||
        directives.assert_valid_keys!(*ORDERED_DIRECTIVES)
 | 
			
		||||
 | 
			
		||||
        super(cask)
 | 
			
		||||
        super(cask, **directives)
 | 
			
		||||
        directives[:signal] = Array(directives[:signal]).flatten.each_slice(2).to_a
 | 
			
		||||
        @directives = directives
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -72,7 +72,7 @@ module Cask
 | 
			
		||||
      attr_reader :path, :args
 | 
			
		||||
 | 
			
		||||
      def initialize(cask, **args)
 | 
			
		||||
        super(cask)
 | 
			
		||||
        super(cask, **args)
 | 
			
		||||
 | 
			
		||||
        if args.key?(:manual)
 | 
			
		||||
          @path = Pathname(args[:manual])
 | 
			
		||||
 | 
			
		||||
@ -23,7 +23,7 @@ module Cask
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      def initialize(cask, path, **stanza_options)
 | 
			
		||||
        super(cask)
 | 
			
		||||
        super(cask, path, **stanza_options)
 | 
			
		||||
        @path = cask.staged_path.join(path)
 | 
			
		||||
        @stanza_options = stanza_options
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
@ -42,12 +42,13 @@ module Cask
 | 
			
		||||
      attr_reader :source, :target
 | 
			
		||||
 | 
			
		||||
      sig {
 | 
			
		||||
        params(cask: Cask, source: T.nilable(T.any(String, Pathname)), target: T.nilable(T.any(String, Pathname)))
 | 
			
		||||
        params(cask: Cask, source: T.nilable(T.any(String, Pathname)), target_hash: String)
 | 
			
		||||
          .void
 | 
			
		||||
      }
 | 
			
		||||
      def initialize(cask, source, target: nil)
 | 
			
		||||
        super(cask)
 | 
			
		||||
      def initialize(cask, source, **target_hash)
 | 
			
		||||
        super(cask, source, **target_hash)
 | 
			
		||||
 | 
			
		||||
        target = target_hash[:target]
 | 
			
		||||
        @source_string = source.to_s
 | 
			
		||||
        @target_string = target.to_s
 | 
			
		||||
        source = cask.staged_path.join(source)
 | 
			
		||||
 | 
			
		||||
@ -14,7 +14,7 @@ module Cask
 | 
			
		||||
      def self.from_args(cask, *args)
 | 
			
		||||
        raise CaskInvalidError.new(cask.token, "'stage_only' takes only a single argument: true") if args != [true]
 | 
			
		||||
 | 
			
		||||
        new(cask)
 | 
			
		||||
        new(cask, true)
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      sig { returns(T::Array[T::Boolean]) }
 | 
			
		||||
 | 
			
		||||
@ -235,7 +235,7 @@ module Cask
 | 
			
		||||
        "installed"      => versions.last,
 | 
			
		||||
        "outdated"       => outdated?,
 | 
			
		||||
        "sha256"         => sha256,
 | 
			
		||||
        "artifacts"      => artifacts.map(&method(:to_h_gsubs)),
 | 
			
		||||
        "artifacts"      => artifacts_list,
 | 
			
		||||
        "caveats"        => (to_h_string_gsubs(caveats) unless caveats.empty?),
 | 
			
		||||
        "depends_on"     => depends_on,
 | 
			
		||||
        "conflicts_with" => conflicts_with,
 | 
			
		||||
@ -281,6 +281,19 @@ module Cask
 | 
			
		||||
 | 
			
		||||
    private
 | 
			
		||||
 | 
			
		||||
    def artifacts_list
 | 
			
		||||
      artifacts.map do |artifact|
 | 
			
		||||
        if artifact.is_a? Artifact::AbstractFlightBlock
 | 
			
		||||
          { type: artifact.summarize }
 | 
			
		||||
        else
 | 
			
		||||
          {
 | 
			
		||||
            type: artifact.class.dsl_key,
 | 
			
		||||
            args: to_h_gsubs(artifact.to_args),
 | 
			
		||||
          }
 | 
			
		||||
        end
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    def to_h_string_gsubs(string)
 | 
			
		||||
      string.to_s
 | 
			
		||||
            .gsub(Dir.home, "$HOME")
 | 
			
		||||
 | 
			
		||||
@ -106,13 +106,19 @@ describe Cask::Cmd::List, :cask do
 | 
			
		||||
            "outdated": false,
 | 
			
		||||
            "sha256": "67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94",
 | 
			
		||||
            "artifacts": [
 | 
			
		||||
              [
 | 
			
		||||
                "Caffeine.app"
 | 
			
		||||
              ],
 | 
			
		||||
              {
 | 
			
		||||
                "trash": "$HOME/support/fixtures/cask/caffeine/org.example.caffeine.plist",
 | 
			
		||||
                "signal": {
 | 
			
		||||
                }
 | 
			
		||||
                "type": "app",
 | 
			
		||||
                "args": [
 | 
			
		||||
                  "Caffeine.app"
 | 
			
		||||
                ]
 | 
			
		||||
              },
 | 
			
		||||
              {
 | 
			
		||||
                "type": "zap",
 | 
			
		||||
                "args": [
 | 
			
		||||
                  {
 | 
			
		||||
                    "trash": "$HOME/support/fixtures/cask/caffeine/org.example.caffeine.plist"
 | 
			
		||||
                  }
 | 
			
		||||
                ]
 | 
			
		||||
              }
 | 
			
		||||
            ],
 | 
			
		||||
            "caveats": null,
 | 
			
		||||
@ -140,9 +146,12 @@ describe Cask::Cmd::List, :cask do
 | 
			
		||||
            "outdated": false,
 | 
			
		||||
            "sha256": "e44ffa103fbf83f55c8d0b1bea309a43b2880798dae8620b1ee8da5e1095ec68",
 | 
			
		||||
            "artifacts": [
 | 
			
		||||
              [
 | 
			
		||||
                "Transmission.app"
 | 
			
		||||
              ]
 | 
			
		||||
              {
 | 
			
		||||
                "type": "app",
 | 
			
		||||
                "args": [
 | 
			
		||||
                  "Transmission.app"
 | 
			
		||||
                ]
 | 
			
		||||
              }
 | 
			
		||||
            ],
 | 
			
		||||
            "caveats": null,
 | 
			
		||||
            "depends_on": {
 | 
			
		||||
@ -172,9 +181,12 @@ describe Cask::Cmd::List, :cask do
 | 
			
		||||
            "outdated": false,
 | 
			
		||||
            "sha256": "67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94",
 | 
			
		||||
            "artifacts": [
 | 
			
		||||
              [
 | 
			
		||||
                "Caffeine.app"
 | 
			
		||||
              ]
 | 
			
		||||
              {
 | 
			
		||||
                "type": "app",
 | 
			
		||||
                "args": [
 | 
			
		||||
                  "Caffeine.app"
 | 
			
		||||
                ]
 | 
			
		||||
              }
 | 
			
		||||
            ],
 | 
			
		||||
            "caveats": null,
 | 
			
		||||
            "depends_on": {
 | 
			
		||||
@ -201,9 +213,12 @@ describe Cask::Cmd::List, :cask do
 | 
			
		||||
            "outdated": false,
 | 
			
		||||
            "sha256": "8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b",
 | 
			
		||||
            "artifacts": [
 | 
			
		||||
              [
 | 
			
		||||
                "ThirdParty.app"
 | 
			
		||||
              ]
 | 
			
		||||
              {
 | 
			
		||||
                "type": "app",
 | 
			
		||||
                "args": [
 | 
			
		||||
                  "ThirdParty.app"
 | 
			
		||||
                ]
 | 
			
		||||
              }
 | 
			
		||||
            ],
 | 
			
		||||
            "caveats": null,
 | 
			
		||||
            "depends_on": {
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user