module Kernel
def silence_stream(stream)
puts 'But this will'
end
puts 'This will never be seen'
silence_stream(STDOUT) do
Silences any stream for the duration of the block.
Deprecated : this method is not thread safe
def silence_stream(stream) old_stream = stream.dup stream.reopen(RbConfig::CONFIG['host_os'] =~ /mswin|mingw/ ? 'NUL:' : '/dev/null') stream.sync = true yield ensure stream.reopen(old_stream) old_stream.close end