File Coverage

lib/XT/Files/Plugin/Files.pm
Criterion Covered Total %
statement 39 39 100.0
branch 11 12 91.6
condition 15 15 100.0
subroutine 5 5 100.0
pod 1 1 100.0
total 71 72 98.6


line stmt bran cond sub pod time code
1             package XT::Files::Plugin::Files;
2              
3 2     2   1294 use 5.006;
  2         7  
4 2     2   9 use strict;
  2         33  
  2         46  
5 2     2   10 use warnings;
  2         5  
  2         116  
6              
7             our $VERSION = '0.002';
8              
9 2     2   11 use parent 'XT::Files::Plugin';
  2         3  
  2         15  
10              
11             sub run {
12 4     4 1 1054 my ( $self, $args ) = @_;
13              
14 4         7 my @files;
15              
16             ARG:
17 4         12 for my $arg ( @{$args} ) {
  4         14  
18 11         17 my ( $key, $value ) = @{$arg};
  11         18  
19              
20 11 100 100     77 if ( ( $key eq 'bin' ) || ( $key eq 'module' ) || ( $key eq 'pod' ) || ( $key eq 'test' ) ) {
      100        
      100        
21 10         17 push @files, $arg;
22 10         17 next ARG;
23             }
24              
25 1         21 $self->log_fatal("Invalid configuration option '$key = $value' for plugin 'Files'");
26             }
27              
28 3         96 my $xtf = $self->xtf;
29              
30             FILE:
31 3         30 for my $file (@files) {
32 10         15 my ( $type, $name ) = @{$file};
  10         22  
33              
34 10 100 100     194 next FILE if -l $name || -d _ || !-e _;
      100        
35              
36 7 100       23 if ( $type eq 'bin' ) {
37 2         14 $xtf->bin_file($name);
38 2         5 next FILE;
39             }
40              
41 5 100       13 if ( $type eq 'module' ) {
42 2         9 $xtf->module_file($name);
43 2         6 next FILE;
44             }
45              
46 3 100       7 if ( $type eq 'pod' ) {
47 1         5 $xtf->pod_file($name);
48 1         2 next FILE;
49             }
50              
51 2 50       8 if ( $type eq 'test' ) {
52 2         14 $xtf->test_file($name);
53 2         5 next FILE;
54             }
55             }
56              
57 3         22 return;
58             }
59              
60             1;
61              
62             __END__