blib/lib/App/CmdDirs/Traverser/Base.pm

filter: Statementstmt 88.5% 31 / 35 Branchbran 66.6% 4 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 83.3% 5 / 6 Podpod 0.0% 0 / 3 totaltotal 80.0% 40 / 50 CC 5 SCAR 11.7
CC
5
Cov
85%
traverse
5.3
test
2.0
BEGIN
1.0
CRAP 3.2
« blib/lib/App/CmdDirs.pm ↑ Summary /usr/local/bin/pod2usage »
1 package App::CmdDirs::Traverser::Base;
2 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 2 ▶use Term::ANSIColor;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 2 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
8 2 my ($class, $command, $topDir, $dirs) = @_;
9  
10 2 my $self = {};
11 2 bless $self, $class;
12  
13 2 $self->{'command'} = $command;
14 2 $self->{'topDir'} = $topDir;
15 2 $self->{'dirs'} = $dirs;
16  
17 2 return $self;
18 }
19  
20 # Return false to skip this directory
21 0 ▶sub test {
Subroutine test: not called CC=1 SCAR=6.9
Pod undocumented
22 # Override this
23 0 return 1;
24 }
25  
26 # Run this class' test() on each directory. If the test passes, descend
27 # into that directory, run $command, and return to the top directory.
28 2 ▶sub traverse {
Subroutine traverse: called CC=5 SCAR=16.6
Pod undocumented
29 2 my ($self, $quiet) = @_;
30  
31 2 my $command = $self->{'command'};
32 2 my $topDir = $self->{'topDir'};
33  
34 2 my @dirs = @{$self->{'dirs'}};
35 2 foreach my $dir (@dirs) {
36 4 ▶ next if ! -d $dir;
Branch: 1 branch
BranchTrueFalseTotal
unless -d $dir 0 4 4
37 4 ▶ next if ! $self->test($dir);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->test($dir) 2 2 4
38  
39 # Tell the user what command is going to be run
40 2 ▶ unless ($quiet) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($quiet) 0 2 2
41 0 print color 'bold green';
42 0 print "Performing `$command` in <$dir>\n";
43 0 print color 'reset';
44 }
45  
46 # Descend into the directory & run the command
47 2 chdir $dir;
48 2 system("$command");
49 2 chdir $topDir;
50  
51 2 print "\n";
52 }
53  
54 2 return 1
55 }
56  
57 2 1;
« blib/lib/App/CmdDirs.pm ↑ Summary /usr/local/bin/pod2usage »