Simplify check for :stage_only.

This commit is contained in:
Markus Reiter 2017-02-05 22:40:14 +01:00
parent 4e7062a9ce
commit e18a174607

View File

@ -270,14 +270,17 @@ module Hbc
ORDINARY_ARTIFACT_TYPES.each do |type|
define_method(type) do |*args|
if type == :stage_only && args != [true]
raise CaskInvalidError.new(token, "'stage_only' takes a single argument: true")
end
artifacts[type] << args
if artifacts.key?(:stage_only) && artifacts.keys.count > 1 &&
!(artifacts.keys & ACTIVATABLE_ARTIFACT_TYPES).empty?
raise CaskInvalidError.new(token, "'stage_only' must be the only activatable artifact")
if type == :stage_only
if args != [true]
raise CaskInvalidError.new(token, "'stage_only' takes a single argument: true")
end
unless (artifacts.keys & ACTIVATABLE_ARTIFACT_TYPES).empty?
raise CaskInvalidError.new(token, "'stage_only' must be the only activatable artifact")
end
end
artifacts[type].add(args)
end
end