version 1.5, 2010/01/09 05:00:21 |
version 1.7, 2010/01/09 05:26:51 |
|
|
package Text::Todo; |
package Text::Todo; |
|
|
# $RedRiver: Todo.pm,v 1.4 2010/01/06 20:07:16 andrew Exp $ |
# $RedRiver: Todo.pm,v 1.6 2010/01/09 05:15:20 andrew Exp $ |
|
|
use warnings; |
use warnings; |
use strict; |
use strict; |
|
|
$file = $self->file($file); |
$file = $self->file($file); |
|
|
if ( !defined $file ) { |
if ( !defined $file ) { |
croak "todo file can't be found"; |
croak q{todo file can't be found}; |
} |
} |
|
|
if ( !-e $file ) { |
if ( !-e $file ) { |
|
|
|
|
$file = $self->file($file); |
$file = $self->file($file); |
if ( !defined $file ) { |
if ( !defined $file ) { |
croak "todo file can't be found"; |
croak q{todo file can't be found}; |
} |
} |
|
|
open my $fh, '>', $file or croak "Couldn't open [$file]: $!"; |
open my $fh, '>', $file or croak "Couldn't open [$file]: $!"; |
|
|
sub list { |
sub list { |
my ($self) = @_; |
my ($self) = @_; |
my $ident = ident($self); |
my $ident = ident($self); |
return if !$list_of{$ident}; |
|
|
|
my @list = @{ $list_of{$ident} }; |
return if !$list_of{$ident}; |
|
return wantarray ? @{ $list_of{$ident} } : $list_of{$ident}; |
return wantarray ? @list : \@list; |
|
} |
} |
|
|
sub listpri { |
sub listpri { |
|
|
return $entry; |
return $entry; |
} |
} |
|
|
sub del { |
sub del { |
my ( $self, $src ) = @_; |
my ( $self, $src ) = @_; |
my $ident = ident($self); |
my $ident = ident($self); |
|
|
my $id = $self->_find_entry_id($src); |
my $id = $self->_find_entry_id($src); |
|
|
my @list = $self->list; |
my @list = $self->list; |
my $entry = splice( @list, $id, 1 ); |
my $entry = splice @list, $id, 1; |
$list_of{$ident} = \@list; |
$list_of{$ident} = \@list; |
|
|
return $entry; |
return $entry; |
|
|
my $src = $self->_find_entry_id($entry); |
my $src = $self->_find_entry_id($entry); |
my @list = $self->list; |
my @list = $self->list; |
|
|
splice( @list, $dst, 0, splice( @list, $src, 1 ) ); |
splice @list, $dst, 0, splice @list, $src, 1; |
|
|
$list_of{$ident} = \@list; |
$list_of{$ident} = \@list; |
|
|
return 1; |
return 1; |
} |
} |
|
|
sub listproj { |
sub listproj { |
my ( $self, $entry, $dst ) = @_; |
my ( $self, $entry, $dst ) = @_; |
my $ident = ident($self); |
my $ident = ident($self); |
|
|
my %available_projects; |
my %available_projects; |
foreach my $e ($self->list) { |
foreach my $e ( $self->list ) { |
foreach my $p ( $e->projects ) { |
foreach my $p ( $e->projects ) { |
$available_projects{$p} = 1; |
$available_projects{$p} = 1; |
} |
} |
|
|
return wantarray ? @projects : \@projects; |
return wantarray ? @projects : \@projects; |
} |
} |
|
|
sub archive { carp "unsupported\n", return } |
sub archive { carp 'unsupported'; return } |
|
sub addto { carp 'unsupported'; return } |
|
sub listfile { carp 'unsupported'; return } |
|
|
sub addto { carp "unsupported\n", return } |
|
sub listfile { carp "unsupported\n", return } |
|
|
|
sub _find_entry_id { |
sub _find_entry_id { |
my ( $self, $entry ) = @_; |
my ( $self, $entry ) = @_; |
my $ident = ident($self); |
my $ident = ident($self); |
|
|
|
|
Text::Todo - Perl interface to todo_txt files |
Text::Todo - Perl interface to todo_txt files |
|
|
|
=head1 VERSION |
|
|
|
I will have to figure out how to include $VERSION in this somehow. |
|
|
|
Perhaps RCS Id is good enough? |
|
|
|
$Id$ |
|
|
=head1 SYNOPSIS |
=head1 SYNOPSIS |
|
|