r3551 - in
/packages/libemail-simple-perl/branches/upstream/current: Changes
MANIFEST META.yml lib/Email/Simple.pm lib/Email/Simple/
lib/Email/Simple/Headers.pm t/header-names.t t/header-pairs.t
t/pod-coverage.t t/preserve-linefeed.t
eloy at users.alioth.debian.org
eloy at users.alioth.debian.org
Thu Aug 31 13:26:43 UTC 2006
Author: eloy
Date: Thu Aug 31 13:26:42 2006
New Revision: 3551
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=3551
Log:
Load /tmp/tmp.HGVlP21393/libemail-simple-perl-1.980 into
packages/libemail-simple-perl/branches/upstream/current.
Added:
packages/libemail-simple-perl/branches/upstream/current/lib/Email/Simple/
packages/libemail-simple-perl/branches/upstream/current/lib/Email/Simple/Headers.pm
packages/libemail-simple-perl/branches/upstream/current/t/header-names.t
packages/libemail-simple-perl/branches/upstream/current/t/header-pairs.t
packages/libemail-simple-perl/branches/upstream/current/t/preserve-linefeed.t
Modified:
packages/libemail-simple-perl/branches/upstream/current/Changes
packages/libemail-simple-perl/branches/upstream/current/MANIFEST
packages/libemail-simple-perl/branches/upstream/current/META.yml
packages/libemail-simple-perl/branches/upstream/current/lib/Email/Simple.pm
packages/libemail-simple-perl/branches/upstream/current/t/pod-coverage.t
Modified: packages/libemail-simple-perl/branches/upstream/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libemail-simple-perl/branches/upstream/current/Changes?rev=3551&op=diff
==============================================================================
--- packages/libemail-simple-perl/branches/upstream/current/Changes (original)
+++ packages/libemail-simple-perl/branches/upstream/current/Changes Thu Aug 31 13:26:42 2006
@@ -1,4 +1,13 @@
Revision history for Perl extension Email::Simple.
+
+1.980 2006-08-17
+
+ - fix _fold() to add a missing line ending [RT #20764] (Brian Cassidy)
+
+1.970 2006-08-17
+
+ - bring ->headers method into Email::Simple
+ - ->header_names and ->header_pairs
1.96 2006-07-28
Modified: packages/libemail-simple-perl/branches/upstream/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libemail-simple-perl/branches/upstream/current/MANIFEST?rev=3551&op=diff
==============================================================================
--- packages/libemail-simple-perl/branches/upstream/current/MANIFEST (original)
+++ packages/libemail-simple-perl/branches/upstream/current/MANIFEST Thu Aug 31 13:26:42 2006
@@ -3,16 +3,20 @@
MANIFEST
README
lib/Email/Simple.pm
+lib/Email/Simple/Headers.pm
t/badly-folded.t
t/basic.t
t/folding.t
t/header-case.t
t/header-junk.t
+t/header-names.t
+t/header-pairs.t
t/long-msgid.t
t/many-repeats.t
t/no-body.t
t/pod-coverage.t
t/pod.t
+t/preserve-linefeed.t
t/test-mails/badly-folded
t/test-mails/badly-folded-noindent
t/test-mails/josey-fold
Modified: packages/libemail-simple-perl/branches/upstream/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libemail-simple-perl/branches/upstream/current/META.yml?rev=3551&op=diff
==============================================================================
--- packages/libemail-simple-perl/branches/upstream/current/META.yml (original)
+++ packages/libemail-simple-perl/branches/upstream/current/META.yml Thu Aug 31 13:26:42 2006
@@ -1,7 +1,7 @@
# http://module-build.sourceforge.net/META-spec.html
#XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX#
name: Email-Simple
-version: 1.96
+version: 1.980
version_from: lib/Email/Simple.pm
installdirs: site
requires:
Modified: packages/libemail-simple-perl/branches/upstream/current/lib/Email/Simple.pm
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libemail-simple-perl/branches/upstream/current/lib/Email/Simple.pm?rev=3551&op=diff
==============================================================================
--- packages/libemail-simple-perl/branches/upstream/current/lib/Email/Simple.pm (original)
+++ packages/libemail-simple-perl/branches/upstream/current/lib/Email/Simple.pm Thu Aug 31 13:26:42 2006
@@ -5,10 +5,9 @@
use Carp;
use vars qw($VERSION $GROUCHY);
-$VERSION = '1.96';
+$VERSION = '1.980';
my $crlf = qr/\x0a\x0d|\x0d\x0a|\x0a|\x0d/; # We are liberal in what we accept.
- # But then, so is a six dollar whore.
$GROUCHY = 0;
@@ -18,30 +17,25 @@
=head1 SYNOPSIS
- my $mail = Email::Simple->new($text);
-
- my $from_header = $mail->header("From");
- my @received = $mail->header("Received");
-
- $mail->header_set("From", 'Simon Cozens <simon at cpan.org>');
-
- my $old_body = $mail->body;
- $mail->body_set("Hello world\nSimon");
-
- print $mail->as_string;
-
- # AND THAT'S ALL.
+ my $email = Email::Simple->new($text);
+
+ my $from_header = $email->header("From");
+ my @received = $email->header("Received");
+
+ $email->header_set("From", 'Simon Cozens <simon at cpan.org>');
+
+ my $old_body = $email->body;
+ $email->body_set("Hello world\nSimon");
+
+ print $email->as_string;
=head1 DESCRIPTION
-C<Email::Simple> is the first deliverable of the "Perl Email Project", a
-reaction against the complexity and increasing bugginess of the
-C<Mail::*> modules. In contrast, C<Email::*> modules are meant to be
+C<Email::Simple> is the first deliverable of the "Perl Email Project." The
+Email:: namespace is a reaction against the complexity and increasing bugginess
+of the C<Mail::*> modules. In contrast, C<Email::*> modules are meant to be
simple to use and to maintain, pared to the bone, fast, minimal in their
external dependencies, and correct.
-
- Can you sum up plan 9 in layman's terms?
- It does everything Unix does only less reliably - kt
=head1 METHODS
@@ -103,7 +97,9 @@
# This is a continuation line. We fold it onto the end of
# the previous header.
chomp $head_hash->{$curhead}->[-1];
- $head_hash->{$curhead}->[-1] .= $head_hash->{$curhead}->[-1] ? " $_" : $_;
+ $head_hash->{$curhead}->[-1] .= $head_hash->{$curhead}->[-1]
+ ? " $_"
+ : $_;
} else {
$curhead = $1;
push @{$head_hash->{$curhead}}, $2;
@@ -115,11 +111,11 @@
=head2 header
-Returns a list of the contents of the given header.
-
-If called in scalar context, will return the B<first> header so named.
-I'm not sure I like that. Maybe it should always return a list. But it
-doesn't.
+ my @values = $email->header($header_name);
+ my $first = $email->header($header_name);
+
+In list context, this returns every value for the named header. In scalar
+context, it returns the I<first> value for the named header.
=cut
@@ -132,7 +128,7 @@
=head2 header_set
- $mail->header_set($field, $line1, $line2, ...);
+ $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.
@@ -160,6 +156,43 @@
return wantarray ? @data : $data[0];
}
+=head2 header_names
+
+ my @header_names = $email->header_names;
+
+This method returns the list of header names currently in the email object.
+These names can be passed to the C<header> method one-at-a-time to get header
+values. You are guaranteed to get a set of headers that are unique. You are not
+guaranteed to get the headers in any order at all.
+
+For backwards compatibility, this method can also be called as B<headers>.
+
+=cut
+
+sub header_names {
+ values %{ $_[0]->{header_names} }
+}
+BEGIN { *headers = \&header_names; }
+
+=head2 header_pairs
+
+ my @headers = $email->header_pairs;
+
+=cut
+
+sub header_pairs {
+ my ($self) = @_;
+
+ my @headers;
+ my %seen;
+
+ for my $header (@{$self->{order}}) {
+ push @headers, ($header, $self->{head}{$header}[ $seen{$header}++ ]);
+ }
+
+ return @headers;
+}
+
=head2 body
Returns the body text of the mail.
@@ -196,21 +229,19 @@
sub as_string {
my $self = shift;
- return _headers_as_string($self).$self->{mycrlf}.$self->body;
+ return $self->_headers_as_string
+ . $self->{mycrlf}
+ . $self->body;
}
sub _headers_as_string {
- my $self = shift;
- my @order = @{$self->{order}};
-
- my $header_str = "";
- my %seen;
-
- for my $header (@{$self->{order}}) {
- $header_str .= $self->_header_as_string(
- $header,
- $self->{head}{$header}[ $seen{$header}++ ]
- );
+ my ($self) = @_;
+
+ my $header_str = '';
+ my @pairs = $self->header_pairs;
+
+ while (my ($name, $value) = splice @pairs, 0, 2) {
+ $header_str .= $self->_header_as_string($name, $value);
}
return $header_str;
@@ -225,7 +256,7 @@
my $string = "$field: $data";
return (length $string > 78) ? $self->_fold($string)
- : "$string$self->{mycrlf}";
+ : ( $string . $self->{mycrlf} );
}
sub _fold {
@@ -240,7 +271,7 @@
$folded .= " " if $line;
} else {
# Basically nothing we can do. :(
- $folded .= $line;
+ $folded .= $line . $self->{mycrlf};
last;
}
}
Added: packages/libemail-simple-perl/branches/upstream/current/lib/Email/Simple/Headers.pm
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libemail-simple-perl/branches/upstream/current/lib/Email/Simple/Headers.pm?rev=3551&op=file
==============================================================================
--- packages/libemail-simple-perl/branches/upstream/current/lib/Email/Simple/Headers.pm (added)
+++ packages/libemail-simple-perl/branches/upstream/current/lib/Email/Simple/Headers.pm Thu Aug 31 13:26:42 2006
@@ -1,0 +1,40 @@
+package Email::Simple::Headers;
+use strict;
+
+use vars qw[$VERSION];
+$VERSION = '1.970';
+
+# XXX: In the future, this should throw a "stop using me!" warning.
+# -- rjbs, 2006-08-01
+
+1;
+
+__END__
+
+=head1 NAME
+
+Email::Simple::Headers - a deprecated module that does nothing!
+
+=head1 SYNOPSIS
+
+ use Email::Simple;
+ # use Email::Simple::Headers; # no longer needed as of 2006-08-17
+
+ my $email = Email::Simple->new($string);
+
+ print $email->header($_), "\n" for $email->headers;
+
+=head1 DESCRIPTION
+
+This module used to provide the method C<headers> for Email::Simple objects.
+That method is now part of the Email::Simple module.
+
+=head1 SEE ALSO
+
+L<Email::Simple>
+
+=head1 AUTHOR
+
+Casey West, <F<casey at geeknest.com>>
+
+=cut
Added: packages/libemail-simple-perl/branches/upstream/current/t/header-names.t
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libemail-simple-perl/branches/upstream/current/t/header-names.t?rev=3551&op=file
==============================================================================
--- packages/libemail-simple-perl/branches/upstream/current/t/header-names.t (added)
+++ packages/libemail-simple-perl/branches/upstream/current/t/header-names.t Thu Aug 31 13:26:42 2006
@@ -1,0 +1,34 @@
+use Test::More tests => 9;
+use strict;
+$^W = 1;
+
+use_ok 'Email::Simple';
+
+my @emails;
+
+push @emails, Email::Simple->new(<<'__MESSAGE__');
+From: casey at geeknest.com
+To: drain at example.com
+Subject: Message in a bottle
+__MESSAGE__
+
+push @emails, Email::Simple->new(<<'__MESSAGE__');
+From: casey at geeknest.com
+To: drain at example.com
+Subject: Message in a bottle
+
+HELP!
+__MESSAGE__
+
+for my $email (@emails) {
+ for my $method ('header_names', 'headers') {
+ can_ok($email, $method);
+ ok(
+ eq_set(
+ [ qw(From To Subject) ],
+ [ $email->$method ],
+ ),
+ 'have expected headers'
+ );
+ }
+}
Added: packages/libemail-simple-perl/branches/upstream/current/t/header-pairs.t
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libemail-simple-perl/branches/upstream/current/t/header-pairs.t?rev=3551&op=file
==============================================================================
--- packages/libemail-simple-perl/branches/upstream/current/t/header-pairs.t (added)
+++ packages/libemail-simple-perl/branches/upstream/current/t/header-pairs.t Thu Aug 31 13:26:42 2006
@@ -1,0 +1,36 @@
+use Test::More tests => 3;
+use strict;
+$^W = 1;
+
+use_ok 'Email::Simple';
+
+my $email = Email::Simple->new(<<'__MESSAGE__');
+From: casey at geeknest.example.com
+X-Your-Face: your face is your face
+To: drain at example.com
+X-Your-Face: your face is my face
+X-Your-Face: from california
+Reply-To: xyzzy at plugh.example.net
+X-Your-Face: to the new york islface
+Subject: Message in a bottle
+
+HELP!
+__MESSAGE__
+
+can_ok $email, 'header_names';
+
+my @header_pairs = $email->header_pairs;
+is_deeply(
+ \@header_pairs,
+ [
+ 'From', 'casey at geeknest.example.com',
+ 'X-Your-Face', 'your face is your face',
+ 'To', 'drain at example.com',
+ 'X-Your-Face', 'your face is my face',
+ 'X-Your-Face', 'from california',
+ 'Reply-To', 'xyzzy at plugh.example.net',
+ 'X-Your-Face', 'to the new york islface',
+ 'Subject', 'Message in a bottle',
+ ],
+ "header pairs came out properly",
+);
Modified: packages/libemail-simple-perl/branches/upstream/current/t/pod-coverage.t
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libemail-simple-perl/branches/upstream/current/t/pod-coverage.t?rev=3551&op=diff
==============================================================================
--- packages/libemail-simple-perl/branches/upstream/current/t/pod-coverage.t (original)
+++ packages/libemail-simple-perl/branches/upstream/current/t/pod-coverage.t Thu Aug 31 13:26:42 2006
@@ -6,5 +6,6 @@
if $@;
all_pod_coverage_ok({
- coverage_class => 'Pod::Coverage::CountParents'
+ coverage_class => 'Pod::Coverage::CountParents',
+ trustme => [ qw(headers) ],
});
Added: packages/libemail-simple-perl/branches/upstream/current/t/preserve-linefeed.t
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libemail-simple-perl/branches/upstream/current/t/preserve-linefeed.t?rev=3551&op=file
==============================================================================
--- packages/libemail-simple-perl/branches/upstream/current/t/preserve-linefeed.t (added)
+++ packages/libemail-simple-perl/branches/upstream/current/t/preserve-linefeed.t Thu Aug 31 13:26:42 2006
@@ -1,0 +1,19 @@
+#!/usr/bin/perl -w
+
+use strict;
+use Test::More tests => 3;
+
+use_ok( 'Email::Simple' );
+
+my $original = <<'EOM';
+subject:
+ =?utf-8?B?ZGVsLmljaW8udXMvbmV0d29yay9qb2VlIC0gW2Zyb20gbWlqaXRdIEJMQiBFY2MgMw==?=
+content-type: text/plain
+
+empty body
+EOM
+
+my $mail = Email::Simple->new( $original );
+isa_ok( $mail, 'Email::Simple' );
+
+is( $mail->as_string, $original );
More information about the Pkg-perl-cvs-commits
mailing list