diff options
| author | Jack Nagel | 2013-10-09 21:41:15 -0500 |
|---|---|---|
| committer | Jack Nagel | 2013-10-09 21:41:15 -0500 |
| commit | 0588dea2d39e58c93dbf0065dececbfe24ffedb5 (patch) | |
| tree | a9ae2a7db7813780111fbc53f59a66f55a4714b4 /Library/Homebrew/download_strategy.rb | |
| parent | 9da55d087ca6b0da91c9d7b9d6edaeda44105fde (diff) | |
| download | homebrew-0588dea2d39e58c93dbf0065dececbfe24ffedb5.tar.bz2 | |
Extract a new superclass for VCS-based download strategies
Diffstat (limited to 'Library/Homebrew/download_strategy.rb')
| -rw-r--r-- | Library/Homebrew/download_strategy.rb | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb index 691ed8736..6fc519c5f 100644 --- a/Library/Homebrew/download_strategy.rb +++ b/Library/Homebrew/download_strategy.rb @@ -9,8 +9,6 @@ class AbstractDownloadStrategy @name = name @resource = resource @url = resource.url - specs = resource.specs - @ref_type, @ref = specs.dup.shift unless specs.empty? end def expand_safe_system_args args @@ -48,6 +46,14 @@ class AbstractDownloadStrategy def cached_location; end end +class VCSDownloadStrategy < AbstractDownloadStrategy + def initialize name, resource + super + specs = resource.specs + @ref_type, @ref = specs.dup.shift unless specs.empty? + end +end + class CurlDownloadStrategy < AbstractDownloadStrategy def initialize name, resource super @@ -302,7 +308,7 @@ class S3DownloadStrategy < CurlDownloadStrategy end end -class SubversionDownloadStrategy < AbstractDownloadStrategy +class SubversionDownloadStrategy < VCSDownloadStrategy def initialize name, resource super @@svn ||= 'svn' @@ -414,7 +420,7 @@ class UnsafeSubversionDownloadStrategy < SubversionDownloadStrategy end end -class GitDownloadStrategy < AbstractDownloadStrategy +class GitDownloadStrategy < VCSDownloadStrategy def initialize name, resource super @@git ||= 'git' @@ -562,7 +568,7 @@ class GitDownloadStrategy < AbstractDownloadStrategy end end -class CVSDownloadStrategy < AbstractDownloadStrategy +class CVSDownloadStrategy < VCSDownloadStrategy def initialize name, resource super @co = Pathname.new("#{HOMEBREW_CACHE}/#{checkout_name("cvs")}") @@ -612,7 +618,7 @@ class CVSDownloadStrategy < AbstractDownloadStrategy end end -class MercurialDownloadStrategy < AbstractDownloadStrategy +class MercurialDownloadStrategy < VCSDownloadStrategy def initialize name, resource super @clone = Pathname.new("#{HOMEBREW_CACHE}/#{checkout_name("hg")}") @@ -667,7 +673,7 @@ class MercurialDownloadStrategy < AbstractDownloadStrategy end end -class BazaarDownloadStrategy < AbstractDownloadStrategy +class BazaarDownloadStrategy < VCSDownloadStrategy def initialize name, resource super @clone = Pathname.new("#{HOMEBREW_CACHE}/#{checkout_name("bzr")}") @@ -715,7 +721,7 @@ class BazaarDownloadStrategy < AbstractDownloadStrategy end end -class FossilDownloadStrategy < AbstractDownloadStrategy +class FossilDownloadStrategy < VCSDownloadStrategy def initialize name, resource super @clone = Pathname.new("#{HOMEBREW_CACHE}/#{checkout_name("fossil")}") |
