Simplify CaskLoader.

This commit is contained in:
Markus Reiter 2017-02-03 22:00:28 +01:00
parent 4eef60c6a6
commit 0802ad734f
2 changed files with 3 additions and 8 deletions

View File

@ -32,17 +32,12 @@ module Hbc
end end
def cask(header_token, &block) def cask(header_token, &block)
@klass = Cask
build_cask(header_token, &block)
end
def build_cask(header_token, &block)
raise CaskTokenDoesNotMatchError.new(@token, header_token) unless @token == header_token raise CaskTokenDoesNotMatchError.new(@token, header_token) unless @token == header_token
if @path.nil? if @path.nil?
@klass.new(@token, &block) Cask.new(@token, &block)
else else
@klass.new(@token, sourcefile_path: @path, &block) Cask.new(@token, sourcefile_path: @path, &block)
end end
end end
end end

View File

@ -1,7 +1,7 @@
module CaskLoaderCompatibilityLayer module CaskLoaderCompatibilityLayer
private private
def build_cask(header_token, &block) def cask(header_token, &block)
if header_token.is_a?(Hash) && header_token.key?(:v1) if header_token.is_a?(Hash) && header_token.key?(:v1)
odeprecated %q("cask :v1 => 'token'"), %q("cask 'token'") odeprecated %q("cask :v1 => 'token'"), %q("cask 'token'")
header_token = header_token[:v1] header_token = header_token[:v1]