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

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


Author: fayland
Date: Thu Jan  8 01:04:49 2009
New Revision: 17625

Added:
   Net-Google-Code/trunk/lib/Net/Google/Code/Wiki.pm
   Net-Google-Code/trunk/t/11.wiki.t
   Net-Google-Code/trunk/t/sample/11.wiki.html
Modified:
   Net-Google-Code/trunk/AUTHORS
   Net-Google-Code/trunk/lib/Net/Google/Code/Downloads.pm

Log:
add Net::Google::Code::Wiki

Modified: Net-Google-Code/trunk/AUTHORS
==============================================================================
--- Net-Google-Code/trunk/AUTHORS	(original)
+++ Net-Google-Code/trunk/AUTHORS	Thu Jan  8 01:04:49 2009
@@ -1,3 +1,3 @@
 In order of first commit:
 sunnavy <sunnavy at bestpractical.com>
-
+Fayland Lam <fayland at gmail.com>

Modified: Net-Google-Code/trunk/lib/Net/Google/Code/Downloads.pm
==============================================================================
--- Net-Google-Code/trunk/lib/Net/Google/Code/Downloads.pm	(original)
+++ Net-Google-Code/trunk/lib/Net/Google/Code/Downloads.pm	Thu Jan  8 01:04:49 2009
@@ -2,7 +2,6 @@
 
 use Moose;
 use XML::Atom::Feed;
-use URI;
 use Params::Validate qw(:all);
 
 our $VERSION = '0.02';

Added: Net-Google-Code/trunk/lib/Net/Google/Code/Wiki.pm
==============================================================================
--- (empty file)
+++ Net-Google-Code/trunk/lib/Net/Google/Code/Wiki.pm	Thu Jan  8 01:04:49 2009
@@ -0,0 +1,73 @@
+package Net::Google::Code::Wiki;
+
+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,
+);
+
+sub all_entries {
+	my $self = shift;
+	
+	my $connection = $self->connection;
+	my $project    = $connection->project;
+	
+	my $wiki_svn = "http://$project.googlecode.com/svn/wiki/";
+	my $content = $connection->_fetch( $wiki_svn );
+	
+	# regex would be OK
+	my @lines = split("\n", $content);
+	my @entries;
+	foreach my $line (@lines ) {
+		# <li><a href="AUTHORS.wiki">AUTHORS.wiki</a></li>
+		if ( $line =~ /href\="(.*?)\.wiki\"\>\1\.wiki/ ) {
+			push @entries, $1;
+		}
+	}
+	
+	return wantarray ? @entries : \@entries;
+}
+
+no Moose;
+__PACKAGE__->meta->make_immutable;
+
+1;
+__END__
+
+=head1 NAME
+
+Net::Google::Code::Wiki - Google Code Wiki
+
+=head1 SYNOPSIS
+
+    use Net::Google::Code::Connection;
+    my $connection = Net::Google::Code::Connection( project => 'net-google-code' );
+
+    use Net::Google::Code::Wiki;
+    my $wiki = Net::Google::Code::Wiki->new( connection => $connection );
+    
+=head1 DESCRIPTION
+
+get Wiki details from Google Code Project
+
+=head1 METHODS
+
+=head2 all_entries
+
+=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.
+

Added: Net-Google-Code/trunk/t/11.wiki.t
==============================================================================
--- (empty file)
+++ Net-Google-Code/trunk/t/11.wiki.t	Thu Jan  8 01:04:49 2009
@@ -0,0 +1,48 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Test::More tests => 7;
+use Test::MockModule;
+use FindBin qw/$Bin/;
+
+my $svn_file = "$Bin/sample/11.wiki.html";
+
+sub read_file {
+	open(my $fh, '<', shift) or die $!;
+	local $/;
+	my $t = <$fh>;
+	close($fh);
+	return $t;
+}
+
+my $svn_content = read_file($svn_file);
+
+my $mock_connection = Test::MockModule->new('Net::Google::Code::Connection');
+$mock_connection->mock(
+    '_fetch',
+    sub {
+    	( undef, my $uri ) = @_;
+    	if ( $uri eq 'http://foorum.googlecode.com/svn/wiki/' ) {
+    		return $svn_content;
+    	}
+    }
+);
+
+use_ok('Net::Google::Code::Connection');
+use_ok('Net::Google::Code::Wiki');
+my $connection = Net::Google::Code::Connection->new( project => 'foorum' );
+my $wiki = Net::Google::Code::Wiki->new( connection => $connection );
+isa_ok( $wiki, 'Net::Google::Code::Wiki' );
+isa_ok( $wiki->connection, 'Net::Google::Code::Connection' );
+
+my @entries = $wiki->all_entries;
+is( scalar @entries, 16 );
+is $entries[0], 'AUTHORS';
+is_deeply(\@entries, ['AUTHORS', 'Configure', 'HowRSS', 'I18N', 'INSTALL', 'PreRelease',
+	'README', 'RULES', 'TODO', 'TroubleShooting', 'Tutorial1', 'Tutorial2', 'Tutorial3',
+	'Tutorial4', 'Tutorial5', 'Upgrade' ]);
+
+
+1;
\ No newline at end of file

Added: Net-Google-Code/trunk/t/sample/11.wiki.html
==============================================================================
--- (empty file)
+++ Net-Google-Code/trunk/t/sample/11.wiki.html	Thu Jan  8 01:04:49 2009
@@ -0,0 +1,24 @@
+<html><head><title>Revision 677: /wiki</title></head>
+<body>
+ <h2>Revision 677: /wiki</h2>
+ <ul>
+  <li><a href="../">..</a></li>
+  <li><a href="AUTHORS.wiki">AUTHORS.wiki</a></li>
+  <li><a href="Configure.wiki">Configure.wiki</a></li>
+  <li><a href="HowRSS.wiki">HowRSS.wiki</a></li>
+  <li><a href="I18N.wiki">I18N.wiki</a></li>
+  <li><a href="INSTALL.wiki">INSTALL.wiki</a></li>
+  <li><a href="PreRelease.wiki">PreRelease.wiki</a></li>
+  <li><a href="README.wiki">README.wiki</a></li>
+  <li><a href="RULES.wiki">RULES.wiki</a></li>
+  <li><a href="TODO.wiki">TODO.wiki</a></li>
+  <li><a href="TroubleShooting.wiki">TroubleShooting.wiki</a></li>
+  <li><a href="Tutorial1.wiki">Tutorial1.wiki</a></li>
+  <li><a href="Tutorial2.wiki">Tutorial2.wiki</a></li>
+  <li><a href="Tutorial3.wiki">Tutorial3.wiki</a></li>
+  <li><a href="Tutorial4.wiki">Tutorial4.wiki</a></li>
+  <li><a href="Tutorial5.wiki">Tutorial5.wiki</a></li>
+  <li><a href="Upgrade.wiki">Upgrade.wiki</a></li>
+ </ul>
+ <hr noshade><em><a href="http://code.google.com/">Google Code</a> powered by <a href="http://subversion.tigris.org/">Subversion</a> </em>
+</body></html>
\ No newline at end of file



More information about the Bps-public-commit mailing list