aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/cmd/audit.rb
diff options
context:
space:
mode:
authorJack Nagel2012-06-18 19:58:35 -0500
committerJack Nagel2012-07-04 22:47:33 -0500
commit76b2eee7771ecf2b339d1023699ef9f30fa3fe65 (patch)
treedf5ab7ba72806e408a6e9617bb3eaa195889be0a /Library/Homebrew/cmd/audit.rb
parent2c6e93cf8aa77c5cfa6f16cafa7bf372d3afc7ab (diff)
downloadbrew-76b2eee7771ecf2b339d1023699ef9f30fa3fe65.tar.bz2
Refactor checksumming
Signed-off-by: Jack Nagel <jacknagel@gmail.com>
Diffstat (limited to 'Library/Homebrew/cmd/audit.rb')
-rwxr-xr-xLibrary/Homebrew/cmd/audit.rb21
1 files changed, 10 insertions, 11 deletions
diff --git a/Library/Homebrew/cmd/audit.rb b/Library/Homebrew/cmd/audit.rb
index 7e05b7b3b..0fd44580b 100755
--- a/Library/Homebrew/cmd/audit.rb
+++ b/Library/Homebrew/cmd/audit.rb
@@ -290,22 +290,21 @@ def audit_formula_specs f
end
end
- cksum = s.checksum_type
- unless cksum.nil?
- hash = s.send(cksum).strip
- len = case cksum
+ cksum = s.checksum
+ next if cksum.nil?
+
+ len = case cksum.hash_type
when :md5 then 32
when :sha1 then 40
when :sha256 then 64
end
- if hash.empty?
- problems << " * #{cksum} is empty"
- else
- problems << " * #{cksum} should be #{len} characters" unless hash.length == len
- problems << " * #{cksum} contains invalid characters" unless hash =~ /^[a-fA-F0-9]+$/
- problems << " * #{cksum} should be lowercase" unless hash == hash.downcase
- end
+ if cksum.empty?
+ problems << " * #{cksum.hash_type} is empty"
+ else
+ problems << " * #{cksum.hash_type} should be #{len} characters" unless cksum.hexdigest.length == len
+ problems << " * #{cksum.hash_type} contains invalid characters" unless cksum.hexdigest =~ /^[a-fA-F0-9]+$/
+ problems << " * #{cksum.hash_type} should be lowercase" unless cksum.hexdigest == cksum.hexdigest.downcase
end
end