File Coverage

blib/lib/Beam/Runner/Steps.pm
Criterion Covered Total %
statement 15 15 100.0
branch 2 2 100.0
condition n/a
subroutine 4 4 100.0
pod 0 1 0.0
total 21 22 95.4


line stmt bran cond sub pod time code
1             package Beam::Runner::Steps;
2             our $VERSION = '0.016';
3             # ABSTRACT: Run a series of steps
4              
5             #pod =head1 SYNOPSIS
6             #pod
7             #pod beam run
8             #pod
9             #pod =head1 DESCRIPTION
10             #pod
11             #pod This runnable module runs a series of other runnable modules in
12             #pod sequence. If any module returns a non-zero value, the steps stop.
13             #pod
14             #pod =head1 SEE ALSO
15             #pod
16             #pod L, L
17             #pod
18             #pod =cut
19              
20 1     1   64391 use Moo;
  1         10916  
  1         5  
21 1     1   1372 use warnings;
  1         2  
  1         36  
22             with 'Beam::Runnable';
23 1     1   562 use Types::Standard qw( ArrayRef ConsumerOf );
  1         72784  
  1         11  
24              
25             #pod =attr steps
26             #pod
27             #pod The steps to run. Must be an arrayref of L objects.
28             #pod
29             #pod =cut
30              
31             has steps => (
32             is => 'ro',
33             isa => ArrayRef[ConsumerOf['Beam::Runnable']],
34             required => 1,
35             );
36              
37             sub run {
38 2     2 0 24623 my ( $self, @args ) = @_;
39 2         6 for my $step ( @{ $self->steps } ) {
  2         9  
40 4         36 my $exit = $step->run( @args );
41 4 100       70 return $exit if $exit != 0;
42             }
43 1         15 return 0;
44             }
45              
46             1;
47              
48             __END__