Verby::Action

Verby::Action is the base role for an action in Verby.
Download

Verby::Action Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Yuval Kogman
  • Publisher web site:
  • http://search.cpan.org/~nobull/

Verby::Action Tags


Verby::Action Description

Verby::Action is the base role for an action in Verby. Verby::Action is the base role for an action in Verby.SYNOPSIS 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.METHODSnew 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. The action instance data should only be used to configure action "flavours", controlling behavior that should not be parameter sensitive (configuration data).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::Run if you want to run a command.verify $cxt 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.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->log_and_die unless verify returns a true value. If $c->error contains a string then it'll be printed as well. Requirements: · Perl


Verby::Action Related Software