ObjectGraph: Ruby Class Hierarchy

What the…?

A simple script that generates a graph of the ruby class hierarchy.

The script relies on GraphViz for generation of the PNG and HTML map files.

Take a look at the basic Ruby class hierarchy here or with a different layout here. Both these examples were created with objectgraph.rb -neato -dot -skip-errno -font Tahoma.

A few useful examples are:


Because it’s neat. And because the online PickAxe seems to be missing some graphs. And because many nubys (myself included) don’t always know the Exception inheritance hierarchy. And because I was home sick and needed something to do (which is a nice excuse why the code may not be all that great :).

Please note that the project is not very active not because I’ve abandoned it, but rather because it’s mostly feature complete. It does more or less all I’ve intended it to do and there are no bugs or issues to resulve. This is reflected by the version number.




    Ruby Class Inheritance Graph, version 1.0.1.
    Generates a png and an HTML map or the ruby

    ruby [-r libs] objectgraph.rb <layout> <options>
    Use the -r lib to require extra libraries into the name-space (or edit the
    script file).
    'layout' is at least one of the following GraphViz layout engines:
             -neato   neato engine ('spring' model layout. recommended :)
             -dot     dot engine (hierarchical tree)
             -circo   circo engine (circular layout. generates large pics)
             -twopi   twopi engine (oval layout)
             -all     generate graphs with all layouts 
    Refer to http://www.research.att.com/sw/tools/graphviz/ for more details.

    'options' are:
             -skip-errno    Does not show the Errno classes
             -font <font>   Uses <font> in the nodes texts.
             -output <fmt>  Output format as supported by GraphViz (defaults to PNG).
             -out-name <name>         Ouput file name. Only useful is only one format is specified.
             -base-class <ClassName>  Display only classes that inherit from <ClassName>.
                                      Cannot be use for inheritance trees based in class Module.
             -name-space <namespace>  Display only classes in <namespace>

Next on the TODO list:

Support links to std-lib classes documentations. (http://www.ruby-doc.org/stdlib/libdoc/XXXLIB/rdoc/classes/XXXCLASS.html).

This site is generated via RedCloth. The original text is in CVS.