=================================================================== RCS file: /cvs/todotxt/Text-Todo-REST-API/lib/Text/Todo/REST/API.pm,v retrieving revision 1.14 retrieving revision 1.18 diff -u -r1.14 -r1.18 --- todotxt/Text-Todo-REST-API/lib/Text/Todo/REST/API.pm 2010/01/26 05:05:00 1.14 +++ todotxt/Text-Todo-REST-API/lib/Text/Todo/REST/API.pm 2010/02/13 21:48:28 1.18 @@ -1,6 +1,6 @@ package Text::Todo::REST::API; -# $AFresh1: API.pm,v 1.13 2010/01/26 04:30:13 andrew Exp $ +# $AFresh1: API.pm,v 1.17 2010/01/31 03:10:39 andrew Exp $ use warnings; use strict; @@ -104,21 +104,20 @@ } if ( $options{action} eq 'entry' && @{ $options{args} } ) { - $options{entry} = shift @{ $options{args} }; - if ( @{ $options{args} } ) { - $options{action} .= q{_} . lc shift @{ $options{args} }; - } + $options{action} .= q{_} . lc shift @{ $options{args} }; } push @{ $options{args} }, @args; - $options{list} - = defined $options{list} ? $options{list} : 'todo_file'; - - if ($options{list} !~ /\Q $options{suffix} \E$/xms) { - $options{list} .= $options{suffix}; + my $list = $self->_todo->file( $options{list} ); + + my $suffix = $self->_suffix || q{}; + if ( $list !~ / \Q$suffix\E $/ixms ) { + $list .= $suffix; } + $options{list} = $list; + if ( $options{format} ) { $format_of{ ident $self } = $options{format}; delete $options{format}; @@ -161,8 +160,9 @@ my ( $self, $path ) = @_; my %options = ( - list => undef, action => undef, + list => undef, + entry => undef, args => [], ); @@ -173,23 +173,24 @@ $options{format} = $1; } - ( $options{list}, $options{action}, @{ $options{args} } ) = split '/', - $path; + ( $options{list}, $options{action}, + @{ $options{args} } ) = split '/', $path; - if ( $options{list} ) { - $options{action} ||= 'list'; - - if ( ( lc $options{list} ) eq 'files' ) { - $options{action} = lc $options{list}; - $options{list} = q{}; + if (!defined $options{action}) { + if ( $options{list} ) { + $options{action} = 'list'; } - elsif ( $self->_todo->file( $options{list} ) ) { - $options{list} = $self->_todo->file( $options{list} ); + else { + $options{action} = 'files'; } } - if ( @{ $options{args} } && ( lc $options{args}[0] ) eq 'entry' ) { - $options{action} = lc shift @{ $options{args} }; + $options{action} = lc( $options{action} ); + + if ($options{action} eq 'entry' + || $options{action} eq 'tags' + ) { + $options{ $options{action} } = shift @{ $options{args} }; } return %options;