gem, specs, README, and general consistency

This commit is contained in:
Loic Nageleisen 2013-10-22 18:23:24 +02:00
parent 31d6fa48c0
commit ef0fffd385
18 changed files with 431 additions and 124 deletions

31
README.md Normal file
View file

@ -0,0 +1,31 @@
# Tee
Allows Enumerables and IO objects to be teed via fibers.
# Examples
Teeing enumerables makes each proc receive its own enumerator. `#tee` returns
an array with each proc's return values.
```ruby
> require 'tee/core_ext'
> [1, 2, 3].tee -> (e) { e.reduce(&:+) },
-> (e) { e.map { |i| i**2 } }
=> [6, [1, 4, 9]]
```
Teeing IOs makes each proc receive its own IO. Those IOs can read the incoming
data in chunks.
```ruby
> require 'tee/core_ext'
> StringIO.new("foo").tee -> (io) { io.chunks.each { |c| puts c } }
foo
=> [nil]
```
Data can currently only be read in whole, uniformly sized chunks. Concurrent
execution is achieved via fibers (no threads needed).
One can skip requiring `core_ext` and get `#tee` on a case by case basis by
including or extending `Enumerable::Tee` and `IO::Tee` modules.