My Ruby gem debug_helper supports printf-style debugging by explicating a given object (sometimes recursively).
The documentation is over at GitHub project debug_helper.
So far I've implemented handling for many of the more commonly-used classes in the core, and for a few classes in the standard library
Now I'm looking at how to implement a custom handler -- that is, a FooHandler
class for your very own class Foo
.
Basically, the custom handler needs to specify which methods to call for the explication, along with any required arguments.
Right now I'm expressing that data as an array of arrays:
[
# Method that takes no argument.
[:foo],
# Method that takes arguments.
[:bar, arg0, arg1]
]
I'm considering allowing more convenience, which also would add complexity:
[
# Method that takes no argument is just a Symbol.
:foo,
# Method that takes arguments can be a an Array, as before.
[:bar, arg0, arg1],
# Method that takes arguments can be a 1-key Hash (method and arguments).
:baz => [arg0, arg1],
]
Opinions?