Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DSL Remove support for old-style header lines #7450

Merged
merged 2 commits into from
Nov 20, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion lib/cask/source/path_base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,15 @@ def load
if %r{\A\s*cask\s+:v([\d_]+)(test)?\s+=>\s+([\'\"])(\S+?)\3(?:\s*,\s*|\s+)do\s*\n}.match(cask_string)
dsl_version = $1
test_cask = ! $2.nil?
header_name = $4
superclass_name = test_cask ? 'TestCask' : 'Cask'
cask_string.sub!(%r{\A[^\n]+\n}, "class #{cask_class_name} < #{superclass_name}\n")
# todo enforce valid DSL version
if header_name != cask_name
raise CaskInvalidError.new(cask_name, "Bad header line: '#{header_name}' does not match file name")
end
else
raise CaskInvalidError.new(cask_name, "Bad header line: parse failed")
end

# simulate "require"
Expand All @@ -72,8 +79,12 @@ def load
end
end

def cask_name
path.basename.to_s.sub(/\.rb/, '')
end

def cask_class_name
path.basename.to_s.sub(/\.rb/, '').split('-').map(&:capitalize).join
cask_name.split('-').map(&:capitalize).join
end

def to_s
Expand Down
2 changes: 1 addition & 1 deletion test/support/Casks/with-suite.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class WithSuite < TestCask
cask :v1 => 'with-suite' do
version '1.2.3'
sha256 'd1302a0dc25aff72ad395ed01a830468b92253ffd28269574f3ac0b5eb8aad54'

Expand Down