[BACK]Return to Entry.pm CVS log [TXT][DIR] Up to [local] / todotxt / Text-Todo / lib / Text / Todo

Diff for /todotxt/Text-Todo/lib/Text/Todo/Entry.pm between version 1.7 and 1.11

version 1.7, 2009/07/13 19:05:50 version 1.11, 2010/01/09 07:08:45
Line 1 
Line 1 
 package Text::Todo::Entry;  package Text::Todo::Entry;
   
 # $RedRiver: Entry.pm,v 1.6 2009/07/13 17:50:37 andrew Exp $  # $RedRiver: Entry.pm,v 1.9 2010/01/08 17:41:56 andrew Exp $
   
 use warnings;  use warnings;
 use strict;  use strict;
Line 23 
Line 23 
         project => q{+},          project => q{+},
     );      );
   
       # XXX Should the completion (x) be case sensitive?
       my $priority_completion_regex = qr/
           ^ \s*
           (?i:   (x)        \s+)?
           (?i:\( ([A-Z]) \) \s+)?
       /xms;
   
     for my $tag ( keys %tags ) {      for my $tag ( keys %tags ) {
         ## no critic strict          ## no critic strict
         no strict 'refs';    # Violates use strict, but allows code generation          no strict 'refs';    # Violates use strict, but allows code generation
Line 39 
Line 46 
         };          };
     }      }
   
       sub replace { _update_entry(@_) }
   
     sub new {      sub new {
         my ( $class, $text ) = @_;          my ( $class, $text ) = @_;
   
Line 63 
Line 72 
             $tags_of{$ident}{$tag} = { map { $_ => q{} }              $tags_of{$ident}{$tag} = { map { $_ => q{} }
                     $text =~ / (?:^|\s) $symbol  (\S+)/gxms };                      $text =~ / (?:^|\s) $symbol  (\S+)/gxms };
         }          }
         ( $completion_status_of{$ident} ) = $text =~ /^ \s*(x) /ixms;          ( $completion_status_of{$ident}, $priority_of{$ident} )
         ( $priority_of{$ident} )              = $text =~ / $priority_completion_regex /xms;
             = $text =~ /^ (?:\s*x)? \s* \( ([A-Z]) \)/ixms;  
   
         return 1;          return 1;
     }      }
Line 90 
Line 98 
         return $text_of{$ident};          return $text_of{$ident};
     }      }
   
     sub priority {      sub depri { pri( @_, '' ) }
         my ($self) = @_;  
       sub pri {
           my ( $self, $new_pri ) = @_;
         my $ident = ident($self);          my $ident = ident($self);
   
         return $priority_of{$ident};          if ( $new_pri !~ /^[a-zA-Z]?$/xms ) {
               croak "Invalid priority [$new_pri]";
           }
   
           $priority_of{$ident} = $new_pri;
   
           return $self->prepend();
     }      }
   
     sub completed {      sub priority {
         my ($self) = @_;          my ( $self, $new_pri ) = @_;
         my $ident = ident($self);          my $ident = ident($self);
   
         return $completion_status_of{$ident};          return $priority_of{$ident};
     }      }
   
     sub change {  
         my ( $self, $text ) = @_;  
         return $self->_update_entry($text);  
     }  
   
     sub prepend {      sub prepend {
         my ( $self, $addition ) = @_;          my ( $self, $addition ) = @_;
   
         my $new = $self->text;          my $new = $self->text;
           my @new;
   
         if ( my $priority = $self->priority ) {          $new =~ s/$priority_completion_regex//xms;
             $new =~ s/^( \s* \( $priority \))/$1 $addition/xms;  
           if ( $self->done ) {
               push @new, $self->done;
         }          }
         else {  
             $new = join q{ }, $addition, $new;          if ( $self->priority ) {
               push @new, '(' . $self->priority . ')';
         }          }
   
         return $self->change($new);          if ( defined $addition && length $addition ) {
               push @new, $addition;
           }
   
           return $self->_update_entry( join q{ }, @new, $new );
     }      }
   
     sub append {      sub append {
         my ( $self, $addition ) = @_;          my ( $self, $addition ) = @_;
         return $self->change( join q{ }, $self->text, $addition );          return $self->_update_entry( join q{ }, $self->text, $addition );
     }      }
   
     sub complete {      sub do {
         my ($self) = @_;          my ($self) = @_;
           my $ident = ident($self);
   
         if ( $self->completed ) {          if ( $self->done ) {
             return 1;              return 1;
         }          }
   
         return $self->change( join q{ }, 'x', $self->text );          $completion_status_of{$ident} = 'x';
   
           return $self->prepend();
     }      }
   
       sub done {
           my ($self) = @_;
           my $ident = ident($self);
   
           return $completion_status_of{$ident};
       }
   
 }  }
 1;    # Magic true value required at end of module  1;    # Magic true value required at end of module
 __END__  __END__
Line 192 
Line 221 
   
 =head2 in_project  =head2 in_project
   
 =head2 change  =head2 replace
   
 =head2 prepend  =head2 prepend
   
 =head2 append  =head2 append
   
 =head2 complete  =head2 do
   
 =head2 completed  =head2 done
   
   =head2 pri
   
   =head2 depri
   
 =head1 DIAGNOSTICS  =head1 DIAGNOSTICS
   

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.11

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>