aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorJack Nagel2014-06-11 12:05:19 -0500
committerJack Nagel2014-06-11 12:05:19 -0500
commit93d8e716410bdf04346791e64b7446528371dfed (patch)
tree720bd82f736bc72ece01d8f1286adc1e19761f88 /Library
parentc0e0bd29843f68ca3b1f194b941804c2493037ba (diff)
downloadbrew-93d8e716410bdf04346791e64b7446528371dfed.tar.bz2
Use Digest#file if it's available
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/extend/pathname.rb14
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