Class: CI::Reporter::OutputCapture
- Inherits:
-
Object
- Object
- CI::Reporter::OutputCapture
- Defined in:
- lib/ci/reporter/output_capture.rb
Overview
Captures $stdout or $stderr in order report it in the XML file.
Class Method Summary collapse
-
.wrap(io, &assign) ⇒ Object
Creates an OutputCapture and immediately starts capturing.
Instance Method Summary collapse
-
#finish ⇒ Object
Finalize the capture and reset to the original IO object.
-
#initialize(io, &assign) ⇒ OutputCapture
constructor
A new instance of OutputCapture.
-
#start ⇒ Object
Start capturing IO.
Constructor Details
#initialize(io, &assign) ⇒ OutputCapture
Returns a new instance of OutputCapture.
13 14 15 16 17 |
# File 'lib/ci/reporter/output_capture.rb', line 13 def initialize(io, &assign) @original_io = io @captured_io = StringIO.new @assign_block = assign end |
Class Method Details
.wrap(io, &assign) ⇒ Object
Creates an OutputCapture and immediately starts capturing.
9 10 11 |
# File 'lib/ci/reporter/output_capture.rb', line 9 def self.wrap(io, &assign) new(io, &assign).tap {|oc| oc.start} end |
Instance Method Details
#finish ⇒ Object
Finalize the capture and reset to the original IO object.
25 26 27 28 |
# File 'lib/ci/reporter/output_capture.rb', line 25 def finish @assign_block.call(@original_io) @captured_io.string end |
#start ⇒ Object
Start capturing IO.
20 21 22 |
# File 'lib/ci/reporter/output_capture.rb', line 20 def start @assign_block.call(@captured_io) end |