| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package App::PerlWatcher::Status; |
|
2
|
|
|
|
|
|
|
{ |
|
3
|
|
|
|
|
|
|
$App::PerlWatcher::Status::VERSION = '0.20'; |
|
4
|
|
|
|
|
|
|
} |
|
5
|
|
|
|
|
|
|
# ABSTRACT: Represents the result of single watcher poll |
|
6
|
|
|
|
|
|
|
|
|
7
|
12
|
|
|
12
|
|
4621
|
use 5.12.0; |
|
|
12
|
|
|
|
|
40
|
|
|
|
12
|
|
|
|
|
555
|
|
|
8
|
12
|
|
|
12
|
|
63
|
use strict; |
|
|
12
|
|
|
|
|
25
|
|
|
|
12
|
|
|
|
|
494
|
|
|
9
|
12
|
|
|
12
|
|
67
|
use warnings; |
|
|
12
|
|
|
|
|
20
|
|
|
|
12
|
|
|
|
|
379
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
12
|
|
|
12
|
|
75
|
use Carp; |
|
|
12
|
|
|
|
|
21
|
|
|
|
12
|
|
|
|
|
821
|
|
|
12
|
12
|
|
|
12
|
|
1924
|
use Smart::Comments -ENV; |
|
|
12
|
|
|
|
|
47094
|
|
|
|
12
|
|
|
|
|
174
|
|
|
13
|
12
|
|
|
12
|
|
9065
|
use Moo; |
|
|
12
|
|
|
|
|
23
|
|
|
|
12
|
|
|
|
|
78
|
|
|
14
|
|
|
|
|
|
|
|
|
15
|
12
|
|
|
12
|
|
4371
|
use App::PerlWatcher::Level; |
|
|
12
|
|
|
|
|
26
|
|
|
|
12
|
|
|
|
|
8452
|
|
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
has 'watcher' => ( is => 'rw'); |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
has 'level' => ( is => 'rw'); |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
has 'description' => ( is => 'rw'); |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
has 'items' => ( is => 'rw'); |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
has 'timestamp' => ( is => 'rw', default => sub { time(); }); |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub updated_from { |
|
34
|
17
|
|
|
17
|
1
|
1738
|
my ($a, $b) = @_; |
|
35
|
17
|
50
|
|
|
|
103
|
carp unless $a->watcher->unique_id eq $b->watcher->unique_id; |
|
36
|
17
|
|
33
|
|
|
1220
|
my $updated = ($a->level != $b->level) |
|
37
|
|
|
|
|
|
|
|| (defined($a->items) && !defined($b->items)) |
|
38
|
|
|
|
|
|
|
|| (!defined($a->items) && defined($b->items)) |
|
39
|
|
|
|
|
|
|
|| (defined($a->items) && defined($b->items) |
|
40
|
|
|
|
|
|
|
&& _items_change_detector($a->items->(), $b->items->()) |
|
41
|
|
|
|
|
|
|
); |
|
42
|
|
|
|
|
|
|
# $updated |
|
43
|
17
|
|
|
|
|
72
|
return $updated; |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub _equals_items { |
|
47
|
6
|
|
|
6
|
|
7
|
my ($a, $b) = @_; |
|
48
|
|
|
|
|
|
|
# $a |
|
49
|
|
|
|
|
|
|
# $b |
|
50
|
6
|
|
|
|
|
14
|
my $result = !($a->content cmp $b->content); #|| ($a->timestamp <=> $b->timestamp) ); |
|
51
|
|
|
|
|
|
|
# $result |
|
52
|
6
|
|
|
|
|
20
|
return $result; |
|
53
|
|
|
|
|
|
|
} |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub _items_change_detector { |
|
56
|
3
|
|
|
3
|
|
12
|
my ($a, $b) = @_; |
|
57
|
|
|
|
|
|
|
# $a |
|
58
|
|
|
|
|
|
|
# $b |
|
59
|
3
|
50
|
|
|
|
9
|
return 1 if(@$a != @$b); |
|
60
|
3
|
|
|
|
|
6
|
for my $i (0..@$a-1) { |
|
61
|
6
|
|
|
|
|
8
|
return 1 |
|
62
|
|
|
|
|
|
|
if ! _equals_items( |
|
63
|
6
|
|
|
|
|
13
|
@{ $a }[$i], |
|
64
|
6
|
50
|
|
|
|
7
|
@{ $b }[$i], |
|
65
|
|
|
|
|
|
|
); |
|
66
|
|
|
|
|
|
|
} |
|
67
|
3
|
|
|
|
|
9
|
return 0; |
|
68
|
|
|
|
|
|
|
} |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub STORABLE_freeze { |
|
71
|
8
|
|
|
8
|
0
|
904
|
my ($self, $cloning) = @_; |
|
72
|
8
|
|
|
|
|
17
|
my $values_hash_ref = {}; |
|
73
|
8
|
|
|
|
|
20
|
my @copy_props = qw/watcher level timestamp/; |
|
74
|
8
|
|
|
|
|
17
|
@$values_hash_ref{ @copy_props } = map { $self->$_() } @copy_props; |
|
|
24
|
|
|
|
|
80
|
|
|
75
|
8
|
|
|
|
|
36
|
$values_hash_ref->{_description_value} = $self->description->(); |
|
76
|
8
|
|
|
|
|
32
|
my $items = $self->items; |
|
77
|
8
|
100
|
|
|
|
23
|
$values_hash_ref->{_items_value} = $items ? $items->() : undef; |
|
78
|
8
|
|
|
|
|
129
|
return ("", $values_hash_ref); |
|
79
|
|
|
|
|
|
|
} |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub STORABLE_thaw { |
|
82
|
8
|
|
|
8
|
0
|
17
|
my ($self, $cloning, $serialized, $values_hash_ref) = @_; |
|
83
|
8
|
|
|
|
|
49
|
my @copy_props = qw/watcher level timestamp/; |
|
84
|
8
|
|
|
|
|
15
|
for my $p (@copy_props) { |
|
85
|
24
|
|
|
|
|
68
|
$self->$p($values_hash_ref->{$p}); |
|
86
|
|
|
|
|
|
|
} |
|
87
|
8
|
|
|
0
|
|
41
|
$self->description( sub { $values_hash_ref->{_description_value} } ); |
|
|
0
|
|
|
|
|
0
|
|
|
88
|
3
|
|
|
3
|
|
39
|
$self->items( sub { $values_hash_ref->{_items_value} } ) |
|
89
|
8
|
100
|
|
|
|
185
|
if $values_hash_ref->{_items_value}; |
|
90
|
|
|
|
|
|
|
} |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
1; |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
__END__ |