[Bps-public-commit] r17845 - in Net-Google-Code/trunk: lib/Net/Google/Code
fayland at bestpractical.com
fayland at bestpractical.com
Tue Jan 20 18:19:59 EST 2009
Author: fayland
Date: Tue Jan 20 18:19:59 2009
New Revision: 17845
Modified:
Net-Google-Code/trunk/lib/Net/Google/Code/WikiEntry.pm
Net-Google-Code/trunk/t/11.wiki.t
Log:
wikientry comments
Modified: Net-Google-Code/trunk/lib/Net/Google/Code/WikiEntry.pm
==============================================================================
--- Net-Google-Code/trunk/lib/Net/Google/Code/WikiEntry.pm (original)
+++ Net-Google-Code/trunk/lib/Net/Google/Code/WikiEntry.pm Tue Jan 20 18:19:59 2009
@@ -115,6 +115,38 @@
},
);
+has 'comments' => (
+ isa => 'ArrayRef',
+ is => 'ro',
+ lazy => 1,
+ default => sub {
+ my $self = shift;
+
+ my @rets;
+
+ my $tree = $self->__html_tree;
+ my @comments = $tree->look_down( class => 'artifactcomment' );
+ foreach my $comment ( @comments ) {
+ my $href = $comment->look_down( class => 'author' )->find_by_tag_name('a')->attr('href');
+ my ( $author ) = ( $href =~ /u\/(.*?)\// );
+ my $date = $comment->look_down( class => 'date' )->attr('title');
+ my $content = $comment->look_down( class => 'commentcontent' )->as_HTML(undef, undef, { } );
+ # remove <div class="commentcontent">
+ # STUPID I!
+ $content =~ s/^\<div class\=\"commentcontent\"\>//;
+ $content =~ s/\<\/div\>$//;
+ chomp($content);
+ push @rets, {
+ author => $author,
+ date => $date,
+ content => $content,
+ };
+ }
+
+ return \@rets;
+ },
+);
+
has 'labels' => (
isa => 'ArrayRef',
is => 'ro',
@@ -194,6 +226,10 @@
last updator of this wiki entry
+=item comments
+
+wiki entry comments
+
=back
=head1 AUTHOR
Modified: Net-Google-Code/trunk/t/11.wiki.t
==============================================================================
--- Net-Google-Code/trunk/t/11.wiki.t (original)
+++ Net-Google-Code/trunk/t/11.wiki.t Tue Jan 20 18:19:59 2009
@@ -3,7 +3,7 @@
use strict;
use warnings;
-use Test::More tests => 13;
+use Test::More tests => 14;
use Test::MockModule;
use FindBin qw/$Bin/;
use File::Slurp;
@@ -65,5 +65,20 @@
is $entry->summary, 'One-sentence summary of this page.';
is_deeply $entry->labels, ['Phase-QA', 'Phase-Support'];
+is_deeply $entry->comments, [
+
+{
+ author => 'fayland',
+ date => 'Wed Jan 7 22:37:57 2009',
+ content => '<p>comment1 </p>',
+},
+{
+ author => 'fayland',
+ date => 'Wed Jan 7 22:38:07 2009',
+ content => '<p>two line comment 2. </p>',
+}
+
+];
+
1;
More information about the Bps-public-commit
mailing list