Skip to content

Commit

Permalink
Merge pull request #3107 from rolandwalker/dsl_no_check_syntax
Browse files Browse the repository at this point in the history
`sha256 :no_check` as synonym for `no_checksum`
  • Loading branch information
rolandwalker committed Feb 25, 2014
2 parents 22e24ea + 3623d13 commit abe1f17
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
2 changes: 1 addition & 1 deletion lib/cask/audit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def _check_required_fields

def _check_checksums
odebug "Auditing checksums"
return if cask.sums == 0
return if cask.sums == :no_check
add_error "could not find checksum or no_checksum" unless cask.sums.is_a?(Array) && cask.sums.length > 0
end

Expand Down
2 changes: 1 addition & 1 deletion lib/cask/download.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def perform
HOMEBREW_CACHE_CASKS.join(downloaded_path.basename)
rescue
end
_check_sums(downloaded_path, cask.sums) unless cask.sums === 0
_check_sums(downloaded_path, cask.sums) unless cask.sums === :no_check
downloaded_path
end

Expand Down
22 changes: 15 additions & 7 deletions lib/cask/dsl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,26 +116,34 @@ def hash_name(hash_type)
end

def sha1(sha1=nil)
if @sums == 0
if @sums == :no_check
raise CaskInvalidError.new(self.title, "'no_checksum' stanza conflicts with 'sha1'")
end
@sums ||= []
@sums << Checksum.new(:sha1, sha1) unless sha1.nil?
if sha1 == :no_check
@sums = sha1
else
@sums ||= []
@sums << Checksum.new(:sha1, sha1) unless sha1.nil?
end
end

def sha256(sha2=nil)
if @sums == 0
if @sums == :no_check
raise CaskInvalidError.new(self.title, "'no_checksum' stanza conflicts with 'sha256'")
end
@sums ||= []
@sums << Checksum.new(:sha2, sha2) unless sha2.nil?
if sha2 == :no_check
@sums = sha2
else
@sums ||= []
@sums << Checksum.new(:sha2, sha2) unless sha2.nil?
end
end

def no_checksum
unless @sums.nil? or @sums.empty?
raise CaskInvalidError.new(self.title, "'no_checksum' stanza conflicts with '#{hash_name(@sums.first.hash_type)}'")
end
@sums = 0
@sums = :no_check
end

def method_missing(method, *args)
Expand Down

0 comments on commit abe1f17

Please sign in to comment.