aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/compat
diff options
context:
space:
mode:
authorJack Nagel2013-02-01 13:11:43 -0600
committerJack Nagel2013-02-01 13:24:36 -0600
commit56a978ba1d29133d4c0893f9a4c9c651524a4c07 (patch)
tree8ede91cfdc698f1eff2d88bdcbfd49b743c1b866 /Library/Homebrew/compat
parentcfe19f01b81c230ef3e86e2ddba3bbac28328bea (diff)
downloadhomebrew-56a978ba1d29133d4c0893f9a4c9c651524a4c07.tar.bz2
Add md5 support to compatibility, with deprecation warning
Diffstat (limited to 'Library/Homebrew/compat')
-rw-r--r--Library/Homebrew/compat/compatibility.rb33
1 files changed, 33 insertions, 0 deletions
diff --git a/Library/Homebrew/compat/compatibility.rb b/Library/Homebrew/compat/compatibility.rb
index 67f540844..fbd6ad737 100644
--- a/Library/Homebrew/compat/compatibility.rb
+++ b/Library/Homebrew/compat/compatibility.rb
@@ -247,3 +247,36 @@ class Version
to_s.slice *args
end
end
+
+
+# MD5 support
+class Formula
+ def self.md5(val=nil)
+ unless val.nil?
+ @stable ||= SoftwareSpec.new
+ @stable.md5(val)
+ end
+ return @stable ? @stable.md5 : @md5
+ end
+end
+
+class SoftwareSpec
+ def md5(val=nil)
+ if val.nil?
+ @checksum if checksum.nil? or @checksum.hash_type == :md5
+ else
+ opoo <<-EOS.undent
+ MD5 support is deprecated and will be removed in a future version.
+ Please switch this formula to #{Checksum::TYPES.map { |t| t.to_s.upcase } * ' or '}.
+ EOS
+ @checksum = Checksum.new(:md5, val)
+ end
+ end
+end
+
+class Pathname
+ def md5
+ require 'digest/md5'
+ incremental_hash(Digest::MD5)
+ end
+end