Sha256: 08bef8a6abbe33aa81e1d07cfb74937d89fe2e9a0cd0c16122fc6ac2bf5671e8

Contents?: true

Size: 282 Bytes

Versions: 3

Compression:

Stored size: 282 Bytes

Contents

# coding: utf-8

module Retter::StreamSupport
  def capture(stream)
    begin
      stream = stream.to_s
      eval "$#{stream} = StringIO.new"
      yield
      result = eval("$#{stream}").string
    ensure
      eval("$#{stream} = #{stream.upcase}")
    end

    result
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
retter-0.1.3 spec/support/stream_capture.rb
retter-0.1.2 spec/support/stream_capture.rb
retter-0.1.1 spec/support/stream_capture.rb