Postfix/UNIX.pm untested

filter: Statementstmt 0.0% 0 / 25 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 4 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 4 totaltotal 0.0% 0 / 44 CC 2 SCAR 11.0
CC
2
Cov
0%
_unlink
6.0
socketfactory_args
2.0
_build_server
2.0
CRAP 3.0
1 use strict;
2 use warnings;
3  
4 package POE::Component::Server::Postfix::UNIX;
5 our $VERSION = '0.001';
6  
7  
8 use MooseX::POE;
9 extends 'POE::Component::Server::Postfix';
10  
11 has path => (is => 'ro', isa => 'Str', required => 1);
12 has mode => (is => 'ro', default => 0755);
13  
14  
15 sub socketfactory_args {
16 my ($self) = @_;
17 return (
18 SocketDomain => Socket::AF_UNIX,
19 BindAddress => $self->path,
20 );
21 }
22  
23 sub _unlink {
24 my ($self) = @_;
25 if (-e $self->path) {
26 unlink $self->path or die "Can't unlink " . $self->path . ": $!";
27 }
28 }
29  
30 sub _build_server {
31 my ($self) = @_;
32 $self->_unlink;
33 my $server = $self->SUPER::_build_server;
34 chmod $self->mode, $self->path or die "Can't chmod " . $self->path . ": $!";
35 return $server;
36 }
37  
38 sub STOP { shift->_unlink }
39  
40 1;
41  
42 __END__