Sha256: 8b3244fa7eb5e939a06d9e7e70ce603e5a0e7a570cf274427a0a7e9940784c24
Contents?: true
Size: 714 Bytes
Versions: 8
Compression:
Stored size: 714 Bytes
Contents
module StdStreamsHelper # Capture STDOUT in a variable # # Usage # # out_stream = StringIO.new # capture_stdout(out_stream) { do_something } def capture_stdout(stdout) original_stdout = $stdout $stdout = stdout yield $stdout = original_stdout end # Capture STDOUT and STDERR in variables # # Usage # # out_stream = StringIO.new # err_stream = StringIO.new # capture_std_streams(out_stream, err_stream) { do_something } def capture_std_streams(stdout, stderr) original_stdout = $stdout $stdout = stdout original_stderr = $stderr $stderr = stderr yield $stdout = original_stdout $stderr = original_stderr end end
Version data entries
8 entries across 8 versions & 1 rubygems