Module: CI::Reporter::OutputCapture
- Included in:
- Delegate
- Defined in:
- lib/ci/reporter/test_suite.rb
Overview
Emulates/delegates IO to $stdout or $stderr in order to capture output to report in the XML file.
Defined Under Namespace
Classes: Delegate
Class Method Summary collapse
Instance Method Summary collapse
-
#capture(io, &assign) ⇒ Object
Start capturing IO, using the given block to assign self to the proper IO global.
-
#finish ⇒ Object
Finalize the capture and reset to the original IO object.
Class Method Details
.wrap(io, &assign) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/ci/reporter/test_suite.rb', line 20 def self.wrap(io, &assign) if defined?(RUBY_ENGINE) # JRuby, Ruby 1.9, etc. Delegate.new(io, &assign) else # Ruby 1.8 requires streams to be subclass of IO IO.new(io.fileno, "w").tap {|x| x.extend self; x.capture(io, &assign) } end end |
Instance Method Details
#capture(io, &assign) ⇒ Object
Start capturing IO, using the given block to assign self to the proper IO global.
29 30 31 32 33 34 |
# File 'lib/ci/reporter/test_suite.rb', line 29 def capture(io, &assign) @delegate_io = io @captured_io = StringIO.new @assign_block = assign @assign_block.call @captured_io end |
#finish ⇒ Object
Finalize the capture and reset to the original IO object.
37 38 39 40 |
# File 'lib/ci/reporter/test_suite.rb', line 37 def finish @assign_block.call @delegate_io @captured_io.string end |