Merge pull request #839 from jawshooah/cask/deprecated-header-syntax

Allow deprecated hash syntax in Cask headers
This commit is contained in:
Josh Hagins 2016-08-31 09:19:57 -04:00 committed by GitHub
commit 2c35d2c939
3 changed files with 22 additions and 0 deletions

View File

@ -55,6 +55,10 @@ class Hbc::Source::PathBase
end
def build_cask(cask_class, header_token, &block)
if header_token.is_a?(Hash)
# Cask file is using old `cask :v1 => 'token'` syntax
header_token = header_token.values.first
end
raise Hbc::CaskTokenDoesNotMatchError.new(cask_token, header_token) unless cask_token == header_token
cask_class.new(cask_token, sourcefile_path: path, &block)
end

View File

@ -62,6 +62,15 @@ describe Hbc::DSL do
it "does not require a DSL version in the header" do
test_cask = Hbc.load("no-dsl-version")
test_cask.token.must_equal "no-dsl-version"
test_cask.url.to_s.must_equal "http://example.com/TestCask.dmg"
test_cask.homepage.must_equal "http://example.com/"
test_cask.version.to_s.must_equal "1.2.3"
end
it "may use deprecated DSL version hash syntax" do
test_cask = Hbc.load("with-dsl-version")
test_cask.token.must_equal "with-dsl-version"
test_cask.url.to_s.must_equal "http://example.com/TestCask.dmg"
test_cask.homepage.must_equal "http://example.com/"
test_cask.version.to_s.must_equal "1.2.3"

View File

@ -0,0 +1,9 @@
test_cask :v1 => 'with-dsl-version' do
version '1.2.3'
sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b'
url 'http://example.com/TestCask.dmg'
homepage 'http://example.com/'
app 'TestCask.app'
end