CI::Reporter::OutputCapture

Emulates/delegates IO to $stdout or $stderr in order to capture output to report in the XML file.

Public Class Methods

wrap(io, &assign) click to toggle source
# 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

Public Instance Methods

capture(io, &assign) click to toggle source

Start capturing IO, using the given block to assign self to the proper IO global.

# 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() click to toggle source

Finalize the capture and reset to the original IO object.

# File lib/ci/reporter/test_suite.rb, line 37
def finish
  @assign_block.call @delegate_io
  @captured_io.string
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.