blib/lib/XT/Files/Plugin/Dirs.pm untested

filter: Statementstmt 0.0% 0 / 40 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 6 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 60 CC 5 SCAR 28.7
CC
5
Cov
0%
run
30.0
BEGIN
2.0
BEGIN
2.0
CRAP 17.6
1 package XT::Files::Plugin::Dirs;
2  
3 use 5.006;
4 use strict;
5 use warnings;
6  
7 our $VERSION = '0.001';
8  
9 use parent 'XT::Files::Plugin';
10  
11 sub run {
12 my ( $self, $args ) = @_;
13  
14 my @dirs;
15  
16 ARG:
17 for my $arg ( @{$args} ) {
18 my ( $key, $value ) = @{$arg};
19  
20 if ( ( $key eq 'bin' ) || ( $key eq 'module' ) || ( $key eq 'test' ) ) {
21 push @dirs, $arg;
22 next ARG;
23 }
24  
25 $self->log_fatal("Invalid configuration option '$key = $value' for plugin 'Dirs'");
26 }
27  
28 my $xtf = $self->xtf;
29  
30 # We sort the dirs because e.g. bin/lib must be scanned before bin
31 # because bin_dir() would add every file found.
32 #
33 # By reverse sorting we guarantee that we always scan the most
34 # significant directory first.
35 DIR:
36 for my $dir ( reverse sort { $a->[1] cmp $b->[1] } @dirs ) {
37 my ( $type, $name ) = @{$dir};
38  
39 if ( $type eq 'bin' ) {
40 $xtf->bin_dir($name);
41 next DIR;
42 }
43  
44 if ( $type eq 'module' ) {
45 $xtf->module_dir($name);
46 next DIR;
47 }
48  
49 if ( $type eq 'test' ) {
50 $xtf->test_dir($name);
51 next DIR;
52 }
53 }
54  
55 return;
56 }
57  
58 1;
59  
60 __END__