diff options
| author | Jack Nagel | 2013-10-11 00:11:58 -0500 |
|---|---|---|
| committer | Jack Nagel | 2013-10-11 00:21:23 -0500 |
| commit | 932091f9e0881ebbc26df08d98544298af1a6116 (patch) | |
| tree | 23aabdd2d355d6dca00eae93629c59f899b2842a /Library/Homebrew | |
| parent | ed7f8faed2080260bb7308c7f7985003504e98e7 (diff) | |
| download | brew-932091f9e0881ebbc26df08d98544298af1a6116.tar.bz2 | |
VCSDownloadStrategy: pull construction of @clone into superclass
Diffstat (limited to 'Library/Homebrew')
| -rw-r--r-- | Library/Homebrew/download_strategy.rb | 46 |
1 files changed, 16 insertions, 30 deletions
diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb index 203712af7..bee4b54cc 100644 --- a/Library/Homebrew/download_strategy.rb +++ b/Library/Homebrew/download_strategy.rb @@ -42,13 +42,14 @@ class VCSDownloadStrategy < AbstractDownloadStrategy def initialize name, resource super @ref_type, @ref = destructure_spec_hash(resource.specs) + @clone = HOMEBREW_CACHE/cache_filename end def destructure_spec_hash(spec) spec.each { |o| return o } end - def cache_filename(tag) + def cache_filename(tag=cache_tag) if name.empty? || name == '__UNKNOWN__' "#{ERB::Util.url_encode(@url)}--#{tag}" else @@ -56,6 +57,10 @@ class VCSDownloadStrategy < AbstractDownloadStrategy end end + def cache_tag + "__UNKNOWN__" + end + def cached_location @clone end @@ -316,15 +321,10 @@ class S3DownloadStrategy < CurlDownloadStrategy end class SubversionDownloadStrategy < VCSDownloadStrategy - def initialize name, resource - super - @@svn ||= 'svn' + @@svn ||= 'svn' - if ARGV.build_head? - @clone = Pathname.new("#{HOMEBREW_CACHE}/#{cache_filename("svn-HEAD")}") - else - @clone = Pathname.new("#{HOMEBREW_CACHE}/#{cache_filename("svn")}") - end + def cache_tag + ARGV.build_head? ? "svn-HEAD" : "svn" end def repo_valid? @@ -424,11 +424,9 @@ class UnsafeSubversionDownloadStrategy < SubversionDownloadStrategy end class GitDownloadStrategy < VCSDownloadStrategy - def initialize name, resource - super - @@git ||= 'git' - @clone = Pathname.new("#{HOMEBREW_CACHE}/#{cache_filename("git")}") - end + @@git ||= 'git' + + def cache_tag; "git" end def fetch ohai "Cloning #@url" @@ -568,10 +566,7 @@ class GitDownloadStrategy < VCSDownloadStrategy end class CVSDownloadStrategy < VCSDownloadStrategy - def initialize name, resource - super - @clone = Pathname.new("#{HOMEBREW_CACHE}/#{cache_filename("cvs")}") - end + def cache_tag; "cvs" end def fetch ohai "Checking out #{@url}" @@ -616,10 +611,7 @@ class CVSDownloadStrategy < VCSDownloadStrategy end class MercurialDownloadStrategy < VCSDownloadStrategy - def initialize name, resource - super - @clone = Pathname.new("#{HOMEBREW_CACHE}/#{cache_filename("hg")}") - end + def cache_tag; "hg" end def hgpath # #{HOMEBREW_PREFIX}/share/python/hg is deprecated, but we levae it in for a while @@ -669,10 +661,7 @@ class MercurialDownloadStrategy < VCSDownloadStrategy end class BazaarDownloadStrategy < VCSDownloadStrategy - def initialize name, resource - super - @clone = Pathname.new("#{HOMEBREW_CACHE}/#{cache_filename("bzr")}") - end + def cache_tag; "bzr" end def bzrpath @path ||= %W[ @@ -715,10 +704,7 @@ class BazaarDownloadStrategy < VCSDownloadStrategy end class FossilDownloadStrategy < VCSDownloadStrategy - def initialize name, resource - super - @clone = Pathname.new("#{HOMEBREW_CACHE}/#{cache_filename("fossil")}") - end + def cache_tag; "fossil" end def fossilpath @path ||= %W[ |
