Look inside your ruby classes with DrX
Tweet Follow @hazula
Justin Love introduced me to a really interesting gem called DrX that can visually display the internals of any ruby class, interactively!
I had some trouble getting it to work, so I’ll include my steps here:
-
Ruby must be compiled with pthread. e.g.
rvm install 1.8.7-p72 -C --enable-pthread
-
You must have tk/tcl. This is most easily installed via ActiveState ActiveTcl. (I’m using ActiveTcl 8.5.11.1)
-
Install graphviz
brew install graphviz
-
Now, add
gem 'drx'
to your Gemfile, bundle, and load your console. tryActiveRecord::Base.see
for example. (I leave the gem commented out of my Gemfile except when I want to use it).
DrX console for ActiveRecord::Base
Full DrX diagram of ActiveRecord::Base, you’ll need to zoom in
Other introspection-type libraries I’m aware of (I’ll update this)
-
rubydeps: https://github.com/dcadenas/rubydeps
-
railroady: https://github.com/preston/railroady (fork of the older railroad https://github.com/tobias/RailRoad )