It’s been awhile since I wrote here, having been busy with my usual tagging ideas. Since last time I wrote, I’ve released two public pieces of rails-related code! : a patch for nested sets as well as my first gem. All shameless plugs aside, I came here to share some old code I revived and a practical use I found for it. The code is here
My goal awhile back was to be able to quickly understand any ruby code given to me. To put myself on that path I did two things: learn to debug Ruby thoroughly with Kernel::set_trace_func and parse ruby files. I wanted to parse ruby files so I could get a quick overview of a file’s classes and their methods. I looked at ParseTree and then rdoc’s parser. Of the two, rdoc seemed to be a little higher level and so the core method looks like:
That little bit opens a file, scans it with rdoc and then saves the methods by class with the recursive function index_class(). If you look at the full version you’ll probably laugh at how small index_class() is.
Since writing rdoc_parse_file(), I’ve been taking apart and writing rails apps. So I recently combined the two. Overview.rb is a script you can drop into you rails script directory to provide a handy outline of the classes and methods by directory under app/. I use it for note taking when dealing with a new rails app.