App-Toodledo

 view release on metacpan or  search on metacpan

lib/App/Toodledo.pm  view on Meta::CPAN


method task_cache_valid () {
  my $ai = $self->account_info;
  unless ( $self->task_cache )
  {
    $self->task_cache( App::Toodledo::TaskCache->new );
    return unless $self->task_cache->exists;
    $self->task_cache->fetch;
  }

  my $fetched = $self->task_cache->last_updated;
  my $logstr = "Edited: " . localtime( $ai->lastedit_task )
             . ", Deleted: " . localtime( $ai->lastdelete_task )
             . " Fetched: " . localtime( $fetched );
  if ( $ai->lastedit_task >= $fetched || $ai->lastdelete_task >= $fetched )
  {
    $self->log->debug( "Task cache invalid ($logstr)\n" );
    return;
  }
  $self->log->debug( "Task cache valid ($logstr)\n" );
  return 1;

lib/App/Toodledo.pm  view on Meta::CPAN

Note: this method is overridden in App::Toodledo::Task.

=head2 $todo->delete( $object )

Delete the given object from Toodledo. The C<id> attribute of the object
must be correctly set. No other attributes will be used.
Note: this method is overridden in App::Toodledo::Task.

=head2 $todo->edit( $object )

The given object will be updated in Toodledo to match the one passed.
Note: this method is overridden in App::Toodledo::Task.  When the object
is a task, the signature is:

=head2 $todo->edit( $task, [@tasks] )

All of the tasks will be edited.  You are responsible for ensuring
that you do not exceed Toodledo limits on the number of tasks passed
(currently 50).

=head2 @objects = $todo->select( \@objects, $expr );

lib/App/Toodledo/Task.pm  view on Meta::CPAN

=head2 $task->edit( @tasks )

This is the method called by:

  App::Toodledo::edit( $task )

You can pass multiple tasks to it:

  $todo->edit( @tasks )

and they will all be updated.
The current maximum number of tasks you can send to Toodledo for
editing is 50.  B<This method does not check for that.>  (They
might raise the limit in the future.)  Bounds checking is the caller's
responsibility.

=head2 $task->status_str, $task->priority_str

Each of these methods operates on the string defined at
http://api.toodledo.com/2/tasks/index.php, not the integer.
The string will be turned into the integer going into Toodledo

lib/App/Toodledo/TaskCache.pm  view on Meta::CPAN

use MooseX::Method::Signatures;
use MooseX::ClassAttribute;
use App::Toodledo::Util qw(home);
use YAML qw(LoadFile DumpFile);
with 'MooseX::Log::Log4perl';

our $VERSION = '1.00';

has tasks          => ( is => 'rw', isa => 'ArrayRef[App::Toodledo::Task]',
		        auto_deref => 1 );
has last_updated   => ( is => 'rw', isa => 'Int' );  # Timestamp
class_has Filename => ( is => 'rw', default => '.toodledo_task_cache' );


sub _cache_filename
{
  File::Spec->catfile( home(), __PACKAGE__->Filename );
}


method exists () {

lib/App/Toodledo/TaskCache.pm  view on Meta::CPAN


method fetch () {
  $self->log->debug( "Loading from task cache\n" );
  %$self = LoadFile( _cache_filename() );
  $self->log->debug( "Fetched " . @{ $self->tasks } . " tasks from "
          . _cache_filename() . "\n" );
}


method store ( App::Toodledo::Task @tasks ) {
  $self->last_updated( time );
  $self->tasks( [ @tasks ] );
  $self->log->debug( "Storing " . @tasks ." tasks in " . _cache_filename() . "\n" );
  DumpFile( _cache_filename(), %$self );
}


1;

__END__

lib/App/Toodledo/TaskCache.pm  view on Meta::CPAN

=head2 $cache->store

Store the cache to the file.

=head1 ATTRIBUTES

=head2 tasks

A hashref of L<App::Toodledo::Task> objects.

=head2 last_updated

Unix time the cache was last written.  Use for comparing with time of
the last operation on the Toodledo server.

=head1 NOTES

Override the routine C<_cache_filename> in this package if you want to
change the filename used for the cache.  It returns the concatenation
of the user's home directory with the class attribute C<Filename>
(default: C<.toodledo_task_cache>).  If you just want to change the



( run in 0.301 second using v1.01-cache-2.11-cpan-05444aca049 )