Initial Commit
This commit is contained in:
391
database/perl/vendor/lib/Email/MIME/Kit/Assembler/Standard.pm
vendored
Normal file
391
database/perl/vendor/lib/Email/MIME/Kit/Assembler/Standard.pm
vendored
Normal file
@@ -0,0 +1,391 @@
|
||||
package Email::MIME::Kit::Assembler::Standard;
|
||||
# ABSTRACT: the standard kit assembler
|
||||
$Email::MIME::Kit::Assembler::Standard::VERSION = '3.000006';
|
||||
use Moose;
|
||||
use Moose::Util::TypeConstraints;
|
||||
|
||||
#pod =head1 WARNING
|
||||
#pod
|
||||
#pod Email::MIME::Kit::Assembler::Standard works well, but is poorly decomposed,
|
||||
#pod internally. Its methods may change substantially in the future, so relying on
|
||||
#pod it as a base class is a bad idea.
|
||||
#pod
|
||||
#pod Because I<being able to> rely on it would be so useful, its behaviors will in
|
||||
#pod the future be more reliable or factored out into roles. Until then, be
|
||||
#pod careful.
|
||||
#pod
|
||||
#pod =cut
|
||||
|
||||
with 'Email::MIME::Kit::Role::Assembler';
|
||||
|
||||
use Email::MIME::Creator;
|
||||
use Encode ();
|
||||
use File::Basename;
|
||||
|
||||
sub BUILD {
|
||||
my ($self) = @_;
|
||||
$self->_setup_content_ids;
|
||||
$self->_pick_and_set_renderer;
|
||||
$self->_build_subassemblies;
|
||||
}
|
||||
|
||||
has parent => (
|
||||
is => 'ro',
|
||||
isa => maybe_type(role_type('Email::MIME::Kit::Role::Assembler')),
|
||||
weak_ref => 1,
|
||||
);
|
||||
|
||||
has renderer => (
|
||||
reader => 'renderer',
|
||||
writer => '_set_renderer',
|
||||
clearer => '_unset_renderer',
|
||||
isa => maybe_type(role_type('Email::MIME::Kit::Role::Renderer')),
|
||||
init_arg => undef,
|
||||
);
|
||||
|
||||
sub assemble {
|
||||
my ($self, $stash) = @_;
|
||||
|
||||
my $manifest = $self->manifest;
|
||||
|
||||
my $has_body = defined $manifest->{body};
|
||||
my $has_path = defined $manifest->{path};
|
||||
my $has_alts = @{ $manifest->{alternatives} || [] };
|
||||
my $has_att = @{ $manifest->{attachments} || [] };
|
||||
|
||||
Carp::croak("neither body, path, nor alternatives provided")
|
||||
unless $has_body or $has_path or $has_alts;
|
||||
|
||||
Carp::croak("you must provide only one of body, path, or alternatives")
|
||||
unless (grep {$_} $has_body, $has_path, $has_alts) == 1;
|
||||
|
||||
my $assembly_method = $has_body ? '_assemble_from_manifest_body'
|
||||
: $has_path ? '_assemble_from_kit'
|
||||
: $has_alts ? '_assemble_mp_alt'
|
||||
: confess "unreachable code is a mistake";
|
||||
|
||||
$self->$assembly_method($stash);
|
||||
}
|
||||
|
||||
sub _assemble_from_string {
|
||||
my ($self, $body, $stash) = @_;
|
||||
|
||||
my %attr = %{ $self->manifest->{attributes} || {} };
|
||||
$attr{content_type} ||= 'text/plain';
|
||||
|
||||
if ($attr{content_type} =~ m{^text/}) {
|
||||
# I really shouldn't have to do this, but I'm not going to go screw around
|
||||
# with @#$@#$ Email::Simple/MIME just to deal with it right now. -- rjbs,
|
||||
# 2009-01-19
|
||||
$body .= "\x0d\x0a" unless $body =~ /[\x0d|\x0a]\z/;
|
||||
}
|
||||
|
||||
my $body_ref = $self->render(\$body, $stash);
|
||||
|
||||
my $email = $self->_contain_attachments({
|
||||
attributes => \%attr,
|
||||
header => $self->manifest->{header},
|
||||
stash => $stash,
|
||||
body => $$body_ref,
|
||||
container_type => $self->manifest->{container_type},
|
||||
});
|
||||
}
|
||||
|
||||
sub _assemble_from_manifest_body {
|
||||
my ($self, $stash) = @_;
|
||||
|
||||
$self->_assemble_from_string(
|
||||
$self->manifest->{body},
|
||||
$stash,
|
||||
);
|
||||
}
|
||||
|
||||
sub _assemble_from_kit {
|
||||
my ($self, $stash) = @_;
|
||||
|
||||
my $type = $self->manifest->{attributes}{content_type} || 'text/plain';
|
||||
my $method = $type =~ m{^text/} ? 'get_decoded_kit_entry' : 'get_kit_entry';
|
||||
|
||||
my $body_ref = $self->kit->$method($self->manifest->{path});
|
||||
|
||||
$self->_assemble_from_string($$body_ref, $stash);
|
||||
}
|
||||
|
||||
sub _assemble_mp_alt {
|
||||
my ($self, $stash) = @_;
|
||||
|
||||
my %attr = %{ $self->manifest->{attributes} || {} };
|
||||
$attr{content_type} = $attr{content_type} || 'multipart/alternative';
|
||||
|
||||
if ($attr{content_type} !~ qr{\Amultipart/alternative\b}) {
|
||||
confess "illegal content_type for mail with alts: $attr{content_type}";
|
||||
}
|
||||
|
||||
my $parts = [ map { $_->assemble($stash) } @{ $self->_alternatives } ];
|
||||
|
||||
my $email = $self->_contain_attachments({
|
||||
attributes => \%attr,
|
||||
header => $self->manifest->{header},
|
||||
stash => $stash,
|
||||
parts => $parts,
|
||||
});
|
||||
}
|
||||
|
||||
sub _renderer_from_override {
|
||||
my ($self, $override) = @_;
|
||||
|
||||
# Allow an explicit undef to mean "no rendering is to be done." -- rjbs,
|
||||
# 2009-01-19
|
||||
return undef unless defined $override;
|
||||
|
||||
return $self->kit->_build_component(
|
||||
'Email::MIME::Kit::Renderer',
|
||||
$override,
|
||||
);
|
||||
}
|
||||
|
||||
sub _pick_and_set_renderer {
|
||||
my ($self) = @_;
|
||||
|
||||
# "renderer" entry at top-level sets the kit default_renderer, so trying to
|
||||
# look at the "renderer" entry at top-level for an override is nonsensical
|
||||
# -- rjbs, 2009-01-22
|
||||
unless ($self->parent) {
|
||||
$self->_set_renderer($self->kit->default_renderer);
|
||||
return;
|
||||
}
|
||||
|
||||
# If there's no override, we just use the parent. We don't need to worry
|
||||
# about the "there is no parent" case, because that was handled above. --
|
||||
# rjbs, 2009-01-22
|
||||
unless (exists $self->manifest->{renderer}) {
|
||||
$self->_set_renderer($self->parent->renderer);
|
||||
return;
|
||||
}
|
||||
|
||||
my $renderer = $self->_renderer_from_override($self->manifest->{renderer});
|
||||
$self->_set_renderer($renderer);
|
||||
}
|
||||
|
||||
has manifest => (
|
||||
is => 'ro',
|
||||
required => 1,
|
||||
);
|
||||
|
||||
has [ qw(_attachments _alternatives) ] => (
|
||||
is => 'ro',
|
||||
isa => 'ArrayRef',
|
||||
init_arg => undef,
|
||||
default => sub { [] },
|
||||
);
|
||||
|
||||
has _body => (
|
||||
reader => 'body',
|
||||
writer => '_set_body',
|
||||
);
|
||||
|
||||
sub _build_subassemblies {
|
||||
my ($self) = @_;
|
||||
|
||||
if (my $body = $self->manifest->{body}) {
|
||||
$self->_set_body($body);
|
||||
}
|
||||
|
||||
for my $attach (@{ $self->manifest->{attachments} || [] }) {
|
||||
my $assembler = $self->kit->_assembler_from_manifest($attach, $self);
|
||||
$assembler->_set_attachment_info($attach)
|
||||
if $assembler->can('_set_attachment_info');
|
||||
push @{ $self->_attachments }, $assembler;
|
||||
}
|
||||
|
||||
for my $alt (@{ $self->manifest->{alternatives} || [] }) {
|
||||
push @{ $self->_alternatives },
|
||||
$self->kit->_assembler_from_manifest($alt, $self);
|
||||
}
|
||||
}
|
||||
|
||||
sub _set_attachment_info {
|
||||
my ($self, $manifest) = @_;
|
||||
|
||||
my $attr = $manifest->{attributes} ||= {};
|
||||
|
||||
$attr->{encoding} = 'base64' unless exists $attr->{encoding};
|
||||
$attr->{disposition} = 'attachment' unless exists $attr->{disposition};
|
||||
|
||||
unless (exists $attr->{filename}) {
|
||||
my $filename;
|
||||
($filename) = File::Basename::fileparse($manifest->{path})
|
||||
if $manifest->{path};
|
||||
|
||||
# XXX: Steal the attachment-name-generator from Email::MIME::Modifier, or
|
||||
# something. -- rjbs, 2009-01-20
|
||||
$filename ||= "unknown-attachment";
|
||||
|
||||
$attr->{filename} = $filename;
|
||||
}
|
||||
}
|
||||
|
||||
sub render {
|
||||
my ($self, $input_ref, $stash) = @_;
|
||||
local $stash->{cid_for} = sub { $self->cid_for_path($_[0]) };
|
||||
return $input_ref unless my $renderer = $self->renderer;
|
||||
return $renderer->render($input_ref, $stash);
|
||||
}
|
||||
|
||||
sub _prep_header {
|
||||
my ($self, $header, $stash) = @_;
|
||||
|
||||
my @done_header;
|
||||
for my $entry (@$header) {
|
||||
confess "no field name candidates"
|
||||
unless my (@hval) = grep { /^[^:]/ } keys %$entry;
|
||||
confess "multiple field name candidates: @hval" if @hval > 1;
|
||||
my $value = $entry->{ $hval[ 0 ] };
|
||||
|
||||
if (ref $value) {
|
||||
my ($v, $p) = @$value;
|
||||
$value = join q{; }, $v, map { "$_=$p->{$_}" } keys %$p;
|
||||
} else {
|
||||
# I don't think I need to bother with $self->render, which will set up
|
||||
# the cid_for callback. Honestly, who is going to be referencing a
|
||||
# content-id from a header? Let's hope I never find out... -- rjbs,
|
||||
# 2009-01-22
|
||||
my $renderer = exists $entry->{':renderer'}
|
||||
? $self->_renderer_from_override($entry->{':renderer'})
|
||||
: $self->renderer;
|
||||
|
||||
$value = ${ $renderer->render(\$value, $stash) } if defined $renderer;
|
||||
}
|
||||
|
||||
push @done_header, $hval[0] => $value;
|
||||
}
|
||||
|
||||
return \@done_header;
|
||||
}
|
||||
|
||||
sub _contain_attachments {
|
||||
my ($self, $arg) = @_;
|
||||
|
||||
my @attachments = @{ $self->_attachments };
|
||||
my $header = $self->_prep_header($arg->{header}, $arg->{stash});
|
||||
|
||||
my $ct = $arg->{container_type};
|
||||
|
||||
my %attr = %{ $arg->{attributes} };
|
||||
my $body_type = 'body';
|
||||
|
||||
if ($attr{content_type} =~ m{^text/}) {
|
||||
$body_type = 'body_str';
|
||||
|
||||
$attr{encoding} ||= 'quoted-printable';
|
||||
$attr{charset} ||= 'UTF-8'
|
||||
} elsif (($arg->{body} || '') =~ /\P{ASCII}/) {
|
||||
$attr{encoding} ||= 'base64';
|
||||
}
|
||||
|
||||
unless (@attachments) {
|
||||
confess "container_type given for single-part assembly" if $ct;
|
||||
|
||||
return Email::MIME->create(
|
||||
attributes => \%attr,
|
||||
header_str => $header,
|
||||
$body_type => $arg->{body},
|
||||
parts => $arg->{parts},
|
||||
);
|
||||
}
|
||||
|
||||
my $email = Email::MIME->create(
|
||||
attributes => \%attr,
|
||||
$body_type => $arg->{body},
|
||||
parts => $arg->{parts},
|
||||
);
|
||||
|
||||
my @att_parts = map { $_->assemble($arg->{stash}) } @attachments;
|
||||
|
||||
my $container = Email::MIME->create(
|
||||
attributes => { content_type => ($ct || 'multipart/mixed') },
|
||||
header_str => $header,
|
||||
parts => [ $email, @att_parts ],
|
||||
);
|
||||
|
||||
return $container;
|
||||
}
|
||||
|
||||
has _cid_registry => (
|
||||
is => 'ro',
|
||||
init_arg => undef,
|
||||
default => sub { { } },
|
||||
);
|
||||
|
||||
sub cid_for_path {
|
||||
my ($self, $path) = @_;
|
||||
my $cid = $self->_cid_registry->{ $path };
|
||||
|
||||
confess "no content-id for path $path" unless $cid;
|
||||
|
||||
return $cid;
|
||||
}
|
||||
|
||||
sub _setup_content_ids {
|
||||
my ($self) = @_;
|
||||
|
||||
for my $att (@{ $self->manifest->{attachments} || [] }) {
|
||||
next unless $att->{path};
|
||||
|
||||
for my $header (@{ $att->{header} }) {
|
||||
my ($header) = grep { /^[^:]/ } keys %$header;
|
||||
Carp::croak("attachments must not supply content-id")
|
||||
if lc $header eq 'content-id';
|
||||
}
|
||||
|
||||
my $cid = $self->kit->_generate_content_id;
|
||||
push @{ $att->{header} }, {
|
||||
'Content-Id' => $cid->in_brackets,
|
||||
':renderer' => undef,
|
||||
};
|
||||
|
||||
$self->_cid_registry->{ $att->{path} } = $cid->as_string;
|
||||
}
|
||||
}
|
||||
|
||||
no Moose::Util::TypeConstraints;
|
||||
no Moose;
|
||||
__PACKAGE__->meta->make_immutable;
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=pod
|
||||
|
||||
=encoding UTF-8
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Email::MIME::Kit::Assembler::Standard - the standard kit assembler
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
version 3.000006
|
||||
|
||||
=head1 WARNING
|
||||
|
||||
Email::MIME::Kit::Assembler::Standard works well, but is poorly decomposed,
|
||||
internally. Its methods may change substantially in the future, so relying on
|
||||
it as a base class is a bad idea.
|
||||
|
||||
Because I<being able to> rely on it would be so useful, its behaviors will in
|
||||
the future be more reliable or factored out into roles. Until then, be
|
||||
careful.
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Ricardo Signes <rjbs@cpan.org>
|
||||
|
||||
=head1 COPYRIGHT AND LICENSE
|
||||
|
||||
This software is copyright (c) 2018 by Ricardo Signes.
|
||||
|
||||
This is free software; you can redistribute it and/or modify it under
|
||||
the same terms as the Perl 5 programming language system itself.
|
||||
|
||||
=cut
|
||||
51
database/perl/vendor/lib/Email/MIME/Kit/KitReader/Dir.pm
vendored
Normal file
51
database/perl/vendor/lib/Email/MIME/Kit/KitReader/Dir.pm
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
package Email::MIME::Kit::KitReader::Dir;
|
||||
# ABSTRACT: read kit entries out of a directory
|
||||
$Email::MIME::Kit::KitReader::Dir::VERSION = '3.000006';
|
||||
use Moose;
|
||||
with 'Email::MIME::Kit::Role::KitReader';
|
||||
|
||||
use File::Spec;
|
||||
|
||||
# cache sometimes
|
||||
sub get_kit_entry {
|
||||
my ($self, $path) = @_;
|
||||
|
||||
my $fullpath = File::Spec->catfile($self->kit->source, $path);
|
||||
|
||||
open my $fh, '<:raw', $fullpath
|
||||
or die "can't open $fullpath for reading: $!";
|
||||
my $content = do { local $/; <$fh> };
|
||||
|
||||
return \$content;
|
||||
}
|
||||
|
||||
no Moose;
|
||||
__PACKAGE__->meta->make_immutable;
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=pod
|
||||
|
||||
=encoding UTF-8
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Email::MIME::Kit::KitReader::Dir - read kit entries out of a directory
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
version 3.000006
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Ricardo Signes <rjbs@cpan.org>
|
||||
|
||||
=head1 COPYRIGHT AND LICENSE
|
||||
|
||||
This software is copyright (c) 2018 by Ricardo Signes.
|
||||
|
||||
This is free software; you can redistribute it and/or modify it under
|
||||
the same terms as the Perl 5 programming language system itself.
|
||||
|
||||
=cut
|
||||
48
database/perl/vendor/lib/Email/MIME/Kit/ManifestReader/JSON.pm
vendored
Normal file
48
database/perl/vendor/lib/Email/MIME/Kit/ManifestReader/JSON.pm
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
package Email::MIME::Kit::ManifestReader::JSON;
|
||||
# ABSTRACT: read manifest.json files
|
||||
$Email::MIME::Kit::ManifestReader::JSON::VERSION = '3.000006';
|
||||
use Moose;
|
||||
|
||||
with 'Email::MIME::Kit::Role::ManifestReader';
|
||||
with 'Email::MIME::Kit::Role::ManifestDesugarer';
|
||||
|
||||
use JSON 2;
|
||||
|
||||
sub read_manifest {
|
||||
my ($self) = @_;
|
||||
|
||||
my $json_ref = $self->kit->kit_reader->get_kit_entry('manifest.json');
|
||||
|
||||
my $content = JSON->new->utf8->decode($$json_ref);
|
||||
}
|
||||
|
||||
no Moose;
|
||||
__PACKAGE__->meta->make_immutable;
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=pod
|
||||
|
||||
=encoding UTF-8
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Email::MIME::Kit::ManifestReader::JSON - read manifest.json files
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
version 3.000006
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Ricardo Signes <rjbs@cpan.org>
|
||||
|
||||
=head1 COPYRIGHT AND LICENSE
|
||||
|
||||
This software is copyright (c) 2018 by Ricardo Signes.
|
||||
|
||||
This is free software; you can redistribute it and/or modify it under
|
||||
the same terms as the Perl 5 programming language system itself.
|
||||
|
||||
=cut
|
||||
51
database/perl/vendor/lib/Email/MIME/Kit/ManifestReader/YAML.pm
vendored
Normal file
51
database/perl/vendor/lib/Email/MIME/Kit/ManifestReader/YAML.pm
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
package Email::MIME::Kit::ManifestReader::YAML;
|
||||
# ABSTRACT: read manifest.yaml files
|
||||
$Email::MIME::Kit::ManifestReader::YAML::VERSION = '3.000006';
|
||||
use Moose;
|
||||
|
||||
with 'Email::MIME::Kit::Role::ManifestReader';
|
||||
with 'Email::MIME::Kit::Role::ManifestDesugarer';
|
||||
|
||||
use YAML::XS ();
|
||||
|
||||
sub read_manifest {
|
||||
my ($self) = @_;
|
||||
|
||||
my $yaml_ref = $self->kit->kit_reader->get_kit_entry('manifest.yaml');
|
||||
|
||||
# YAML::XS is documented as expecting UTF-8 bytes, which we give it.
|
||||
my ($content) = YAML::XS::Load($$yaml_ref);
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
no Moose;
|
||||
__PACKAGE__->meta->make_immutable;
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=pod
|
||||
|
||||
=encoding UTF-8
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Email::MIME::Kit::ManifestReader::YAML - read manifest.yaml files
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
version 3.000006
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Ricardo Signes <rjbs@cpan.org>
|
||||
|
||||
=head1 COPYRIGHT AND LICENSE
|
||||
|
||||
This software is copyright (c) 2018 by Ricardo Signes.
|
||||
|
||||
This is free software; you can redistribute it and/or modify it under
|
||||
the same terms as the Perl 5 programming language system itself.
|
||||
|
||||
=cut
|
||||
118
database/perl/vendor/lib/Email/MIME/Kit/Renderer/TestRenderer.pm
vendored
Normal file
118
database/perl/vendor/lib/Email/MIME/Kit/Renderer/TestRenderer.pm
vendored
Normal file
@@ -0,0 +1,118 @@
|
||||
package Email::MIME::Kit::Renderer::TestRenderer;
|
||||
# ABSTRACT: extremely simple renderer for testing purposes only
|
||||
$Email::MIME::Kit::Renderer::TestRenderer::VERSION = '3.000006';
|
||||
use Moose;
|
||||
with 'Email::MIME::Kit::Role::Renderer';
|
||||
|
||||
#pod =head1 WARNING
|
||||
#pod
|
||||
#pod Seriously, this is horrible code. If you want, look at it. It's swell for
|
||||
#pod testing simple things, but if you use this for real mkits, you're going to be
|
||||
#pod upset by something horrible soon.
|
||||
#pod
|
||||
#pod =head1 DESCRIPTION
|
||||
#pod
|
||||
#pod The test renderer is like a version of Template Toolkit 2 that has had a crayon
|
||||
#pod shoved up its nose and into its brain. It can only do a very few things, but
|
||||
#pod it does them well enough to test simple kits.
|
||||
#pod
|
||||
#pod Given the following template:
|
||||
#pod
|
||||
#pod This will say "I love pie": [% actor %] [% m_obj.verb() %] [% z_by("me") %]
|
||||
#pod
|
||||
#pod ...and the following set of variables:
|
||||
#pod
|
||||
#pod {
|
||||
#pod actor => 'I',
|
||||
#pod m_obj => $object_whose_verb_method_returns_love,
|
||||
#pod z_by => sub { 'me' },
|
||||
#pod }
|
||||
#pod
|
||||
#pod ..then it will be a true statement.
|
||||
#pod
|
||||
#pod In method calls, the parens are B<not> optional. Anything between them (or
|
||||
#pod between the parens in a coderef call) is evaluated like perl code. For
|
||||
#pod example, this will actually get the OS:
|
||||
#pod
|
||||
#pod [% z_by($^O) %]
|
||||
#pod
|
||||
#pod =cut
|
||||
|
||||
sub render {
|
||||
my ($self, $content_ref, $stash) = @_;
|
||||
|
||||
my $output = $$content_ref;
|
||||
for my $key (sort %$stash) {
|
||||
$output =~
|
||||
s<\[%\s+\Q$key\E(?:(?:\.(\w+))?\((.*?)\))?\s+%\]>
|
||||
[ defined $2
|
||||
? ($1 ? $stash->{$key}->$1(eval $2) : $stash->{$key}->(eval $2))
|
||||
: $stash->{$key}
|
||||
]ge;
|
||||
}
|
||||
|
||||
return \$output;
|
||||
}
|
||||
|
||||
no Moose;
|
||||
__PACKAGE__->meta->make_immutable;
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=pod
|
||||
|
||||
=encoding UTF-8
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Email::MIME::Kit::Renderer::TestRenderer - extremely simple renderer for testing purposes only
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
version 3.000006
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
The test renderer is like a version of Template Toolkit 2 that has had a crayon
|
||||
shoved up its nose and into its brain. It can only do a very few things, but
|
||||
it does them well enough to test simple kits.
|
||||
|
||||
Given the following template:
|
||||
|
||||
This will say "I love pie": [% actor %] [% m_obj.verb() %] [% z_by("me") %]
|
||||
|
||||
...and the following set of variables:
|
||||
|
||||
{
|
||||
actor => 'I',
|
||||
m_obj => $object_whose_verb_method_returns_love,
|
||||
z_by => sub { 'me' },
|
||||
}
|
||||
|
||||
..then it will be a true statement.
|
||||
|
||||
In method calls, the parens are B<not> optional. Anything between them (or
|
||||
between the parens in a coderef call) is evaluated like perl code. For
|
||||
example, this will actually get the OS:
|
||||
|
||||
[% z_by($^O) %]
|
||||
|
||||
=head1 WARNING
|
||||
|
||||
Seriously, this is horrible code. If you want, look at it. It's swell for
|
||||
testing simple things, but if you use this for real mkits, you're going to be
|
||||
upset by something horrible soon.
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Ricardo Signes <rjbs@cpan.org>
|
||||
|
||||
=head1 COPYRIGHT AND LICENSE
|
||||
|
||||
This software is copyright (c) 2018 by Ricardo Signes.
|
||||
|
||||
This is free software; you can redistribute it and/or modify it under
|
||||
the same terms as the Perl 5 programming language system itself.
|
||||
|
||||
=cut
|
||||
55
database/perl/vendor/lib/Email/MIME/Kit/Role/Assembler.pm
vendored
Normal file
55
database/perl/vendor/lib/Email/MIME/Kit/Role/Assembler.pm
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
package Email::MIME::Kit::Role::Assembler;
|
||||
# ABSTRACT: things that assemble messages (or parts)
|
||||
$Email::MIME::Kit::Role::Assembler::VERSION = '3.000006';
|
||||
use Moose::Role;
|
||||
with 'Email::MIME::Kit::Role::Component';
|
||||
|
||||
#pod =head1 IMPLEMENTING
|
||||
#pod
|
||||
#pod This role also performs L<Email::MIME::Kit::Role::Component>.
|
||||
#pod
|
||||
#pod Classes implementing this role must provide an C<assemble> method. This method
|
||||
#pod will be passed a hashref of assembly parameters, and should return the fully
|
||||
#pod assembled Email::MIME object.
|
||||
#pod
|
||||
#pod =cut
|
||||
|
||||
requires 'assemble';
|
||||
|
||||
no Moose::Role;
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=pod
|
||||
|
||||
=encoding UTF-8
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Email::MIME::Kit::Role::Assembler - things that assemble messages (or parts)
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
version 3.000006
|
||||
|
||||
=head1 IMPLEMENTING
|
||||
|
||||
This role also performs L<Email::MIME::Kit::Role::Component>.
|
||||
|
||||
Classes implementing this role must provide an C<assemble> method. This method
|
||||
will be passed a hashref of assembly parameters, and should return the fully
|
||||
assembled Email::MIME object.
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Ricardo Signes <rjbs@cpan.org>
|
||||
|
||||
=head1 COPYRIGHT AND LICENSE
|
||||
|
||||
This software is copyright (c) 2018 by Ricardo Signes.
|
||||
|
||||
This is free software; you can redistribute it and/or modify it under
|
||||
the same terms as the Perl 5 programming language system itself.
|
||||
|
||||
=cut
|
||||
55
database/perl/vendor/lib/Email/MIME/Kit/Role/Component.pm
vendored
Normal file
55
database/perl/vendor/lib/Email/MIME/Kit/Role/Component.pm
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
package Email::MIME::Kit::Role::Component;
|
||||
# ABSTRACT: things that are kit components
|
||||
$Email::MIME::Kit::Role::Component::VERSION = '3.000006';
|
||||
use Moose::Role;
|
||||
|
||||
#pod =head1 DESCRIPTION
|
||||
#pod
|
||||
#pod All (or most, anyway) components of an Email::MIME::Kit will perform this role.
|
||||
#pod Its primary function is to provide a C<kit> attribute that refers back to the
|
||||
#pod Email::MIME::Kit into which the component was installed.
|
||||
#pod
|
||||
#pod =cut
|
||||
|
||||
has kit => (
|
||||
is => 'ro',
|
||||
isa => 'Email::MIME::Kit',
|
||||
required => 1,
|
||||
weak_ref => 1,
|
||||
);
|
||||
|
||||
no Moose::Role;
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=pod
|
||||
|
||||
=encoding UTF-8
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Email::MIME::Kit::Role::Component - things that are kit components
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
version 3.000006
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
All (or most, anyway) components of an Email::MIME::Kit will perform this role.
|
||||
Its primary function is to provide a C<kit> attribute that refers back to the
|
||||
Email::MIME::Kit into which the component was installed.
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Ricardo Signes <rjbs@cpan.org>
|
||||
|
||||
=head1 COPYRIGHT AND LICENSE
|
||||
|
||||
This software is copyright (c) 2018 by Ricardo Signes.
|
||||
|
||||
This is free software; you can redistribute it and/or modify it under
|
||||
the same terms as the Perl 5 programming language system itself.
|
||||
|
||||
=cut
|
||||
74
database/perl/vendor/lib/Email/MIME/Kit/Role/KitReader.pm
vendored
Normal file
74
database/perl/vendor/lib/Email/MIME/Kit/Role/KitReader.pm
vendored
Normal file
@@ -0,0 +1,74 @@
|
||||
package Email::MIME::Kit::Role::KitReader;
|
||||
# ABSTRACT: things that can read kit contents
|
||||
$Email::MIME::Kit::Role::KitReader::VERSION = '3.000006';
|
||||
use Moose::Role;
|
||||
with 'Email::MIME::Kit::Role::Component';
|
||||
|
||||
#pod =head1 IMPLEMENTING
|
||||
#pod
|
||||
#pod This role also performs L<Email::MIME::Kit::Role::Component>.
|
||||
#pod
|
||||
#pod Classes implementing this role must provide a C<get_kit_entry> method. It will
|
||||
#pod be called with one parameter, the name of a path to an entry in the kit. It
|
||||
#pod should return a reference to a scalar holding the contents (as octets) of the
|
||||
#pod named entry. If no entry is found, it should raise an exception.
|
||||
#pod
|
||||
#pod A method called C<get_decoded_kit_entry> is provided. It behaves like
|
||||
#pod C<get_kit_entry>, but assumes that the entry for that name is stored in UTF-8
|
||||
#pod and will decode it to text before returning.
|
||||
#pod
|
||||
#pod =cut
|
||||
|
||||
requires 'get_kit_entry';
|
||||
|
||||
sub get_decoded_kit_entry {
|
||||
my ($self, $name) = @_;
|
||||
my $content_ref = $self->get_kit_entry($name);
|
||||
|
||||
require Encode;
|
||||
my $decoded = Encode::decode('utf-8', $$content_ref);
|
||||
return \$decoded;
|
||||
}
|
||||
|
||||
no Moose::Role;
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=pod
|
||||
|
||||
=encoding UTF-8
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Email::MIME::Kit::Role::KitReader - things that can read kit contents
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
version 3.000006
|
||||
|
||||
=head1 IMPLEMENTING
|
||||
|
||||
This role also performs L<Email::MIME::Kit::Role::Component>.
|
||||
|
||||
Classes implementing this role must provide a C<get_kit_entry> method. It will
|
||||
be called with one parameter, the name of a path to an entry in the kit. It
|
||||
should return a reference to a scalar holding the contents (as octets) of the
|
||||
named entry. If no entry is found, it should raise an exception.
|
||||
|
||||
A method called C<get_decoded_kit_entry> is provided. It behaves like
|
||||
C<get_kit_entry>, but assumes that the entry for that name is stored in UTF-8
|
||||
and will decode it to text before returning.
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Ricardo Signes <rjbs@cpan.org>
|
||||
|
||||
=head1 COPYRIGHT AND LICENSE
|
||||
|
||||
This software is copyright (c) 2018 by Ricardo Signes.
|
||||
|
||||
This is free software; you can redistribute it and/or modify it under
|
||||
the same terms as the Perl 5 programming language system itself.
|
||||
|
||||
=cut
|
||||
116
database/perl/vendor/lib/Email/MIME/Kit/Role/ManifestDesugarer.pm
vendored
Normal file
116
database/perl/vendor/lib/Email/MIME/Kit/Role/ManifestDesugarer.pm
vendored
Normal file
@@ -0,0 +1,116 @@
|
||||
package Email::MIME::Kit::Role::ManifestDesugarer;
|
||||
# ABSTRACT: helper for desugaring manifests
|
||||
$Email::MIME::Kit::Role::ManifestDesugarer::VERSION = '3.000006';
|
||||
use Moose::Role;
|
||||
|
||||
#pod =head1 IMPLEMENTING
|
||||
#pod
|
||||
#pod This role also performs L<Email::MIME::Kit::Role::Component>.
|
||||
#pod
|
||||
#pod This is a role more likely to be consumed than implemented. It wraps C<around>
|
||||
#pod the C<read_manifest> method in the consuming class, and "desugars" the contents
|
||||
#pod of the loaded manifest before returning it.
|
||||
#pod
|
||||
#pod At present, desugaring is what allows the C<type> attribute in attachments and
|
||||
#pod alternatives to be given instead of a C<content_type> entry in the
|
||||
#pod C<attributes> entry. In other words, desugaring turns:
|
||||
#pod
|
||||
#pod {
|
||||
#pod header => [ ... ],
|
||||
#pod type => 'text/plain',
|
||||
#pod }
|
||||
#pod
|
||||
#pod Into:
|
||||
#pod
|
||||
#pod {
|
||||
#pod header => [ ... ],
|
||||
#pod attributes => { content_type => 'text/plain' },
|
||||
#pod }
|
||||
#pod
|
||||
#pod More behavior may be added to the desugarer later.
|
||||
#pod
|
||||
#pod =cut
|
||||
|
||||
my $ct_desugar;
|
||||
$ct_desugar = sub {
|
||||
my ($self, $content) = @_;
|
||||
|
||||
for my $thing (qw(alternatives attachments)) {
|
||||
for my $part (@{ $content->{ $thing } }) {
|
||||
my $headers = $part->{header} ||= [];
|
||||
if (my $type = delete $part->{type}) {
|
||||
confess "specified both type and content_type attribute"
|
||||
if $part->{attributes}{content_type};
|
||||
|
||||
$part->{attributes}{content_type} = $type;
|
||||
}
|
||||
|
||||
$self->$ct_desugar($part);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
around read_manifest => sub {
|
||||
my ($orig, $self, @args) = @_;
|
||||
my $content = $self->$orig(@args);
|
||||
|
||||
$self->$ct_desugar($content);
|
||||
|
||||
return $content;
|
||||
};
|
||||
|
||||
no Moose::Role;
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=pod
|
||||
|
||||
=encoding UTF-8
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Email::MIME::Kit::Role::ManifestDesugarer - helper for desugaring manifests
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
version 3.000006
|
||||
|
||||
=head1 IMPLEMENTING
|
||||
|
||||
This role also performs L<Email::MIME::Kit::Role::Component>.
|
||||
|
||||
This is a role more likely to be consumed than implemented. It wraps C<around>
|
||||
the C<read_manifest> method in the consuming class, and "desugars" the contents
|
||||
of the loaded manifest before returning it.
|
||||
|
||||
At present, desugaring is what allows the C<type> attribute in attachments and
|
||||
alternatives to be given instead of a C<content_type> entry in the
|
||||
C<attributes> entry. In other words, desugaring turns:
|
||||
|
||||
{
|
||||
header => [ ... ],
|
||||
type => 'text/plain',
|
||||
}
|
||||
|
||||
Into:
|
||||
|
||||
{
|
||||
header => [ ... ],
|
||||
attributes => { content_type => 'text/plain' },
|
||||
}
|
||||
|
||||
More behavior may be added to the desugarer later.
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Ricardo Signes <rjbs@cpan.org>
|
||||
|
||||
=head1 COPYRIGHT AND LICENSE
|
||||
|
||||
This software is copyright (c) 2018 by Ricardo Signes.
|
||||
|
||||
This is free software; you can redistribute it and/or modify it under
|
||||
the same terms as the Perl 5 programming language system itself.
|
||||
|
||||
=cut
|
||||
55
database/perl/vendor/lib/Email/MIME/Kit/Role/ManifestReader.pm
vendored
Normal file
55
database/perl/vendor/lib/Email/MIME/Kit/Role/ManifestReader.pm
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
package Email::MIME::Kit::Role::ManifestReader;
|
||||
# ABSTRACT: things that read kit manifests
|
||||
$Email::MIME::Kit::Role::ManifestReader::VERSION = '3.000006';
|
||||
use Moose::Role;
|
||||
with 'Email::MIME::Kit::Role::Component';
|
||||
|
||||
#pod =head1 IMPLEMENTING
|
||||
#pod
|
||||
#pod This role also performs L<Email::MIME::Kit::Role::Component>.
|
||||
#pod
|
||||
#pod Classes implementing this role must provide a C<read_manifest> method, which is
|
||||
#pod expected to locate and read a manifest for the kit. Classes implementing this
|
||||
#pod role should probably include L<Email::MIME::Kit::Role::ManifestDesugarer>, too.
|
||||
#pod
|
||||
#pod =cut
|
||||
|
||||
requires 'read_manifest';
|
||||
|
||||
no Moose::Role;
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=pod
|
||||
|
||||
=encoding UTF-8
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Email::MIME::Kit::Role::ManifestReader - things that read kit manifests
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
version 3.000006
|
||||
|
||||
=head1 IMPLEMENTING
|
||||
|
||||
This role also performs L<Email::MIME::Kit::Role::Component>.
|
||||
|
||||
Classes implementing this role must provide a C<read_manifest> method, which is
|
||||
expected to locate and read a manifest for the kit. Classes implementing this
|
||||
role should probably include L<Email::MIME::Kit::Role::ManifestDesugarer>, too.
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Ricardo Signes <rjbs@cpan.org>
|
||||
|
||||
=head1 COPYRIGHT AND LICENSE
|
||||
|
||||
This software is copyright (c) 2018 by Ricardo Signes.
|
||||
|
||||
This is free software; you can redistribute it and/or modify it under
|
||||
the same terms as the Perl 5 programming language system itself.
|
||||
|
||||
=cut
|
||||
59
database/perl/vendor/lib/Email/MIME/Kit/Role/Renderer.pm
vendored
Normal file
59
database/perl/vendor/lib/Email/MIME/Kit/Role/Renderer.pm
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
package Email::MIME::Kit::Role::Renderer;
|
||||
# ABSTRACT: things that render templates into contents
|
||||
$Email::MIME::Kit::Role::Renderer::VERSION = '3.000006';
|
||||
use Moose::Role;
|
||||
with 'Email::MIME::Kit::Role::Component';
|
||||
|
||||
#pod =head1 IMPLEMENTING
|
||||
#pod
|
||||
#pod This role also performs L<Email::MIME::Kit::Role::Component>.
|
||||
#pod
|
||||
#pod Classes implementing this role must provide a C<render> method, which is
|
||||
#pod expected to turn a template and arguments into rendered output. The method is
|
||||
#pod used like this:
|
||||
#pod
|
||||
#pod my $output_ref = $renderer->render($input_ref, \%arg);
|
||||
#pod
|
||||
#pod =cut
|
||||
|
||||
requires 'render';
|
||||
|
||||
no Moose::Role;
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=pod
|
||||
|
||||
=encoding UTF-8
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Email::MIME::Kit::Role::Renderer - things that render templates into contents
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
version 3.000006
|
||||
|
||||
=head1 IMPLEMENTING
|
||||
|
||||
This role also performs L<Email::MIME::Kit::Role::Component>.
|
||||
|
||||
Classes implementing this role must provide a C<render> method, which is
|
||||
expected to turn a template and arguments into rendered output. The method is
|
||||
used like this:
|
||||
|
||||
my $output_ref = $renderer->render($input_ref, \%arg);
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Ricardo Signes <rjbs@cpan.org>
|
||||
|
||||
=head1 COPYRIGHT AND LICENSE
|
||||
|
||||
This software is copyright (c) 2018 by Ricardo Signes.
|
||||
|
||||
This is free software; you can redistribute it and/or modify it under
|
||||
the same terms as the Perl 5 programming language system itself.
|
||||
|
||||
=cut
|
||||
60
database/perl/vendor/lib/Email/MIME/Kit/Role/Validator.pm
vendored
Normal file
60
database/perl/vendor/lib/Email/MIME/Kit/Role/Validator.pm
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
package Email::MIME::Kit::Role::Validator;
|
||||
# ABSTRACT: things that validate assembly parameters
|
||||
$Email::MIME::Kit::Role::Validator::VERSION = '3.000006';
|
||||
use Moose::Role;
|
||||
|
||||
#pod =head1 IMPLEMENTING
|
||||
#pod
|
||||
#pod This role also performs L<Email::MIME::Kit::Role::Component>.
|
||||
#pod
|
||||
#pod Classes implementing this role are used to validate that the arguments passed
|
||||
#pod to C<< $mkit->assemble >> are valid. Classes must provide a C<validate> method
|
||||
#pod which will be called with the hashref of values passed to the kit's C<assemble>
|
||||
#pod method. If the arguments are not valid for the kit, the C<validate> method
|
||||
#pod should raise an exception.
|
||||
#pod
|
||||
#pod =cut
|
||||
|
||||
with 'Email::MIME::Kit::Role::Component';
|
||||
|
||||
requires 'validate';
|
||||
|
||||
no Moose::Role;
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=pod
|
||||
|
||||
=encoding UTF-8
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Email::MIME::Kit::Role::Validator - things that validate assembly parameters
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
version 3.000006
|
||||
|
||||
=head1 IMPLEMENTING
|
||||
|
||||
This role also performs L<Email::MIME::Kit::Role::Component>.
|
||||
|
||||
Classes implementing this role are used to validate that the arguments passed
|
||||
to C<< $mkit->assemble >> are valid. Classes must provide a C<validate> method
|
||||
which will be called with the hashref of values passed to the kit's C<assemble>
|
||||
method. If the arguments are not valid for the kit, the C<validate> method
|
||||
should raise an exception.
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Ricardo Signes <rjbs@cpan.org>
|
||||
|
||||
=head1 COPYRIGHT AND LICENSE
|
||||
|
||||
This software is copyright (c) 2018 by Ricardo Signes.
|
||||
|
||||
This is free software; you can redistribute it and/or modify it under
|
||||
the same terms as the Perl 5 programming language system itself.
|
||||
|
||||
=cut
|
||||
Reference in New Issue
Block a user