r3448 - in /packages/libemail-simple-creator-perl: ./ branches/ branches/upstream/ branches/upstream/current/ branches/upstream/current/lib/ branches/upstream/current/lib/Email/ branches/upstream/current/lib/Email/Simple/ branches/upstream/current/t/ tags/

pabs-guest at users.alioth.debian.org pabs-guest at users.alioth.debian.org
Sat Aug 12 08:17:40 UTC 2006


Author: pabs-guest
Date: Sat Aug 12 08:17:39 2006
New Revision: 3448

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=3448
Log:
[svn-inject] Installing original source of libemail-simple-creator-perl

Added:
    packages/libemail-simple-creator-perl/
    packages/libemail-simple-creator-perl/branches/
    packages/libemail-simple-creator-perl/branches/upstream/
    packages/libemail-simple-creator-perl/branches/upstream/current/
    packages/libemail-simple-creator-perl/branches/upstream/current/Changes
    packages/libemail-simple-creator-perl/branches/upstream/current/MANIFEST
    packages/libemail-simple-creator-perl/branches/upstream/current/META.yml
    packages/libemail-simple-creator-perl/branches/upstream/current/Makefile.PL
    packages/libemail-simple-creator-perl/branches/upstream/current/README
    packages/libemail-simple-creator-perl/branches/upstream/current/lib/
    packages/libemail-simple-creator-perl/branches/upstream/current/lib/Email/
    packages/libemail-simple-creator-perl/branches/upstream/current/lib/Email/Simple/
    packages/libemail-simple-creator-perl/branches/upstream/current/lib/Email/Simple/Creator.pm
    packages/libemail-simple-creator-perl/branches/upstream/current/t/
    packages/libemail-simple-creator-perl/branches/upstream/current/t/create.t
    packages/libemail-simple-creator-perl/tags/

Added: packages/libemail-simple-creator-perl/branches/upstream/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libemail-simple-creator-perl/branches/upstream/current/Changes?rev=3448&op=file
==============================================================================
--- packages/libemail-simple-creator-perl/branches/upstream/current/Changes (added)
+++ packages/libemail-simple-creator-perl/branches/upstream/current/Changes Sat Aug 12 08:17:39 2006
@@ -1,0 +1,16 @@
+1.4    2004-07-25
+
+  - use Email::Date
+
+1.3    2004-07-05
+
+  - Create a message using its local crlf (Casey West).
+  - Include timezone info in the Date header (Steffen Goeldner).
+
+1.2    2004-07-05
+
+  - Handle undefined values in the header list properly.
+
+1.1
+
+  - Initial Version

Added: packages/libemail-simple-creator-perl/branches/upstream/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libemail-simple-creator-perl/branches/upstream/current/MANIFEST?rev=3448&op=file
==============================================================================
--- packages/libemail-simple-creator-perl/branches/upstream/current/MANIFEST (added)
+++ packages/libemail-simple-creator-perl/branches/upstream/current/MANIFEST Sat Aug 12 08:17:39 2006
@@ -1,0 +1,7 @@
+Changes
+lib/Email/Simple/Creator.pm
+Makefile.PL
+MANIFEST			This list of files
+META.yml
+README
+t/create.t

Added: packages/libemail-simple-creator-perl/branches/upstream/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libemail-simple-creator-perl/branches/upstream/current/META.yml?rev=3448&op=file
==============================================================================
--- packages/libemail-simple-creator-perl/branches/upstream/current/META.yml (added)
+++ packages/libemail-simple-creator-perl/branches/upstream/current/META.yml Sat Aug 12 08:17:39 2006
@@ -1,0 +1,13 @@
+# http://module-build.sourceforge.net/META-spec.html
+#XXXXXXX This is a prototype!!!  It will change in the future!!! XXXXX#
+name:         Email-Simple-Creator
+version:      1.4
+version_from: lib/Email/Simple/Creator.pm
+installdirs:  site
+requires:
+    Email::Date:                   
+    Email::Simple:                 
+    Test::More:                    0.47
+
+distribution_type: module
+generated_by: ExtUtils::MakeMaker version 6.17

Added: packages/libemail-simple-creator-perl/branches/upstream/current/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libemail-simple-creator-perl/branches/upstream/current/Makefile.PL?rev=3448&op=file
==============================================================================
--- packages/libemail-simple-creator-perl/branches/upstream/current/Makefile.PL (added)
+++ packages/libemail-simple-creator-perl/branches/upstream/current/Makefile.PL Sat Aug 12 08:17:39 2006
@@ -1,0 +1,13 @@
+use ExtUtils::MakeMaker;
+
+WriteMakefile (
+               AUTHOR        => 'Casey West <casey at geeknest.com>',
+               ABSTRACT      => "Email::Simple constructor for starting anew.",
+               NAME          => 'Email::Simple::Creator',
+               PREREQ_PM     => {
+                                 'Test::More'        => '0.47',
+                                 'Email::Simple'     => '',
+                                 'Email::Date'       => '',
+                                },
+               VERSION_FROM  => 'lib/Email/Simple/Creator.pm',
+              );

Added: packages/libemail-simple-creator-perl/branches/upstream/current/README
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libemail-simple-creator-perl/branches/upstream/current/README?rev=3448&op=file
==============================================================================
--- packages/libemail-simple-creator-perl/branches/upstream/current/README (added)
+++ packages/libemail-simple-creator-perl/branches/upstream/current/README Sat Aug 12 08:17:39 2006
@@ -1,0 +1,55 @@
+NAME
+    Email::Simple::Creator - Email::Simple constructor for starting anew.
+
+SYNOPSIS
+      use Email::Simple;
+      use Email::Simple::Creator;
+  
+      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;
+
+DESCRIPTION
+    This software provides a constructor to Email::Simple for creating
+    messages from scratch.
+
+  Methods
+    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 "header" parameter's value is a
+         list reference containing a set of headers to be created. The
+         "body" parameter's value is a scalar value holding the contents of
+         the message body.
+
+         If no "Date" header is specified, one will be provided for you
+         based on the "gmtime()" of the local machine. This is because the
+         "Date" field is a required header and is a pain in the neck to
+         create manually for every message. The "From" field is also a
+         required header, but it is *not* provided for you.
+
+         The parameters passed are used to create an email message that is
+         passed to "Email::Simple->new()". "create()" returns the value
+         returned by "new()". With skill, that's an "Email::Simple" object.
+
+SEE ALSO
+    Email::Simple, perl.
+
+AUTHOR
+    Casey West, <casey at geeknest.com>.
+
+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.
+

Added: packages/libemail-simple-creator-perl/branches/upstream/current/lib/Email/Simple/Creator.pm
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libemail-simple-creator-perl/branches/upstream/current/lib/Email/Simple/Creator.pm?rev=3448&op=file
==============================================================================
--- packages/libemail-simple-creator-perl/branches/upstream/current/lib/Email/Simple/Creator.pm (added)
+++ packages/libemail-simple-creator-perl/branches/upstream/current/lib/Email/Simple/Creator.pm Sat Aug 12 08:17:39 2006
@@ -1,0 +1,121 @@
+package Email::Simple::Creator;
+# $Id: Creator.pm,v 1.4 2004/07/25 20:29:28 cwest Exp $
+use strict;
+
+use vars qw[$VERSION $CRLF];
+$VERSION = (qw$Revision: 1.4 $)[1];
+$CRLF    = "\x0a\x0d";
+
+sub _date_header {
+    require Email::Date;
+    Email::Date::format_date();
+}
+
+sub _add_to_header {
+    my ($class, $header, $key, $value) = @_;
+    return unless $value;
+    ${$header} .= join(": ", $key, $value) . $CRLF;
+}
+
+package Email::Simple;
+use strict;
+
+use vars qw[$CREATOR];
+$CREATOR = 'Email::Simple::Creator';
+
+sub create {
+    my ($class, %args) = @_;
+
+    my @headers = @{ $args{header} || [] };
+    my $body    = $args{body} || '';
+    my $header  = '';
+    my %headers;
+
+    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 $headers{Date};
+
+    my $email = $class->new($header);
+    $email->body_set($body . $email->{mycrlf});
+    return $email;
+}
+
+1;
+
+__END__
+
+=head1 NAME
+
+Email::Simple::Creator - Email::Simple constructor for starting anew.
+
+=head1 SYNOPSIS
+
+  use Email::Simple;
+  use Email::Simple::Creator;
+  
+  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
+
+This software provides a constructor to L<Email::Simple|Email::Simple> for
+creating messages from scratch.
+
+=head2 Methods
+
+=over 5
+
+=item create
+
+  my $email = Email::Simple->create(header => [ @headers ], body => '...');
+
+This method is a constructor that creates an C<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.
+
+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.
+
+The parameters passed are used to create an email message that is passed
+to C<< Email::Simple->new() >>. C<create()> returns the value returned
+by C<new()>. With skill, that's an C<Email::Simple> object.
+
+=back
+
+=head1 SEE ALSO
+
+L<Email::Simple>,
+L<perl>.
+
+=head1 AUTHOR
+
+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

Added: packages/libemail-simple-creator-perl/branches/upstream/current/t/create.t
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libemail-simple-creator-perl/branches/upstream/current/t/create.t?rev=3448&op=file
==============================================================================
--- packages/libemail-simple-creator-perl/branches/upstream/current/t/create.t (added)
+++ packages/libemail-simple-creator-perl/branches/upstream/current/t/create.t Sat Aug 12 08:17:39 2006
@@ -1,0 +1,49 @@
+use Test::More qw[no_plan];
+use_ok 'Email::Simple::Creator';
+use_ok 'Email::Simple';
+
+sub test_email;
+
+test_email 0 => {
+  header => [
+    To => 'you',
+  ],
+  body => 'test test',
+} => <<__MESSAGE__;
+To: you
+Date: Thu, 17 Jun 2004 18:13:14 -0000
+
+test test
+__MESSAGE__
+
+test_email 1 => {
+  header => [
+    Date => 'testing',
+    'X-Header' => 'one',
+    'X-Header' => 'two',
+    'X-Header' => 'three',
+  ],
+  body => q[This is a multi-
+  line message.],
+} => <<__MESSAGE__;
+Date: testing
+X-Header: one
+X-Header: two
+X-Header: three
+
+This is a multi-
+  line message.
+__MESSAGE__
+
+sub test_email {
+    my ($pass, $args, $message) = @_;
+    my $email = Email::Simple->create(%{$args});
+    print $email->as_string and return unless $message; # debugging
+    isa_ok $email, 'Email::Simple';
+    my $string = $email->as_string;
+    $string  =~ s/\x0a\x0d/\n/g;
+    $message =~ s/\x0a\x0d/\n/g;
+    $pass ?
+      is   $string, $message :
+      isnt $string, $message;
+}




More information about the Pkg-perl-cvs-commits mailing list