version 1.8, 2010/01/09 06:26:43 |
version 1.9, 2010/01/09 06:54:15 |
|
|
|
|
$loaded_of{$ident} = undef; |
$loaded_of{$ident} = undef; |
|
|
|
$file = $self->file($file); |
|
|
if ( $list_of{$ident} = $self->listfile($file) ) { |
if ( $list_of{$ident} = $self->listfile($file) ) { |
$loaded_of{$ident} = $file; |
$loaded_of{$ident} = $file; |
return 1; |
return 1; |
|
|
} |
} |
close $fh or croak "Couldn't close [$file]: $!"; |
close $fh or croak "Couldn't close [$file]: $!"; |
|
|
|
$loaded_of{$ident} = $file; |
|
|
return 1; |
return 1; |
} |
} |
|
|
|
|
return wantarray ? @projects : \@projects; |
return wantarray ? @projects : \@projects; |
} |
} |
|
|
sub archive { carp 'unsupported'; return } |
sub archive { |
|
my ($self) = @_; |
|
my $ident = ident($self); |
|
|
|
if ( !defined $loaded_of{$ident} |
|
|| $loaded_of{$ident} ne $self->file('todo_file') ) |
|
{ |
|
carp 'todo_file not loaded'; |
|
return; |
|
} |
|
|
|
my $archived = 0; |
|
ENTRY: foreach my $e ( $self->list ) { |
|
if ( $e->done ) { |
|
if ( $self->addto( 'done_file', $e ) && $self->del($e) ) { |
|
$archived++; |
|
} |
|
else { |
|
carp q{Couldn't archive entry [} . $e->text . ']'; |
|
last ENTRY; |
|
} |
|
} |
|
} |
|
|
|
if ($archived) { |
|
$self->save; |
|
} |
|
|
|
return $archived; |
|
} |
|
|
sub addto { |
sub addto { |
my ( $self, $file, $entry ) = @_; |
my ( $self, $file, $entry ) = @_; |
my $ident = ident($self); |
my $ident = ident($self); |
|
|
croak q{file can't be found}; |
croak q{file can't be found}; |
} |
} |
|
|
|
if ( ref $entry ) { |
|
if ( ref $entry eq 'Text::Todo::Entry' ) { |
|
$entry = $entry->text; |
|
} |
|
else { |
|
carp 'Unknown ref [' . ref($entry) . ']'; |
|
return; |
|
} |
|
} |
|
|
open my $fh, '>>', $file or croak "Couldn't open [$file]: $!"; |
open my $fh, '>>', $file or croak "Couldn't open [$file]: $!"; |
print {$fh} $entry, "\n" |
print {$fh} $entry, "\n" |
or croak "Couldn't print to [$file]: $!"; |
or croak "Couldn't print to [$file]: $!"; |
|
|
|
|
=head2 new |
=head2 new |
|
|
|
=head2 file |
|
|
=head2 load |
=head2 load |
|
|
=head2 save |
=head2 save |
|
|
=head2 file |
|
|
|
=head2 list |
=head2 list |
|
|
|
=head2 listpri |
|
|
|
=head2 listproj |
|
|
=head2 add |
=head2 add |
|
|
|
=head2 del |
|
|
|
=head2 move |
|
|
|
=head2 archive |
|
|
|
=head2 addto |
|
|
|
=head2 listfile |
|
|
=head1 DIAGNOSTICS |
=head1 DIAGNOSTICS |
|
|