blib/lib/App/CmdDirs.pm

filter: Statementstmt 93.6% 44 / 47 Branchbran 60.0% 6 / 10 Conditioncond 50.0% 3 / 6 MC/DCmcdc 25.0% 1 / 4 Subroutinesub 100% 9 / 9 Podpod 0.0% 0 / 3 totaltotal 79.7% 63 / 79 CC 8 SCAR 13.1
CC
8
Cov
84%
getTraverser
7.2
run
3.0
BEGIN
1.0
CRAP 3.7
↑ Summary blib/lib/App/CmdDirs/Traverser/Base.pm »
1 package App::CmdDirs;
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 Cwd;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 2 ▶use App::CmdDirs::Traverser::Base;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 2 our $VERSION;
10 2 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 $VERSION = '1.02';
12 }
13  
14 2 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
15 2 my ($class, $argv, $options) = @_;
16  
17 2 my $self = {};
18 2 $self->{'argv'} = $argv;
19 2 $self->{'options'} = $options;
20 2 bless $self, $class;
21  
22 2 return $self;
23 }
24  
25 # Find directories to act upon, choose a traverser, and go
26 2 ▶sub run {
Subroutine run: called CC=3 SCAR=11.1
Pod undocumented
27 2 my ($self) = @_;
28  
29 # Pull working dir & post-option arguments
30 2 my $topDir = cwd();
31 2 my @argv = @{$self->{'argv'}};
32 2 my $command = $argv[0];
33 2 my @dirs;
34  
35 # Get any dirs passed on the command line
36 2 ▶ foreach (my $x = 1; $x < scalar(@argv); $x++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($x < scalar @argv) 0 2 2
37 0 push @dirs, $argv[$x];
38 }
39  
40 # No directories passed, glob all
41 2 ▶ if ($#dirs == -1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($#dirs == -1) 2 0 2
42 2 ▶ @dirs = glob '*';
Subroutine BEGIN: called CC=1 SCAR=0.0
43 }
44  
45 2 my $traverser = $self->getTraverser($command, $topDir, \@dirs);
46  
47 2 $traverser->traverse($self->{'options'}->{'quiet'});
48  
49 2 return 1;
50 }
51  
52 # Create a traverser for specific command types
53 2 ▶sub getTraverser {
Subroutine getTraverser: called CC=6 SCAR=19.7
Pod undocumented
54 2 my ($self, $command, $topDir, $dirs) = @_;
55 2 my $traverser;
56  
57 2 ▶ if ($self->{'options'}{'all'}) {
Branch: 3 branches
BranchTrueFalseTotal
if ($self->{'options'}{'all'}) { } 0 2 2
elsif ($self->{'options'}{'git'} or $command =~ /git/) { } 1 1 2
elsif ($self->{'options'}{'svn'} or $command =~ /svn/) { } 1 0 1
58 0 $traverser = App::CmdDirs::Traverser::Base->new($command, $topDir, $dirs);
59 ▶ } elsif ($self->{'options'}->{'git'} || $command =~ /git/) {
Condition66%2/3
$self->{"options"}{"git"} or $command =~ /git/
l!l&&r!l&&!r
011
MC/DC50%1/2
$self->{"options"}{"git"} or $command =~ /git/
$self->{"options"}{"git"} $command =~ /git/
Truth table66%2/3
A or B
A= $self->{"options"}{"git"}B= $command =~ /git/
ABresult
1X1
011
000
60 1 require App::CmdDirs::Traverser::Git;
61 1 $traverser = App::CmdDirs::Traverser::Git->new($command, $topDir, $dirs);
62 ▶ } elsif ($self->{'options'}->{'svn'} || $command =~ /svn/) {
Condition33%1/3
$self->{"options"}{"svn"} or $command =~ /svn/
l!l&&r!l&&!r
010
MC/DC0%0/2
$self->{"options"}{"svn"} or $command =~ /svn/
$self->{"options"}{"svn"} $command =~ /svn/
Truth table33%1/3
A or B
A= $self->{"options"}{"svn"}B= $command =~ /svn/
ABresult
1X1
011
000
63 1 require App::CmdDirs::Traverser::Subversion;
64 1 $traverser = App::CmdDirs::Traverser::Subversion->new($command, $topDir, $dirs);
65 } else {
66 0 $traverser = App::CmdDirs::Traverser::Base->new($command, $topDir, $dirs);
67 }
68  
69 2 return $traverser;
70 }
71  
72 2 1;
↑ Summary blib/lib/App/CmdDirs/Traverser/Base.pm »