[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.9 and 1.10

version 1.9, 2010/01/23 07:15:40 version 1.10, 2010/01/24 04:17:39
Line 1 
Line 1 
 package Text::Todo::REST::API;  package Text::Todo::REST::API;
   
 # $AFresh1: API.pm,v 1.8 2010/01/19 03:18:34 andrew Exp $  # $AFresh1: API.pm,v 1.9 2010/01/23 07:15:40 andrew Exp $
   
 use warnings;  use warnings;
 use strict;  use strict;
 use Carp;  use Carp;
   
 use Text::Todo;  use Text::Todo;
   use Text::Todo::REST::API::Response;
   
 use Class::Std::Utils;  use Class::Std::Utils;
 use Digest::MD5 qw/ md5_hex /;  use Digest::MD5 qw/ md5_hex /;
Line 94 
Line 95 
             }              }
         }          }
   
         if ($options{action} eq 'entry' && @{ $options{args} }) {          if ( $options{action} eq 'entry' && @{ $options{args} } ) {
             $options{entry} = shift @{ $options{args} };              $options{entry} = shift @{ $options{args} };
             if (@{ $options{args} }) {              if ( @{ $options{args} } ) {
                 $options{action} = lc shift @{ $options{args} };                  $options{action} = lc shift @{ $options{args} };
             }              }
         }          }
   
         push @{ $options{args} }, @args;          push @{ $options{args} }, @args;
   
         $options{list} = defined $options{list} ? $options{list} : 'todo_file';          $options{list}
               = defined $options{list} ? $options{list} : 'todo_file';
   
         if ( $options{format} ) {          if ( $options{format} ) {
             $format_of{ ident $self } = $options{format};              $format_of{ ident $self } = $options{format};
Line 124 
Line 126 
     sub _handle_action {      sub _handle_action {
         my ( $self, @args ) = @_;          my ( $self, @args ) = @_;
   
         my ($method, %options) = $self->_parse_options(@args);          my ( $method, %options ) = $self->_parse_options(@args);
   
         my $todo = $self->_todo;          my $todo = $self->_todo;
         $todo->load( $options{list} );          $todo->load( $options{list} );
   
         foreach my $class ( $self ) {          foreach my $class ($self) {
             if ($class->can($method) ) {              if ( $class->can($method) ) {
                 return $class->$method( $todo, \%options );                  my @data = $class->$method( $todo, \%options );
   
                   return Text::Todo::REST::API::Response->new({
                       type   => $options{action},
                       format => $self->_format,
                       data   => \@data,
                   });
             }              }
         }          }
   
Line 162 
Line 170 
   
             my $suffix = $self->_suffix;              my $suffix = $self->_suffix;
   
             if (( lc $options{list} ) eq 'files') {              if ( ( lc $options{list} ) eq 'files' ) {
                 $options{action} = lc $options{list};                  $options{action} = lc $options{list};
                 $options{list} = q{};                  $options{list}   = q{};
             }              }
             elsif ($self->_todo->file( $options{list} )) {              elsif ( $self->_todo->file( $options{list} ) ) {
                $options{list} = $self->_todo->file( $options{list} );                  $options{list} = $self->_todo->file( $options{list} );
             }              }
         }          }
   
Line 197 
Line 205 
             return @entries;              return @entries;
         }          }
         elsif ( ref $key eq 'HASH' ) {          elsif ( ref $key eq 'HASH' ) {
             if (exists $key->{entry}) {              if ( exists $key->{entry} ) {
                $key = $key->{entry};                  $key = $key->{entry};
             }              }
             else {              else {
                 return $self->fail('get_entry requires key [entry]');                  return $self->fail('get_entry requires key [entry]');
Line 230 
Line 238 
     }      }
   
     sub get_list {      sub get_list {
         my ($self, $todo) = @_;          my ( $self, $todo ) = @_;
   
         my $line = 1;          my $line = 1;
         return map ( {          return map ( {
Line 242 
Line 250 
     }      }
   
     sub get_files {      sub get_files {
         my ($self, $todo) = @_;          my ( $self, $todo ) = @_;
         my $dir = $todo->file('todo_dir');          my $dir = $todo->file('todo_dir');
   
         if ( !$dir ) {          if ( !$dir ) {

Legend:
Removed from v.1.9  
changed lines
  Added in v.1.10

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