Skip to content

Tool to save eval'ed code strings to a file, first, as eval time

Notifications You must be signed in to change notification settings

rdp/ruby_remembered_evals

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 

Repository files navigation

remembered_evals:

A library to make debugging eval'ed code possible.  

This library monkey patches Kernel.*eval to save eval'ed code to a cache file before evaluating it (files saved to ~/._remembered_evals/hash_of_that_code).

You can thus debug [ex: using ruby-debug] THROUGH eval'ed code, now, as well as see appropriate (useful) eval'ed code lines in exception backtraces, instead of just eval(2) as the line number in the backtrace.

It also offers an additional tool for developers:  Since it saves code by hash value, and doesn't write over cached files, you can actually edit eval'ed blocks and it will eval the edited version--i.e. it allows you to override certain strings passed to eval [it uses yours instead of the original]-- quite useful for debugging purposes if you use meta-programming heavily.

Note also that it breaks eval'ed code that assumes the default binding, i.e.
eval("a = 4") # this won't work right
eval("a = 4", binding) # works though

The small price we pay for debugging convenience.  To minimize the impact of this, require all other gems before this one.

Competition:
None known

Install:
$ gem sources -a http://gems.github.com # if necessary
$ gem install rogerdpack-remembered_evals # may need to precede with sudo

require 'remembered_evals' at the beginning of your script, then enjoy the eval'ed code bliss.

Feedback welcome rdp@github

About

Tool to save eval'ed code strings to a file, first, as eval time

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages