F
Florian Gross
Moin!
Breakpoint.rb is a small library that lets you set breakpoints by
calling a method. When executed, a breakpoint causes an interactive ruby
session to be spawned with the current context. This makes it especially
useful for debugging because Ruby has powerful built-in capabilities for
exploring object environments. (Kernel#caller, Object#inspect,
Object#respond_to?, Kernel#local_variables, Object#instance_variables
and so on.)
There's also support for overriding return values and for an assert()
method that automatically sets a breakpoint in case an unexpected
situation occurs.
I wrote this because I constantly found myself placing calls to p() in
my code when debugging -- I think that this library is a good
replacement for doing that which is the reason of me releasing it.
The code and documentation (including a sample session) is available
from the following URL:
http://cb.wardust.net/codepaste/view/paste/54
You'll need to have Binding.of_caller available. It can be obtained at
this location:
http://noegnud.sourceforge.net/flgr/binding_of_caller.rb
This should be easier to use than the debug.rb that comes with Ruby, but
debug.rb is more powerful overall. (It has stepping capabilities, for
example.)
I'm currently overloading IRB.start -- If anybody knows of a better way
to spawn an irb session with a custom binding: I'd love to hear about it.
Regards,
Florian Gross
Breakpoint.rb is a small library that lets you set breakpoints by
calling a method. When executed, a breakpoint causes an interactive ruby
session to be spawned with the current context. This makes it especially
useful for debugging because Ruby has powerful built-in capabilities for
exploring object environments. (Kernel#caller, Object#inspect,
Object#respond_to?, Kernel#local_variables, Object#instance_variables
and so on.)
There's also support for overriding return values and for an assert()
method that automatically sets a breakpoint in case an unexpected
situation occurs.
I wrote this because I constantly found myself placing calls to p() in
my code when debugging -- I think that this library is a good
replacement for doing that which is the reason of me releasing it.
The code and documentation (including a sample session) is available
from the following URL:
http://cb.wardust.net/codepaste/view/paste/54
You'll need to have Binding.of_caller available. It can be obtained at
this location:
http://noegnud.sourceforge.net/flgr/binding_of_caller.rb
This should be easier to use than the debug.rb that comes with Ruby, but
debug.rb is more powerful overall. (It has stepping capabilities, for
example.)
I'm currently overloading IRB.start -- If anybody knows of a better way
to spawn an irb session with a custom binding: I'd love to hear about it.
Regards,
Florian Gross