ProcessTable/Table.pm

filter: Statementstmt 97.1% 34 / 35 Branchbran 50.0% 3 / 6 Conditioncond 33.3% 3 / 9 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 100% 6 / 6 Podpod n/a totaltotal 74.1% 46 / 62 CC 1 SCAR 0.0
CC
1
Cov
80%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« ProcessTable.pm ↑ Summary ProcessTable/Process.pm »
1 package P9Y::ProcessTable::Table;
2  
3 3 our $AUTHORITY = 'cpan:BBYRD'; # AUTHORITY
4 3 our $VERSION = '1.06_01'; # VERSION
5  
6 #############################################################################
7 # Modules
8  
9 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 3 ▶use Module::Runtime ();
Subroutine BEGIN: called CC=1 SCAR=0.0
13 3 ▶use Path::Class ();
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 3 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 # Figure out which OS role we should consume
18 3 my %OS_TRANSLATE = (
19 cygwin => 'MSWin32',
20 );
21  
22 3 my $role_base = 'P9Y::ProcessTable::Role::Table::';
23 3 ▶my $role = 'OS::'.($OS_TRANSLATE{$^O} || $^O);
Condition33%1/3
$OS_TRANSLATE{$^O} || $^O
l!l&&r!l&&!r
030
MC/DC0%0/2
$OS_TRANSLATE{$^O} || $^O
$OS_TRANSLATE{$^O} $^O
Truth table33%1/3
A || B
A= $OS_TRANSLATE{$^O}B= $^O
ABresult
1X1
011
000
24  
25 3 $@ = '';
26 3 my $has_os_role = eval { Module::Runtime::require_module($role_base.$role) };
27 3 ▶die $@ if $@ and $@ !~ /^Can't locate /;
Branch: 1 branch
BranchTrueFalseTotal
if $@ and not $@ =~ /^Can't locate / 0 3 3
Condition33%1/3
$@ and not $@ =~ /^Can't locate /
!ll&&!rl&&r
030
MC/DC0%0/2
$@ and not $@ =~ /^Can't locate /
$@ not $@ =~ /^Can't locate /
Truth table33%1/3
A and not(B)
A= $@B= not $@ =~ /^Can't locate /
ABresult
0X0
100
111
28  
29 3 ▶unless ($has_os_role) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($has_os_role) 3 0 3
30 # let's hope they have /proc
31 3 ▶ if ( -d '/proc' and @{[ glob('/proc/*') ]} ) { $role = 'ProcFS'; }
Branch: 1 branch
BranchTrueFalseTotal
if (-d '/proc' and @{[glob('/proc/*')];}) { } 3 0 3
Condition33%1/3
-d "/proc" and @{[glob("/proc/*")];}
!ll&&!rl&&r
003
MC/DC0%0/2
-d "/proc" and @{[glob("/proc/*")];}
-d "/proc" @{[glob("/proc/*")];}
Truth table33%1/3
A and B
A= -d "/proc"B= @{[glob("/proc/*")];}
ABresult
0X0
100
111
32 # ...or that Proc::ProcessTable can handle it
33 0 else { $role = 'PPT'; }
34 }
35  
36 # This here first, so that it gets overloaded
37 3 extends 'P9Y::ProcessTable::Table::Base';
38  
39 3 with $role_base.$role;
40  
41 3 ▶use P9Y::ProcessTable::Process;
Subroutine BEGIN: called CC=1 SCAR=0.0
42  
43 3 42;
« ProcessTable.pm ↑ Summary ProcessTable/Process.pm »