blib/lib/Complete/Program.pm

filter: Statementstmt 100% 30 / 30 Branchbran 83.3% 5 / 6 Conditioncond 60.0% 3 / 5 MC/DCmcdc 33.3% 1 / 3 Subroutinesub 100% 5 / 5 Podpod 100% 1 / 1 totaltotal 90.0% 45 / 50 CC 8 SCAR 17.6
CC
8
Cov
93%
complete_program
8.2
BEGIN
1.0
BEGIN
1.0
CRAP 5.8
↑ Summary
1 package Complete::Program;
2  
3 2 our $DATE = '2016-02-06'; # DATE
4 2 our $VERSION = '0.39'; # VERSION
5  
6 2 ▶use 5.010001;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 2 ▶use Complete::Common qw(:all);
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 2 require Exporter;
13 2 our @ISA = qw(Exporter);
14 2 our @EXPORT_OK = qw(
15 complete_program
16 );
17  
18 2 our %SPEC;
19  
20 2 $SPEC{':package'} = {
21 v => 1.1,
22 summary => 'Completion routines related to program names',
23 };
24  
25 $SPEC{complete_program} = {
26 2 v => 1.1,
27 summary => 'Complete program name found in PATH',
28 description => <<'_',
29  
30 Windows is supported, on Windows PATH will be split using /;/ instead of /:/.
31  
32 _
33 args => {
34 word => { schema=>[str=>{default=>''}], pos=>0, req=>1 },
35 },
36 result_naked => 1,
37 result => {
38 schema => 'array',
39 },
40 };
41 6 ▶sub complete_program {
Subroutine complete_program: called CC=8 SCAR=21.0
Pod documented
42 6 require Complete::Util;
43  
44 6 my %args = @_;
45 6 ▶ my $word = $args{word} // "";
Condition50%1/2
$args{"word"} // ""
l!l
60
MC/DC0%0/1
$args{"word"} // ""
$args{"word"}
Truth table50%1/2
A
A= $args{"word"}
Aresult
11
00
46  
47 6 ▶ my @dirs = split(($^O =~ /Win32/ ? qr/;/ : qr/:/), $ENV{PATH});
Branch: 1 branch
BranchTrueFalseTotal
$^O =~ /Win32/ ? : 3 3 6
48 6 my @all_progs;
49 6 for my $dir (@dirs) {
50 12 ▶ opendir my($dh), $dir or next;
Branch: 1 branch
BranchTrueFalseTotal
opendir my $dh, $dir or next 12 0 12
51 12 for (readdir($dh)) {
52 42 ▶ push @all_progs, $_ if !(-d "$dir/$_") && (-x _);
Branch: 1 branch
BranchTrueFalseTotal
if not -d "$dir/$_" and -x _ 18 24 42
Condition66%2/3
not -d "$dir/$_" and -x _
!ll&&!rl&&r
24018
MC/DC50%1/2
not -d "$dir/$_" and -x _
not -d "$dir/$_" -x _
Truth table66%2/3
not(A) and B
A= not -d "$dir/$_"B= -x _
ABresult
0X0
100
111
53 }
54 }
55  
56 Complete::Util::complete_array_elem(
57 6 word => $word, array => \@all_progs,
58 );
59 }
60  
61 2 1;
62 # ABSTRACT: Completion routines related to program names
63  
64 __END__
↑ Summary