agnoster/literapi — pull request #9 by agnoster (2012-10-10 12:45:07+00:00)
Title: Major Literapi refactor

In order to do some of the stuff that we need (capturing bindings from headers, output that shows progress and summary for the whole suite, creating a new user for each document's tests, and much more) I've realized we're sort of hitting the limits of the current design.

This refactor changes Literapi into something of a multi-tiered middleware runner (sort of like [connect](http://www.senchalabs.org/connect/)).

The `/plugins/` dir will now have all the basic operations, which can happen on a per-document *or* per-example level. Internally, it chains like this:

```js
var literapi = require('literapi')(options)
.use(literapi.readfile)
.use(literapi.markdown)
.use(literapi.http({ root: options.root }))
.use(literapi.jsonexp)
.use(literapi.reporters.default)

if (options.write) {
literapi.use(literapi.markdown_output)
literapi.use(literapi.writefile)
}

literapi.runWithFiles(files)
```

This makes it really easy to keep the logic for each piece of literapi separate. Adding custom middleware is laughably easy - with this new setup, adding something like creating new users for each test run is a piece of cake.

Anyway, it's not ready yet, but progress is looking good, I think!