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