What have you found for these years?

2011-06-16

a new feature mainly for anchor in ripl-rc

I just made Ripl.enable_anchor take a block, which would be
working like, say, File.open{ ... } would close the file for you,
Ripl.enable_anchor{ ... } would disable the anchor for you.

Consider we're running a large application. You want to debug
something would be called many times, but you only want to look
inside it (i.e. put a ripl-rc anchor here :)) under some conditions.

If you simply put Ripl.anchor(binding) in the place where you
want to inspect, it would open up the inspecting session each
time when this method got called.

This is definitely not desired. So we might want to disable the anchor
at the beginning, and only enable it when the program met your
conditions.

We'll do this before:
(remember to insert Ripl.anchor into where you want to inspect!)

require 'ripl-rc'
Ripl.disable_anchor
# ...
# ...
# the conditions meet!
Ripl.enable_anchor
# calling the thing you want to inspect!
Ripl.disable_anchor
# ...anything below this would simply ignore Ripl.anchor calls.
# ...

Yeah, it works fine, I used this a lot, but it's a lot of typing....
Now we can do this instead:

require 'ripl/rc/debug'
# ...
# ...
# the conditions meet!
Ripl.enable_anchor{
  # calling the thing you want to inspect!
}
# ...anything below this would simply ignore Ripl.anchor calls.
# ...

Woot! It's a lot easier now. :)

On the other hand, we also have Ripl.disable_anchor{ ... }
as a dual. Also, this extension is for every ripl-rc plugins.
Thus you would have something like Ripl.disable_multiline{ ... }
as well, and so do any other ripl-rc plugins. Well, I don't know
if anyone would need that, but, ripl-rc plugins might be buggy,
sorry about that, you can file a ticket on github for me, meanwhile,
you can use this trick to temporary disable any buggy plugins
as a work around, and waiting for me to fix the bug for you. :)

Have fun!

0 retries:

Post a Comment

Note: Only a member of this blog may post a comment.



All texts are licensed under CC Attribution 3.0