[Bps-public-commit] r17421 - in Net-Trac/trunk: . t

trs at bestpractical.com trs at bestpractical.com
Tue Dec 30 00:34:30 EST 2008


Author: trs
Date: Tue Dec 30 00:34:30 2008
New Revision: 17421

Modified:
   Net-Trac/trunk/   (props changed)
   Net-Trac/trunk/lib/Net/Trac/Ticket.pm
   Net-Trac/trunk/t/comments.t

Log:
 r43272 at zot:  tom | 2008-12-30 00:26:01 -0500
 Add a comments convenience function


Modified: Net-Trac/trunk/lib/Net/Trac/Ticket.pm
==============================================================================
--- Net-Trac/trunk/lib/Net/Trac/Ticket.pm	(original)
+++ Net-Trac/trunk/lib/Net/Trac/Ticket.pm	Tue Dec 30 00:34:30 2008
@@ -174,5 +174,16 @@
     return $hist;
 }
 
+sub comments {
+    my $self = shift;
+    my $hist = $self->history;
+
+    my @comments;
+    for ( @{$hist->entries} ) {
+        push @comments, $_ if $_->content =~ /\S/;
+    }
+    return wantarray ? @comments : \@comments;
+}
+
 #http://barnowl.mit.edu/ticket/36?format=tab
 1;

Modified: Net-Trac/trunk/t/comments.t
==============================================================================
--- Net-Trac/trunk/t/comments.t	(original)
+++ Net-Trac/trunk/t/comments.t	Tue Dec 30 00:34:30 2008
@@ -39,8 +39,8 @@
 can_ok($ticket => 'comment');
 ok($ticket->comment( 'I like fish.' ), "Creating comment about fish.");
 
-is(@{$ticket->history->entries}, 2, "Got two history entries.");
-like($ticket->history->entries->[1]->content, qr/fish/, "The comment looks correct.");
-like($ticket->history->entries->[0]->content, qr/moose/, "The previous comment looks correct.");
-
+can_ok( $ticket => 'comments' );
+is(@{$ticket->comments}, 2, "Got two comments.");
+like($ticket->comments->[1]->content, qr/fish/, "The comment looks correct.");
+like($ticket->comments->[0]->content, qr/moose/, "The previous comment looks correct.");
 



More information about the Bps-public-commit mailing list