Parts/Perl.pm

filter: Statementstmt 100% 49 / 49 Branchbran 75.0% 2 / 4 (1 uncoverable) Conditioncond 100% 2 / 2 MC/DCmcdc 100% 1 / 1 Subroutinesub 100% 12 / 12 Podpod 100% 6 / 6 totaltotal 98.6% 72 / 74 (1 uncoverable) CC 3 SCAR 2.5
CC
3
Cov
98%
run_parts_command
2.0
run
2.0
BEGIN
1.0
CRAP 1.3
« Parts/Common.pm ↑ Summary Parts/Debian.pm »
1 package Run::Parts::Perl;
2  
3 # ABSTRACT: Pure Perl implementation of Debian's run-parts tool
4  
5 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 5 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 5 ▶use autodie;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 5 ▶use Taint::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 5 ▶use Run::Parts::Common;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 5 our $VERSION = '0.09'; # VERSION generated by DZP::OurPkgVersion
14  
15  
16 # On DOS and Windows, run-parts' regular expressions are not really
17 # applicable. Allow an arbitrary alphanumerical suffix there.
18 5 ▶my $win_suffix = dosish() ? qr/\.[a-z0-9]+/i : qr'';
Branch: 1 branch
BranchTrueFalseTotal
dosish() ? : 0 5 5
19 5 my $file_re = qr/^[-A-Za-z0-9_]+($win_suffix)?$/;
20  
21  
22 5 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
23 5 my $self = {};
24 5 bless($self, shift);
25 5 $self->{dir} = shift;
26  
27 5 return $self;
28 }
29  
30  
31 26 ▶sub run_parts_command {
Subroutine run_parts_command: called CC=2 SCAR=6.9
Pod documented
32 26 my $self = shift;
33 26 ▶ my $rp_cmd = shift // 'run';
Condition100%2/2
shift() // "run"
l!l
224
MC/DC100%1/1
shift() // "run"
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
34  
35 26 my @result = $self->$rp_cmd(@_);
36  
37 26 return lines(@result);
38 }
39  
40  
41 26 ▶sub list {
Subroutine list: called CC=1 SCAR=0.0
Pod documented
42 26 my $self = shift;
43 26 my $dir = $self->{dir};
44  
45 26 opendir(my $dh, $dir);
46 my @list = sort map {
47 # $dir can neither be '' nor undef, hence no check necessary
48 104 "$dir/$_";
49 } grep {
50 26 /$file_re/
51 } readdir($dh);
52 }
53  
54  
55 12 ▶sub test {
Subroutine test: called CC=1 SCAR=0.0
Pod documented
56 12 my $self = shift;
57 12 my $dir = $self->{dir};
58  
59 12 return grep { -x } $self->list($dir);
60 }
61  
62  
63 4 ▶sub run {
Subroutine run: called CC=2 SCAR=6.9
Pod documented
64 4 my $self = shift;
65 4 my $dir = $self->{dir};
66  
67 return map {
68 4 my $command = $_;
69 8 untaint($command);
70 # uncoverable branch true
71 8 ▶ $command =~ s(/)(\\)g if dosish();
Branch: 1 branch
BranchTrueFalseTotal
if dosish() 0 8 8
72 8 my $output = `$command`;
73 8 chomp($output);
74 8 $output;
75 } $self->test($dir);
76 }
77  
78  
79 13 ▶sub dosish {
Subroutine dosish: called CC=1 SCAR=0.0
Pod documented
80 13 return $^O =~ /^(dos|os2|MSWin32)$/;
81 }
82  
83  
84 5 qr/\.d$/; # End of Run::Parts::Perl
85  
86 __END__
« Parts/Common.pm ↑ Summary Parts/Debian.pm »