aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/resource.rb
diff options
context:
space:
mode:
authorAndrew Janke2016-04-10 22:53:56 -0400
committerAndrew Janke2016-04-18 12:23:08 -0400
commitacc9a7ca8554bc2413dee2d6d0f407b3a59c628c (patch)
tree4fb68e17149a73d9d123d9538e2d5fdccdd0ffd9 /Library/Homebrew/resource.rb
parent0e8140b012181413438002b65290c84284721694 (diff)
downloadbrew-acc9a7ca8554bc2413dee2d6d0f407b3a59c628c.tar.bz2
brew test, install, update-test: add --keep-tmp option
Also enables sandbox for --interactive and --debug use of install and test, using automatic retention. Closes #66. Signed-off-by: Andrew Janke <andrew@apjanke.net>
Diffstat (limited to 'Library/Homebrew/resource.rb')
-rw-r--r--Library/Homebrew/resource.rb15
1 files changed, 10 insertions, 5 deletions
diff --git a/Library/Homebrew/resource.rb b/Library/Homebrew/resource.rb
index a15788fb3..5077ac149 100644
--- a/Library/Homebrew/resource.rb
+++ b/Library/Homebrew/resource.rb
@@ -72,6 +72,10 @@ class Resource
downloader.clear_cache
end
+ # Verifies download and unpacks it
+ # The block may call `|resource,staging| staging.retain!` to retain the staging
+ # directory. Subclasses that override stage should implement the tmp
+ # dir using FileUtils.mktemp so that works with all subtypes.
def stage(target = nil, &block)
unless target || block
raise ArgumentError, "target directory or block is required"
@@ -81,15 +85,16 @@ class Resource
unpack(target, &block)
end
- # If a target is given, unpack there; else unpack to a temp folder
- # If block is given, yield to that block
- # A target or a block must be given, but not both
+ # If a target is given, unpack there; else unpack to a temp folder.
+ # If block is given, yield to that block with |self, staging|, where staging
+ # is a staging context that responds to retain!().
+ # A target or a block must be given, but not both.
def unpack(target = nil)
- mktemp(download_name) do
+ mktemp(download_name) do |staging|
downloader.stage
@source_modified_time = downloader.source_modified_time
if block_given?
- yield self
+ yield self, staging
elsif target
target = Pathname.new(target) unless target.is_a? Pathname
target.install Dir["*"]