[Bps-public-commit] r17762 - in Net-Google-Code/trunk: lib/Net/Google/Code
fayland at bestpractical.com
fayland at bestpractical.com
Fri Jan 16 02:43:58 EST 2009
Author: fayland
Date: Fri Jan 16 02:43:57 2009
New Revision: 17762
Modified:
Net-Google-Code/trunk/lib/Net/Google/Code/WikiEntry.pm
Net-Google-Code/trunk/t/11.wiki.t
Log:
summary in wiki entry
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 Fri Jan 16 02:43:57 2009
@@ -4,7 +4,7 @@
use Params::Validate qw(:all);
with 'Net::Google::Code::Role';
-our $VERSION = '0.02';
+our $VERSION = '0.03';
our $AUTHORITY = 'cpan:FAYLAND';
has name => ( is => 'ro', isa => 'Str', required => 1 );
@@ -13,6 +13,7 @@
isa => 'Str',
is => 'ro',
lazy => 1,
+ predicate => 'has_source',
default => sub {
my $self = shift;
return $self->fetch( $self->base_svn_url . 'wiki/' . $self->name . '.wiki' );
@@ -88,6 +89,32 @@
},
);
+has 'summary' => (
+ isa => 'Maybe[Str]',
+ is => 'ro',
+ lazy => 1,
+ default => sub {
+ my $self = shift;
+
+ if ( $self->has_source ) { # get from source
+ my @lines = split(/\n/, $self->source);
+ foreach my $line (@lines ) {
+ if ( $line =~ /^\#summary\s+(.*?)$/ ) {
+ return $1;
+ }
+ last if ( $line !~ /^\#/ );
+ }
+ return;
+ }
+ # get from the html tree
+ my $tree = $self->__html_tree;
+ my $title = $tree->find_by_tag_name('title')->content_array_ref->[0];
+ my @parts = split(/\s+\-\s+/, $title, 4);
+ return $parts[3] if ( scalar @parts == 4 );
+ return;
+ },
+);
+
no Moose;
__PACKAGE__->meta->make_immutable;
@@ -121,6 +148,10 @@
html code of this wiki entry
+=head2 summary
+
+summary of this wiki entry
+
=head2 updated_time
last updated time of this wiki entry
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 Fri Jan 16 02:43:57 2009
@@ -3,7 +3,7 @@
use strict;
use warnings;
-use Test::More tests => 9;
+use Test::More tests => 10;
use Test::MockModule;
use FindBin qw/$Bin/;
use File::Slurp;
@@ -48,10 +48,11 @@
my $entry = $wiki->entry('TODO');
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';
+is $entry->summary, 'One-sentence summary of this page.';
+is $entry->source, 'Please check [http://code.google.com/p/foorum/issues/list] for more issues.';
1;
More information about the Bps-public-commit
mailing list