From 0eaf4bbcd9e4afb8a92a678ee072e8167e841527 Mon Sep 17 00:00:00 2001 From: Adam Vandenberg Date: Tue, 11 Aug 2009 12:20:55 -0700 Subject: [PATCH] Factor out downloading from Formula This patch adds a ArchiveDownloadStrategy that handles downloading tarbarlls and decompressing them into the staging area ready for brewing. Refactored safe_system and curl into utils.rb Signed-off-by: Max Howell Modifications to Adam's original patch: I reverted objectification of checksum verification because I couldn't think of any other download validation methods that might be useful to us in the future, so allowing such flexibility had no advantages. If we ever need this to be OO we can add it. But for now less complexity is preferable. I removed the @svnurl class member. Instead download_strategy is autodetected by examining the url. The user can override the download_strategy in case this fails. Thus we already can easily add support for clones of git repositories. --- Library/Homebrew/formula.rb | 148 +++++++++++++++++------------ Library/Homebrew/pathname+yeast.rb | 5 +- Library/Homebrew/unittest.rb | 26 ++--- Library/Homebrew/utils.rb | 14 +++ 4 files changed, 119 insertions(+), 74 deletions(-) diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index c0cb925a2a..2b3d3d9961 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -16,6 +16,63 @@ # along with Homebrew. If not, see . +class AbstractDownloadStrategy + def initialize url, name, version + @url=url + @unique_token="#{name}-#{version}" + end +end + +class HttpDownloadStrategy