line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Email::Sender::Server::Base; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
1238
|
use Moo::Role; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
8
|
|
4
|
1
|
|
|
1
|
|
443
|
use Carp 'confess'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
89
|
|
5
|
1
|
|
|
1
|
|
6
|
use File::Path 'mkpath'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
53
|
|
6
|
1
|
|
|
|
|
787
|
use File::Spec::Functions 'rel2abs', 'catdir', 'catfile', 'curdir', |
7
|
1
|
|
|
1
|
|
5
|
'splitdir', 'splitpath'; |
|
1
|
|
|
|
|
7
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '1.000001'; # VERSION |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub BUILD { |
12
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
13
|
|
|
|
|
|
|
|
14
|
0
|
|
|
|
|
|
my $dir = $self->directory; |
15
|
|
|
|
|
|
|
|
16
|
0
|
0
|
0
|
|
|
|
if (-d $dir && -w $dir) { |
17
|
0
|
|
|
|
|
|
$self->directory('queued'); |
18
|
0
|
|
|
|
|
|
$self->directory('passed'); |
19
|
0
|
|
|
|
|
|
$self->directory('failed'); |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
else { |
22
|
0
|
|
|
|
|
|
confess "Couldn't find or access (write-to) the data directory $dir"; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
0
|
|
|
|
|
|
return $self; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub filepath { |
29
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
30
|
0
|
|
|
|
|
|
my $filename = pop; |
31
|
|
|
|
|
|
|
|
32
|
0
|
|
|
|
|
|
return catfile splitdir join '/', $self->directory(@_), $filename; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub directory { |
36
|
0
|
|
|
0
|
0
|
|
my ($self, @dir) = @_; |
37
|
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
|
my @root = (); |
39
|
0
|
0
|
|
|
|
|
@root = (rel2abs($ENV{ESS_DATA})) if $ENV{ESS_DATA}; |
40
|
0
|
0
|
|
|
|
|
@root = (rel2abs(curdir() || (splitpath($0))[1]), 'ess_data') unless @root; |
41
|
0
|
|
|
|
|
|
my $path = catdir splitdir join '/', @root; |
42
|
|
|
|
|
|
|
|
43
|
0
|
0
|
|
|
|
|
mkpath $path unless -d $path; |
44
|
|
|
|
|
|
|
|
45
|
0
|
0
|
|
|
|
|
if (@dir) { |
46
|
0
|
|
|
|
|
|
my $dir = $path; |
47
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
|
for my $sub (@dir) { |
49
|
0
|
|
|
|
|
|
$path = catdir splitdir join '/', $path, $sub; |
50
|
0
|
0
|
|
|
|
|
mkpath $path unless -d $path; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
0
|
|
|
|
|
|
return catdir splitdir join '/', @root, @dir; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub message_filelist { |
58
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
59
|
0
|
0
|
|
|
|
|
my $directory = @_ ? $self->directory(@_) : $self->workspace ; |
60
|
|
|
|
|
|
|
|
61
|
0
|
|
|
|
|
|
[ glob catfile splitdir join '/', $directory, '*.msg' ] |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub message_filename { |
65
|
0
|
|
|
0
|
0
|
|
my ($self, $filepath) = @_; |
66
|
|
|
|
|
|
|
|
67
|
0
|
0
|
|
|
|
|
return undef unless $filepath; |
68
|
|
|
|
|
|
|
|
69
|
0
|
|
|
|
|
|
my ($filename) = $filepath =~ /(\d{14}-\d{1,10}-\w{4,10}\.msg)$/; |
70
|
|
|
|
|
|
|
|
71
|
0
|
|
|
|
|
|
return $filename; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub stop_polling { |
75
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
76
|
|
|
|
|
|
|
|
77
|
0
|
|
|
|
|
|
return -e $self->filepath('shutdown') ; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
1; |