From fd082f63b6a039f39da6017eb0f5f2b262433fc7 Mon Sep 17 00:00:00 2001 From: Adam Vandenberg Date: Sat, 17 Dec 2011 17:01:21 -0800 Subject: [PATCH] Extract checksum type function --- Library/Homebrew/formula.rb | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index e020939be6..158e7f017b 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