| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Courriel::Types::Internal; |
|
2
|
|
|
|
|
|
|
|
|
3
|
10
|
|
|
10
|
|
3894733
|
use strict; |
|
|
10
|
|
|
|
|
17
|
|
|
|
10
|
|
|
|
|
358
|
|
|
4
|
10
|
|
|
10
|
|
62
|
use warnings; |
|
|
10
|
|
|
|
|
11
|
|
|
|
10
|
|
|
|
|
292
|
|
|
5
|
10
|
|
|
10
|
|
36
|
use namespace::autoclean; |
|
|
10
|
|
|
|
|
12
|
|
|
|
10
|
|
|
|
|
73
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.42'; |
|
8
|
|
|
|
|
|
|
|
|
9
|
10
|
|
|
10
|
|
2245
|
use List::AllUtils qw( all ); |
|
|
10
|
|
|
|
|
33907
|
|
|
|
10
|
|
|
|
|
650
|
|
|
10
|
10
|
|
|
10
|
|
46
|
use Scalar::Util qw( blessed ); |
|
|
10
|
|
|
|
|
12
|
|
|
|
10
|
|
|
|
|
508
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
10
|
|
|
|
|
79
|
use MooseX::Types -declare => [ |
|
13
|
|
|
|
|
|
|
qw( |
|
14
|
|
|
|
|
|
|
Body |
|
15
|
|
|
|
|
|
|
EmailAddressStr |
|
16
|
|
|
|
|
|
|
HeaderArray |
|
17
|
|
|
|
|
|
|
Headers |
|
18
|
|
|
|
|
|
|
Part |
|
19
|
|
|
|
|
|
|
Printable |
|
20
|
|
|
|
|
|
|
Streamable |
|
21
|
|
|
|
|
|
|
StringRef |
|
22
|
|
|
|
|
|
|
) |
|
23
|
10
|
|
|
10
|
|
45
|
]; |
|
|
10
|
|
|
|
|
13
|
|
|
24
|
10
|
|
|
10
|
|
48582
|
use MooseX::Types::Common::String qw( NonEmptyStr ); |
|
|
10
|
|
|
|
|
15
|
|
|
|
10
|
|
|
|
|
66
|
|
|
25
|
|
|
|
|
|
|
use MooseX::Types::Moose |
|
26
|
10
|
|
|
10
|
|
18634
|
qw( ArrayRef CodeRef FileHandle HashRef Object ScalarRef Str ); |
|
|
10
|
|
|
|
|
13
|
|
|
|
10
|
|
|
|
|
60
|
|
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
#<<< |
|
29
|
|
|
|
|
|
|
subtype Body, |
|
30
|
|
|
|
|
|
|
as role_type('Courriel::Role::Body'); |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
subtype Headers, |
|
33
|
|
|
|
|
|
|
as class_type('Courriel::Headers'); |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
subtype EmailAddressStr, |
|
36
|
|
|
|
|
|
|
as NonEmptyStr; |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
coerce EmailAddressStr, |
|
39
|
|
|
|
|
|
|
from class_type('Email::Address'), |
|
40
|
|
|
|
|
|
|
via { $_->format }; |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
my $_check_header_array = sub { |
|
43
|
|
|
|
|
|
|
return 0 unless @{$_} % 2 == 0; |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
my ( @even, @odd ); |
|
46
|
|
|
|
|
|
|
for my $i ( 0 .. $#{$_} ) { |
|
47
|
|
|
|
|
|
|
if ( $i % 2 ) { |
|
48
|
|
|
|
|
|
|
push @odd, $i; |
|
49
|
|
|
|
|
|
|
} |
|
50
|
|
|
|
|
|
|
else { |
|
51
|
|
|
|
|
|
|
push @even, $i; |
|
52
|
|
|
|
|
|
|
} |
|
53
|
|
|
|
|
|
|
} |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
## no critic (ControlStructures::ProhibitNegativeExpressionsInUnlessAndUntilConditions) |
|
56
|
|
|
|
|
|
|
return 0 unless all { defined $_ && length $_ && !ref $_ } @{$_}[@even]; |
|
57
|
|
|
|
|
|
|
## use critic; |
|
58
|
|
|
|
|
|
|
return 0 |
|
59
|
|
|
|
|
|
|
unless all { blessed($_) && $_->isa('Courriel::Header') } @{$_}[@odd]; |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
return 1; |
|
62
|
|
|
|
|
|
|
}; |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
subtype HeaderArray, |
|
65
|
|
|
|
|
|
|
as ArrayRef, |
|
66
|
|
|
|
|
|
|
# prototype wants an actual block, not a ref to a sub |
|
67
|
|
|
|
|
|
|
&where($_check_header_array), |
|
68
|
|
|
|
|
|
|
message { 'The array reference must contain an even number of elements' }; |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
subtype Part, |
|
71
|
|
|
|
|
|
|
as role_type('Courriel::Role::Part'); |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
subtype Printable, |
|
74
|
|
|
|
|
|
|
as Object, |
|
75
|
|
|
|
|
|
|
where { $_->can('print') }; |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
subtype Streamable, |
|
78
|
|
|
|
|
|
|
as CodeRef; |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
coerce Streamable, |
|
81
|
|
|
|
|
|
|
from FileHandle, |
|
82
|
|
|
|
|
|
|
via sub { |
|
83
|
|
|
|
|
|
|
my $fh = $_; |
|
84
|
|
|
|
|
|
|
return sub { print {$fh} @_ or die $! }; |
|
85
|
|
|
|
|
|
|
}; |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
coerce Streamable, |
|
88
|
|
|
|
|
|
|
from Printable, |
|
89
|
|
|
|
|
|
|
via sub { |
|
90
|
|
|
|
|
|
|
my $obj = $_; |
|
91
|
|
|
|
|
|
|
return sub { $obj->print(@_) }; |
|
92
|
|
|
|
|
|
|
}; |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
subtype StringRef, |
|
95
|
|
|
|
|
|
|
as ScalarRef[Str]; |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
coerce StringRef, |
|
98
|
|
|
|
|
|
|
from Str, |
|
99
|
|
|
|
|
|
|
via { my $str = $_; \$str }; |
|
100
|
|
|
|
|
|
|
#>>> |
|
101
|
|
|
|
|
|
|
1; |