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
commit4d3b9efe81fd19d68bf46d32058b458b62e9c4e9 (patch)
tree624feadd1f985b80fcf4a4586a1077c535f5b5a1 /Library
parent29675443a9e33ab3d9943a98a938b1f02c9222c8 (diff)
downloadhomebrew-4d3b9efe81fd19d68bf46d32058b458b62e9c4e9.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