[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.3 and 1.5

version 1.3, 2010/01/17 23:48:06 version 1.5, 2010/01/18 03:10:42
Line 1 
Line 1 
 package Text::Todo::REST::API;  package Text::Todo::REST::API;
   
 # $AFresh1: API.pm,v 1.2 2010/01/17 23:15:00 andrew Exp $  # $AFresh1: API.pm,v 1.4 2010/01/18 00:30:42 andrew Exp $
   
 use warnings;  use warnings;
 use strict;  use strict;
Line 9 
Line 9 
 use Data::Dumper;  use Data::Dumper;
 use Text::Todo;  use Text::Todo;
   
 use Class::Std;  use Class::Std::Utils;
 use Digest::MD5 qw/ md5_hex /;  use Digest::MD5 qw/ md5_hex /;
 use File::Spec;  use File::Spec;
   
Line 24 
Line 24 
 );  );
   
 {  {
     my (%todo_of,         %basedir_of,    %subdir_of,      my @attr_refs = \(
         %suffix_of,       %file_regex_of, %user_of,          my %todo_of,
         %list_of,         %action_of,     %args_of,          my %basedir_of,
         %action_handlers, %format_handlers,          my %subdir_of,
     ) : ATTRS;          my %suffix_of,
           my %file_regex_of,
           my %user_of,
           my %list_of,
           my %action_of,
           my %args_of,
           my %action_handlers,
           my %format_handlers,
       );
   
     sub BUILD {      sub new {
         my ( $self, $ident, $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 107 
Line 118 
         $todo_of{$ident}->load('todo_file')          $todo_of{$ident}->load('todo_file')
             or $self->fail('Unable to create Text::Todo object');              or $self->fail('Unable to create Text::Todo object');
   
         return;          return $self;
     }      }
   
     sub RegisterFormatHandler {      sub RegisterFormatHandler {
Line 130 
Line 141 
         return 1;          return 1;
     }      }
   
       sub content_type {return}
   
     sub Dump {      sub Dump {
         my ($self) = @_;          my ($self) = @_;
         return $self->fail( 'Unable to Dump [' . $self->_action . ']' );          return $self->fail( 'Unable to Dump [' . $self->_action . ']' );
Line 231 
Line 244 
         return $todo_of{$ident}->listtag($tag);          return $todo_of{$ident}->listtag($tag);
     }      }
   
     sub POST   {      sub POST {
         my ( $self, @args ) = @_;          my ( $self, @args ) = @_;
         return $self->_handle_action( 'POST', @args );          return $self->_handle_action( 'POST', @args );
     }      }
   
     sub PUT    {      sub PUT {
         my ( $self, @args ) = @_;          my ( $self, @args ) = @_;
         return $self->_handle_action( 'PUT', @args );          return $self->_handle_action( 'PUT', @args );
     }      }
Line 261 
Line 274 
     sub _action     { my ($self) = @_; return $action_of{ ident $self}; }      sub _action     { my ($self) = @_; return $action_of{ ident $self}; }
     sub _args       { my ($self) = @_; return $args_of{ ident $self}; }      sub _args       { my ($self) = @_; return $args_of{ ident $self}; }
   
       sub DESTROY {
           my ($self) = @_;
           my $ident = ident $self;
           foreach my $attr_ref (@attr_refs) {
               delete $attr_ref->{$ident};
           }
       }
 }  }
 1;    # Magic true value required at end of module  1;    # Magic true value required at end of module
 __END__  __END__

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

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