Balancer/Actor.pm untested

filter: Statementstmt 0.0% 0 / 42 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 0.0% 0 / 12 Podpod 0.0% 0 / 6 totaltotal 0.0% 0 / 74 CC 4 SCAR 15.1
CC
4
Cov
0%
executable
12.0
kill
6.0
start
2.0
CRAP 4.5
1 package HTTP::Balancer::Actor;
2 use Modern::Perl;
3 use Moose;
4 use Path::Tiny;
5  
6 with qw(HTTP::Balancer::Role);
7  
8 use Text::Xslate;
9  
10 our @PATH = qw(
11 /usr/local/bin
12 /usr/local/sbin
13 /usr/bin
14 /usr/sbin
15 );
16  
17 sub start {
18 my $class = shift;
19 die "you do not implement the start() for $class";
20 }
21  
22 sub stop {
23 my $class = shift;
24 die "you do not implement the stop() for $class";
25 }
26  
27 sub kill {
28 my ($self, $pid) = @_;
29 if (kill 0, $pid) {
30 kill 15, $pid;
31 } else {
32 warn "could not kill $pid";
33 }
34 }
35  
36 sub executable {
37 my $class = ref($_[0]) ? ref(shift) : shift;
38 my $name = do {
39 no strict "refs";
40 ${ $class . "::NAME" } or die $class . "::NAME not defined yet";
41 };
42 for (@PATH) {
43 return path($_)->child($name)->stringify if path($_)->child($name)->exists;
44 }
45 }
46  
47 sub template {
48 my ($self, ) = @_;
49 state $result;
50 no strict "refs";
51 local $/ = undef;
52 $result //= readline *{ref($self) . "::DATA"};
53 }
54  
55 sub render {
56 my ($self, %args) = @_;
57 Text::Xslate->new->render_string($self->template, \%args);
58 }
59  
60 1;
61 __END__