formula: move mktemp.

This should be an instance rather than a class method.
This commit is contained in:
Mike McQuaid 2018-07-14 15:41:16 +01:00
parent 3742cf892c
commit abf3043125
3 changed files with 13 additions and 13 deletions

View File

@ -1689,7 +1689,7 @@ class Formula
ENV.clear_sensitive_environment!
Formula.mktemp("#{name}-test") do |staging|
mktemp("#{name}-test") do |staging|
staging.retain! if ARGV.keep_tmp?
@testpath = staging.tmpdir
test_env[:HOME] = @testpath
@ -1897,6 +1897,16 @@ class Formula
eligible_for_cleanup
end
# Create a temporary directory then yield. When the block returns,
# recursively delete the temporary directory. Passing opts[:retain]
# or calling `do |staging| ... staging.retain!` in the block will skip
# the deletion and retain the temporary directory's contents.
def mktemp(prefix = name, opts = {})
Mktemp.new(prefix, opts).run do |staging|
yield staging
end
end
private
# Returns the prefix for a given formula version number.
@ -2465,16 +2475,6 @@ class Formula
@pour_bottle_check.instance_eval(&block)
end
# Create a temporary directory then yield. When the block returns,
# recursively delete the temporary directory. Passing opts[:retain]
# or calling `do |staging| ... staging.retain!` in the block will skip
# the deletion and retain the temporary directory's contents.
def mktemp(prefix = name, opts = {})
Mktemp.new(prefix, opts).run do |staging|
yield staging
end
end
# @private
def link_overwrite(*paths)
paths.flatten!

View File

@ -1,4 +1,4 @@
# Performs `Formula.mktemp`'s functionality, and tracks the results.
# Performs `Formula#mktemp`'s functionality, and tracks the results.
# Each instance is only intended to be used once.
class Mktemp
include FileUtils

View File

@ -82,7 +82,7 @@ class Resource
# 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.
# dir using Resource#mktemp so that works with all subtypes.
def stage(target = nil, &block)
unless target || block
raise ArgumentError, "target directory or block is required"