File Coverage

blib/lib/App/Prove/RunScripts.pm
Criterion Covered Total %
statement 29 29 100.0
branch 1 2 50.0
condition n/a
subroutine 9 9 100.0
pod n/a
total 39 40 97.5


line stmt bran cond sub pod time code
1             package App::Prove::RunScripts;
2              
3 4     4   104451 use 5.008008;
  4         16  
  4         152  
4 4     4   22 use strict;
  4         6  
  4         147  
5 4     4   22 use warnings;
  4         25  
  4         133  
6 4     4   3742 use parent 'App::Prove';
  4         1199  
  4         24  
7 4     4   317362 use Class::Method::Modifiers qw(around install_modifier);
  4         6099  
  4         290  
8 4     4   29 use Getopt::Long;
  4         9  
  4         31  
9 4     4   574 use Carp ();
  4         9  
  4         1842  
10              
11             our $VERSION = '0.05';
12              
13             around 'process_args' => sub {
14             my $orig = shift;
15             my ( $self, @args ) = @_;
16              
17             $self->{before} = [];
18             $self->{after} = [];
19              
20             local @ARGV = @args;
21             Getopt::Long::Configure(qw(no_ignore_case bundling pass_through));
22             GetOptions(
23             'before=s@' => $self->{before},
24             'after=s@' => $self->{after},
25             ) or Carp::croak('Unable to continue');
26              
27             $self->_install_scripts;
28             $orig->( $self, @ARGV );
29             };
30              
31             sub _install_scripts {
32 7     7   11 my $self = shift;
33 7         16 for my $type (qw(before after)) {
34             install_modifier 'App::Prove', $type, 'run', sub {
35 2     2   648821 for my $script ( @{ $self->{$type} } ) {
  2         15  
36 2         5 local $@;
37 2         1264 do $script;
38 2 50       66 die $@ if $@;
39             }
40 14         823 };
41             }
42             }
43              
44             1;
45             __END__