[Bps-public-commit] r10406 - in Net-Hiveminder: lib/Net

sartak at bestpractical.com sartak at bestpractical.com
Mon Jan 21 01:49:09 EST 2008


Author: sartak
Date: Mon Jan 21 01:49:08 2008
New Revision: 10406

Modified:
   Net-Hiveminder/   (props changed)
   Net-Hiveminder/Changes
   Net-Hiveminder/Makefile.PL
   Net-Hiveminder/lib/Net/Hiveminder.pm

Log:
 r50626 at onn:  sartak | 2008-01-21 01:49:06 -0500
 Add comment_on(task, message) method, which adds an optional dependency on Email::Simple::Creator


Modified: Net-Hiveminder/Changes
==============================================================================
--- Net-Hiveminder/Changes	(original)
+++ Net-Hiveminder/Changes	Mon Jan 21 01:49:08 2008
@@ -8,6 +8,7 @@
         You can pass arguments to braindump. The "tokens" argument must now be
             passed in as a special option (tokens => 'foo')
         Add comments_on(task) method
+        Add comment_on(task, msg) method
 
 0.02    Sat Jan 12 08 22:48:24
         Remove canonicalize_priority, Hiveminder does it for us.

Modified: Net-Hiveminder/Makefile.PL
==============================================================================
--- Net-Hiveminder/Makefile.PL	(original)
+++ Net-Hiveminder/Makefile.PL	Mon Jan 21 01:49:08 2008
@@ -6,6 +6,13 @@
 requires        'Net::Jifty' => '0.04';
 requires        'Number::RecordLocator';
 
+features(
+    'comment on tasks' => [
+        -default => 1,
+        requires('Email::Simple::Creator'),
+    ],
+);
+
 build_requires  'Test::More';
 
 auto_install;

Modified: Net-Hiveminder/lib/Net/Hiveminder.pm
==============================================================================
--- Net-Hiveminder/lib/Net/Hiveminder.pm	(original)
+++ Net-Hiveminder/lib/Net/Hiveminder.pm	Mon Jan 21 01:49:08 2008
@@ -466,6 +466,36 @@
            $self->read('TaskEmail', task_id => $task);
 }
 
+=head2 comment_on TASK, MESSAGE
+
+Add a comment to TASK.
+
+This method requires L<Email::Simple::Creator>, which is an optional dependency
+of Net::Hiveminder. If Creator is unavailable, then this will throw an error.
+
+=cut
+
+sub comment_on {
+    my $self = shift;
+    my $task = $self->loc2id(shift);
+    my $msg  = shift;
+
+    require Email::Simple;
+    require Email::Simple::Creator;
+
+    my $email = Email::Simple->create(
+        header => [
+            From => $self->email,
+        ],
+        body => $msg,
+    );
+
+    $self->create('TaskEmail',
+        task_id => $task,
+        message => $email->as_string,
+    );
+}
+
 =head1 SEE ALSO
 
 L<Jifty>, L<Net::Jifty>



More information about the Bps-public-commit mailing list