Emulates/delegates IO to $stdout or $stderr in order to capture output to report in the XML file.
# 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
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
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