aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/cask/lib/hbc/artifact/artifact.rb
blob: b42db877d04cf7cb5f16cff3846cf2db4fb304b7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
require "hbc/artifact/moved"

require "hbc/utils/hash_validator"

module Hbc
  module Artifact
    class Artifact < Moved
      def self.artifact_english_name
        "Generic Artifact"
      end

      def self.artifact_dirmethod
        :appdir
      end

      def load_specification(artifact_spec)
        source_string, target_hash = artifact_spec
        raise CaskInvalidError.new(@cask.token, "no source given for artifact") if source_string.nil?
        @source = @cask.staged_path.join(source_string)
        raise CaskInvalidError.new(@cask.token, "target required for generic artifact #{source_string}") unless target_hash.is_a?(Hash)
        target_hash.extend(HashValidator).assert_valid_keys(:target)
        @target = Pathname.new(target_hash[:target])
      end
    end
  end
end