Extract a new superclass for VCS-based download strategies

This commit is contained in:
Jack Nagel committed 2013-10-09 21:41:15 -05:00
1 parent 9da55d087c
commit 0588dea2d3
2 files changed
+15 -9

No files matched your search

+14 -8
View File
@@ -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")}")
@@ -40,7 +40,7 @@ end
class DownloadStrategyCheckoutNameTests < Test::Unit::TestCase
def setup
@resource = ResourceDouble.new("http://foo.com/bar")
@strategy = AbstractDownloadStrategy
@strategy = VCSDownloadStrategy
end
def escaped(tag)