diff options
author | Xavier Noria <fxn@hashref.com> | 2011-05-13 01:41:52 +0200 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2011-05-13 01:41:52 +0200 |
commit | bdbb15e5a5c647823aa6b9fd04020dab16360ae1 (patch) | |
tree | 1002c18700ef0e29104864a2f961934322b09658 /railties/guides/source/active_support_core_extensions.textile | |
parent | b0062eef347199639db4eece358e7e72792a3f28 (diff) | |
download | rails-bdbb15e5a5c647823aa6b9fd04020dab16360ae1.tar.gz rails-bdbb15e5a5c647823aa6b9fd04020dab16360ae1.tar.bz2 rails-bdbb15e5a5c647823aa6b9fd04020dab16360ae1.zip |
new reporting method Kernel#quietly
Diffstat (limited to 'railties/guides/source/active_support_core_extensions.textile')
-rw-r--r-- | railties/guides/source/active_support_core_extensions.textile | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/railties/guides/source/active_support_core_extensions.textile b/railties/guides/source/active_support_core_extensions.textile index f2170e120b..d82bdfee43 100644 --- a/railties/guides/source/active_support_core_extensions.textile +++ b/railties/guides/source/active_support_core_extensions.textile @@ -417,6 +417,14 @@ silence_stream(STDOUT) do end </ruby> +The +quietly+ method addresses the common use case where you want to silence STDOUT and STDERR, even in subprocesses: + +<ruby> +quietly { system 'bundle install' } +</ruby> + +For example, the railties test suite uses that one in a few places to prevent command messages from being echoed intermixed with the progress status. + Silencing exceptions is also possible with +suppress+. This method receives an arbitrary number of exception classes. If an exception is raised during the execution of the block and is +kind_of?+ any of the arguments, +suppress+ captures it and returns silently. Otherwise the exception is reraised: <ruby> |