diff options
Diffstat (limited to 'activesupport')
-rw-r--r-- | activesupport/lib/active_support/core_ext/kernel/reporting.rb | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/activesupport/lib/active_support/core_ext/kernel/reporting.rb b/activesupport/lib/active_support/core_ext/kernel/reporting.rb index 232443601c..a5cec50245 100644 --- a/activesupport/lib/active_support/core_ext/kernel/reporting.rb +++ b/activesupport/lib/active_support/core_ext/kernel/reporting.rb @@ -21,20 +21,25 @@ module Kernel $VERBOSE = old_verbose end - # Silences stderr for the duration of the block. + # For compatibility + def silence_stderr #:nodoc: + silence_stream(STDERR) { yield } + end + + # Silences any stream for the duration of the block. # - # silence_stderr do - # $stderr.puts 'This will never be seen' + # silence_stream(STDOUT) do + # puts 'This will never be seen' # end # - # $stderr.puts 'But this will' - def silence_stderr - old_stderr = STDERR.dup - STDERR.reopen(RUBY_PLATFORM =~ /mswin/ ? 'NUL:' : '/dev/null') - STDERR.sync = true + # puts 'But this will' + def silence_stream(stream) + old_stream = stream.dup + stream.reopen(RUBY_PLATFORM =~ /mswin/ ? 'NUL:' : '/dev/null') + stream.sync = true yield ensure - STDERR.reopen(old_stderr) + stream.reopen(old_stream) end def suppress(*exception_classes) |