[Bps-public-commit] r17639 - in Net-Google-Code/trunk: lib/Net/Google/Code

fayland at bestpractical.com fayland at bestpractical.com
Thu Jan 8 05:52:07 EST 2009


Author: fayland
Date: Thu Jan  8 05:52:07 2009
New Revision: 17639

Modified:
   Net-Google-Code/trunk/lib/Net/Google/Code/WikiEntry.pm
   Net-Google-Code/trunk/t/11.wiki.t

Log:
add updated_time and updated_by in WikiEntry.pm

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	Thu Jan  8 05:52:07 2009
@@ -82,6 +82,33 @@
     },
 );
 
+has 'updated_time' => (
+    isa => 'Str',
+    is  => 'ro',
+    lazy => 1,
+    default => sub {
+        my $self = shift;
+        
+        my $tree = $self->__html_tree;
+        return $tree->look_down(id => 'wikimaincol')->find_by_tag_name('td')
+	    ->find_by_tag_name('span')->attr('title');
+    },
+);
+has 'updated_by' => (
+    isa => 'Str',
+    is  => 'ro',
+    lazy => 1,
+    default => sub {
+        my $self = shift;
+        
+        my $tree = $self->__html_tree;
+        my $href = $tree->look_down(id => 'wikimaincol')->find_by_tag_name('td')
+	    ->find_by_tag_name('a')->attr('href');
+        my ( $author ) = ( $href =~ /u\/(.*?)\// );
+        return $author;
+    },
+);
+
 no Moose;
 __PACKAGE__->meta->make_immutable;
 
@@ -114,6 +141,14 @@
 
 html code of this wiki entry
 
+=head2 updated_time
+
+last updated time of this wiki entry
+
+=head2 updated_by
+
+last updator of this wiki entry
+
 =head1 AUTHOR
 
 Fayland Lam, C<< <fayland at gmail.com> >>

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	Thu Jan  8 05:52:07 2009
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 10;
+use Test::More tests => 12;
 use Test::MockModule;
 use FindBin qw/$Bin/;
 use File::Slurp;
@@ -48,6 +48,8 @@
 isa_ok( $entry, 'Net::Google::Code::WikiEntry' );
 is $entry->source, 'Please check [http://code.google.com/p/foorum/issues/list] for more issues.';
 like $entry->html, qr/Add your content here/;
+is $entry->updated_time, 'Wed Jan  7 22:32:44 2009';
+is $entry->updated_by, 'fayland';
 
 1;
 



More information about the Bps-public-commit mailing list