line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CPAN::Changes::HasEntries; |
2
|
32
|
|
|
32
|
|
322548
|
use strict; |
|
32
|
|
|
|
|
100
|
|
|
32
|
|
|
|
|
1006
|
|
3
|
32
|
|
|
32
|
|
228
|
use warnings; |
|
32
|
|
|
|
|
116
|
|
|
32
|
|
|
|
|
1775
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.500_001'; |
6
|
|
|
|
|
|
|
$VERSION =~ tr/_//d; |
7
|
|
|
|
|
|
|
|
8
|
32
|
|
|
32
|
|
751
|
use Sub::Quote qw(qsub); |
|
32
|
|
|
|
|
5160
|
|
|
32
|
|
|
|
|
1612
|
|
9
|
32
|
|
|
32
|
|
1352
|
use Types::Standard qw(ArrayRef InstanceOf Str); |
|
32
|
|
|
|
|
168612
|
|
|
32
|
|
|
|
|
259
|
|
10
|
|
|
|
|
|
|
|
11
|
32
|
|
|
32
|
|
25714
|
use Moo::Role; |
|
32
|
|
|
|
|
146
|
|
|
32
|
|
|
|
|
261
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
my $entry_type = (InstanceOf['CPAN::Changes::Entry'])->plus_coercions( |
14
|
|
|
|
|
|
|
Str ,=> qsub q{ CPAN::Changes::Entry->new(text => $_[0]) }, |
15
|
|
|
|
|
|
|
); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
has entries => ( |
18
|
|
|
|
|
|
|
is => 'rw', |
19
|
|
|
|
|
|
|
default => sub { [] }, |
20
|
|
|
|
|
|
|
isa => ArrayRef[$entry_type], |
21
|
|
|
|
|
|
|
coerce => 1, |
22
|
|
|
|
|
|
|
); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub clone { |
25
|
15
|
|
|
15
|
0
|
347
|
my $self = shift; |
26
|
15
|
|
|
|
|
52
|
my %attrs = %$self; |
27
|
15
|
|
|
|
|
27
|
$attrs{entries} = [ map $_->clone, @{$self->entries} ]; |
|
15
|
|
|
|
|
246
|
|
28
|
15
|
|
|
|
|
1636
|
(ref $self)->new(%attrs, @_); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub has_entries { |
32
|
151
|
|
|
151
|
0
|
277
|
my $self = shift; |
33
|
151
|
|
66
|
|
|
2390
|
!!($self->entries && @{$self->entries}); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub find_entry { |
37
|
2
|
|
|
2
|
0
|
15
|
my ($self, $find) = @_; |
38
|
|
|
|
|
|
|
return undef |
39
|
2
|
50
|
|
|
|
8
|
unless $self->has_entries; |
40
|
2
|
100
|
|
|
|
23
|
if (ref $find ne 'Regexp') { |
41
|
1
|
|
|
|
|
32
|
$find = qr/\A\Q$find\E\z/; |
42
|
|
|
|
|
|
|
} |
43
|
2
|
|
|
|
|
6
|
my ($entry) = grep { $_->text =~ $find } @{ $self->entries }; |
|
11
|
|
|
|
|
55
|
|
|
2
|
|
|
|
|
34
|
|
44
|
2
|
|
|
|
|
10
|
return $entry; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
around serialize => sub { |
48
|
|
|
|
|
|
|
my ($orig, $self, %args) = @_; |
49
|
|
|
|
|
|
|
my $indents = $args{indents} || []; |
50
|
|
|
|
|
|
|
my $styles = $args{styles} || []; |
51
|
|
|
|
|
|
|
my $width = $args{width} || 75; |
52
|
|
|
|
|
|
|
$indents = [ @{$indents}[1 .. $#$indents], ' '], |
53
|
|
|
|
|
|
|
$styles = [ @{$styles}[1 .. $#$styles], '-'], |
54
|
|
|
|
|
|
|
my $out = $self->$orig(@_); |
55
|
|
|
|
|
|
|
my $entries = $self->entries || []; |
56
|
|
|
|
|
|
|
for my $entry ( @$entries ) { |
57
|
|
|
|
|
|
|
my $sub = $entry->serialize( |
58
|
|
|
|
|
|
|
indents => $indents, |
59
|
|
|
|
|
|
|
styles => $styles, |
60
|
|
|
|
|
|
|
width => $width - length $indents->[0], |
61
|
|
|
|
|
|
|
); |
62
|
|
|
|
|
|
|
$sub =~ s/^(.)/$indents->[0]$1/mg; |
63
|
|
|
|
|
|
|
$sub .= "\n" |
64
|
|
|
|
|
|
|
if $entry->has_entries; |
65
|
|
|
|
|
|
|
$out .= $sub; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
$out =~ s/\n\n+\z/\n/; |
68
|
|
|
|
|
|
|
return $out; |
69
|
|
|
|
|
|
|
}; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub add_entry { |
72
|
7
|
|
|
7
|
0
|
268
|
my ($self, @entries) = @_; |
73
|
|
|
|
|
|
|
$_ = $entry_type->coerce($_) |
74
|
7
|
|
|
|
|
34
|
for @entries; |
75
|
7
|
|
|
|
|
408
|
push @{ $self->entries }, @entries; |
|
7
|
|
|
|
|
137
|
|
76
|
7
|
50
|
|
|
|
77
|
return wantarray ? @entries : $entries[-1]; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub remove_entry { |
80
|
0
|
|
|
0
|
0
|
|
my ($self, $entry) = @_; |
81
|
0
|
0
|
0
|
|
|
|
$entry |
82
|
|
|
|
|
|
|
= ref $entry && $entry->isa('CPAN::Changes::Entry') ? $entry |
83
|
|
|
|
|
|
|
: $self->find_entry($entry); |
84
|
0
|
0
|
|
|
|
|
return unless $entry; |
85
|
0
|
|
|
|
|
|
my @entries = grep { $_ != $entry } @{ $self->entries }; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
86
|
0
|
|
|
|
|
|
$self->entries(\@entries); |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
require CPAN::Changes::Entry; |
90
|
|
|
|
|
|
|
1; |