35 lines
916 B
Ruby
Raw Normal View History

2021-09-11 01:00:23 +01:00
# typed: strict
# frozen_string_literal: true
require "cask/artifact/moved"
2016-08-18 22:11:42 +03:00
2018-09-06 08:29:14 +02:00
module Cask
2016-09-24 13:52:43 +02:00
module Artifact
2020-08-19 10:23:41 +02:00
# Generic artifact corresponding to the `artifact` stanza.
2016-09-24 13:52:43 +02:00
class Artifact < Moved
2020-10-20 12:03:48 +02:00
sig { returns(String) }
def self.english_name
2016-09-24 13:52:43 +02:00
"Generic Artifact"
end
2016-08-18 22:11:42 +03:00
2020-12-13 03:12:30 +01:00
sig { params(cask: Cask, args: T.untyped).returns(T.attached_class) }
def self.from_args(cask, *args)
2020-12-13 03:12:30 +01:00
source, options = args
2020-12-13 03:12:30 +01:00
raise CaskInvalidError.new(cask.token, "No source provided for #{english_name}.") if source.blank?
2023-10-08 09:36:08 -07:00
unless options&.key?(:target)
2020-12-13 03:12:30 +01:00
raise CaskInvalidError.new(cask.token, "#{english_name} '#{source}' requires a target.")
end
2016-08-18 22:11:42 +03:00
2020-12-13 03:12:30 +01:00
new(cask, source, **options)
end
2020-12-13 03:12:30 +01:00
sig { params(target: T.any(String, Pathname)).returns(Pathname) }
def resolve_target(target)
2020-12-13 03:12:30 +01:00
super(target, base_dir: nil)
end
2016-09-24 13:52:43 +02:00
end
2016-08-18 22:11:42 +03:00
end
end