| 1 | package CPAN::Changes::Release; | ||||||||||||||||||||||||||||
| 2 | 31 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 31 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 31 | our $VERSION = '0.500002'; | |||||||||||||||||||||||||||
| 6 | 31 | $VERSION =~ tr/_//d; | |||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 31 | ▶ | use Moo; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 31 | with 'CPAN::Changes::HasEntries'; | |||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 31 | has version => (is => 'rw'); | |||||||||||||||||||||||||||
| 13 | 31 | has date => (is => 'rw'); | |||||||||||||||||||||||||||
| 14 | 31 | has note => (is => 'rw'); | |||||||||||||||||||||||||||
| 15 | 31 | has line => (is => 'ro'); | |||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | around BUILDARGS => sub { | ||||||||||||||||||||||||||||
| 18 | 231 | ▶ | my ($orig, $class, @args) = @_; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=17.1
| |||||||||||||||||||||||||||||
| 19 | 231 | my $args = $class->$orig(@args); | |||||||||||||||||||||||||||
| 20 | 231 | ▶ | if (my $changes = delete $args->{changes}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 21 | 7 | ▶ | if ($args->{entries}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 22 | 0 | die "Mixing back-compat interface with new interface not allowed"; | |||||||||||||||||||||||||||
| 23 | } | ||||||||||||||||||||||||||||
| 24 | 7 | $args->{entries} = []; | |||||||||||||||||||||||||||
| 25 | 7 | for my $group (sort keys %$changes) { | |||||||||||||||||||||||||||
| 26 | 7 | my @entries = @{$changes->{$group}}; | |||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 7 | ▶ | if ($group eq '') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 29 | 7 | push @{$args->{entries}}, @entries; | |||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||
| 31 | else { | ||||||||||||||||||||||||||||
| 32 | 0 | my $entry = CPAN::Changes::Entry->new( | |||||||||||||||||||||||||||
| 33 | text => $group, | ||||||||||||||||||||||||||||
| 34 | entries => \@entries, | ||||||||||||||||||||||||||||
| 35 | ); | ||||||||||||||||||||||||||||
| 36 | 0 | push @{$args->{entries}}, $entry; | |||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||
| 40 | 231 | $args; | |||||||||||||||||||||||||||
| 41 | 31 | }; | |||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | sub serialize { | ||||||||||||||||||||||||||||
| 44 | 21 | ▶ | my ($self, %args) = @_; | ||||||||||||||||||||||||||
|
Subroutine
serialize: called CC=6 SCAR=18.4
Pod
documented
| |||||||||||||||||||||||||||||
| 45 | 21 | ▶ | my $indents = $args{indents} || ['', ' ', '']; | ||||||||||||||||||||||||||
|
Condition50%1/2
$args{'indents'} || ['', ' ', '']
MC/DC0%0/1
$args{'indents'} || ['', ' ', '']
$args{'indents'}
Truth table50%1/2
A
A= $args{'indents'}
| |||||||||||||||||||||||||||||
| 46 | 21 | ▶ | my $styles = $args{styles} || ['', '[]']; | ||||||||||||||||||||||||||
|
Condition50%1/2
$args{'styles'} || ['', '[]']
MC/DC0%0/1
$args{'styles'} || ['', '[]']
$args{'styles'}
Truth table50%1/2
A
A= $args{'styles'}
| |||||||||||||||||||||||||||||
| 47 | 21 | ▶ | my $width = $args{width} || 75; | ||||||||||||||||||||||||||
|
Condition50%1/2
$args{'width'} || 75
MC/DC0%0/1
$args{'width'} || 75
$args{'width'}
Truth table50%1/2
A
A= $args{'width'}
| |||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 21 | my $out = $indents->[0] . $styles->[0] . $self->version; | |||||||||||||||||||||||||||
| 50 | 21 | ▶ | if ($self->date || $self->note) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->date or $self->note
MC/DC50%1/2
$self->date or $self->note
$self->date
$self->note
Truth table66%2/3
A or B
A= $self->dateB= $self->note
| |||||||||||||||||||||||||||||
| 51 | 19 | $out .= ' ' . join ' ', (grep { defined } $self->date, $self->note); | |||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||
| 53 | 21 | $out . "\n"; | |||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | around serialize => sub { | ||||||||||||||||||||||||||||
| 57 | 21 | ▶ | my ($orig, $self, %args) = @_; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||
| 58 | 21 | ▶ | $args{indents} ||= ['', ' ', '']; | ||||||||||||||||||||||||||
|
Condition100%2/2
$args{"indents"} ||= ["", " ", ""]
MC/DC100%1/1
$args{"indents"} ||= ["", " ", ""]
$args{"indents"}
Truth table100%2/2
A
A= $args{"indents"}
| |||||||||||||||||||||||||||||
| 59 | 21 | ▶ | $args{styles} ||= ['', '[]']; | ||||||||||||||||||||||||||
|
Condition100%2/2
$args{"styles"} ||= ["", "[]"]
MC/DC100%1/1
$args{"styles"} ||= ["", "[]"]
$args{"styles"}
Truth table100%2/2
A
A= $args{"styles"}
| |||||||||||||||||||||||||||||
| 60 | 21 | ▶ | $args{width} ||= 75; | ||||||||||||||||||||||||||
|
Condition100%2/2
$args{"width"} ||= 75
MC/DC100%1/1
$args{"width"} ||= 75
$args{"width"}
Truth table100%2/2
A
A= $args{"width"}
| |||||||||||||||||||||||||||||
| 61 | 21 | ▶ | if (my $sort = $args{group_sort}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 62 | 3 | my $entries = $self->_sorted_groups($sort); | |||||||||||||||||||||||||||
| 63 | 3 | $self = $self->clone(entries => $entries); | |||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||
| 65 | 21 | $self->$orig(%args); | |||||||||||||||||||||||||||
| 66 | 31 | }; | |||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | sub changes { | ||||||||||||||||||||||||||||
| 69 | 35 | ▶ | my ($self, $group) = @_; | ||||||||||||||||||||||||||
|
Subroutine
changes: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 70 | 35 | ▶ | if (defined $group) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 71 | 15 | return $self->get_group($group)->changes; | |||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||
| 73 | else { | ||||||||||||||||||||||||||||
| 74 | 20 | return { map { $_ => $self->get_group($_)->changes } $self->groups }; | |||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | sub add_changes { | ||||||||||||||||||||||||||||
| 79 | 2 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
add_changes: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||
| 80 | 2 | my %opts; | |||||||||||||||||||||||||||
| 81 | 2 | ▶ | if (@_ > 1 && ref $_[0] eq 'HASH') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
@_ > 1 and ref $_[0] eq "HASH"
MC/DC50%1/2
@_ > 1 and ref $_[0] eq "HASH"
@_ > 1
ref $_[0] eq "HASH"
Truth table66%2/3
A and B
A= @_ > 1B= ref $_[0] eq "HASH"
| |||||||||||||||||||||||||||||
| 82 | 1 | %opts = %{ +shift }; | |||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||
| 84 | 2 | ▶ | $self->get_group($opts{group} || '')->add_changes(@_); | ||||||||||||||||||||||||||
|
Condition100%2/2
$opts{'group'} || ''
MC/DC100%1/1
$opts{'group'} || ''
$opts{'group'}
Truth table100%2/2
A
A= $opts{'group'}
| |||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | sub set_changes { | ||||||||||||||||||||||||||||
| 88 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
set_changes: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 89 | 0 | my %opts; | |||||||||||||||||||||||||||
| 90 | 0 | ▶ | if (@_ > 1 && ref $_[0] eq 'HASH') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@_ > 1 and ref $_[0] eq "HASH"
MC/DC0%0/2
@_ > 1 and ref $_[0] eq "HASH"
@_ > 1
ref $_[0] eq "HASH"
Truth table0%0/3
A and B
A= @_ > 1B= ref $_[0] eq "HASH"
| |||||||||||||||||||||||||||||
| 91 | 0 | %opts = %{ +shift }; | |||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||
| 93 | 0 | ▶ | $self->get_group($opts{group} || '')->set_changes(@_); | ||||||||||||||||||||||||||
|
Condition0%0/2
$opts{'group'} || ''
MC/DC0%0/1
$opts{'group'} || ''
$opts{'group'}
Truth table0%0/2
A
A= $opts{'group'}
| |||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | sub clear_changes { | ||||||||||||||||||||||||||||
| 97 | 1 | ▶ | $_[0]->entries([]); | ||||||||||||||||||||||||||
|
Subroutine
clear_changes: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | sub groups { | ||||||||||||||||||||||||||||
| 101 | 42 | ▶ | my ($self, %args) = @_; | ||||||||||||||||||||||||||
|
Subroutine
groups: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||
| 102 | 42 | ▶ | my $sort = $args{sort} || sub { sort @_ }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.1
Condition66%2/3
$args{'sort'} || sub {
sort @_;
}
MC/DC0%0/2
$args{'sort'} || sub {
sort @_;
}
$args{'sort'}
sub {
sort @_;
}
Truth table66%2/3
A || B
A= $args{'sort'}B= sub {
sort @_;
}
| |||||||||||||||||||||||||||||
| 103 | 42 | my %groups; | |||||||||||||||||||||||||||
| 104 | 42 | for my $entry ( @{ $self->entries } ) { | |||||||||||||||||||||||||||
| 105 | 44 | ▶ | if ($entry->has_entries) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 106 | 12 | $groups{$entry->text}++; | |||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||
| 108 | else { | ||||||||||||||||||||||||||||
| 109 | 32 | $groups{''}++; | |||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||
| 112 | 42 | return $sort->(keys %groups); | |||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||
| 115 | sub add_group { | ||||||||||||||||||||||||||||
| 116 | 0 | ▶ | my ($self, @groups) = @_; | ||||||||||||||||||||||||||
|
Subroutine
add_group: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 117 | 0 | push @{ $self->entries }, map { CPAN::Changes::Entry->new(text => $_) } @groups; | |||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | sub delete_group { | ||||||||||||||||||||||||||||
| 121 | 0 | ▶ | my ($self, @groups) = @_; | ||||||||||||||||||||||||||
|
Subroutine
delete_group: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 122 | 0 | my @entries = @{ $self->entries }; | |||||||||||||||||||||||||||
| 123 | 0 | for my $name (@groups) { | |||||||||||||||||||||||||||
| 124 | 0 | @entries = grep { $_->text ne $name } @entries; | |||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||
| 126 | 0 | $self->entries(\@entries); | |||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||
| 129 | # this is nonsense, but try to emulate. if nothing has entries, then there | ||||||||||||||||||||||||||||
| 130 | # are no "groups", so leave everything. | ||||||||||||||||||||||||||||
| 131 | sub delete_empty_groups { | ||||||||||||||||||||||||||||
| 132 | 4 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
delete_empty_groups: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 133 | 4 | my @entries = grep { $_->has_entries } @{ $self->entries }; | |||||||||||||||||||||||||||
| 134 | return | ||||||||||||||||||||||||||||
| 135 | 4 | ▶ | if !@entries; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 136 | 3 | $self->entries(\@entries); | |||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||
| 139 | sub get_group { | ||||||||||||||||||||||||||||
| 140 | 36 | ▶ | my ($self, $name) = @_; | ||||||||||||||||||||||||||
|
Subroutine
get_group: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||
| 141 | 36 | require CPAN::Changes::Group; | |||||||||||||||||||||||||||
| 142 | 36 | ▶ | if (defined $name && length $name) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $name and length $name
MC/DC50%1/2
defined $name and length $name
defined $name
length $name
Truth table66%2/3
A and B
A= defined $nameB= length $name
| |||||||||||||||||||||||||||||
| 143 | 5 | my ($entry) = grep { $_->text eq $name } @{ $self->entries }; | |||||||||||||||||||||||||||
| 144 | 5 | ▶ | $entry ||= $self->add_entry($name); | ||||||||||||||||||||||||||
|
Condition66%2/3
$entry ||= $self->add_entry($name)
MC/DC0%0/2
$entry ||= $self->add_entry($name)
$entry
$self->add_entry($name)
Truth table66%2/3
A ||= B
A= $entryB= $self->add_entry($name)
| |||||||||||||||||||||||||||||
| 145 | 5 | return CPAN::Changes::Group->new(_entry => $entry); | |||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||
| 147 | else { | ||||||||||||||||||||||||||||
| 148 | 31 | return CPAN::Changes::Group->new(_entry => $self); | |||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||
| 152 | sub attach_group { | ||||||||||||||||||||||||||||
| 153 | 2 | ▶ | my ($self, $group) = @_; | ||||||||||||||||||||||||||
|
Subroutine
attach_group: called CC=3 SCAR=11.2
Pod
documented
| |||||||||||||||||||||||||||||
| 154 | 2 | my $entry = $group->_maybe_entry; | |||||||||||||||||||||||||||
| 155 | 2 | my $text = $entry->text; | |||||||||||||||||||||||||||
| 156 | 2 | my $entries = $self->entries; | |||||||||||||||||||||||||||
| 157 | 2 | ▶ | if ($text eq '') { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 158 | 0 | $self->add_entry( @{ $entry->entries } ); | |||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||
| 160 | 1 | elsif (my ($found) = grep { $_->text eq $text } @$entries) { | |||||||||||||||||||||||||||
| 161 | 1 | $found->add_entry( @{ $entry->entries } ); | |||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||
| 163 | else { | ||||||||||||||||||||||||||||
| 164 | 1 | $self->add_entry( $entry ); | |||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||
| 168 | sub group_values { | ||||||||||||||||||||||||||||
| 169 | 0 | ▶ | my ($self, @groups) = @_; | ||||||||||||||||||||||||||
|
Subroutine
group_values: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 170 | 0 | return map { $self->get_group($_) } $self->groups(@groups); | |||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||
| 173 | sub _sorted_groups { | ||||||||||||||||||||||||||||
| 174 | 3 | ▶ | my ($self, $sort_function) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_sorted_groups: called CC=4 SCAR=14.0
| |||||||||||||||||||||||||||||
| 175 | 3 | my @groups = grep { $_->has_entries } @{ $self->entries }; | |||||||||||||||||||||||||||
| 176 | 3 | my @bare = grep { !$_->has_entries } @{ $self->entries }; | |||||||||||||||||||||||||||
| 177 | return \@bare | ||||||||||||||||||||||||||||
| 178 | 3 | ▶ | if !@groups; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||
| 180 | 3 | my %entries = map { $_->text => [$_] } @groups; | |||||||||||||||||||||||||||
| 181 | 3 | ▶ | $entries{''} = \@bare | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 182 | if @bare; | ||||||||||||||||||||||||||||
| 183 | 3 | my @sorted = $sort_function->(keys %entries); | |||||||||||||||||||||||||||
| 184 | 3 | ▶ | return [ map { @{ $entries{$_} || [] } } @sorted ]; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||
| 187 | 31 | 1; | |||||||||||||||||||||||||||
| 188 | __END__ | ||||||||||||||||||||||||||||