Sha256: adf01416e62f3ab1341248d7fe8e5d1368ade57636fab6c0d1c678eaa0a3c35c

Contents?: true

Size: 442 Bytes

Versions: 11

Compression:

Stored size: 442 Bytes

Contents

# Provides a utility method withIO() used by several test-cases.  Runs
# the specified block with stdin and stdout replumbed to the provided
# file-handles; the old values of stdin and stdout are passed to the
# block, in case they should be needed.

def withIO(newin, newout)
  old_STDIN = $stdin
  old_STDOUT = $stdout
  $stdin = newin
  $stdout = newout
  yield old_STDIN, old_STDOUT
ensure
  $stdin = old_STDIN
  $stdout = old_STDOUT
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
scottkit-1.6.0 lib/scottkit/withio.rb
scottkit-1.5.0 lib/scottkit/withio.rb
scottkit-1.4.0 lib/scottkit/withio.rb
scottkit-1.3.0 lib/scottkit/withio.rb
scottkit-1.2.0 lib/scottkit/withio.rb
scottkit-1.1.0 lib/scottkit/withio.rb
scottkit-1.0.0 lib/scottkit/withio.rb
scottkit-0.4.0 lib/scottkit/withio.rb
scottkit-0.2.0 lib/scottkit/withio.rb
scottkit-0.1.0 lib/scottkit/withio.rb
scottkit-0.0.0 test/withio.rb