diff options
| author | Jack Nagel | 2014-12-09 16:46:28 -0500 |
|---|---|---|
| committer | Jack Nagel | 2014-12-09 16:46:28 -0500 |
| commit | b2a6ebb6839ca5f08c27c08c5a20b68db201c8a3 (patch) | |
| tree | 300688815794b406bea903473b9b521d55a7d3c4 | |
| parent | 763e17c4baf59129904c819748c28262a06a44ac (diff) | |
| download | homebrew-b2a6ebb6839ca5f08c27c08c5a20b68db201c8a3.tar.bz2 | |
Move tool path methods to AbstractDownloadStrategy
| -rw-r--r-- | Library/Homebrew/download_strategy.rb | 81 |
1 files changed, 43 insertions, 38 deletions
diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb index fe10cda78..dd0cbe0a7 100644 --- a/Library/Homebrew/download_strategy.rb +++ b/Library/Homebrew/download_strategy.rb @@ -37,6 +37,49 @@ class AbstractDownloadStrategy def stage; end def cached_location; end def clear_cache; end + + private + + def xzpath + "#{HOMEBREW_PREFIX}/opt/xz/bin/xz" + end + + def lzippath + "#{HOMEBREW_PREFIX}/opt/lzip/bin/lzip" + end + + def cvspath + @cvspath ||= %W[ + /usr/bin/cvs + #{HOMEBREW_PREFIX}/bin/cvs + #{HOMEBREW_PREFIX}/opt/cvs/bin/cvs + #{which("cvs")} + ].find { |p| File.executable? p } + end + + def hgpath + @hgpath ||= %W[ + #{which("hg")} + #{HOMEBREW_PREFIX}/bin/hg + #{HOMEBREW_PREFIX}/opt/mercurial/bin/hg + ].find { |p| File.executable? p } + end + + def bzrpath + @bzrpath ||= %W[ + #{which("bzr")} + #{HOMEBREW_PREFIX}/bin/bzr + #{HOMEBREW_PREFIX}/opt/bazaar/bin/bzr + ].find { |p| File.executable? p } + end + + def fossilpath + @fossilpath ||= %W[ + #{which("fossil")} + #{HOMEBREW_PREFIX}/bin/fossil + #{HOMEBREW_PREFIX}/opt/fossil/bin/fossil + ].find { |p| File.executable? p } + end end class VCSDownloadStrategy < AbstractDownloadStrategy @@ -217,14 +260,6 @@ class CurlDownloadStrategy < AbstractDownloadStrategy super end - def xzpath - "#{HOMEBREW_PREFIX}/opt/xz/bin/xz" - end - - def lzippath - "#{HOMEBREW_PREFIX}/opt/lzip/bin/lzip" - end - def chdir entries = Dir['*'] case entries.length @@ -637,15 +672,6 @@ class CVSDownloadStrategy < VCSDownloadStrategy url=parts.join(':') [ mod, url ] end - - def cvspath - @path ||= %W[ - /usr/bin/cvs - #{HOMEBREW_PREFIX}/bin/cvs - #{HOMEBREW_PREFIX}/opt/cvs/bin/cvs - #{which("cvs")} - ].find { |p| File.executable? p } - end end class MercurialDownloadStrategy < VCSDownloadStrategy @@ -680,14 +706,6 @@ class MercurialDownloadStrategy < VCSDownloadStrategy def update cached_location.cd { quiet_safe_system hgpath, "pull", "--update" } end - - def hgpath - @path ||= %W[ - #{which("hg")} - #{HOMEBREW_PREFIX}/bin/hg - #{HOMEBREW_PREFIX}/opt/mercurial/bin/hg - ].find { |p| File.executable? p } - end end class BazaarDownloadStrategy < VCSDownloadStrategy @@ -717,13 +735,6 @@ class BazaarDownloadStrategy < VCSDownloadStrategy def update cached_location.cd { quiet_safe_system bzrpath, "update" } end - - def bzrpath - @path ||= %W[ - #{which("bzr")} - #{HOMEBREW_PREFIX}/bin/bzr - ].find { |p| File.executable? p } - end end class FossilDownloadStrategy < VCSDownloadStrategy @@ -749,12 +760,6 @@ class FossilDownloadStrategy < VCSDownloadStrategy safe_system fossilpath, "pull", "-R", cached_location end - def fossilpath - @path ||= %W[ - #{which("fossil")} - #{HOMEBREW_PREFIX}/bin/fossil - ].find { |p| File.executable? p } - end end class DownloadStrategyDetector |
