formula: move mktemp.
This should be an instance rather than a class method.
This commit is contained in:
parent
3742cf892c
commit
abf3043125
@ -1689,7 +1689,7 @@ class Formula
|
|||||||
|
|
||||||
ENV.clear_sensitive_environment!
|
ENV.clear_sensitive_environment!
|
||||||
|
|
||||||
Formula.mktemp("#{name}-test") do |staging|
|
mktemp("#{name}-test") do |staging|
|
||||||
staging.retain! if ARGV.keep_tmp?
|
staging.retain! if ARGV.keep_tmp?
|
||||||
@testpath = staging.tmpdir
|
@testpath = staging.tmpdir
|
||||||
test_env[:HOME] = @testpath
|
test_env[:HOME] = @testpath
|
||||||
@ -1897,6 +1897,16 @@ class Formula
|
|||||||
eligible_for_cleanup
|
eligible_for_cleanup
|
||||||
end
|
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
|
private
|
||||||
|
|
||||||
# Returns the prefix for a given formula version number.
|
# Returns the prefix for a given formula version number.
|
||||||
@ -2465,16 +2475,6 @@ class Formula
|
|||||||
@pour_bottle_check.instance_eval(&block)
|
@pour_bottle_check.instance_eval(&block)
|
||||||
end
|
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
|
# @private
|
||||||
def link_overwrite(*paths)
|
def link_overwrite(*paths)
|
||||||
paths.flatten!
|
paths.flatten!
|
||||||
|
@ -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.
|
# Each instance is only intended to be used once.
|
||||||
class Mktemp
|
class Mktemp
|
||||||
include FileUtils
|
include FileUtils
|
||||||
|
@ -82,7 +82,7 @@ class Resource
|
|||||||
# Verifies download and unpacks it
|
# Verifies download and unpacks it
|
||||||
# The block may call `|resource,staging| staging.retain!` to retain the staging
|
# The block may call `|resource,staging| staging.retain!` to retain the staging
|
||||||
# directory. Subclasses that override stage should implement the tmp
|
# 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)
|
def stage(target = nil, &block)
|
||||||
unless target || block
|
unless target || block
|
||||||
raise ArgumentError, "target directory or block is required"
|
raise ArgumentError, "target directory or block is required"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user