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

sunnavy at bestpractical.com sunnavy at bestpractical.com
Thu Jan 8 02:26:53 EST 2009


Author: sunnavy
Date: Thu Jan  8 02:26:53 2009
New Revision: 17633

Added:
   Net-Google-Code/trunk/t/20.code.t
Modified:
   Net-Google-Code/trunk/   (props changed)
   Net-Google-Code/trunk/lib/Net/Google/Code.pm

Log:
 r18645 at sunnavys-mb:  sunnavy | 2009-01-08 15:26:32 +0800
 a wrapper api in Code.pm


Modified: Net-Google-Code/trunk/lib/Net/Google/Code.pm
==============================================================================
--- Net-Google-Code/trunk/lib/Net/Google/Code.pm	(original)
+++ Net-Google-Code/trunk/lib/Net/Google/Code.pm	Thu Jan  8 02:26:53 2009
@@ -5,12 +5,58 @@
 use Moose;
 
 our $VERSION = '0.01';
+use Net::Google::Code::Connection;
 
 has 'project' => (
     isa      => 'Str',
+    is       => 'ro',
     required => 1,
 );
 
+has 'connection' => (
+    isa  => 'Net::Google::Code::Connection',
+    is   => 'ro',
+    lazy => 1,
+    default =>
+      sub { Net::Google::Code::Connection->new( project => $_[0]->project ) },
+);
+
+has 'url' => (
+    isa     => 'Str',
+    is      => 'ro',
+    lazy    => 1,
+    default => sub { $_[0]->connection->base_url . $_[0]->project . '/' },
+);
+
+has 'issue' => (
+    isa     => 'Net::Google::Code::Issue',
+    is      => 'rw',
+    lazy    => 1,
+    default => sub {
+        require Net::Google::Code::Issue;
+        Net::Google::Code::Issue->new( connection => $_[0]->connection );
+    }
+);
+
+has 'downloads' => (
+    isa     => 'Net::Google::Code::Downloads',
+    is      => 'rw',
+    lazy    => 1,
+    default => sub {
+        require Net::Google::Code::Downloads;
+        Net::Google::Code::Downloads->new( connection => $_[0]->connection );
+    }
+);
+
+has 'wiki' => (
+    isa     => 'Net::Google::Code::Wiki',
+    is      => 'rw',
+    lazy    => 1,
+    default => sub {
+        require Net::Google::Code::Wiki;
+        Net::Google::Code::Wiki->new( connection => $_[0]->connection );
+    }
+);
 
 no Moose;
 __PACKAGE__->meta->make_immutable;
@@ -31,18 +77,11 @@
 
 =head1 SYNOPSIS
 
-    use Net::Google::Code::Connection;
-    my $connection = Net::Google::Code::Connection( project => 'foo' );
-
-    use Net::Google::Code::Issue;
-    my $ticket = Net::Google::Code::Issue->new( connection => $connection );
-    $ticket->load( 42 );
-
-    use Net::Google::Code::IssueSearch;
-    my $search = Net::Google::Code::IssueSearch->new( connection => $connection );
-    $search->search( _can => 'all', _q => 'foo bar' );
-    my @ids = $search->ids();
-
+    use Net::Google::Code;
+    my $project = Net::Google::Code->new( project => 'net-google-code' );
+    $project->issue;
+    $project->downloads;
+    $project->wiki;
 
 =head1 DESCRIPTION
 

Added: Net-Google-Code/trunk/t/20.code.t
==============================================================================
--- (empty file)
+++ Net-Google-Code/trunk/t/20.code.t	Thu Jan  8 02:26:53 2009
@@ -0,0 +1,14 @@
+use strict;
+use warnings;
+
+use Test::More tests => 7;
+use_ok('Net::Google::Code');
+my $name = 'net-google-code';
+my $project = Net::Google::Code->new( project => $name );
+is( $project->url, "http://code.google.com/p/$name/", 'default url' );
+is( $project->project, $name, 'project name' );
+isa_ok( $project->connection, 'Net::Google::Code::Connection' );
+isa_ok( $project->issue,      'Net::Google::Code::Issue' );
+isa_ok( $project->downloads,  'Net::Google::Code::Downloads' );
+isa_ok( $project->wiki,       'Net::Google::Code::Wiki' );
+



More information about the Bps-public-commit mailing list