File Coverage

blib/lib/App/JobLog/Log/Note.pm
Criterion Covered Total %
statement 37 51 72.5
branch 3 6 50.0
condition 5 9 55.5
subroutine 16 22 72.7
pod 14 14 100.0
total 75 102 73.5


line stmt bran cond sub pod time code
1             package App::JobLog::Log::Note;
2             $App::JobLog::Log::Note::VERSION = '1.039';
3             # ABSTRACT: timestamped annotation in log
4              
5              
6 4     4   2904 use Modern::Perl;
  4         10  
  4         27  
7 4     4   517 use Class::Autouse qw{DateTime};
  4         9  
  4         26  
8 4     4   198 use autouse 'App::JobLog::Time' => qw(now);
  4         6  
  4         23  
9 4     4   419 use autouse 'Carp' => qw(carp);
  4         9  
  4         15  
10              
11             # for debugging
12             use overload '""' => sub {
13 1     1   39 $_[0]->data->to_string;
14 4     4   474 };
  4         6  
  4         33  
15 4     4   315 use overload 'bool' => sub { 1 };
  4     43061   8  
  4         32  
  43061         548080  
16              
17              
18             sub new {
19 10982     10982 1 18207 my ( $class, $logline ) = @_;
20 10982   66     39570 $class = ref $class || $class;
21 10982         30220 my $self = bless { log => $logline }, $class;
22 10982         40012 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 68423 $_[0]->{log};
35             }
36              
37              
38             sub start : lvalue {
39 17610     17610 1 43122 $_[0]->data->time;
40             }
41              
42              
43             sub tags : lvalue {
44 1809     1809 1 6970 $_[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 652 my ( $self, @tags ) = @_;
68 434         850 $self->data->all_tags(@tags);
69             }
70              
71              
72             sub cmp {
73 161     161 1 227 my ( $self, $other ) = @_;
74 161 50       478 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     1877 return -$other->cmp($self)
78             if ref $self eq __PACKAGE__ && ref $other ne __PACKAGE__;
79              
80 161         342 return DateTime->compare( $self->start, $other->start );
81             }
82              
83              
84             sub split_days {
85 63     63 1 211 return $_[0];
86             }
87              
88              
89             sub intersects {
90 63     63 1 93 my ( $self, $other ) = @_;
91 63 50       176 if ( $other->can('end') ) {
92 63   33     635 return $self->start >= $other->start && $self->start < $other->end;
93             }
94 0           return $self->start == $other->start;
95             }
96              
97              
98 0     0 1   sub is_open { 0 }
99              
100             1;
101              
102             __END__