[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.6 and 1.7

version 1.6, 2010/01/18 03:51:40 version 1.7, 2010/01/18 13:47:53
Line 1 
Line 1 
 package Text::Todo::REST::API;  package Text::Todo::REST::API;
   
 # $AFresh1: API.pm,v 1.5 2010/01/18 03:10:42 andrew Exp $  # $AFresh1: API.pm,v 1.6 2010/01/18 03:51:40 andrew Exp $
   
 use warnings;  use warnings;
 use strict;  use strict;
Line 15 
Line 15 
     search_path => __PACKAGE__ . '::Representations',      search_path => __PACKAGE__ . '::Representations',
     sub_name    => 'representations';      sub_name    => 'representations';
 use Digest::MD5 qw/ md5_hex /;  use Digest::MD5 qw/ md5_hex /;
 use File::Spec;  
   
 use version; our $VERSION = qv('0.0.1');  use version; our $VERSION = qv('0.0.1');
   
Line 31 
Line 30 
     my @attr_refs = \(      my @attr_refs = \(
         my %todo_of,          my %todo_of,
   
         my %basedir_of,  
         my %subdir_of,  
   
         my %suffix_of,          my %suffix_of,
         my %file_regex_of,          my %file_regex_of,
   
Line 75 
Line 71 
             }              }
         }          }
   
         $basedir_of{$ident} = $options->{basedir};  
         $subdir_of{$ident}  = $options->{subdir};  
         $suffix_of{$ident}  = $options->{suffix} || '.txt';          $suffix_of{$ident}  = $options->{suffix} || '.txt';
   
         $file_regex_of{$ident} = $options->{file_regex} || qr{          $file_regex_of{$ident} = $options->{file_regex} || qr{
Line 87 
Line 81 
             $              $
         }ixms;          }ixms;
   
         if ( !$basedir_of{$ident} ) {  
             return $self->fail('Required option [basedir]');  
         }  
   
         $options->{path_info} ||= q{};          $options->{path_info} ||= q{};
         $options->{path_info} =~ s{^/}{}xms;          $options->{path_info} =~ s{^/}{}xms;
         (   $user_of{$ident},   $list_of{$ident},          (   $list_of{$ident}, $action_of{$ident}, @{ $args_of{$ident} },
             $action_of{$ident}, @{ $args_of{$ident} },  
         ) = split '/', $options->{path_info};          ) = split '/', $options->{path_info};
   
         if ( $list_of{$ident} ) {          if ( $list_of{$ident} ) {
             $action_of{$ident} ||= 'list';              $action_of{$ident} ||= 'list';
         }          }
         elsif ( $user_of{$ident} ) {          else {
             $action_of{$ident} = 'files';              $action_of{$ident} = 'files';
         }          }
   
         my @todo_dir = $basedir_of{$ident};          eval { $todo_of{$ident} = Text::Todo->new(
               {   todo_dir  => $options->{todo_dir},
         my $todo_dir;                  todo_file => $options->{todo_file},
         if ( $user_of{$ident} ) {  
             push @todo_dir, $user_of{$ident};  
             if ( $subdir_of{$ident} ) {  
                 push @todo_dir, $subdir_of{$ident};  
             }              }
           ) };
             $todo_dir = File::Spec->catdir(@todo_dir);          if ($@) {
               $self->fail('Unable to create Text::Todo object' . $@);
         }          }
   
         my $todo_file;  
         if ( $list_of{$ident} ) {  
             $todo_file = $list_of{$ident} . $suffix_of{$ident};  
         }  
   
         $todo_of{$ident} = Text::Todo->new(  
             {   todo_dir  => $todo_dir,  
                 todo_file => $todo_file,  
             }  
         ) or $self->fail('Unable to create Text::Todo object');  
   
         $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 load todo_file in Text::Todo object');
   
         return $self;          return $self;
     }      }
Line 267 
Line 242 
     }      }
   
     sub _todo       { my ($self) = @_; return $todo_of{ ident $self }; }      sub _todo       { my ($self) = @_; return $todo_of{ ident $self }; }
     sub _basedir    { my ($self) = @_; return $basedir_of{ ident $self}; }  
     sub _subdir     { my ($self) = @_; return $subdir_of{ ident $self}; }  
     sub _suffix     { my ($self) = @_; return $suffix_of{ ident $self}; }      sub _suffix     { my ($self) = @_; return $suffix_of{ ident $self}; }
     sub _file_regex { my ($self) = @_; return $file_regex_of{ ident $self}; }      sub _file_regex { my ($self) = @_; return $file_regex_of{ ident $self}; }
     sub _user       { my ($self) = @_; return $user_of{ ident $self}; }      sub _user       { my ($self) = @_; return $user_of{ ident $self}; }

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

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