Verby::Action - The base role for an action in Verby.
package MyAction; use Moose; with qw/Verby::Action/; sub do { ... } sub verify { ... }
A Verby::Action is an object encapsulating reusable code. Steps usually delegate to actions, for the actual grunt work.
Instantiate an action. Actions should be able to live indefinitely, and should not carry internal state with them. All the parameters for do or verify are provided within the context.
do
verify
The action instance data should only be used to configure action "flavours", controlling behavior that should not be parameter sensitive (configuration data).
The thing that the action really does. For example
package Verby::Action::Download; sub do { my ($self, $c) = @_; system("wget", "-O", $c->file, $c->url); }
Will use wget to download $c->url to $c->file.
$c->url
$c->file
This is a bad example though, you ought to subclass Verby::Action::Run if you want to run a command.
Perform a boolean check - whether or not the action is completed, for a given set of arguments.
For example, if do downloads $c->file from $c->url, then the verify method would look like:
sub verify { my ($self, $c) = @_; -f $c->file; }
or it could even make a HEAD request and make sure that $c->file is up to date.
Typically called at the end of an action's do:
sub do { my ($self, $c) = @_; ... $self->confirm($c); }
It will call $c->logger->log_and_die unless verify returns a true value.
$c->logger->log_and_die
If $c->error contains a string then it'll be printed as well.
$c->error
Since Verby is an abstraction layer over POE and every step get's it's own POE::Session, an actions do method can create child sessions, and the parent session will wait till they are completed, as per default POE behavior.
Note that this documentation assumes delegation of step methods to action methods.
Verby::Dispatcher actually has nothing to do with Verby::Action, it's just that typically a Verby::Step is just a thin wrapper for Verby::Action, so the methods roughly correspond.
See Verby::Step::Closure for a trivial way to generate steps given a Verby::Action subclass.
None that we are aware of. Of course, if you find a bug, let us know, and we will be sure to fix it.
We use Devel::Cover to test the code coverage of the tests, please refer to COVERAGE section of the Verby module for more information.
Yuval Kogman, <nothingmuch@woobling.org>
Copyright 2005-2008 by Infinity Interactive, Inc.
http://www.iinteractive.com
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
1 POD Error
The following errors were encountered while parsing the POD:
=back without =over
To install Verby, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Verby
CPAN shell
perl -MCPAN -e shell install Verby
For more information on module installation, please visit the detailed CPAN module installation guide.