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

sunnavy at bestpractical.com sunnavy at bestpractical.com
Tue May 12 04:00:54 EDT 2009


Author: sunnavy
Date: Tue May 12 04:00:54 2009
New Revision: 19629

Modified:
   Net-Google-Code/trunk/lib/Net/Google/Code/Issue.pm
   Net-Google-Code/trunk/t/02.issue.t

Log:
make labels array ref, do *not* bother to parse it

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 04:00:54 2009
@@ -11,9 +11,9 @@
 );
 
 has 'labels' => (
-    isa     => 'HashRef',
+    isa     => 'ArrayRef',
     is      => 'rw',
-    default => sub { {} },
+    default => sub { [] },
 );
 
 has 'comments' => (
@@ -115,16 +115,8 @@
         else {
             my $href = $meta->find_by_tag_name('a')->attr_get_i('href');
 
-# from issue tracking faq:
-# The prefix before the first dash is the key, and the part after it is the value.
-            if ( $href =~ /list\?q=label:([^-]+?)-(.+)/ ) {
-                $self->labels->{$1} = $2;
-            }
-            elsif ( $href =~ /list\?q=label:([^-]+)$/ ) {
-                $self->labels->{$1} = undef;
-            }
-            else {
-                warn "can't parse label from $href";
+            if ( $href =~ /list\?q=label:(.+)/ ) {
+                $self->labels( [ @{$self->labels}, $1 ] );
             }
         }
     }
@@ -187,6 +179,12 @@
 
 =item description
 
+=item labels
+
+=item comments
+
+=item attachments
+
 =back
 
 =head1 AUTHOR

Modified: Net-Google-Code/trunk/t/02.issue.t
==============================================================================
--- Net-Google-Code/trunk/t/02.issue.t	(original)
+++ Net-Google-Code/trunk/t/02.issue.t	Tue May 12 04:00:54 2009
@@ -49,14 +49,9 @@
     closed => undef,
 );
 
-my %labels = (
-    Type   => 'Bug',
-    Pri    => 2,
-    OS     => 'All',
-    Area   => 'Installer',
-    intext => undef,
-    Mstone => 'X',
-    Foo    => 'Bar-Baz', # this is one we fake, for more than 1 hyphen
+my @labels = (
+    'Type-Bug', 'Pri-2',    'OS-All', 'Area-Installer',
+    'intext',   'Mstone-X', 'Foo-Bar-Baz',
 );
 
 for my $item ( qw/id summary description owner cc reporter status closed/ ) {
@@ -68,7 +63,7 @@
     }
 }
 
-is_deeply( $ticket->labels, \%labels, 'labels is extracted' );
+is_deeply( $ticket->labels, \@labels, 'labels is extracted' );
 
 is( scalar @{$ticket->comments}, 50, 'comments are extracted' );
 is( $ticket->comments->[0]->sequence, 1, 'sequence of 1st comments is 1' );



More information about the Bps-public-commit mailing list