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

sunnavy at bestpractical.com sunnavy at bestpractical.com
Wed Dec 31 04:32:25 EST 2008


Author: sunnavy
Date: Wed Dec 31 04:32:23 2008
New Revision: 17488

Modified:
   Net-Google-Code/trunk/   (props changed)
   Net-Google-Code/trunk/lib/Net/Google/Code/Ticket.pm

Log:
 r18453 at sunnavys-mb:  sunnavy | 2008-12-31 17:32:01 +0800
 extract attachments for ticket


Modified: Net-Google-Code/trunk/lib/Net/Google/Code/Ticket.pm
==============================================================================
--- Net-Google-Code/trunk/lib/Net/Google/Code/Ticket.pm	(original)
+++ Net-Google-Code/trunk/lib/Net/Google/Code/Ticket.pm	Wed Dec 31 04:32:23 2008
@@ -27,6 +27,12 @@
     default => sub { [] },
 );
 
+has attachments => (
+    isa     => 'ArrayRef',
+    is      => 'rw',
+    default => sub { [] },
+);
+
 our @PROPS = qw(id status owner closed cc summary reporter description);
 
 for my $prop (@PROPS) {
@@ -62,7 +68,23 @@
     $text =~ s/\s+$/\n/;
     $text =~ s/\r\n/\n/g;
     $self->state->{description} = $text;
-    # TODO extract attachments if there are some
+
+    my $attachments = $description->look_down(class => 'attachments');
+    if ( $attachments ) {
+        my @items = $attachments->find_by_tag_name( 'tr' );
+        require Net::Google::Code::TicketAttachment;
+        while ( scalar @items ) {
+            my $tr1 = shift @items;
+            my $tr2 = shift @items;
+            my $a =
+              Net::Google::Code::TicketAttachment->new(
+                connection => $self->connection );
+
+            if ( $a->parse( $tr1, $tr2 ) ) {
+                push @{$self->attachments}, $a;
+            }
+        }
+    }
 
     my ($meta) = $tree->look_down( id => 'issuemeta' );
     my @meta = $meta->find_by_tag_name('tr');



More information about the Bps-public-commit mailing list