line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Email::MIME::Kit::KitReader::SWAK 1.093065; |
2
|
|
|
|
|
|
|
# ABSTRACT: the swiss army knife of EMK kit readers |
3
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
67477
|
use Moose; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
5
|
|
|
|
|
|
|
with 'Email::MIME::Kit::Role::KitReader'; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
#pod =head1 DESCRIPTION |
8
|
|
|
|
|
|
|
#pod |
9
|
|
|
|
|
|
|
#pod This replaces and extends the standard (Dir) kit reader for Email::MIME::Kit, |
10
|
|
|
|
|
|
|
#pod letting your kit refer to resources in locations other than the kit itself. |
11
|
|
|
|
|
|
|
#pod |
12
|
|
|
|
|
|
|
#pod In your manifest (assuming it's YAML, for readability): |
13
|
|
|
|
|
|
|
#pod |
14
|
|
|
|
|
|
|
#pod --- |
15
|
|
|
|
|
|
|
#pod kit_reader: SWAK |
16
|
|
|
|
|
|
|
#pod attachments: |
17
|
|
|
|
|
|
|
#pod - type: text/html |
18
|
|
|
|
|
|
|
#pod path: template.html |
19
|
|
|
|
|
|
|
#pod |
20
|
|
|
|
|
|
|
#pod - type: text/plain |
21
|
|
|
|
|
|
|
#pod path: /dist/Your-App/config.conf |
22
|
|
|
|
|
|
|
#pod |
23
|
|
|
|
|
|
|
#pod - type: text/plain |
24
|
|
|
|
|
|
|
#pod path: /fs/etc/motd |
25
|
|
|
|
|
|
|
#pod |
26
|
|
|
|
|
|
|
#pod This will find the first file in the kit (the absolute path prefix F</kit> |
27
|
|
|
|
|
|
|
#pod could also be used), the second file in the L<File::ShareDir|File::ShareDir> |
28
|
|
|
|
|
|
|
#pod shared dist space for the Your-App, and the third file on the root filesystem. |
29
|
|
|
|
|
|
|
#pod |
30
|
|
|
|
|
|
|
#pod SWAK may be given a C<fs_root> option to start the contents of F</fs> somewhere |
31
|
|
|
|
|
|
|
#pod other than root. |
32
|
|
|
|
|
|
|
#pod |
33
|
|
|
|
|
|
|
#pod =cut |
34
|
|
|
|
|
|
|
|
35
|
1
|
|
|
1
|
|
6265
|
use Path::Resolver::Resolver::Mux::Prefix; |
|
1
|
|
|
|
|
366174
|
|
|
1
|
|
|
|
|
7
|
|
36
|
1
|
|
|
1
|
|
888
|
use Path::Resolver::Resolver::FileSystem; |
|
1
|
|
|
|
|
172032
|
|
|
1
|
|
|
|
|
38
|
|
37
|
1
|
|
|
1
|
|
523
|
use Path::Resolver::Resolver::AnyDist; |
|
1
|
|
|
|
|
37707
|
|
|
1
|
|
|
|
|
300
|
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
has resolver => ( |
40
|
|
|
|
|
|
|
reader => 'resolver', |
41
|
|
|
|
|
|
|
writer => '_set_resolver', |
42
|
|
|
|
|
|
|
does => 'Path::Resolver::Role::Resolver', |
43
|
|
|
|
|
|
|
init_arg => undef, |
44
|
|
|
|
|
|
|
lazy => 1, |
45
|
|
|
|
|
|
|
default => sub { |
46
|
|
|
|
|
|
|
my ($self) = @_; |
47
|
|
|
|
|
|
|
my $prs = sub { 'Path::Resolver::Resolver::' . $_[0] }; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
my $old_kr = $self->kit->kit_reader; |
50
|
|
|
|
|
|
|
confess(__PACKAGE__ . ' must (for now) replace an existing KitReader::Dir') |
51
|
|
|
|
|
|
|
unless $old_kr and $old_kr->isa('Email::MIME::Kit::KitReader::Dir'); |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
my $kit_resolver = $prs->('FileSystem')->new({ |
54
|
|
|
|
|
|
|
root => $self->kit->source, |
55
|
|
|
|
|
|
|
}); |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
Path::Resolver::Resolver::Mux::Prefix->new({ |
58
|
|
|
|
|
|
|
prefixes => { |
59
|
|
|
|
|
|
|
fs => $prs->('FileSystem')->new({ root => $self->fs_root }), |
60
|
|
|
|
|
|
|
dist => $prs->('AnyDist')->new, |
61
|
|
|
|
|
|
|
kit => $kit_resolver, |
62
|
|
|
|
|
|
|
q{} => $kit_resolver, |
63
|
|
|
|
|
|
|
}, |
64
|
|
|
|
|
|
|
}); |
65
|
|
|
|
|
|
|
}, |
66
|
|
|
|
|
|
|
); |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
has fs_root => ( |
69
|
|
|
|
|
|
|
is => 'ro', |
70
|
|
|
|
|
|
|
isa => 'Str', |
71
|
|
|
|
|
|
|
default => '/', |
72
|
|
|
|
|
|
|
); |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub get_kit_entry { |
75
|
4
|
|
|
4
|
0
|
77495
|
my ($self, $path) = @_; |
76
|
|
|
|
|
|
|
|
77
|
4
|
|
|
|
|
116
|
my $content = $self->resolver->entity_at($path)->content_ref; |
78
|
4
|
50
|
|
|
|
8865
|
return $content if $content; |
79
|
|
|
|
|
|
|
|
80
|
0
|
|
|
|
|
0
|
confess "no content for $path"; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub BUILD { |
84
|
1
|
|
|
1
|
0
|
3
|
my ($self) = @_; |
85
|
1
|
|
|
|
|
34
|
$self->resolver; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
1
|
|
|
1
|
|
8
|
no Moose; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
8
|
|
89
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
__END__ |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=pod |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=encoding UTF-8 |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head1 NAME |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
Email::MIME::Kit::KitReader::SWAK - the swiss army knife of EMK kit readers |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 VERSION |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
version 1.093065 |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head1 DESCRIPTION |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
This replaces and extends the standard (Dir) kit reader for Email::MIME::Kit, |
108
|
|
|
|
|
|
|
letting your kit refer to resources in locations other than the kit itself. |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
In your manifest (assuming it's YAML, for readability): |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
--- |
113
|
|
|
|
|
|
|
kit_reader: SWAK |
114
|
|
|
|
|
|
|
attachments: |
115
|
|
|
|
|
|
|
- type: text/html |
116
|
|
|
|
|
|
|
path: template.html |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
- type: text/plain |
119
|
|
|
|
|
|
|
path: /dist/Your-App/config.conf |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
- type: text/plain |
122
|
|
|
|
|
|
|
path: /fs/etc/motd |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
This will find the first file in the kit (the absolute path prefix F</kit> |
125
|
|
|
|
|
|
|
could also be used), the second file in the L<File::ShareDir|File::ShareDir> |
126
|
|
|
|
|
|
|
shared dist space for the Your-App, and the third file on the root filesystem. |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
SWAK may be given a C<fs_root> option to start the contents of F</fs> somewhere |
129
|
|
|
|
|
|
|
other than root. |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head1 PERL VERSION |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
This module should work on any version of perl still receiving updates from |
134
|
|
|
|
|
|
|
the Perl 5 Porters. This means it should work on any version of perl released |
135
|
|
|
|
|
|
|
in the last two to three years. (That is, if the most recently released |
136
|
|
|
|
|
|
|
version is v5.40, then this module should work on both v5.40 and v5.38.) |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
Although it may work on older versions of perl, no guarantee is made that the |
139
|
|
|
|
|
|
|
minimum required version will not be increased. The version may be increased |
140
|
|
|
|
|
|
|
for any reason, and there is no promise that patches will be accepted to lower |
141
|
|
|
|
|
|
|
the minimum required perl. |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head1 AUTHOR |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
Ricardo SIGNES <cpan@semiotic.systems> |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=head1 CONTRIBUTOR |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=for stopwords Ricardo Signes |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
Ricardo Signes <rjbs@semiotic.systems> |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
This software is copyright (c) 2022 by Ricardo SIGNES. |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
158
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=cut |