aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorJack Nagel2014-12-10 00:53:57 -0500
committerJack Nagel2014-12-10 00:53:57 -0500
commit0f428cd12ac0a08e7e08bc07a68893a7ed66de0c (patch)
tree60892e1d40c5243d9af10b7badc0f18297637f75 /Library
parentdaaf370ad5cc335ef106424ffc4fc569429e139d (diff)
downloadhomebrew-0f428cd12ac0a08e7e08bc07a68893a7ed66de0c.tar.bz2
Reorganize methods in CurlDownloadStrategy
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/download_strategy.rb62
1 files changed, 31 insertions, 31 deletions
diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb
index ff75d8262..c4fe88173 100644
--- a/Library/Homebrew/download_strategy.rb
+++ b/Library/Homebrew/download_strategy.rb
@@ -159,23 +159,6 @@ class CurlDownloadStrategy < AbstractDownloadStrategy
@temporary_path = Pathname.new("#{tarball_path}.incomplete")
end
- def cached_location
- tarball_path
- end
-
- def clear_cache
- [cached_location, temporary_path].each { |f| f.unlink if f.exist? }
- end
-
- def downloaded_size
- temporary_path.size? or 0
- end
-
- # Private method, can be overridden if needed.
- def _fetch
- curl @url, '-C', downloaded_size, '-o', temporary_path
- end
-
def fetch
ohai "Downloading #{@url}"
unless tarball_path.exist?
@@ -210,20 +193,6 @@ class CurlDownloadStrategy < AbstractDownloadStrategy
retry
end
- # gunzip and bunzip2 write the output file in the same directory as the input
- # file regardless of the current working directory, so we need to write it to
- # the correct location ourselves.
- def buffered_write(tool)
- target = File.basename(basename_without_params, tarball_path.extname)
-
- Utils.popen_read(tool, "-f", tarball_path.to_s, "-c") do |pipe|
- File.open(target, "wb") do |f|
- buf = ""
- f.write(buf) while pipe.read(1024, buf)
- end
- end
- end
-
def stage
case tarball_path.compression_type
when :zip
@@ -254,8 +223,25 @@ class CurlDownloadStrategy < AbstractDownloadStrategy
end
end
+ def cached_location
+ tarball_path
+ end
+
+ def clear_cache
+ [cached_location, temporary_path].each { |f| f.unlink if f.exist? }
+ end
+
private
+ # Private method, can be overridden if needed.
+ def _fetch
+ curl @url, "-C", downloaded_size, "-o", temporary_path
+ end
+
+ def downloaded_size
+ temporary_path.size? || 0
+ end
+
def curl(*args)
args << '--connect-timeout' << '5' unless mirrors.empty?
args << "--user" << meta.fetch(:user) if meta.key?(:user)
@@ -270,6 +256,20 @@ class CurlDownloadStrategy < AbstractDownloadStrategy
end
end
+ # gunzip and bunzip2 write the output file in the same directory as the input
+ # file regardless of the current working directory, so we need to write it to
+ # the correct location ourselves.
+ def buffered_write(tool)
+ target = File.basename(basename_without_params, tarball_path.extname)
+
+ Utils.popen_read(tool, "-f", tarball_path.to_s, "-c") do |pipe|
+ File.open(target, "wb") do |f|
+ buf = ""
+ f.write(buf) while pipe.read(1024, buf)
+ end
+ end
+ end
+
def basename_without_params
# Strip any ?thing=wad out of .c?thing=wad style extensions
File.basename(@url)[/[^?]+/]