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

Diff for /todotxt/Text-Todo-REST-API/lib/Text/Todo/REST/API.pm between version 1.5 and 1.6

version 1.5, 2010/01/18 03:10:42 version 1.6, 2010/01/18 03:51:40
Line 1 
Line 1 
 package Text::Todo::REST::API;  package Text::Todo::REST::API;
   
 # $AFresh1: API.pm,v 1.4 2010/01/18 00:30:42 andrew Exp $  # $AFresh1: API.pm,v 1.5 2010/01/18 03:10:42 andrew Exp $
   
 use warnings;  use warnings;
 use strict;  use strict;
Line 10 
Line 10 
 use Text::Todo;  use Text::Todo;
   
 use Class::Std::Utils;  use Class::Std::Utils;
   use Module::Pluggable
       require     => 1,
       search_path => __PACKAGE__ . '::Representations',
       sub_name    => 'representations';
 use Digest::MD5 qw/ md5_hex /;  use Digest::MD5 qw/ md5_hex /;
 use File::Spec;  use File::Spec;
   
Line 26 
Line 30 
 {  {
     my @attr_refs = \(      my @attr_refs = \(
         my %todo_of,          my %todo_of,
   
         my %basedir_of,          my %basedir_of,
         my %subdir_of,          my %subdir_of,
   
         my %suffix_of,          my %suffix_of,
         my %file_regex_of,          my %file_regex_of,
   
         my %user_of,          my %user_of,
         my %list_of,          my %list_of,
         my %action_of,          my %action_of,
         my %args_of,          my %args_of,
   
         my %action_handlers,          my %action_handlers,
         my %format_handlers,  
     );      );
   
     sub new {      sub new {
         my ( $class, $options ) = @_;          my ( $class, $options ) = @_;
   
         my $self = bless anon_scalar(), $class;  
         my $ident = ident($self);  
   
         my $format = $options->{default_format};          my $format = $options->{default_format};
         if ( $options->{format} ) {          if ( $options->{format} ) {
             $format = $options->{format};              $format = $options->{format};
Line 54 
Line 58 
             $format = $1;              $format = $1;
         }          }
   
           my $self = bless anon_scalar(), $class;
           my $ident = ident($self);
   
         if ( ref $self eq __PACKAGE__ && $format ) {          if ( ref $self eq __PACKAGE__ && $format ) {
             if ( $format_handlers{$format} ) {              my $found_handler = 0;
                 bless $self, $format_handlers{$format};          REP: foreach my $rep ( $self->representations ) {
                   if ( $rep->_handles($format) ) {
                       $self          = $rep->new($options);
                       $found_handler = 1;
                       last REP;
                   }
             }              }
             else {              if ( !$found_handler ) {
                 croak("Unable to find handler for [$format]\n");                  croak("Unable to find handler for [$format]\n");
             }              }
         }          }
Line 119 
Line 131 
             or $self->fail('Unable to create Text::Todo object');              or $self->fail('Unable to create Text::Todo object');
   
         return $self;          return $self;
     }  
   
     sub RegisterFormatHandler {  
         my ( $handler, @types ) = @_;  
   
         foreach my $type (@types) {  
             $format_handlers{$type} = $handler;  
         }  
   
         return 1;  
     }      }
   
     sub RegisterActionHandler {      sub RegisterActionHandler {

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6

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