diff options
| author | Jack Nagel | 2014-06-11 12:05:19 -0500 |
|---|---|---|
| committer | Jack Nagel | 2014-06-11 12:05:19 -0500 |
| commit | 77ee6d10d2d76b7a24887d5d3f81f96eb160229d (patch) | |
| tree | a9807e7e15aa2ab9b6d4b65ea0f848c3c56fcb25 /Library/Homebrew/extend | |
| parent | 1a6d7958a55a78fe40f7e4bfb86e697c6d1ee0e0 (diff) | |
| download | homebrew-77ee6d10d2d76b7a24887d5d3f81f96eb160229d.tar.bz2 | |
Use Digest#file if it's available
Diffstat (limited to 'Library/Homebrew/extend')
| -rw-r--r-- | Library/Homebrew/extend/pathname.rb | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/Library/Homebrew/extend/pathname.rb b/Library/Homebrew/extend/pathname.rb index d0e77682c..aca499720 100644 --- a/Library/Homebrew/extend/pathname.rb +++ b/Library/Homebrew/extend/pathname.rb @@ -244,11 +244,15 @@ class Pathname %r[^#!\s*\S+] === open('r') { |f| f.read(1024) } end - def incremental_hash(hasher) - incr_hash = hasher.new - buf = "" - open('rb') { |f| incr_hash << buf while f.read(1024, buf) } - incr_hash.hexdigest + def incremental_hash(klass) + digest = klass.new + if digest.respond_to?(:file) + digest.file(self) + else + buf = "" + open("rb") { |f| digest << buf while f.read(1024, buf) } + end + digest.hexdigest end def sha1 |
