Silki/Util.pm

filter: Statementstmt 60.9% 25 / 41 Branchbran 37.5% 6 / 16 Conditioncond 100% 3 / 3 MC/DCmcdc 100% 2 / 2 Subroutinesub 77.7% 7 / 9 Podpod 0.0% 0 / 3 totaltotal 58.1% 43 / 74 CC 11 SCAR 24.0
CC
11
Cov
57%
detach_and_run
30.0
_find_executable
12.0
string_is_empty
3.0
CRAP 11.0
« Silki/ConfigData.pm ↑ Summary Silki/Web/Form.pm »
1 package Silki::Util;
2 {
3 8 $Silki::Util::VERSION = '0.29';
4 }
5  
6 8 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 8 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 8 ▶use Exporter qw( import );
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 8 ▶use File::Which qw( which );
Subroutine BEGIN: called CC=1 SCAR=0.0
12 8 ▶use Path::Class qw( file );
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 8 our @EXPORT_OK = qw( string_is_empty english_list detach_and_run );
15  
16 30 ▶sub string_is_empty {
Subroutine string_is_empty: called CC=3 SCAR=11.0
Pod undocumented
17 30 ▶ return 1 if !defined $_[0] || !length $_[0];
Branch: 1 branch
BranchTrueFalseTotal
unless defined $_[0] and length $_[0] 22 8 30
Condition100%3/3
defined $_[0] and length $_[0]
!ll&&!rl&&r
2028
MC/DC100%2/2
defined $_[0] and length $_[0]
defined $_[0] length $_[0]
Truth table100%3/3
A and B
A= defined $_[0]B= length $_[0]
ABresult
0X0
100
111
18 8 return 0;
19 }
20  
21 3 ▶sub english_list {
Subroutine english_list: called CC=3 SCAR=11.0
Pod undocumented
22 3 ▶ return $_[0] if @_ <= 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ <= 1 1 2 3
23  
24 2 ▶ return join ' and ', @_ if @_ == 2;
Branch: 1 branch
BranchTrueFalseTotal
if @_ == 2 1 1 2
25  
26 1 my $last = pop @_;
27  
28 1 return ( join ', ', @_ ) . ', and ' . $last;
29 }
30  
31 0 ▶sub detach_and_run {
Subroutine detach_and_run: not called CC=5 SCAR=34.0
Pod undocumented
32 0 my $executable = _find_executable( $_[0] );
33  
34 0 ▶ return if fork;
Branch: 1 branch
BranchTrueFalseTotal
if fork 0 0 0
35  
36 0 require POSIX;
37 0 ▶ exit 1 unless POSIX::setsid();
Branch: 1 branch
BranchTrueFalseTotal
unless POSIX::setsid() 0 0 0
38  
39 0 ▶ if ( Silki::Schema->can('DBIManager') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ("Silki::Schema"->can("DBIManager")) 0 0 0
40 $_->dbh()->{InactiveDestroy} = 1
41 0 for Silki::Schema->DBIManager()->sources();
42 }
43  
44 0 local $ENV{PERL5LIB} = join ':', @INC;
45 0 exec {$executable} @_;
46  
47 0 die "Could not exec - $executable @_: $!";
48 }
49  
50 0 ▶sub _find_executable {
Subroutine _find_executable: not called CC=3 SCAR=24.8
51 0 my $executable = shift;
52  
53 0 my $path = which($executable);
54  
55 0 ▶ return $path if $path;
Branch: 1 branch
BranchTrueFalseTotal
if $path 0 0 0
56  
57 0 my $rel = file( 'bin', $executable );
58  
59 0 ▶ return $rel if -x $rel;
Branch: 1 branch
BranchTrueFalseTotal
if -x $rel 0 0 0
60  
61 0 die "Cannot find an executable named $executable";
62 }
63  
64 8 1;
65  
66 # ABSTRACT: A utility module
67  
68 __END__
« Silki/ConfigData.pm ↑ Summary Silki/Web/Form.pm »