seancribbs/webmachine-ruby — pull request #53 by seancribbs (2012-06-05 08:57:40+00:00)
Title: Add the Visual Debugger

*This is currently incomplete, but I'm making a pull-request so everyone else can see the state of the work.* This adds the visual debugger, largely copied from the Erlang version. The visual debugger logs decisions and callbacks in the FSM and then presents, via an additional resource, a web interface that presents the diagram and draws the path the decisions took through the diagram. Each branch is annotated with which resource callbacks were invoked and their return values, as well as any exceptions that occurred.

* To enable tracing, a resource simply overrides the `trace?` callback, returning true.
* The developer can set a location to store the traces on disk with something like the below, otherwise they are stored in memory by default.

```ruby
Webmachine::Trace.trace_store = :pstore, "/tmp/webmachine.trace"
```

* Once enabled for the resource, the tracer will inject some functionality into the decision FSM that proxies calls to the resource so that they are logged into the trace, and then save the trace to the store after the `finish_request` callback.

**TODOS:**

* The transformation of the trace into the JS format is unimplemented.
* Modifications of the JS code will need to be done to excise some Erlang-isms.