From bdbb15e5a5c647823aa6b9fd04020dab16360ae1 Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Fri, 13 May 2011 01:41:52 +0200 Subject: new reporting method Kernel#quietly --- .../lib/active_support/core_ext/kernel/reporting.rb | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'activesupport/lib/active_support/core_ext/kernel') diff --git a/activesupport/lib/active_support/core_ext/kernel/reporting.rb b/activesupport/lib/active_support/core_ext/kernel/reporting.rb index 37a827123a..c6920098a8 100644 --- a/activesupport/lib/active_support/core_ext/kernel/reporting.rb +++ b/activesupport/lib/active_support/core_ext/kernel/reporting.rb @@ -62,7 +62,7 @@ module Kernel # Captures the given stream and returns it: # - # stream = capture(:stdout){ puts "Cool" } + # stream = capture(:stdout) { puts "Cool" } # stream # => "Cool\n" # def capture(stream) @@ -78,4 +78,16 @@ module Kernel result end alias :silence :capture + + # Silences both STDOUT and STDERR, even for subprocesses. + # + # quietly { system 'bundle install' } + # + def quietly + silence_stream(STDOUT) do + silence_stream(STDERR) do + yield + end + end + end end -- cgit v1.2.3