File Coverage

blib/lib/App/JobLog/Log/Note.pm
Criterion Covered Total %
statement 38 52 73.0
branch 3 6 50.0
condition 5 9 55.5
subroutine 17 23 73.9
pod 15 15 100.0
total 78 105 74.2


line stmt bran cond sub pod time code
1             package App::JobLog::Log::Note;
2             $App::JobLog::Log::Note::VERSION = '1.040';
3             # ABSTRACT: timestamped annotation in log
4              
5              
6 4     4   2853 use Modern::Perl;
  4         10  
  4         28  
7 4     4   503 use Class::Autouse qw{DateTime};
  4         10  
  4         25  
8 4     4   190 use autouse 'App::JobLog::Time' => qw(now);
  4         8  
  4         27  
9 4     4   419 use autouse 'Carp' => qw(carp);
  4         10  
  4         16  
10              
11             # for debugging
12             use overload '""' => sub {
13 1     1   39 $_[0]->data->to_string;
14 4     4   423 };
  4         9  
  4         32  
15 4     4   307 use overload 'bool' => sub { 1 };
  4     43061   8  
  4         24  
  43061         538950  
16              
17              
18             sub new {
19 10982     10982 1 18495 my ( $class, $logline ) = @_;
20 10982   66     43006 $class = ref $class || $class;
21 10982         33176 my $self = bless { log => $logline }, $class;
22 10982         39223 return $self;
23             }
24              
25              
26             sub clone {
27 0     0 1 0 my ($self) = @_;
28 0         0 my $clone = $self->new( $self->data->clone );
29 0         0 return $clone;
30             }
31              
32              
33             sub data {
34 21146     21146 1 70224 $_[0]->{log};
35             }
36              
37              
38             sub start : lvalue {
39 17610     17610 1 44137 $_[0]->data->time;
40             }
41              
42              
43             sub tags : lvalue {
44 1809     1809 1 6665 $_[0]->data->{tags};
45             }
46              
47              
48 0     0 1 0 sub tagged { !!@{ $_[0]->tags } }
  0         0  
49              
50              
51 0     0 1 0 sub tag_list { @{ $_[0]->tags } }
  0         0  
52              
53              
54             sub describe {
55 0     0 1 0 my ($self) = @_;
56 0         0 join '; ', @{ $self->data->description };
  0         0  
57             }
58              
59              
60             sub exists_tag {
61 0     0 1 0 my ( $self, @tags ) = @_;
62 0         0 $self->data->exists_tag(@tags);
63             }
64              
65              
66             sub all_tags {
67 434     434 1 635 my ( $self, @tags ) = @_;
68 434         827 $self->data->all_tags(@tags);
69             }
70              
71              
72             sub cmp {
73 161     161 1 754 my ( $self, $other ) = @_;
74 161 50       514 carp 'argument must also be time' unless $other->isa(__PACKAGE__);
75              
76             # defer to subclass sort order if other is a subclass and self isn't
77 161 50 66     1909 return -$other->cmp($self)
78             if ref $self eq __PACKAGE__ && ref $other ne __PACKAGE__;
79              
80 161         333 return DateTime->compare( $self->start, $other->start );
81             }
82              
83              
84             sub split_days {
85 63     63 1 176 return $_[0];
86             }
87              
88              
89             sub intersects {
90 63     63 1 100 my ( $self, $other ) = @_;
91 63 50       261 if ( $other->can('end') ) {
92 63   33     698 return $self->start >= $other->start && $self->start < $other->end;
93             }
94 0         0 return $self->start == $other->start;
95             }
96              
97              
98             sub is_note {
99             shift->{log}->is_note
100 20     20 1 83 }
101              
102              
103 0     0 1   sub is_open { 0 }
104              
105             1;
106              
107             __END__