What is RailRoad?
RailRoad is a class diagrams generator for Ruby on Rails applications. It's a Ruby script that loads the application classes and analyzes its properties (attributes, methods) and relationships (inheritance, model associations like has_many, etc.) The output is a graph description in the DOT language, suitable to be handled with tools like Graphviz.
RailRoad can produce:
- Model diagrams, showing both inheritance hierarchy and models associations. You can choose to show the model "content columns" and its types.
- Controller diagrams, showing inheritance hierarchy. You can include the controllers' methods, grouped by its visibility (public, protected, private.)
- State machine diagramas (for use with the "acts_as_state_machine" plugin.)
Download RailRoad
If you're using gem, you can install RailRoad by issuing:
gem install railroad
Usage
Run RailRoad on the Rails application's root directory. You can redirect its output to a .dot file or pipe it to the dot or neato utilities to produce a graphic. Model diagrams are intended to be processed using dot and controller diagrams are best processed using neato.
railroad [options] command
Common options
-b, --brief
Generate compact diagram (no attributes nor methods)-e, --exclude file1[,fileN]
Exclude given files-i, --inheritance
Include inheritance relations-l, --label
Add a label with diagram information (type, date, migration, version)-o, --output FILE
Write diagram to fileFILE
-r, --root PATH
SetPATH
as the application root-v, --verbose
Enable verbose output (produce messages to STDOUT)
Models diagram options
-a, --all
Include all models (not onlyActiveRecord::Base
derived)--hide-magic
Hide magic field names--hide-types
Hide attributes type-j, --join
Concentrate edges-m, --modules
Include modules-p, --plugins-models
Include plugins models-t, --transitive
Include transitive associations (through inheritance)
Controllers diagram options
--hide-public
Hide public methods--hide-protected
Hide protected methods--hide-private
Hide private methods
Other options
-h, --help
Show this message--version
Show version and copyright
Commands
(You must supply one of these)
-M, --models
Generate models diagram-C, --controllers
Generate controllers diagram-A, --aasm
Generate "acts as state machine" diagram
Examples
railroad -o models.dot -M
Produces a models diagram to the file 'models.dot'railroad -a -i -o full_models.dot -M
Models diagram with all classes showing inheritance relationsrailroad -M | dot -Tsvg > models.svg
Model diagram in SVG formatrailroad -C | neato -Tpng > controllers.png
Controller diagram in PNG formatrailroad -h
Shows usage help
No comments:
Post a Comment