Embra/Plugin/GatherDir.pm

filter: Statementstmt 98.3% 59 / 60 Branchbran 75.0% 12 / 16 Conditioncond 91.6% 11 / 12 MC/DCmcdc 85.7% 6 / 7 Subroutinesub 94.4% 17 / 18 Podpod n/a totaltotal 92.9% 105 / 113 CC 13 SCAR 15.8
CC
13
Cov
93%
__ANON__
11.1
mvp_multivalue_args
2.0
gather_files
2.0
CRAP 4.9
« Embra/Role/Plugin.pm ↑ Summary Embra.pm »
1 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 package App::Embra::Plugin::GatherDir;
5 4 $App::Embra::Plugin::GatherDir::VERSION = '0.001'; # TRIAL
6 # ABSTRACT: gather all the files in a directory
7  
8 4 ▶use Path::Class::Dir;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 4 ▶use List::MoreUtils qw< any >;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 4 ▶use Method::Signatures;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 4 ▶use App::Embra::File;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 4 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 4 ▶method mvp_multivalue_args() { qw< exclude_match >; }
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine mvp_multivalue_args: called CC=2 SCAR=7.0
Branch: 1 branch
BranchTrueFalseTotal
if scalar @_ > 0 0 4 4
16  
17  
18  
19 has 'from' => (
20 is => 'ro',
21 required => 1,
22 0 ▶ default => sub { '.' },
Subroutine __ANON__: not called CC=1 SCAR=6.9
23 4 ▶ coerce => sub { Path::Class::Dir->new( $_[0] )->absolute },
Subroutine __ANON__: called CC=1 SCAR=0.0
24 4 );
25  
26  
27 has 'include_dotfiles' => (
28 is => 'ro',
29 3 ▶ default => sub { !1 },
Subroutine __ANON__: called CC=1 SCAR=0.0
30 4 );
31  
32  
33 has 'exclude_match' => (
34 is => 'ro',
35 4 ▶ coerce => sub { [ map { qr{$_} } @{ $_[0] } ] },
Subroutine __ANON__: called CC=1 SCAR=0.0
36 3 ▶ default => sub { [] },
Subroutine __ANON__: called CC=1 SCAR=0.0
37 4 );
38  
39 4 ▶method gather_files {
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine gather_files: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
if scalar @_ > 0 0 4 4
40 4 $self->debug( 'looking in '.$self->from );
41 35 ▶ $self->from->recurse( callback => func( $file ) {
Subroutine __ANON__: called CC=11 SCAR=24.0
Branch: 2 branches
BranchTrueFalseTotal
unless scalar @_ > 0 0 35 35
if scalar @_ > 1 0 35 35
42 35 ▶ return if $file eq $self->from;
Branch: 1 branch
BranchTrueFalseTotal
if $file eq $self->from 4 31 35
43 31 ▶ my $skip = $file->basename =~ m/ \A [.] /xms && not $self->include_dotfiles;
Condition100%3/3
$file->basename =~ / \A [.] /msx && !$self->include_dotfiles
!ll&&!rl&&r
2326
MC/DC100%2/2
$file->basename =~ / \A [.] /msx && !$self->include_dotfiles
$file->basename =~ / \A [.] /msx !$self->include_dotfiles
Truth table100%3/3
A && not(B)
A= $file->basename =~ / \A [.] /msxB= !$self->include_dotfiles
ABresult
0X0
100
111
44 31 ▶ my $exclude = any { $file =~ $_ } @{ $self->exclude_match };
Subroutine __ANON__: called CC=1 SCAR=0.0
45 31 ▶ return $file->PRUNE if $file->is_dir and $skip || $exclude;
Branch: 1 branch
BranchTrueFalseTotal
if $file->is_dir and $skip || $exclude 5 26 31
Condition100%6/6
$file->is_dir and $skip || $exclude
!ll&&!rl&&r
15115
$skip or $exclude
l!l&&r!l&&!r
3211
MC/DC100%3/3
$file->is_dir and $skip || $exclude
$file->is_dir $skip $exclude
Truth table100%4/4
A and B or C
A= $file->is_dirB= $skipC= $exclude
ABCresult
0XX0
1000
11X1
1011
46 26 ▶ return if $file->is_dir;
Branch: 1 branch
BranchTrueFalseTotal
if $file->is_dir 11 15 26
47 15 $self->debug( "considering $file" );
48 15 ▶ return if $skip or $exclude;
Branch: 1 branch
BranchTrueFalseTotal
if $skip or $exclude 3 12 15
Condition66%2/3
$skip or $exclude
l!l&&r!l&&!r
3012
MC/DC50%1/2
$skip or $exclude
$skip $exclude
Truth table66%2/3
A or B
A= $skipB= $exclude
ABresult
1X1
011
000
49 12 my $embra_file = App::Embra::File->new( name => $file->stringify );
50 12 $embra_file->name( $file->relative( $self->from )->stringify );
51 12 $self->add_file( $embra_file );
52 4 } );
53 }
54  
55 4 with 'App::Embra::Role::FileGatherer';
56  
57 4 1;
58  
59 __END__
« Embra/Role/Plugin.pm ↑ Summary Embra.pm »