Hi All,
By now, some of you may have been playing with FSA::Rules. I've added
GraphViz support to generate state machine graphs on the fly. And
example can be found at
http://users.easystreet.com/ovid/images/pg_rules.png
To do this, here's how a state is defined:
installed => {
do => sub {
my $state = shift;
$state->result($self->_is_installed);
$state->message($self->app_name ." does not appear to be
installed" )
unless $state->result;
},
rules => [
fail => { "Postgres not\ninstalled" => sub {! shift->result },
version => { "Postgres\ninstalled" => sub { shift->result },
],
},
Each rule now takes an optional hash reference. If supplied, the key
is the "label" that appears on the line leading from state to state
(take a look at the first state, "installed", and see the names.)
If you prefer, you can also specify the rules the old way:
rules => [
fail => sub { ! shift->result },
version => sub { shift->result }
],
The only difference is that there is no label if a graph is generated.
In other words, for rules you can use a subref or a hashref. Does that
sound confusing? I think it is.
Can anyone suggest a cleaner syntax for the rule labels? Having state
machine graphs auto-generated is really cool, but I don't know if it's
worth the expense of making things too confusing to use.
Cheers,
Ovid
PS: The graphing features have not been uploaded to the CPAN because
of this issue. I can email the new version if anyone wants it.
=====
Silence is Evil
http://users.easystreet.com/ovid/philosophy/decency.html
Ovid http://www.perlmonks.org/index.pl?node_id=17000
Web Programming with Perl http://users.easystreet.com/ovid/cgi_course/