state_machine

https://github.com/pluginaweek/state_machine

Ruby

Adds support for creating state machines for attributes on any Ruby class

StateMachine::Machine#draw

Draws a directed graph of the machine for visualizing the various events,
states, and their transitions.

This requires both the Ruby graphviz gem and the graphviz library be
installed on the system.

Configuration options:
* <tt>:name</tt> - The name of the file to write to (without the file extension).
  Default is "#{owner_class.name}_#{name}"
* <tt>:path</tt> - The path to write the graph file to.  Default is the
  current directory (".").
* <tt>:format</tt> - The image format to generate the graph in.
  Default is "png'.
* <tt>:font</tt> - The name of the font to draw state names in.
  Default is "Arial".
* <tt>:orientation</tt> - The direction of the graph ("portrait" or
  "landscape").  Default is "portrait".
* <tt>:human_names</tt> - Whether to use human state / event names for
  node labels on the graph instead of the internal name.  Default is false.

Source | Google | Stack overflow

Edit

git clone [email protected]:pluginaweek/state_machine.git

cd state_machine

open lib/state_machine/machine.rb

Contribute

# Make a new branch

git checkout -b -your-name--update-docs-StateMachine--Machine-draw-for-pr


# Commit to git

git add lib/state_machine/machine.rbgit commit -m "better docs for StateMachine::Machine#draw"


# Open pull request

gem install hub # on a mac you can `brew install hub`

hub fork

git push <your name> -your-name--update-docs-StateMachine--Machine-draw-for-pr

hub pull-request


# Celebrate!