download_strategy: allow to suppress output
This commit is contained in:
parent
1693ddbdcb
commit
09d21ad258
@ -6,6 +6,7 @@ class AbstractDownloadStrategy
|
||||
include FileUtils
|
||||
|
||||
attr_reader :meta, :name, :version, :resource
|
||||
attr_reader :shutup
|
||||
|
||||
def initialize(name, resource)
|
||||
@name = name
|
||||
@ -19,6 +20,19 @@ class AbstractDownloadStrategy
|
||||
def fetch
|
||||
end
|
||||
|
||||
# Supress output
|
||||
def shutup!
|
||||
@shutup = true
|
||||
end
|
||||
|
||||
def puts(*args)
|
||||
super(*args) unless shutup
|
||||
end
|
||||
|
||||
def ohai(*args)
|
||||
super(*args) unless shutup
|
||||
end
|
||||
|
||||
# Unpack {#cached_location} into the current working directory, and possibly
|
||||
# chdir into the newly-unpacked directory.
|
||||
# Unlike {Resource#stage}, this does not take a block.
|
||||
@ -59,6 +73,14 @@ class AbstractDownloadStrategy
|
||||
args
|
||||
end
|
||||
|
||||
def safe_system(*args)
|
||||
if @shutup
|
||||
quiet_system(*args) || raise(ErrorDuringExecution.new(args.shift, *args))
|
||||
else
|
||||
super(*args)
|
||||
end
|
||||
end
|
||||
|
||||
def quiet_safe_system(*args)
|
||||
safe_system(*expand_safe_system_args(args))
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user