Skip to content

Commit

Permalink
Merge pull request #7450 from rolandwalker/remove_old_header_support
Browse files Browse the repository at this point in the history
DSL Remove support for old-style header lines
  • Loading branch information
rolandwalker committed Nov 20, 2014
2 parents 540aa3c + 6c53607 commit 80dd4ca
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
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

0 comments on commit 80dd4ca

Please sign in to comment.