[Bps-public-commit] r18280 - in Net-Trac/trunk: t

jesse at bestpractical.com jesse at bestpractical.com
Sun Feb 8 23:15:26 EST 2009


Author: jesse
Date: Sun Feb  8 23:15:26 2009
New Revision: 18280

Modified:
   Net-Trac/trunk/lib/Net/Trac/Ticket.pm
   Net-Trac/trunk/lib/Net/Trac/TicketHistoryEntry.pm
   Net-Trac/trunk/t/parse_props.t

Log:
Starting to work on removing MooseX::ClassAccessor
Working on props parsing

Modified: Net-Trac/trunk/lib/Net/Trac/Ticket.pm
==============================================================================
--- Net-Trac/trunk/lib/Net/Trac/Ticket.pm	(original)
+++ Net-Trac/trunk/lib/Net/Trac/Ticket.pm	Sun Feb  8 23:15:26 2009
@@ -59,8 +59,10 @@
 
 has _attachments            => ( isa => 'ArrayRef', is => 'rw' );
 
-class_has _loaded_new_metadata    => ( isa => 'Bool',     is => 'rw' );
-class_has _loaded_update_metadata => ( isa => 'Bool',     is => 'rw' );
+our $LOADED_NEW_METADATA =0;
+our $LOADED_UPDATE_METADATA =0;
+
+
 
 class_has valid_milestones  => ( isa => 'ArrayRef', is => 'rw', default => sub {[]} );
 class_has valid_types       => ( isa => 'ArrayRef', is => 'rw', default => sub {[]} );
@@ -94,7 +96,7 @@
 
 sub BUILD {
     my $self = shift;
-    $self->_fetch_new_ticket_metadata unless ($self->_loaded_new_metadata);
+    $self->_fetch_new_ticket_metadata unless ($LOADED_NEW_METADATA);
 }
 
 =head1 METHODS
@@ -187,7 +189,7 @@
 sub _fetch_new_ticket_metadata {
     my $self = shift;
 
-    return 1 if $self->_loaded_new_metadata;
+    return 1 if $LOADED_NEW_METADATA;
 
     my ($form, $form_num) = $self->_get_new_ticket_form;
     return undef unless $form;
@@ -199,14 +201,14 @@
 
     my $severity = $form->find_input("field_severity");
     $self->valid_severities([ $severity->possible_values ]) if $severity;
-    $self->_loaded_new_metadata( 1 );
+    $LOADED_NEW_METADATA++;
     return 1;
 }
 
 sub _fetch_update_ticket_metadata {
     my $self = shift;
 
-    return 1 if $self->_loaded_update_metadata;
+    return 1 if $LOADED_UPDATE_METADATA;
 
     my ($form, $form_num) = $self->_get_update_ticket_form;
     return undef unless $form;
@@ -214,7 +216,7 @@
     my $resolutions = $form->find_input("action_resolve_resolve_resolution");
     $self->valid_resolutions( [$resolutions->possible_values] ) if $resolutions;
     
-    $self->_loaded_update_metadata( 1 );
+    $LOADED_UPDATE_METADATA++;
     return 1;
 }
 
@@ -223,8 +225,8 @@
     my $type = lc shift;
 
     # Ensure that we've loaded up metadata
-    $self->_fetch_new_ticket_metadata unless ($self->_loaded_new_metadata);
-    $self->_fetch_update_ticket_metadata if ( ( $type eq 'update' ) && ! $self->_loaded_update_metadata);
+    $self->_fetch_new_ticket_metadata unless $LOADED_NEW_METADATA;
+    $self->_fetch_update_ticket_metadata if ( ( $type eq 'update' ) && ! $LOADED_UPDATE_METADATA);
 
     my %rules;
     for my $prop ( @_ ) {

Modified: Net-Trac/trunk/lib/Net/Trac/TicketHistoryEntry.pm
==============================================================================
--- Net-Trac/trunk/lib/Net/Trac/TicketHistoryEntry.pm	(original)
+++ Net-Trac/trunk/lib/Net/Trac/TicketHistoryEntry.pm	Sun Feb  8 23:15:26 2009
@@ -102,9 +102,9 @@
             # of descriptions
             next; 
         }
-        if ($line =~ m{<strong>keywords</strong>(.*)$}is ) {
-            my $value_changes = $1;
-            $prop = 'keywords';
+        if ($line =~ m{<strong>(keywords|cc)</strong>(.*)$}is ) {
+            my $value_changes = $2;
+            $prop = $1;
             my (@added, @removed);
             if ($value_changes =~ m{^\s*<em>(.*?)</em> added}is) {
                     my $added = $1;
@@ -126,7 +126,7 @@
 
             $old = join(' ', sort (@before, @removed));
             $new = join(' ', sort (@after));
-            $ticket_state->{keywords} = $old;
+            $ticket_state->{$prop} = $old;
         }
         elsif ( $line =~ m{<strong>(.*?)</strong>\s+changed\s+from\s+<em>(.*)</em>\s+to\s+<em>(.*)</em>}is ) {
             $prop = $1;

Modified: Net-Trac/trunk/t/parse_props.t
==============================================================================
--- Net-Trac/trunk/t/parse_props.t	(original)
+++ Net-Trac/trunk/t/parse_props.t	Sun Feb  8 23:15:26 2009
@@ -5,7 +5,6 @@
 <strong>owner</strong> changed from <em>somebody</em> to <em>jrv</em>.</li>
     <li><strong>status</strong> changed from <em>new</em> to <em>assigned</em>.</li>
     <li><strong>type</strong> changed from <em>defect</em> to <em>enhancement</em>.</li>
-    <li><strong>description</strong> set to <em>cry</em>
 
 EOF
 
@@ -13,7 +12,7 @@
 
 my $e = Net::Trac::TicketHistoryEntry->new();
 my $prop_data = $e->_parse_props($props);
-is(scalar keys %$prop_data, 4, "Four properties");
-my @keys = sort (qw(owner status type description));
+is(scalar keys %$prop_data, 3, "Four properties");
+my @keys = sort (qw(owner status type));
 is_deeply([sort keys %$prop_data], [sort @keys]);
 



More information about the Bps-public-commit mailing list