| 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.12.0'; |
|
5
|
3
|
|
|
3
|
|
18
|
use strict; |
|
|
3
|
|
|
|
|
5
|
|
|
|
3
|
|
|
|
|
82
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
3
|
|
|
3
|
|
749
|
use experimental 'postderef'; |
|
|
3
|
|
|
|
|
5587
|
|
|
|
3
|
|
|
|
|
13
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
3
|
|
|
3
|
|
1070
|
use Clone; |
|
|
3
|
|
|
|
|
3999
|
|
|
|
3
|
|
|
|
|
1275
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new { |
|
13
|
4
|
|
|
4
|
1
|
2183
|
my $class = shift; |
|
14
|
4
|
100
|
|
|
|
12
|
$class = ref $class if ref $class; |
|
15
|
|
|
|
|
|
|
|
|
16
|
4
|
|
|
|
|
7
|
my $data = pop; |
|
17
|
|
|
|
|
|
|
|
|
18
|
4
|
50
|
|
|
|
15
|
$data->{_wrapper} = shift if @_; |
|
19
|
|
|
|
|
|
|
|
|
20
|
4
|
|
|
|
|
42
|
bless $data, $class; |
|
21
|
|
|
|
|
|
|
} |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub add_note { |
|
24
|
1
|
|
|
1
|
0
|
7
|
my ( $self, $note ) = @_; |
|
25
|
|
|
|
|
|
|
|
|
26
|
1
|
|
50
|
|
|
7
|
$self->{annotations} ||= []; |
|
27
|
|
|
|
|
|
|
|
|
28
|
1
|
|
|
|
|
400
|
require DateTime::Functions; |
|
29
|
1
|
|
|
|
|
384269
|
my $now = DateTime::Functions::now(); |
|
30
|
|
|
|
|
|
|
|
|
31
|
1
|
|
|
|
|
392
|
my $timestamp = $now->ymd("") . 'T' . $now->hms("") . "Z"; |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
push $self->{annotations}->@*, { |
|
34
|
1
|
|
|
|
|
36
|
entry => $timestamp, |
|
35
|
|
|
|
|
|
|
description => $note, |
|
36
|
|
|
|
|
|
|
}; |
|
37
|
|
|
|
|
|
|
} |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub clone { |
|
41
|
1
|
|
|
1
|
1
|
2
|
my $self = shift; |
|
42
|
|
|
|
|
|
|
|
|
43
|
1
|
|
|
|
|
9
|
my $cloned = Clone::clone($self); |
|
44
|
|
|
|
|
|
|
|
|
45
|
1
|
|
|
|
|
23
|
delete $cloned->{$_} for qw/ id uuid entry modified end urgency status /; |
|
46
|
|
|
|
|
|
|
|
|
47
|
1
|
|
|
|
|
3
|
return $self->new( $self->{_wrapper}, $cloned ); |
|
48
|
|
|
|
|
|
|
} |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub data { |
|
51
|
2
|
|
|
2
|
0
|
5
|
my $self = shift; |
|
52
|
2
|
|
|
|
|
11
|
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
|
696
|
my $self = shift; |
|
58
|
|
|
|
|
|
|
|
|
59
|
2
|
|
|
|
|
8
|
my $new = $self->{_wrapper}->save($self->data); |
|
60
|
|
|
|
|
|
|
|
|
61
|
2
|
|
|
|
|
8750
|
%$self = %$new; |
|
62
|
|
|
|
|
|
|
# delete $self->{$_} for keys %$self; |
|
63
|
|
|
|
|
|
|
# $self->{$_} = $new->{$_} for keys %$new; |
|
64
|
|
|
|
|
|
|
|
|
65
|
2
|
|
|
|
|
7
|
return $self; |
|
66
|
|
|
|
|
|
|
} |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub AUTOLOAD { |
|
70
|
5
|
|
|
5
|
|
3399
|
my $self = shift; |
|
71
|
|
|
|
|
|
|
|
|
72
|
5
|
|
|
|
|
32
|
(my $meth = our $AUTOLOAD) =~ s/.+:://; |
|
73
|
5
|
100
|
|
|
|
40
|
return if $meth eq 'DESTROY'; |
|
74
|
|
|
|
|
|
|
|
|
75
|
1
|
|
|
|
|
4
|
$meth =~ tr/_/-/; |
|
76
|
|
|
|
|
|
|
|
|
77
|
1
|
|
33
|
|
|
8
|
$self->{_wrapper} ||= Taskwarrior::Kusarigama::Wrapper->new; |
|
78
|
|
|
|
|
|
|
|
|
79
|
1
|
50
|
|
|
|
4
|
unshift @_, [] unless 'ARRAY' eq ref $_[0]; |
|
80
|
|
|
|
|
|
|
|
|
81
|
3
|
|
|
3
|
|
20
|
use Carp; |
|
|
3
|
|
|
|
|
6
|
|
|
|
3
|
|
|
|
|
336
|
|
|
82
|
|
|
|
|
|
|
my $uuid = $self->{uuid} |
|
83
|
1
|
50
|
|
|
|
3
|
or croak "task doesn't have an uuid\n"; |
|
84
|
|
|
|
|
|
|
|
|
85
|
1
|
|
|
|
|
3
|
push $_[0]->@*, { uuid => $uuid }; |
|
86
|
|
|
|
|
|
|
|
|
87
|
1
|
|
|
|
|
4
|
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.12.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) 2019, 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 |