line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Taskwarrior::Kusarigama::Task; |
2
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:YANICK'; |
3
|
|
|
|
|
|
|
# ABSTRACT: per-task Taskwarrior::Kusarigama::Wrapper |
4
|
|
|
|
|
|
|
$Taskwarrior::Kusarigama::Task::VERSION = '0.11.0'; |
5
|
3
|
|
|
3
|
|
22
|
use strict; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
98
|
|
6
|
|
|
|
|
|
|
|
7
|
3
|
|
|
3
|
|
985
|
use experimental 'postderef'; |
|
3
|
|
|
|
|
6521
|
|
|
3
|
|
|
|
|
16
|
|
8
|
|
|
|
|
|
|
|
9
|
3
|
|
|
3
|
|
1312
|
use Clone; |
|
3
|
|
|
|
|
4797
|
|
|
3
|
|
|
|
|
1614
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new { |
13
|
4
|
|
|
4
|
1
|
2513
|
my $class = shift; |
14
|
4
|
100
|
|
|
|
14
|
$class = ref $class if ref $class; |
15
|
|
|
|
|
|
|
|
16
|
4
|
|
|
|
|
6
|
my $data = pop; |
17
|
|
|
|
|
|
|
|
18
|
4
|
50
|
|
|
|
20
|
$data->{_wrapper} = shift if @_; |
19
|
|
|
|
|
|
|
|
20
|
4
|
|
|
|
|
49
|
bless $data, $class; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub add_note { |
24
|
1
|
|
|
1
|
0
|
7
|
my ( $self, $note ) = @_; |
25
|
|
|
|
|
|
|
|
26
|
1
|
|
50
|
|
|
8
|
$self->{annotations} ||= []; |
27
|
|
|
|
|
|
|
|
28
|
1
|
|
|
|
|
581
|
require DateTime::Functions; |
29
|
1
|
|
|
|
|
492336
|
my $now = DateTime::Functions::now(); |
30
|
|
|
|
|
|
|
|
31
|
1
|
|
|
|
|
421
|
my $timestamp = $now->ymd("") . 'T' . $now->hms("") . "Z"; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
push $self->{annotations}->@*, { |
34
|
1
|
|
|
|
|
38
|
entry => $timestamp, |
35
|
|
|
|
|
|
|
description => $note, |
36
|
|
|
|
|
|
|
}; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub clone { |
41
|
1
|
|
|
1
|
1
|
2
|
my $self = shift; |
42
|
|
|
|
|
|
|
|
43
|
1
|
|
|
|
|
11
|
my $cloned = Clone::clone($self); |
44
|
|
|
|
|
|
|
|
45
|
1
|
|
|
|
|
8
|
delete $cloned->{$_} for qw/ id uuid entry modified end urgency status /; |
46
|
|
|
|
|
|
|
|
47
|
1
|
|
|
|
|
19
|
return $self->new( $self->{_wrapper}, $cloned ); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub data { |
51
|
2
|
|
|
2
|
0
|
4
|
my $self = shift; |
52
|
2
|
|
|
|
|
14
|
require List::Util; |
53
|
2
|
|
|
7
|
|
22
|
return { List::Util::pairgrep( sub { $a !~ /^_/ }, %$self ) } |
|
7
|
|
|
|
|
42
|
|
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub save { |
57
|
2
|
|
|
2
|
0
|
735
|
my $self = shift; |
58
|
|
|
|
|
|
|
|
59
|
2
|
|
|
|
|
7
|
my $new = $self->{_wrapper}->save($self->data); |
60
|
|
|
|
|
|
|
|
61
|
2
|
|
|
|
|
10966
|
%$self = %$new; |
62
|
|
|
|
|
|
|
# delete $self->{$_} for keys %$self; |
63
|
|
|
|
|
|
|
# $self->{$_} = $new->{$_} for keys %$new; |
64
|
|
|
|
|
|
|
|
65
|
2
|
|
|
|
|
8
|
return $self; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub AUTOLOAD { |
70
|
5
|
|
|
5
|
|
3929
|
my $self = shift; |
71
|
|
|
|
|
|
|
|
72
|
5
|
|
|
|
|
37
|
(my $meth = our $AUTOLOAD) =~ s/.+:://; |
73
|
5
|
100
|
|
|
|
47
|
return if $meth eq 'DESTROY'; |
74
|
|
|
|
|
|
|
|
75
|
1
|
|
|
|
|
3
|
$meth =~ tr/_/-/; |
76
|
|
|
|
|
|
|
|
77
|
1
|
|
33
|
|
|
11
|
$self->{_wrapper} ||= Taskwarrior::Kusarigama::Wrapper->new; |
78
|
|
|
|
|
|
|
|
79
|
1
|
50
|
|
|
|
5
|
unshift @_, [] unless 'ARRAY' eq ref $_[0]; |
80
|
|
|
|
|
|
|
|
81
|
3
|
|
|
3
|
|
38
|
use Carp; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
417
|
|
82
|
|
|
|
|
|
|
my $uuid = $self->{uuid} |
83
|
1
|
50
|
|
|
|
4
|
or croak "task doesn't have an uuid\n"; |
84
|
|
|
|
|
|
|
|
85
|
1
|
|
|
|
|
4
|
push $_[0]->@*, { uuid => $uuid }; |
86
|
|
|
|
|
|
|
|
87
|
1
|
|
|
|
|
5
|
return $self->{_wrapper}->RUN($meth, @_); |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
1; |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
__END__ |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=pod |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=encoding UTF-8 |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head1 NAME |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Taskwarrior::Kusarigama::Task - per-task Taskwarrior::Kusarigama::Wrapper |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 VERSION |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
version 0.11.0 |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 SYNOPSIS |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
use Taskwarrior::Kusarigama::Wrapper; |
110
|
|
|
|
|
|
|
use Taskwarrior::Kusarigama::Task; |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
my $tw = Taskwarrior::Kusarigama::Wrapper->new; |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
my ( $task ) = $tw->export; |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
say $task->info; |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head1 DESCRIPTION |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
Thin wrapper around the task hashrefs that calls L<Taskwarrior::Kusarigama::Wrapper>. |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
Unless specified otherwise, the task must have |
123
|
|
|
|
|
|
|
an C<uuid> to be acted upon. |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head1 METHODS |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head2 new |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
my $task = Taskwarrior::Kusarigama::Task->new( \%data ); |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
my $task = Taskwarrior::Kusarigama::Task->new( $wrapper, \%data ); |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
Constructor. Takes in a raw hashref of the task's |
134
|
|
|
|
|
|
|
attributes as would be give by C<task export>, and |
135
|
|
|
|
|
|
|
an optional C<$wrapper>, which is the |
136
|
|
|
|
|
|
|
L<Taskwarrior::Kusarigama::Wrapper> |
137
|
|
|
|
|
|
|
object to use. The wrapper object can also |
138
|
|
|
|
|
|
|
be passed via a C<_wrapper> attribute. |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
# equivalent to the two-argument 'new' |
141
|
|
|
|
|
|
|
my $task = Taskwarrior::Kusarigama::Task->new( |
142
|
|
|
|
|
|
|
{ _wrapper => $wrapper, %data } |
143
|
|
|
|
|
|
|
); |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=head2 clone |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
Clone the current task. All attributes are copied, except for |
148
|
|
|
|
|
|
|
C<id>, C<uuid>, C<urgency>, C<status>, C<entry> and C<modified>. |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=head1 AUTHOR |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
Yanick Champoux <yanick@cpan.org> |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
This software is copyright (c) 2018, 2017 by Yanick Champoux. |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
159
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=cut |