Allow deprecated hash syntax in Cask headers
This commit is contained in:
parent
1b6908f41e
commit
5b593ebb89
@ -55,6 +55,10 @@ class Hbc::Source::PathBase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def build_cask(cask_class, header_token, &block)
|
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
|
raise Hbc::CaskTokenDoesNotMatchError.new(cask_token, header_token) unless cask_token == header_token
|
||||||
cask_class.new(cask_token, sourcefile_path: path, &block)
|
cask_class.new(cask_token, sourcefile_path: path, &block)
|
||||||
end
|
end
|
||||||
|
|||||||
@ -62,6 +62,15 @@ describe Hbc::DSL do
|
|||||||
|
|
||||||
it "does not require a DSL version in the header" do
|
it "does not require a DSL version in the header" do
|
||||||
test_cask = Hbc.load("no-dsl-version")
|
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.url.to_s.must_equal "http://example.com/TestCask.dmg"
|
||||||
test_cask.homepage.must_equal "http://example.com/"
|
test_cask.homepage.must_equal "http://example.com/"
|
||||||
test_cask.version.to_s.must_equal "1.2.3"
|
test_cask.version.to_s.must_equal "1.2.3"
|
||||||
|
|||||||
@ -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
|
||||||
Loading…
x
Reference in New Issue
Block a user