File Coverage

blib/lib/Test/BrewBuild/Plugin/DefaultExec.pm
Criterion Covered Total %
statement 12 12 100.0
branch 1 2 50.0
condition n/a
subroutine 2 2 100.0
pod 0 1 0.0
total 15 17 88.2


line stmt bran cond sub pod time code
1             package Test::BrewBuild::Plugin::DefaultExec;
2              
3             # default exec command set plugin for Test::BrewBuild
4              
5             our $VERSION = '2.11';
6              
7             my $state = bless {}, __PACKAGE__;
8              
9             sub brewbuild_exec{
10 1     1 0 4003 shift; # throw away class
11 1         3 my $log = shift;
12 1         3 my $clog = $log->child( __PACKAGE__.'::brewbuild_exec' );
13 1         22 $clog->_6( 'performing plugin duties' );
14 1         75 return _cmd();
15             }
16             sub _cmd {
17 1     1   3 my $module = shift;
18              
19             #FIXME: we have to do the below nonsense, because DATA can't
20             # be opened twice if we get called more than once per run
21              
22 1 50       6 if (! defined $state->{raw}){
23 1         14 @{ $state->{raw} } = ;
  1         4  
24             }
25              
26 1         3 my @cmd = @{ $state->{raw} };
  1         3  
27              
28 1         11 return @cmd;
29             }
30             1;
31              
32             =pod
33              
34             =head1 NAME
35              
36             Test::BrewBuild::Plugin::DefaultExec - The default 'exec' command plugin.
37              
38             =head1 SYNOPSIS
39              
40             To use, if you've actually installed your plugin:
41              
42             brewbuild --plugin My::ExecPlugin
43              
44             If you have it in a local directory (ie. not installed) (note the path can be
45             relative):
46              
47             brewbuild --plugin /path/to/ExecPlugin.pm
48              
49             Send in arguments to your plugin. The C<--args, -a> flag sets an array. For
50             each argument, C is called once, passing in the next element of the
51             array.
52              
53             berrybrew -p My::Plugin --args 1 -a 2
54              
55             =head1 CREATION
56              
57             To create a temporary or test plugin, simply create a C<*.pm> file just like
58             this one with the same subroutine, and in the C<__DATA__> section, include the
59             code you need executed by C<*brew exec>.
60              
61             The first argument you will receive is the C log object of
62             the core L. You can ignore this, or create a child and log
63             throughout your plugin.
64              
65             =head1 AUTHOR
66              
67             Steve Bertrand, C<< >>
68              
69             =cut
70              
71             __DATA__