r29913 - in /trunk/libemail-mime-creator-perl: Changes META.yml Makefile.PL README lib/Email/MIME/Creator.pm t/auto_create.t
dmn at users.alioth.debian.org
dmn at users.alioth.debian.org
Wed Jan 21 20:29:33 UTC 2009
Author: dmn
Date: Wed Jan 21 20:29:30 2009
New Revision: 29913
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=29913
Log:
really apply 1.454 -> 1.455 changes in trunk
Modified:
trunk/libemail-mime-creator-perl/Changes
trunk/libemail-mime-creator-perl/META.yml
trunk/libemail-mime-creator-perl/Makefile.PL
trunk/libemail-mime-creator-perl/README
trunk/libemail-mime-creator-perl/lib/Email/MIME/Creator.pm
trunk/libemail-mime-creator-perl/t/auto_create.t
Modified: trunk/libemail-mime-creator-perl/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libemail-mime-creator-perl/Changes?rev=29913&op=diff
==============================================================================
--- trunk/libemail-mime-creator-perl/Changes (original)
+++ trunk/libemail-mime-creator-perl/Changes Wed Jan 21 20:29:30 2009
@@ -1,0 +1,35 @@
+Revision history for Email-MIME-Creator
+
+1.455 2009-01-20
+ fix a horrendous bug that would let you end up with:
+ Content-Type: image/jpeg; charset="utf-8"
+
+1.454 2007-07-14
+ fix some spurious "Date" headers in badly-written tests
+
+1.453 2007-04-19
+ fix a bizarre test that broke on some OSes (at least some Win32's)
+ thanks to "chris" for the report!
+
+1.452 2007-03-22
+ packaging improvements
+
+1.451 2006-08-04
+ require Email::MIME::Modifier 1.440 to avoid bug
+
+1.45 2006-07-06
+ better detection of non-7bit parts
+ don't base64-encode 7bit parts
+
+1.41 2004-12-23
+ Parts can now be automatically created from non-reference strings when
+ calling create(), using parts => [], for generating multi-part
+ messages. Parts default to 'text/plain' unless they appear to be
+ binary, then they're 'application/x-binary'.
+
+1.3 2004-09-25
+ Minor documentation nits.
+ Makefile.PL dependency fixes.
+
+1.1 2004-07-05
+ Initial version.
Modified: trunk/libemail-mime-creator-perl/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libemail-mime-creator-perl/META.yml?rev=29913&op=diff
==============================================================================
--- trunk/libemail-mime-creator-perl/META.yml (original)
+++ trunk/libemail-mime-creator-perl/META.yml Wed Jan 21 20:29:30 2009
@@ -1,0 +1,26 @@
+--- #YAML:1.0
+name: Email-MIME-Creator
+version: 1.455
+abstract: Email::MIME constructor for starting anew
+author:
+ - Ricardo SIGNES <rjbs at cpan.org>
+license: perl
+distribution_type: module
+configure_requires:
+ ExtUtils::MakeMaker: 0
+requires:
+ Email::MIME: 1.82
+ Email::MIME::Modifier: 1.440
+ Email::Simple: 1.92
+ Email::Simple::Creator: 1.4
+ Test::More: 0.47
+resources:
+ Repository: http://github.com/rjbs/email-mime-creator
+no_index:
+ directory:
+ - t
+ - inc
+generated_by: ExtUtils::MakeMaker version 6.48
+meta-spec:
+ url: http://module-build.sourceforge.net/META-spec-v1.4.html
+ version: 1.4
Modified: trunk/libemail-mime-creator-perl/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libemail-mime-creator-perl/Makefile.PL?rev=29913&op=diff
==============================================================================
--- trunk/libemail-mime-creator-perl/Makefile.PL (original)
+++ trunk/libemail-mime-creator-perl/Makefile.PL Wed Jan 21 20:29:30 2009
@@ -1,0 +1,24 @@
+use ExtUtils::MakeMaker;
+
+WriteMakefile (
+ AUTHOR => 'Ricardo SIGNES <rjbs at cpan.org>',
+ ABSTRACT => "Email::MIME constructor for starting anew",
+ NAME => 'Email::MIME::Creator',
+ (eval { ExtUtils::MakeMaker->VERSION(6.21) } ? (LICENSE => 'perl') : ()),
+ PREREQ_PM => {
+ 'Email::MIME' => '1.82',
+ 'Email::MIME::Modifier' => '1.440', # allow forced multipart
+ 'Email::Simple' => '1.92',
+ 'Email::Simple::Creator' => '1.4',
+ 'Test::More' => '0.47',
+ },
+ VERSION_FROM => 'lib/Email/MIME/Creator.pm',
+ (eval { ExtUtils::MakeMaker->VERSION(6.46) }
+ ? (META_MERGE => {
+ resources => {
+ Repository => 'http://github.com/rjbs/email-mime-creator'
+ }
+ })
+ : ()
+ ),
+);
Modified: trunk/libemail-mime-creator-perl/README
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libemail-mime-creator-perl/README?rev=29913&op=diff
==============================================================================
--- trunk/libemail-mime-creator-perl/README (original)
+++ trunk/libemail-mime-creator-perl/README Wed Jan 21 20:29:30 2009
@@ -1,0 +1,13 @@
+README for Email-MIME-Creator 1.455
+
+This is a library to allow the creation of MIME messages from Perl data.
+
+Consult its POD for more information.
+
+To install:
+
+ perl Makefile.PL
+ make
+ make test
+ sudo make install
+
Modified: trunk/libemail-mime-creator-perl/lib/Email/MIME/Creator.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libemail-mime-creator-perl/lib/Email/MIME/Creator.pm?rev=29913&op=diff
==============================================================================
--- trunk/libemail-mime-creator-perl/lib/Email/MIME/Creator.pm (original)
+++ trunk/libemail-mime-creator-perl/lib/Email/MIME/Creator.pm Wed Jan 21 20:29:30 2009
@@ -1,0 +1,232 @@
+package Email::MIME::Creator;
+use strict;
+
+use vars qw[$VERSION];
+$VERSION = '1.455';
+
+use base q[Email::Simple::Creator];
+use Email::MIME;
+
+sub _construct_part {
+ my ($class, $body) = @_;
+
+ my $is_binary = $body =~ /[\x00\x80-\xFF]/;
+
+ my $content_type = $is_binary
+ ? 'application/x-binary'
+ : 'text/plain';
+
+ Email::MIME->create(
+ attributes => {
+ content_type => $content_type,
+ encoding => ($is_binary ? 'base64' : ''), # be safe
+ },
+ body => $body,
+ );
+}
+
+package Email::MIME;
+use strict;
+
+use vars qw[$CREATOR];
+$CREATOR = 'Email::MIME::Creator';
+
+use Email::MIME::Modifier;
+
+sub create {
+ my ($class, %args) = @_;
+
+ my $header = '';
+ my %headers;
+ if (exists $args{header}) {
+ my @headers = @{ $args{header} };
+ pop @headers if @headers % 2 == 1;
+ while (my ($key, $value) = splice @headers, 0, 2) {
+ $headers{$key} = 1;
+ $CREATOR->_add_to_header(\$header, $key, $value);
+ }
+ }
+ $CREATOR->_add_to_header(\$header, Date => $CREATOR->_date_header)
+ unless exists $headers{Date};
+ $CREATOR->_add_to_header(\$header, 'MIME-Version' => '1.0',);
+
+ my %attrs = $args{attributes} ? %{ $args{attributes} } : ();
+
+ # XXX: This is awful... but if we don't do this, then Email::MIME->new will
+ # end up calling parse_content_type($self->content_type) which will mean
+ # parse_content_type(undef) which, for some reason, returns the default.
+ # It's really sort of mind-boggling. Anyway, the default ends up being
+ # q{text/plain; charset="us-ascii"} so that if content_type is in the
+ # attributes, but not charset, then charset isn't changedand you up with
+ # something that's q{image/jpeg; charset="us-ascii"} and you look like a
+ # moron. -- rjbs, 2009-01-20
+ if (grep {exists $attrs{$_}} qw(content_type charset name format boundary)) {
+ $CREATOR->_add_to_header(\$header, 'Content-Type' => 'text/plain',);
+ }
+
+ my $email = $class->new($header);
+
+ foreach (
+ qw[content_type charset name format boundary
+ encoding
+ disposition filename]
+ )
+ {
+ my $set = "$_\_set";
+ $email->$set($attrs{$_}) if exists $attrs{$_};
+ }
+
+ if ($args{parts} && @{ $args{parts} }) {
+ foreach my $part (@{ $args{parts} }) {
+ $part = $CREATOR->_construct_part($part)
+ unless ref($part);
+ }
+ $email->parts_set($args{parts});
+ } elsif (exists $args{body}) {
+ $email->body_set($args{body});
+ }
+
+ $email;
+}
+
+1;
+
+__END__
+
+=head1 NAME
+
+Email::MIME::Creator - Email::MIME constructor for starting anew.
+
+=head1 SYNOPSIS
+
+ use Email::MIME::Creator;
+ use IO::All;
+
+ # multipart message
+ my @parts = (
+ Email::MIME->create(
+ attributes => {
+ filename => "report.pdf",
+ content_type => "application/pdf",
+ encoding => "quoted-printable",
+ name => "2004-financials.pdf",
+ },
+ body => io( "2004-financials.pdf" )->all,
+ ),
+ Email::MIME->create(
+ attributes => {
+ content_type => "text/plain",
+ disposition => "attachment",
+ charset => "US-ASCII",
+ },
+ body => "Hello there!",
+ ),
+ );
+
+ my $email = Email::MIME->create(
+ header => [ From => 'casey at geeknest.com' ],
+ parts => [ @parts ],
+ );
+
+ # nesting parts
+ $email->parts_set(
+ [
+ $email->parts,
+ Email::MIME->create( parts => [ @parts ] ),
+ ],
+ );
+
+ # standard modifications
+ $email->header_set( 'X-PoweredBy' => 'RT v3.0' );
+ $email->header_set( To => rcpts() );
+ $email->header_set( Cc => aux_rcpts() );
+ $email->header_set( Bcc => sekrit_rcpts() );
+
+ # more advanced
+ $_->encoding_set( 'base64' ) for $email->parts;
+
+ # Quick multipart creation
+ my $quicky = Email::MIME->create(
+ header => [
+ From => 'my at address',
+ To => 'your at address',
+ ],
+ parts => [
+ q[This is part one],
+ q[This is part two],
+ q[These could be binary too],
+ ],
+ );
+
+ print $email->as_string;
+
+ *rcpts = *aux_rcpts = *sekrit_rcpts = sub { 'you at example.com' };
+
+=head1 DESCRIPTION
+
+=head2 Methods
+
+=over 5
+
+=item create
+
+ my $single = Email::MIME->create(
+ header => [ ... ],
+ attributes => { ... },
+ body => '...',
+ );
+
+ my $multi = Email::MIME->create(
+ header => [ ... ],
+ attributes => { ... },
+ parts => [ ... ],
+ );
+
+This method creates a new MIME part. The C<header> parameter is a lis of
+headers to include in the message. C<attributes> is a hash of MIME
+attributes to assign to the part, and may override portions of the
+header set in the C<header> parameter.
+
+The C<parts> parameter is a list reference containing C<Email::MIME>
+objects. Elements of the C<parts> list can also be a non-reference
+string of data. In that case, an C<Email::MIME> object will be created
+for you. Simple checks will determine if the part is binary or not, and
+all parts created in this fashion are encoded with C<base64>, just in case.
+
+C<parts> takes precedence over C<body>, which will set this part's body
+if assigned. So, multi part messages shold use the C<parts> parameter
+and single part messages should use C<body>.
+
+Back to C<attributes>. The hash keys correspond directly to methods or
+modifying a message from C<Email::MIME::Modifier>. The allowed keys are:
+content_type, charset, name, format, boundary, encoding, disposition,
+and filename. They will be mapped to C<"$attr\_set"> for message
+modification.
+
+=back
+
+=head1 SEE ALSO
+
+L<Email::MIME>,
+L<Email::MIME::Modifier>,
+L<Email::Simple::Creator>,
+C<IO::All> or C<File::Slurp> (for file slurping to create parts from strings),
+L<perl>.
+
+=head1 PERL EMAIL PROJECT
+
+This module is maintained by the Perl Email Project.
+
+L<http://emailproject.perl.org/wiki/Email::MIME::Creator>
+
+=head1 ORIGINAL AUTHOR
+
+B<Do not send bug reports to>: Casey West, <F<casey at geeknest.com>>.
+
+=head1 COPYRIGHT
+
+ Copyright (c) 2004 Casey West. All rights reserved.
+ This module is free software; you can redistribute it and/or modify it
+ under the same terms as Perl itself.
+
+=cut
Modified: trunk/libemail-mime-creator-perl/t/auto_create.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libemail-mime-creator-perl/t/auto_create.t?rev=29913&op=diff
==============================================================================
--- trunk/libemail-mime-creator-perl/t/auto_create.t (original)
+++ trunk/libemail-mime-creator-perl/t/auto_create.t Wed Jan 21 20:29:30 2009
@@ -1,0 +1,35 @@
+use Test::More qw[no_plan];
+use strict;
+$^W = 1;
+
+use_ok 'Email::MIME::Creator';
+
+my $email = Email::MIME->create(
+ header => [
+ From => 'me',
+ To => 'you',
+ Subject => 'test',
+ ],
+ parts => [
+ q[Part one],
+ q[Part two],
+ generate_binary_data(),
+ ],
+);
+
+isa_ok $email, 'Email::MIME';
+is scalar($email->parts), 3, 'two parts';
+
+my @parts = $email->parts;
+
+isa_ok $_, 'Email::MIME' for @parts;
+
+like $parts[0]->body, qr/Part one/;
+like $parts[1]->body, qr/Part two/;
+
+like $parts[2]->content_type, qr/binary/, 'third part is binary';
+
+sub generate_binary_data {
+ my $string = join '', map { chr } 1 .. 255;
+ return $string;
+}
More information about the Pkg-perl-cvs-commits
mailing list