NAME

Verby::Action - The baseclass for an action in Verby.

SYNOPSIS

use base qw/Verby::Action/;
sub do { ... }
sub confirm { ... }

DESCRIPTION

A Verby::Action is basically a reusable bit of code.

Assuming it gets a Verby::Context object sent to both do and verify, it knows to check whether it needs to be done, and actually do the job.

Think of it as an abstraction of a make target.

METHODS

new
do $cxt

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.

This is a bad example though, you ought to subclass Verby::Action::RunCmd if you want to run a command.

verify $cxt

Perform a boolean check - whether or not the action needs to happen or not.

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;
}
confirm $cxt

Typically called at the end of an action's do:

sub do {
	my ($self, $c) = @_;
	...
	$self->confirm($c);
}

It will call $c->logger->logdie unless verify returns a true value.

ASYNCHRONEOUS INTERFACE

An asynchroneous action typically implements two or three methods instead of do, analogeous to IPC::Run's nonblocking interface:

start $cxt

Initiate the action, returning as early as possible.

finish $cxt

Clean up the action.

pump $cxt

Perform any nonblocking operation needed to keep things moving.

If this retrurns a false value, the action is considered finished, and finish will be called by the Verby::Dispatcher.

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.

BUGS

None that we are aware of. Of course, if you find a bug, let us know, and we will be sure to fix it.

CODE COVERAGE

We use Devel::Cover to test the code coverage of the tests, please refer to COVERAGE section of the Verby module for more information.

SEE ALSO

AUTHOR

Yuval Kogman, <nothingmuch@woobling.org>

COPYRIGHT AND LICENSE

Copyright 2005 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.