[Bps-public-commit] r17628 - in Net-Google-Code/trunk: . lib/Net/Google/Code t/sample

fayland at bestpractical.com fayland at bestpractical.com
Thu Jan 8 01:25:25 EST 2009


Author: fayland
Date: Thu Jan  8 01:25:25 2009
New Revision: 17628

Added:
   Net-Google-Code/trunk/lib/Net/Google/Code/WikiEntry.pm
   Net-Google-Code/trunk/t/sample/11.TODO.wiki
Modified:
   Net-Google-Code/trunk/Changes
   Net-Google-Code/trunk/lib/Net/Google/Code/Wiki.pm
   Net-Google-Code/trunk/t/11.wiki.t

Log:
add WikiEntry.pm

Modified: Net-Google-Code/trunk/Changes
==============================================================================
--- Net-Google-Code/trunk/Changes	(original)
+++ Net-Google-Code/trunk/Changes	Thu Jan  8 01:25:25 2009
@@ -2,6 +2,7 @@
 
 0.02
        new Net::Google::Code::Downloads
+       new Net::Google::Code::Wiki
 
 0.01 Tue Jan  6 10:17:56 CST 2009
        Initial release.

Modified: Net-Google-Code/trunk/lib/Net/Google/Code/Wiki.pm
==============================================================================
--- Net-Google-Code/trunk/lib/Net/Google/Code/Wiki.pm	(original)
+++ Net-Google-Code/trunk/lib/Net/Google/Code/Wiki.pm	Thu Jan  8 01:25:25 2009
@@ -3,6 +3,8 @@
 use Moose;
 use Params::Validate qw(:all);
 
+use Net::Google::Code::WikiEntry;
+
 our $VERSION = '0.02';
 our $AUTHORITY = 'cpan:FAYLAND';
 
@@ -26,7 +28,7 @@
 	my @entries;
 	foreach my $line (@lines ) {
 		# <li><a href="AUTHORS.wiki">AUTHORS.wiki</a></li>
-		if ( $line =~ /href\="(.*?)\.wiki\"\>\1\.wiki/ ) {
+		if ( $line =~ /href\=\"(.*?)\.wiki\"\>\1\.wiki/ ) {
 			push @entries, $1;
 		}
 	}
@@ -34,6 +36,14 @@
 	return wantarray ? @entries : \@entries;
 }
 
+sub entry {
+    my $self = shift;
+    
+    my ($wiki_item) = validate_pos( @_, { type => SCALAR } );
+    
+    return Net::Google::Code::WikiEntry->new( connection => $self->connection, name => $wiki_item );
+}
+
 no Moose;
 __PACKAGE__->meta->make_immutable;
 
@@ -52,6 +62,8 @@
     use Net::Google::Code::Wiki;
     my $wiki = Net::Google::Code::Wiki->new( connection => $connection );
     
+    my @entries = $wiki->all_entries;
+    
 =head1 DESCRIPTION
 
 get Wiki details from Google Code Project
@@ -60,6 +72,12 @@
 
 =head2 all_entries
 
+get all entries from wiki svn
+
+=head2 entry
+
+return a instance of L<Net::Google::Code::WikiEntry>
+
 =head1 AUTHOR
 
 Fayland Lam, C<< <fayland at gmail.com> >>

Added: Net-Google-Code/trunk/lib/Net/Google/Code/WikiEntry.pm
==============================================================================
--- (empty file)
+++ Net-Google-Code/trunk/lib/Net/Google/Code/WikiEntry.pm	Thu Jan  8 01:25:25 2009
@@ -0,0 +1,72 @@
+package Net::Google::Code::WikiEntry;
+
+use Moose;
+use Params::Validate qw(:all);
+
+our $VERSION = '0.02';
+our $AUTHORITY = 'cpan:FAYLAND';
+
+has connection => (
+    isa => 'Net::Google::Code::Connection',
+    is  => 'ro',
+    required => 1,
+);
+
+has name => ( is => 'ro', isa => 'Str', required => 1 );
+
+has 'source' => (
+    isa => 'Str',
+    is  => 'ro',
+    lazy => 1,
+    default => sub {
+        my $self = shift;
+        
+        my $name       = $self->name;
+        my $connection = $self->connection;
+        my $project    = $connection->project;
+        
+        my $wiki_url = "http://$project.googlecode.com/svn/wiki/$name.wiki";
+        my $content = $connection->_fetch( $wiki_url );
+        
+        return $content;
+    }
+);
+
+no Moose;
+__PACKAGE__->meta->make_immutable;
+
+1;
+__END__
+
+=head1 NAME
+
+Net::Google::Code::WikiEntry - Google Code Wiki Entry
+
+=head1 SYNOPSIS
+
+    use Net::Google::Code::Connection;
+    my $connection = Net::Google::Code::Connection( project => 'net-google-code' );
+
+    use Net::Google::Code::WikiEntry;
+    my $wiki_entry = Net::Google::Code::WikiEntry->new( connection => $connection, name => 'AUTHORS' );
+
+=head1 DESCRIPTION
+
+get Wiki details from Google Code Project
+
+=head1 ATTRIBUTES
+
+=head2 source
+
+wiki source code
+
+=head1 AUTHOR
+
+Fayland Lam, C<< <fayland at gmail.com> >>
+
+=head1 LICENCE AND COPYRIGHT
+
+Copyright 2008-2009 Best Practical Solutions.
+
+This program is free software; you can redistribute it and/or modify it
+under the same terms as Perl itself.

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 01:25:25 2009
@@ -3,11 +3,12 @@
 use strict;
 use warnings;
 
-use Test::More tests => 7;
+use Test::More tests => 9;
 use Test::MockModule;
 use FindBin qw/$Bin/;
 
-my $svn_file = "$Bin/sample/11.wiki.html";
+my $svn_file  = "$Bin/sample/11.wiki.html";
+my $wiki_file = "$Bin/sample/11.TODO.wiki";
 
 sub read_file {
 	open(my $fh, '<', shift) or die $!;
@@ -17,7 +18,8 @@
 	return $t;
 }
 
-my $svn_content = read_file($svn_file);
+my $svn_content  = read_file($svn_file);
+my $wiki_content = read_file($wiki_file);
 
 my $mock_connection = Test::MockModule->new('Net::Google::Code::Connection');
 $mock_connection->mock(
@@ -26,6 +28,8 @@
     	( undef, my $uri ) = @_;
     	if ( $uri eq 'http://foorum.googlecode.com/svn/wiki/' ) {
     		return $svn_content;
+    	} elsif ( $uri eq 'http://foorum.googlecode.com/svn/wiki/TODO.wiki' ) {
+    	    return $wiki_content;
     	}
     }
 );
@@ -44,5 +48,8 @@
 	'README', 'RULES', 'TODO', 'TroubleShooting', 'Tutorial1', 'Tutorial2', 'Tutorial3',
 	'Tutorial4', 'Tutorial5', 'Upgrade' ]);
 
+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.';
 
 1;
\ No newline at end of file

Added: Net-Google-Code/trunk/t/sample/11.TODO.wiki
==============================================================================
--- (empty file)
+++ Net-Google-Code/trunk/t/sample/11.TODO.wiki	Thu Jan  8 01:25:25 2009
@@ -0,0 +1 @@
+Please check [http://code.google.com/p/foorum/issues/list] for more issues.
\ No newline at end of file



More information about the Bps-public-commit mailing list