aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/extend/pathname.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/extend/pathname.rb
parent2c6e93cf8aa77c5cfa6f16cafa7bf372d3afc7ab (diff)
downloadbrew-76b2eee7771ecf2b339d1023699ef9f30fa3fe65.tar.bz2
Refactor checksumming
Signed-off-by: Jack Nagel <jacknagel@gmail.com>
Diffstat (limited to 'Library/Homebrew/extend/pathname.rb')
-rw-r--r--Library/Homebrew/extend/pathname.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/Library/Homebrew/extend/pathname.rb b/Library/Homebrew/extend/pathname.rb
index 907679f99..5edd8b664 100644
--- a/Library/Homebrew/extend/pathname.rb
+++ b/Library/Homebrew/extend/pathname.rb
@@ -301,6 +301,13 @@ class Pathname
require 'digest/sha2'
incremental_hash(Digest::SHA2)
end
+ alias_method :sha256, :sha2
+
+ def verify_checksum expected
+ raise ChecksumMissingError if expected.nil? or expected.empty?
+ actual = Checksum.new(expected.hash_type, send(expected.hash_type).downcase)
+ raise ChecksumMismatchError.new(expected, actual) unless expected == actual
+ end
if '1.9' <= RUBY_VERSION
alias_method :to_str, :to_s