Project

io-capture

0.0
No commit activity in last 3 years
No release in over 3 years
easily capture writes to STDOUT, Files, or any IO
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies
 Project Readme

capture¶ ↑

A simple gem for easily capturing writes to STDOUT & STDERR

I needed to write this for testing calls to #puts in an app and it took me awhile to get the code working properly (especially without having to write to the filesystem to get the output properly).

I figured that I might need this again or someone else might find this handy so … here it is!

Install¶ ↑

$ gem sources -a http://gems.github.com
$ sudo gem install remi-capture

Usage¶ ↑

>> Capture { puts 'hello' }
=> 'hello'

>> Capture(:stdout){ puts 'hello stdout' }
=> 'hello stdout'

>> Capture(:stderr){ warn 'hello stderr' }
=> 'hello stderr'

That’s it! Like I said, super simple.

Notes¶ ↑

If I get bored, I’d like to update this to be able to capture writes to any IO object. That could be super useful!