blib/lib/Perlbal/Control.pm

filter: Statementstmt 29.1% 14 / 48 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 27.2% 3 / 11 Podpod 14.2% 1 / 7 totaltotal 20.4% 18 / 88 CC 12 SCAR 32.5
CC
12
Cov
21%
get_server_pid
56.0
find_pid_file
30.0
construct_command_line
6.0
CRAP 25.8
↑ Summary
1 package Perlbal::Control;
2
3 2 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use Proc::ProcessTable;
Subroutine BEGIN: called CC=1 SCAR=0.0
5
6 2 our $VERSION = '0.02';
7 2 our $AUTHORITY = 'cpan:FAYLAND';
8
9 2 with 'MooseX::Control';
10
11 2 has '+control_name' => ( default => 'perlbal' );
12
13 0 ▶sub pre_startup { inner() }
Subroutine pre_startup: not called CC=1 SCAR=6.9
Pod undocumented
14 0 ▶sub post_startup { inner() }
Subroutine post_startup: not called CC=1 SCAR=6.9
Pod undocumented
15
16 0 ▶sub pre_shutdown { inner() }
Subroutine pre_shutdown: not called CC=1 SCAR=6.9
Pod undocumented
17 0 ▶sub post_shutdown { inner() }
Subroutine post_shutdown: not called CC=1 SCAR=6.9
Pod undocumented
18
19 0 ▶sub get_server_pid {
Subroutine get_server_pid: not called CC=7 SCAR=40.3
Pod documented
20 0 my $self = shift;
21
22 0 my $pid_file = $self->pid_file;
23
24 0 ▶ if ($pid_file and $pid_file ne Path::Class::File->new('/tmp/unknown.pid')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pid_file and $pid_file ne 'Path::Class::File'->new('/tmp/unknown.pid')) { } 0 0 0
Condition0%0/3
$pid_file and $pid_file ne "Path::Class::File"->new("/tmp/unknown.pid")
!ll&&!rl&&r
000
MC/DC0%0/2
$pid_file and $pid_file ne "Path::Class::File"->new("/tmp/unknown.pid")
$pid_file $pid_file ne "Path::Class::File"->new("/tmp/unknown.pid")
Truth table0%0/3
A and B
A= $pid_fileB= $pid_file ne "Path::Class::File"->new("/tmp/unknown.pid")
ABresult
0X0
100
111
25 0 my $pid = $pid_file->slurp(chomp => 1);
26 0 ▶ ($pid)
Branch: 1 branch
BranchTrueFalseTotal
$pid or confess('No PID found in pid_file (' . $pid_file . ')') 0 0 0
27 || confess "No PID found in pid_file (" . $pid_file . ")";
28
29 0 return $pid;
30 } else {
31 0 my $config_file = $self->config_file->stringify;
32 0 my $control_name = $self->control_name;
33 0 my $p = new Proc::ProcessTable( 'cache_ttys' => 1 );
34 0 my $all = $p->table;
35 0 foreach my $one (@$all) {
36 0 ▶ if ($one->cmndline =~ /$control_name/ and $one->cmndline =~ /$config_file/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($one->cmndline =~ /$control_name/ and $one->cmndline =~ /$config_file/) 0 0 0
Condition0%0/3
$one->cmndline =~ /$control_name/ and $one->cmndline =~ /$config_file/
!ll&&!rl&&r
000
MC/DC0%0/2
$one->cmndline =~ /$control_name/ and $one->cmndline =~ /$config_file/
$one->cmndline =~ /$control_name/ $one->cmndline =~ /$config_file/
Truth table0%0/3
A and B
A= $one->cmndline =~ /$control_name/B= $one->cmndline =~ /$config_file/
ABresult
0X0
100
111
37 0 return $one->pid;
38 }
39 }
40 }
41 0 return 0;
42 }
43
44 0 ▶sub construct_command_line {
Subroutine construct_command_line: not called CC=2 SCAR=17.9
Pod undocumented
45 0 my $self = shift;
46 0 my @opts = @_;
47 0 my $conf = $self->config_file;
48
49 0 ▶ (-f $conf)
Branch: 1 branch
BranchTrueFalseTotal
-f $conf or confess("Could not locate configuration file ($conf)") 0 0 0
50 || confess "Could not locate configuration file ($conf)";
51
52 0 ($self->binary_path, '--daemon', '--config', $conf->stringify);
53 }
54
55 0 ▶sub find_pid_file {
Subroutine find_pid_file: not called CC=5 SCAR=34.0
Pod undocumented
56 0 my $self = shift;
57
58 0 my $config_file = $self->config_file;
59
60 0 ▶ (-f $config_file)
Branch: 1 branch
BranchTrueFalseTotal
-f $config_file or confess("Could not find pid_file because could not find config file ($config_file)") 0 0 0
61 || confess "Could not find pid_file because could not find config file ($config_file)";
62
63 my @approaches = (
64 0 ▶ sub { $config_file->slurp(chomp => 1) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
65 0 );
66
67 # it's optional
68 0 foreach my $approach (@approaches) {
69 0 my @config = $approach->();
70 0 foreach my $line (@config) {
71 0 ▶ if ($line =~ /pid_file\s*\=\s*(.*)\s*/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /pid_file\s*\=\s*(.*)\s*/) 0 0 0
72 0 return Path::Class::File->new($1);
73 }
74 }
75 }
76
77 # if not find, just return nothing
78 0 return Path::Class::File->new('/tmp/unknown.pid');
79 };
80
81 2 ▶no Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
82
83 2 1;
84 __END__
↑ Summary