2018-09-03 19:39:07 +01:00
|
|
|
require "cask/artifact/moved"
|
2016-08-18 22:11:42 +03:00
|
|
|
|
2018-07-16 22:46:02 +02:00
|
|
|
require "extend/hash_validator"
|
|
|
|
using HashValidator
|
2016-10-04 15:24:58 +02:00
|
|
|
|
2018-09-06 08:29:14 +02:00
|
|
|
module Cask
|
2016-09-24 13:52:43 +02:00
|
|
|
module Artifact
|
|
|
|
class Artifact < Moved
|
2017-04-06 00:33:31 +02:00
|
|
|
def self.english_name
|
2016-09-24 13:52:43 +02:00
|
|
|
"Generic Artifact"
|
|
|
|
end
|
2016-08-18 22:11:42 +03:00
|
|
|
|
2017-04-06 00:33:31 +02:00
|
|
|
def self.from_args(cask, *args)
|
|
|
|
source_string, target_hash = args
|
|
|
|
|
2019-02-19 13:11:32 +00:00
|
|
|
raise CaskInvalidError.new(cask.token, "no source given for #{english_name}") if source_string.nil?
|
2017-04-06 00:33:31 +02:00
|
|
|
|
|
|
|
unless target_hash.is_a?(Hash)
|
|
|
|
raise CaskInvalidError.new(cask.token, "target required for #{english_name} '#{source_string}'")
|
|
|
|
end
|
2016-08-18 22:11:42 +03:00
|
|
|
|
2018-07-16 22:46:02 +02:00
|
|
|
target_hash.assert_valid_keys!(:target)
|
2017-04-06 00:33:31 +02:00
|
|
|
|
|
|
|
new(cask, source_string, **target_hash)
|
|
|
|
end
|
|
|
|
|
2017-12-03 21:21:31 +01:00
|
|
|
def resolve_target(target)
|
2017-04-06 00:33:31 +02:00
|
|
|
Pathname(target)
|
|
|
|
end
|
|
|
|
|
|
|
|
def initialize(cask, source, target: nil)
|
|
|
|
super(cask, source, target: target)
|
2016-09-24 13:52:43 +02:00
|
|
|
end
|
|
|
|
end
|
2016-08-18 22:11:42 +03:00
|
|
|
end
|
|
|
|
end
|