[Bps-public-commit] r19628 - in Net-Google-Code/trunk/lib/Net/Google/Code: Issue Role

sunnavy at bestpractical.com sunnavy at bestpractical.com
Tue May 12 03:37:06 EDT 2009


Author: sunnavy
Date: Tue May 12 03:37:06 2009
New Revision: 19628

Modified:
   Net-Google-Code/trunk/lib/Net/Google/Code/Issue.pm
   Net-Google-Code/trunk/lib/Net/Google/Code/Issue/Attachment.pm
   Net-Google-Code/trunk/lib/Net/Google/Code/Issue/Comment.pm
   Net-Google-Code/trunk/lib/Net/Google/Code/Issue/PropChange.pm
   Net-Google-Code/trunk/lib/Net/Google/Code/Issue/Search.pm
   Net-Google-Code/trunk/lib/Net/Google/Code/Role/Fetchable.pm

Log:
mainly syntax improve

Modified: Net-Google-Code/trunk/lib/Net/Google/Code/Issue.pm
==============================================================================
--- Net-Google-Code/trunk/lib/Net/Google/Code/Issue.pm	(original)
+++ Net-Google-Code/trunk/lib/Net/Google/Code/Issue.pm	Tue May 12 03:37:06 2009
@@ -4,26 +4,26 @@
 with 'Net::Google::Code::Role';
 use Net::Google::Code::Issue::Comment;
 
-has state => (
+has 'state' => (
     isa     => 'HashRef',
     is      => 'rw',
     default => sub { {} },
 );
 
-has labels => (
+has 'labels' => (
     isa     => 'HashRef',
     is      => 'rw',
     default => sub { {} },
 );
 
-has comments => (
-    isa     => 'ArrayRef[Net::Google::Code::Comment]',
+has 'comments' => (
+    isa     => 'ArrayRef[Net::Google::Code::Issue::Comment]',
     is      => 'rw',
     default => sub { [] },
 );
 
-has attachments => (
-    isa     => 'ArrayRef[Net::Google::CodeTicketAttachment]',
+has 'attachments' => (
+    isa     => 'ArrayRef[Net::Google::Code::Issue::Attachment]',
     is      => 'rw',
     default => sub { [] },
 );
@@ -68,9 +68,10 @@
     $text =~ s/\r\n/\n/g;
     $self->state->{description} = $text;
 
-    my $attachments = $description->look_down( class => 'attachments' );
-    if ($attachments) {
-        my @items = $attachments->find_by_tag_name('tr');
+    my $att_tags = $tree->look_down( class => 'attachments' );
+    my @attachments;
+    for my $tag ($att_tags) {
+        my @items = $att_tags->find_by_tag_name('tr');
         require Net::Google::Code::Issue::Attachment;
         while ( scalar @items ) {
             my $tr1 = shift @items;
@@ -79,11 +80,12 @@
               Net::Google::Code::Issue::Attachment->new(
                 project => $self->project );
 
-            if ( $a->parse( [$tr1, $tr2] ) ) {
-                push @{ $self->attachments }, $a;
+            if ( $a->parse( [ $tr1, $tr2 ] ) ) {
+                push @attachments, $a;
             }
         }
     }
+    $self->attachments( \@attachments );
 
     my ($meta) = $tree->look_down( id => 'issuemeta' );
     my @meta = $meta->find_by_tag_name('tr');
@@ -128,14 +130,16 @@
     }
 
     # extract comments
-    my @comments = $tree->look_down( class => 'vt issuecomment' );
-    pop @comments;    # last one is for adding comment
-    for my $comment (@comments) {
-        my $object =
+    my @comments_tag = $tree->look_down( class => 'vt issuecomment' );
+    pop @comments_tag;    # last one is for adding comment
+    my @comments;
+    for my $tag (@comments_tag) {
+        my $comment =
           Net::Google::Code::Issue::Comment->new( project => $self->project );
-        $object->parse($comment);
-        push @{ $self->comments }, $object;
+        $comment->parse($tag);
+        push @comments, $comment;
     }
+    $self->comments( \@comments );
 
 }
 

Modified: Net-Google-Code/trunk/lib/Net/Google/Code/Issue/Attachment.pm
==============================================================================
--- Net-Google-Code/trunk/lib/Net/Google/Code/Issue/Attachment.pm	(original)
+++ Net-Google-Code/trunk/lib/Net/Google/Code/Issue/Attachment.pm	Tue May 12 03:37:06 2009
@@ -3,9 +3,9 @@
 with 'Net::Google::Code::Role';
 use Scalar::Util qw/blessed/;
 
-has name    => ( isa => 'Str', is => 'rw' );
-has url     => ( isa => 'Str', is => 'rw' );
-has size    => ( isa => 'Str', is => 'rw' );
+has 'name'    => ( isa => 'Str', is => 'rw' );
+has 'url'     => ( isa => 'Str', is => 'rw' );
+has 'size'    => ( isa => 'Str', is => 'rw' );
 
 sub parse {
     my $self = shift;

Modified: Net-Google-Code/trunk/lib/Net/Google/Code/Issue/Comment.pm
==============================================================================
--- Net-Google-Code/trunk/lib/Net/Google/Code/Issue/Comment.pm	(original)
+++ Net-Google-Code/trunk/lib/Net/Google/Code/Issue/Comment.pm	Tue May 12 03:37:06 2009
@@ -2,12 +2,12 @@
 use Moose;
 with 'Net::Google::Code::Role';
 
-has updates => ( isa => 'HashRef', is => 'rw', default => sub { {} } );
-has author  => ( isa => 'Str',     is => 'rw' );
-has date    => ( isa => 'Str',     is => 'rw' );
-has content => ( isa => 'Str',     is => 'rw' );
-has sequence => ( isa => 'Int', is => 'rw' );
-has attachments => (
+has 'updates' => ( isa => 'HashRef', is => 'rw', default => sub { {} } );
+has 'author'  => ( isa => 'Str',     is => 'rw' );
+has 'date'    => ( isa => 'Str',     is => 'rw' );
+has 'content' => ( isa => 'Str',     is => 'rw' );
+has 'sequence' => ( isa => 'Int', is => 'rw' );
+has 'attachments' => (
     isa     => 'ArrayRef[Net::Google::Code::Issue::Attachment]',
     is      => 'rw',
     default => sub { [] },
@@ -90,9 +90,10 @@
         }
 
     }
-    my $attachments = $element->look_down( class => 'attachments' );
-    if ($attachments) {
-        my @items = $attachments->find_by_tag_name('tr');
+    my @att_tags = $element->look_down( class => 'attachments' );
+    my @attachments;
+    for my $tag (@att_tags) {
+        my @items = $tag->find_by_tag_name('tr');
         require Net::Google::Code::Issue::Attachment;
         while ( scalar @items ) {
             my $tr1 = shift @items;
@@ -102,10 +103,11 @@
                 project => $self->project );
 
             if ( $a->parse( [ $tr1, $tr2 ] ) ) {
-                push @{ $self->attachments }, $a;
+                push @attachments, $a;
             }
         }
     }
+    $self->attachments( \@attachments );
 
     return 1;
 }

Modified: Net-Google-Code/trunk/lib/Net/Google/Code/Issue/PropChange.pm
==============================================================================
--- Net-Google-Code/trunk/lib/Net/Google/Code/Issue/PropChange.pm	(original)
+++ Net-Google-Code/trunk/lib/Net/Google/Code/Issue/PropChange.pm	Tue May 12 03:37:06 2009
@@ -1,9 +1,9 @@
 package Net::Google::Code::Issue::PropChange;
 use Moose;
 
-has property  => ( isa => 'Str', is => 'rw' );
-has old_value => ( isa => 'Str', is => 'rw' );
-has new_value => ( isa => 'Str', is => 'rw' );
+has 'property'  => ( isa => 'Str', is => 'rw' );
+has 'old_value' => ( isa => 'Str', is => 'rw' );
+has 'new_value' => ( isa => 'Str', is => 'rw' );
 
 no Moose;
 __PACKAGE__->meta->make_immutable;

Modified: Net-Google-Code/trunk/lib/Net/Google/Code/Issue/Search.pm
==============================================================================
--- Net-Google-Code/trunk/lib/Net/Google/Code/Issue/Search.pm	(original)
+++ Net-Google-Code/trunk/lib/Net/Google/Code/Issue/Search.pm	Tue May 12 03:37:06 2009
@@ -81,7 +81,7 @@
             my @ids = $tree->look_down( class => 'vt id col_0' );
             @ids =
               map { $_->content_array_ref->[0]->content_array_ref->[0] } @ids;
-            push @{ $self->ids }, @ids;
+            $self->ids( [ @{$self->ids}, @ids ] );
 
             while ( scalar @{$self->ids} < $total ) {
                 if ($mech->follow_link( text_regex => qr/Next\s+/ ) ) {
@@ -94,7 +94,7 @@
                           map {
                             $_->content_array_ref->[0]->content_array_ref->[0]
                           } @ids;
-                        push @{ $self->ids }, @ids;
+                        $self->ids( [ @{$self->ids}, @ids ] );
                     }
                     else {
                         die "failed to follow link: Next";

Modified: Net-Google-Code/trunk/lib/Net/Google/Code/Role/Fetchable.pm
==============================================================================
--- Net-Google-Code/trunk/lib/Net/Google/Code/Role/Fetchable.pm	(original)
+++ Net-Google-Code/trunk/lib/Net/Google/Code/Role/Fetchable.pm	Tue May 12 03:37:06 2009
@@ -3,7 +3,7 @@
 use Params::Validate ':all';
 use WWW::Mechanize;
 
-has mech => (
+has 'mech' => (
     isa     => 'WWW::Mechanize',
     is      => 'ro',
     lazy    => 1,



More information about the Bps-public-commit mailing list