line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Courriel::Types::Internal; |
2
|
|
|
|
|
|
|
|
3
|
10
|
|
|
10
|
|
6154499
|
use strict; |
|
10
|
|
|
|
|
24
|
|
|
10
|
|
|
|
|
525
|
|
4
|
10
|
|
|
10
|
|
93
|
use warnings; |
|
10
|
|
|
|
|
18
|
|
|
10
|
|
|
|
|
437
|
|
5
|
10
|
|
|
10
|
|
46
|
use namespace::autoclean; |
|
10
|
|
|
|
|
18
|
|
|
10
|
|
|
|
|
92
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.44'; |
8
|
|
|
|
|
|
|
|
9
|
10
|
|
|
10
|
|
4015
|
use List::AllUtils qw( all ); |
|
10
|
|
|
|
|
39269
|
|
|
10
|
|
|
|
|
1001
|
|
10
|
10
|
|
|
10
|
|
90
|
use Scalar::Util qw( blessed ); |
|
10
|
|
|
|
|
20
|
|
|
10
|
|
|
|
|
846
|
|
11
|
|
|
|
|
|
|
|
12
|
10
|
|
|
|
|
117
|
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
|
|
84
|
]; |
|
10
|
|
|
|
|
21
|
|
24
|
10
|
|
|
10
|
|
70855
|
use MooseX::Types::Common::String qw( NonEmptyStr ); |
|
10
|
|
|
|
|
34
|
|
|
10
|
|
|
|
|
109
|
|
25
|
|
|
|
|
|
|
use MooseX::Types::Moose |
26
|
10
|
|
|
10
|
|
26567
|
qw( ArrayRef CodeRef FileHandle HashRef Object ScalarRef Str ); |
|
10
|
|
|
|
|
21
|
|
|
10
|
|
|
|
|
87
|
|
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; |