r46776 - in /branches/upstream/libemail-simple-perl/current: Changes MANIFEST META.yml Makefile.PL lib/Email/Simple.pm lib/Email/Simple/Creator.pm lib/Email/Simple/Header.pm t/create.t t/perl-minver.t
nhandler-guest at users.alioth.debian.org
nhandler-guest at users.alioth.debian.org
Thu Nov 5 04:33:46 UTC 2009
Author: nhandler-guest
Date: Thu Nov 5 04:33:40 2009
New Revision: 46776
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=46776
Log:
[svn-upgrade] Integrating new upstream version, libemail-simple-perl (2.100)
Added:
branches/upstream/libemail-simple-perl/current/lib/Email/Simple/Creator.pm
branches/upstream/libemail-simple-perl/current/t/create.t
Modified:
branches/upstream/libemail-simple-perl/current/Changes
branches/upstream/libemail-simple-perl/current/MANIFEST
branches/upstream/libemail-simple-perl/current/META.yml
branches/upstream/libemail-simple-perl/current/Makefile.PL
branches/upstream/libemail-simple-perl/current/lib/Email/Simple.pm
branches/upstream/libemail-simple-perl/current/lib/Email/Simple/Header.pm
branches/upstream/libemail-simple-perl/current/t/perl-minver.t
Modified: branches/upstream/libemail-simple-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libemail-simple-perl/current/Changes?rev=46776&op=diff
==============================================================================
--- branches/upstream/libemail-simple-perl/current/Changes (original)
+++ branches/upstream/libemail-simple-perl/current/Changes Thu Nov 5 04:33:40 2009
@@ -1,4 +1,7 @@
Revision history for Perl extension Email::Simple.
+
+2.100 2009-11-03
+ merge Email-Simple-Creator into Email-Simple distribution
2.005 2009-01-22
add repository metadata
Modified: branches/upstream/libemail-simple-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libemail-simple-perl/current/MANIFEST?rev=46776&op=diff
==============================================================================
--- branches/upstream/libemail-simple-perl/current/MANIFEST (original)
+++ branches/upstream/libemail-simple-perl/current/MANIFEST Thu Nov 5 04:33:40 2009
@@ -1,11 +1,14 @@
Changes
lib/Email/Simple.pm
+lib/Email/Simple/Creator.pm
lib/Email/Simple/Header.pm
+LICENSE
Makefile.PL
MANIFEST
README
t/badly-folded.t
t/basic.t
+t/create.t
t/ct-header.t
t/folding.t
t/header-case.t
@@ -34,5 +37,4 @@
t/test-mails/many-repeats
t/undef-message.t
t/unit.t
-LICENSE
META.yml Module meta-data (added by MakeMaker)
Modified: branches/upstream/libemail-simple-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libemail-simple-perl/current/META.yml?rev=46776&op=diff
==============================================================================
--- branches/upstream/libemail-simple-perl/current/META.yml (original)
+++ branches/upstream/libemail-simple-perl/current/META.yml Thu Nov 5 04:33:40 2009
@@ -1,21 +1,24 @@
--- #YAML:1.0
name: Email-Simple
-version: 2.005
+version: 2.100
abstract: ~
author: []
license: perl
distribution_type: module
configure_requires:
ExtUtils::MakeMaker: 0
+build_requires:
+ ExtUtils::MakeMaker: 0
requires:
- Test::More: 0.47
+ Email::Date::Format: 0
+ Test::More: 0.47
resources:
Repository: http://github.com/rjbs/email-simple
no_index:
directory:
- t
- inc
-generated_by: ExtUtils::MakeMaker version 6.48
+generated_by: ExtUtils::MakeMaker version 6.55_02
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
version: 1.4
Modified: branches/upstream/libemail-simple-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libemail-simple-perl/current/Makefile.PL?rev=46776&op=diff
==============================================================================
--- branches/upstream/libemail-simple-perl/current/Makefile.PL (original)
+++ branches/upstream/libemail-simple-perl/current/Makefile.PL Thu Nov 5 04:33:40 2009
@@ -6,7 +6,6 @@
# This is so stupid! We need to make sure that Email::MIME, a downstream
# module, is running a version that doesn't screw around with the guts of
# Email::Simple.
-my @prereq;
if (eval { require Email::MIME }) {
unless (eval { Email::MIME->VERSION(1.857) }) {
warn <<END_ACHTUNG;
@@ -25,8 +24,8 @@
VERSION_FROM => 'lib/Email/Simple.pm',
(eval { ExtUtils::MakeMaker->VERSION(6.21) } ? (LICENSE => 'perl') : ()),
PREREQ_PM => {
- @prereq,
'Test::More' => '0.47',
+ 'Email::Date::Format' => 0,
},
(eval { ExtUtils::MakeMaker->VERSION(6.46) }
? (META_MERGE => {
Modified: branches/upstream/libemail-simple-perl/current/lib/Email/Simple.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libemail-simple-perl/current/lib/Email/Simple.pm?rev=46776&op=diff
==============================================================================
--- branches/upstream/libemail-simple-perl/current/lib/Email/Simple.pm (original)
+++ branches/upstream/libemail-simple-perl/current/lib/Email/Simple.pm Thu Nov 5 04:33:40 2009
@@ -1,13 +1,15 @@
+use 5.006;
+use strict;
+use warnings;
package Email::Simple;
-use 5.00503; # why? -- rjbs, 2007-04-01
-use strict;
use Carp ();
+use Email::Simple::Creator;
use Email::Simple::Header;
-$Email::Simple::VERSION = '2.005';
-$Email::Simple::GROUCHY = 0;
+our $VERSION = '2.100';
+our $GROUCHY = 0;
# We are liberal in what we accept.
sub __crlf_re { qr/\x0a\x0d|\x0d\x0a|\x0a|\x0d/; }
@@ -28,6 +30,21 @@
my $old_body = $email->body;
$email->body_set("Hello world\nSimon");
+ print $email->as_string;
+
+...or, to create a message from scratch...
+
+ my $email = Email::Simple->create(
+ header => [
+ From => 'casey at geeknest.com',
+ To => 'drain at example.com',
+ Subject => 'Message in a bottle',
+ ],
+ body => '...',
+ );
+
+ $email->header_set( 'X-Content-Container' => 'bottle/glass' );
+
print $email->as_string;
=head1 DESCRIPTION
@@ -109,6 +126,58 @@
}
}
+=head2 create
+
+ my $email = Email::Simple->create(header => [ @headers ], body => '...');
+
+This method is a constructor that creates an Email::Simple object
+from a set of named parameters. The C<header> parameter's value is a
+list reference containing a set of headers to be created. The C<body>
+parameter's value is a scalar value holding the contents of the message
+body. Line endings in the body will normalized to CRLF.
+
+If no C<Date> header is specified, one will be provided for you based on the
+C<gmtime> of the local machine. This is because the C<Date> field is a required
+header and is a pain in the neck to create manually for every message. The
+C<From> field is also a required header, but it is I<not> provided for you.
+
+=cut
+
+our $CREATOR = 'Email::Simple::Creator';
+
+sub create {
+ my ($class, %args) = @_;
+
+ # We default it in here as well as below because by having it here, then we
+ # know that if there are no other headers, we'll get the proper CRLF.
+ # Otherwise, we get a message with incorrect CRLF. -- rjbs, 2007-07-13
+ my $headers = $args{header} || [ Date => $CREATOR->_date_header ];
+ my $body = $args{body} || '';
+
+ my $empty = q{};
+ my $header = \$empty;
+
+ for my $idx (map { $_ * 2 } 0 .. @$headers / 2 - 1) {
+ my ($key, $value) = @$headers[ $idx, $idx + 1 ];
+ $CREATOR->_add_to_header($header, $key, $value);
+ }
+
+ $CREATOR->_finalize_header($header);
+
+ my $email = $class->new($header);
+
+ $email->header_set(Date => $CREATOR->_date_header)
+ unless defined $email->header('Date');
+
+ $body = (join $CREATOR->_crlf, split /\x0d\x0a|\x0a\x0d|\x0a|\x0d/, $body)
+ . $CREATOR->_crlf;
+
+ $email->body_set($body);
+
+ return $email;
+}
+
+
=head2 header_obj
my $header = $email->header_obj;
@@ -155,7 +224,8 @@
$email->header_set($field, $line1, $line2, ...);
Sets the header to contain the given data. If you pass multiple lines
-in, you get multiple headers, and order is retained.
+in, you get multiple headers, and order is retained. If no values are given to
+set, the header will be removed from to the message entirely.
=head2 header_names
Added: branches/upstream/libemail-simple-perl/current/lib/Email/Simple/Creator.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libemail-simple-perl/current/lib/Email/Simple/Creator.pm?rev=46776&op=file
==============================================================================
--- branches/upstream/libemail-simple-perl/current/lib/Email/Simple/Creator.pm (added)
+++ branches/upstream/libemail-simple-perl/current/lib/Email/Simple/Creator.pm Thu Nov 5 04:33:40 2009
@@ -1,0 +1,53 @@
+use strict;
+use warnings;
+package Email::Simple::Creator;
+
+our $VERSION = '2.100';
+
+sub _crlf {
+ "\x0d\x0a";
+}
+
+sub _date_header {
+ require Email::Date::Format;
+ Email::Date::Format::email_date();
+}
+
+sub _add_to_header {
+ my ($class, $header, $key, $value) = @_;
+ $value = '' unless defined $value;
+ $$header .= "$key: $value" . $class->_crlf;
+}
+
+sub _finalize_header {
+ my ($class, $header) = @_;
+ $$header .= $class->_crlf;
+}
+
+1;
+
+__END__
+
+=head1 NAME
+
+Email::Simple::Creator - private helper for building Email::Simple objects
+
+=head1 PERL EMAIL PROJECT
+
+This module is maintained by the Perl Email Project
+
+L<http://emailproject.perl.org/wiki/Email::Simple::Creator>
+
+=head1 AUTHORS
+
+Casey West originally wrote Email::Simple::Creator in 2004. Ricardo SIGNES
+took over maintenance in 2006.
+
+=head1 COPYRIGHT AND LICENSE
+
+Copyright (c) 2004 Casey West.
+
+This library is free software; you can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+=cut
Modified: branches/upstream/libemail-simple-perl/current/lib/Email/Simple/Header.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libemail-simple-perl/current/lib/Email/Simple/Header.pm?rev=46776&op=diff
==============================================================================
--- branches/upstream/libemail-simple-perl/current/lib/Email/Simple/Header.pm (original)
+++ branches/upstream/libemail-simple-perl/current/lib/Email/Simple/Header.pm Thu Nov 5 04:33:40 2009
@@ -185,7 +185,8 @@
$header->header_set($field => @values);
This method updates the value of the given header. Existing headers have their
-values set in place. Additional headers are added at the end.
+values set in place. Additional headers are added at the end. If no values
+are given to set, the header will be removed from to the message entirely.
=cut
Added: branches/upstream/libemail-simple-perl/current/t/create.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libemail-simple-perl/current/t/create.t?rev=46776&op=file
==============================================================================
--- branches/upstream/libemail-simple-perl/current/t/create.t (added)
+++ branches/upstream/libemail-simple-perl/current/t/create.t Thu Nov 5 04:33:40 2009
@@ -1,0 +1,154 @@
+use strict;
+use warnings;
+
+use Test::More tests => 25;
+
+use_ok 'Email::Simple';
+use_ok 'Email::Simple::Creator';
+
+sub tested_email {
+ my ($name, %args) = @_;
+
+ my $email = Email::Simple->create(%args);
+ isa_ok $email, 'Email::Simple', "$name message";
+
+ my $string = $email->as_string;
+
+ my @last_two = (
+ substr($string, -2, 1),
+ substr($string, -1, 1),
+ );
+
+ is(
+ sprintf("%03u %03u", map { ord } @last_two),
+ '013 010',
+ "$name: stringified message ends with std CRLF"
+ );
+
+ unlike(
+ $email->as_string,
+ qr/(?<!\x0d)\x0a/,
+ "$name: message has no LF that aren't preceded by CR",
+ );
+
+ return $email;
+}
+
+{
+ my $body = "This body uses\x0d"
+ . "LF only, and not\x0d"
+ . "CRLF like it might ought to do.";
+
+ tested_email(crlf =>
+ body => $body,
+ header => [
+ Subject => 'all tests and no code make rjbs something something',
+ From => 'jack',
+ To => 'sissy',
+ ],
+ );
+}
+
+{ # should get an automatic date header
+ my $email = tested_email(auto_date =>
+ header => [
+ To => 'you',
+ ],
+ body => 'test test',
+ );
+
+ like(
+ $email->header('date'),
+ qr/^[A-Z][a-z]{2},/, # lame -- rjbs, 2007-02-23
+ "we got an auto-generated date header starting with a DOW",
+ );
+}
+
+{ # who needs args? (why is this legal? who knows -- rjbs, 2007-07-13)
+ my $email = tested_email('argless');
+
+ like(
+ $email->header('date'),
+ qr/^[A-Z][a-z]{2},/, # lame -- rjbs, 2007-02-23
+ "we got an auto-generated date header starting with a DOW",
+ );
+}
+
+{ # no need to add CRLF if it's there
+ my $email = tested_email(has_crlf =>
+ header => [
+ To => 'you',
+ ],
+ body => "test test\x0d\x0a",
+ );
+}
+
+{ # no date header, we provided one
+ my $email = tested_email(has_date =>
+ header => [
+ Date => 'testing',
+ 'X-Header' => 'one',
+ 'X-Header' => 'two',
+ 'X-Header' => 'three',
+ ],
+ body => q[This is a multi-
+ line message.],
+ );
+
+ my $expected = <<'END_MESSAGE';
+Date: testing
+X-Header: one
+X-Header: two
+X-Header: three
+
+This is a multi-
+ line message.
+END_MESSAGE
+
+ my $string = $email->as_string;
+ $string =~ s/\x0d\x0a/\n/gsm;
+
+ is(
+ $string,
+ $expected,
+ "we got just the string we expected",
+ );
+}
+
+{ # a few headers with false values
+ my $email = tested_email(falsies =>
+ header => [
+ Date => undef,
+ Zero => 0,
+ Empty => '',
+ ],
+ body => "The body is uninteresting.",
+ );
+
+ is_deeply(
+ [ $email->header_pairs ],
+ [
+ Date => '',
+ Zero => 0,
+ Empty => '',
+ ],
+ "got the false headers back we want",
+ );
+
+ my $expected = <<'END_MESSAGE';
+Date:
+Zero: 0
+Empty:
+
+The body is uninteresting.
+END_MESSAGE
+
+ my $string = $email->as_string;
+ $string =~ s/\x0d\x0a/\n/gsm;
+
+ is(
+ $string,
+ $expected,
+ "we got just the string we expected",
+ );
+}
Modified: branches/upstream/libemail-simple-perl/current/t/perl-minver.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libemail-simple-perl/current/t/perl-minver.t?rev=46776&op=diff
==============================================================================
--- branches/upstream/libemail-simple-perl/current/t/perl-minver.t (original)
+++ branches/upstream/libemail-simple-perl/current/t/perl-minver.t Thu Nov 5 04:33:40 2009
@@ -10,4 +10,4 @@
plan skip_all => "this test requires Test::MinimumVersion" if $@;
-all_minimum_version_ok(5.00503);
+all_minimum_version_ok(5.006);
More information about the Pkg-perl-cvs-commits
mailing list