You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
1.0 KiB
41 lines
1.0 KiB
require 'cask/checkable'
|
|
|
|
class Cask::Audit
|
|
attr_reader :cask
|
|
|
|
include Cask::Checkable
|
|
|
|
def initialize(cask)
|
|
@cask = cask
|
|
end
|
|
|
|
def run!
|
|
_check_required_fields
|
|
_check_checksums
|
|
_check_sourceforge_download_url_format
|
|
return if errors?
|
|
end
|
|
|
|
def summary_header
|
|
"audit for #{cask}"
|
|
end
|
|
|
|
def _check_required_fields
|
|
add_error "url is required" unless cask.url
|
|
add_error "version is required" unless cask.version
|
|
add_error "homepage is required" unless cask.homepage
|
|
end
|
|
|
|
def _check_checksums
|
|
return if cask.sums == 0
|
|
add_error "could not find checksum or no_checksum" unless cask.sums.is_a?(Array) && cask.sums.length > 0
|
|
end
|
|
|
|
def _check_sourceforge_download_url_format
|
|
if cask.url.to_s.match(/\S*sourceforge\.\S*\/\S*/i)
|
|
unless cask.url.to_s.match(/\S*downloads.sourceforge.net\/\S+/i)
|
|
add_warning "SourceForge URL format incorrect. See https://github.com/phinze/homebrew-cask/pull/225#issuecomment-16536889 for details"
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|