tmm1/pygments.rb — pull request #33 by tnm (2012-07-08 22:26:43+00:00)
Title: Pipe

This adds a full implementation of the Pipe Based Method of talking to Pygments. It maintains full API compatibility with the existing pygments.rb library.

The basic data flow:

1. Rubyland opens a pipe to the `mentos.py` process if one does not already exist

2. mentos listens for a fixed 32-length string, representing an integer, which represents header length

3. Rubyland sends over a JSON header of the 'RPC'-ish method name, args, kwargs, and length of text to come (if any)

4. Rubyland sends over the text, if any

5. mentos returns the requested data

This pull also includes handling for dealing with dead child processes, catching `SIGCHLD` and then issuing the subsequent `wait`. We are also able to re-spawn child processes if they die. We also catch relevant errors involved in the syscalls.

This also adds a benchmark tool allowing for arbitrary iterations as well as increasing the length of the input data itself.

All existing tests are green, and I've also added several more unit tests. There is also some test data files (from Redis and Gunicorn) in `test/`