line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Email::MIME::Kit::Role::ManifestDesugarer 3.000007; |
2
|
|
|
|
|
|
|
# ABSTRACT: helper for desugaring manifests |
3
|
|
|
|
|
|
|
|
4
|
6
|
|
|
6
|
|
3475
|
use v5.20.0; |
|
6
|
|
|
|
|
26
|
|
5
|
6
|
|
|
6
|
|
40
|
use Moose::Role; |
|
6
|
|
|
|
|
14
|
|
|
6
|
|
|
|
|
60
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
#pod =head1 IMPLEMENTING |
8
|
|
|
|
|
|
|
#pod |
9
|
|
|
|
|
|
|
#pod This role also performs L<Email::MIME::Kit::Role::Component>. |
10
|
|
|
|
|
|
|
#pod |
11
|
|
|
|
|
|
|
#pod This is a role more likely to be consumed than implemented. It wraps C<around> |
12
|
|
|
|
|
|
|
#pod the C<read_manifest> method in the consuming class, and "desugars" the contents |
13
|
|
|
|
|
|
|
#pod of the loaded manifest before returning it. |
14
|
|
|
|
|
|
|
#pod |
15
|
|
|
|
|
|
|
#pod At present, desugaring is what allows the C<type> attribute in attachments and |
16
|
|
|
|
|
|
|
#pod alternatives to be given instead of a C<content_type> entry in the |
17
|
|
|
|
|
|
|
#pod C<attributes> entry. In other words, desugaring turns: |
18
|
|
|
|
|
|
|
#pod |
19
|
|
|
|
|
|
|
#pod { |
20
|
|
|
|
|
|
|
#pod header => [ ... ], |
21
|
|
|
|
|
|
|
#pod type => 'text/plain', |
22
|
|
|
|
|
|
|
#pod } |
23
|
|
|
|
|
|
|
#pod |
24
|
|
|
|
|
|
|
#pod Into: |
25
|
|
|
|
|
|
|
#pod |
26
|
|
|
|
|
|
|
#pod { |
27
|
|
|
|
|
|
|
#pod header => [ ... ], |
28
|
|
|
|
|
|
|
#pod attributes => { content_type => 'text/plain' }, |
29
|
|
|
|
|
|
|
#pod } |
30
|
|
|
|
|
|
|
#pod |
31
|
|
|
|
|
|
|
#pod More behavior may be added to the desugarer later. |
32
|
|
|
|
|
|
|
#pod |
33
|
|
|
|
|
|
|
#pod =cut |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
my $ct_desugar; |
36
|
|
|
|
|
|
|
$ct_desugar = sub { |
37
|
|
|
|
|
|
|
my ($self, $content) = @_; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
for my $thing (qw(alternatives attachments)) { |
40
|
|
|
|
|
|
|
for my $part (@{ $content->{ $thing } }) { |
41
|
|
|
|
|
|
|
my $headers = $part->{header} ||= []; |
42
|
|
|
|
|
|
|
if (my $type = delete $part->{type}) { |
43
|
|
|
|
|
|
|
confess "specified both type and content_type attribute" |
44
|
|
|
|
|
|
|
if $part->{attributes}{content_type}; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
$part->{attributes}{content_type} = $type; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
$self->$ct_desugar($part); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
}; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
around read_manifest => sub { |
55
|
|
|
|
|
|
|
my ($orig, $self, @args) = @_; |
56
|
|
|
|
|
|
|
my $content = $self->$orig(@args); |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
$self->$ct_desugar($content); |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
return $content; |
61
|
|
|
|
|
|
|
}; |
62
|
|
|
|
|
|
|
|
63
|
6
|
|
|
6
|
|
32386
|
no Moose::Role; |
|
6
|
|
|
|
|
15
|
|
|
6
|
|
|
|
|
70
|
|
64
|
|
|
|
|
|
|
1; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
__END__ |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=pod |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=encoding UTF-8 |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 NAME |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Email::MIME::Kit::Role::ManifestDesugarer - helper for desugaring manifests |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 VERSION |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
version 3.000007 |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 PERL VERSION |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
This library should run on perls released even a long time ago. It should work |
83
|
|
|
|
|
|
|
on any version of perl released in the last five years. |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Although it may work on older versions of perl, no guarantee is made that the |
86
|
|
|
|
|
|
|
minimum required version will not be increased. The version may be increased |
87
|
|
|
|
|
|
|
for any reason, and there is no promise that patches will be accepted to lower |
88
|
|
|
|
|
|
|
the minimum required perl. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head1 IMPLEMENTING |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
This role also performs L<Email::MIME::Kit::Role::Component>. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
This is a role more likely to be consumed than implemented. It wraps C<around> |
95
|
|
|
|
|
|
|
the C<read_manifest> method in the consuming class, and "desugars" the contents |
96
|
|
|
|
|
|
|
of the loaded manifest before returning it. |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
At present, desugaring is what allows the C<type> attribute in attachments and |
99
|
|
|
|
|
|
|
alternatives to be given instead of a C<content_type> entry in the |
100
|
|
|
|
|
|
|
C<attributes> entry. In other words, desugaring turns: |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
{ |
103
|
|
|
|
|
|
|
header => [ ... ], |
104
|
|
|
|
|
|
|
type => 'text/plain', |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
Into: |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
{ |
110
|
|
|
|
|
|
|
header => [ ... ], |
111
|
|
|
|
|
|
|
attributes => { content_type => 'text/plain' }, |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
More behavior may be added to the desugarer later. |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head1 AUTHOR |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
Ricardo Signes <rjbs@cpan.org> |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
This software is copyright (c) 2023 by Ricardo Signes. |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
125
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=cut |