aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorAdam Vandenberg2011-12-17 17:01:21 -0800
committerAdam Vandenberg2011-12-18 16:24:56 -0800
commitfd082f63b6a039f39da6017eb0f5f2b262433fc7 (patch)
tree92258789943f8d3d6b0d5f9de3f7fc48be96742c /Library
parentf052bcbd62fcb8cd3ccfc2adaf82944f27532eed (diff)
downloadbrew-fd082f63b6a039f39da6017eb0f5f2b262433fc7.tar.bz2
Extract checksum type function
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/formula.rb13
1 files changed, 9 insertions, 4 deletions
diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb
index e020939be..158e7f017 100644
--- a/Library/Homebrew/formula.rb
+++ b/Library/Homebrew/formula.rb
@@ -588,14 +588,19 @@ private
return fetched, downloader
end
+ # Detect which type of checksum is being used, or nil if none
+ def checksum_type
+ CHECKSUM_TYPES.detect { |type| instance_variable_defined?("@#{type}") }
+ end
+
# For FormulaInstaller.
def verify_download_integrity fn, *args
require 'digest'
if args.length != 2
- type=CHECKSUM_TYPES.detect { |type| instance_variable_defined?("@#{type}") }
- type ||= :md5
- supplied=instance_variable_get("@#{type}")
- type=type.to_s.upcase
+ type = checksum_type || :md5
+ supplied = instance_variable_get("@#{type}")
+ # Convert symbol to readable string
+ type = type.to_s.upcase
else
supplied, type = args
end