| 1 | package App::Changelord::Role::Versions; | ||||||||||||||||||||||||||||
| 2 | 8 | our $AUTHORITY = 'cpan:YANICK'; | |||||||||||||||||||||||||||
| 3 | 8 | $App::Changelord::Role::Versions::VERSION = '0.0.2'; | |||||||||||||||||||||||||||
| 4 | 8 | ▶ | use v5.36.0; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 8 | ▶ | use List::AllUtils qw/ first min /; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 8 | ▶ | use Version::Dotted::Semantic; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 8 | ▶ | use Moo::Role; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 8 | ▶ | use feature 'try'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 8 | requires 'changelog'; | |||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 3 | ▶ | sub latest_version($self){ | ||||||||||||||||||||||||||
|
Subroutine
latest_version: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 16 | 3 | ▶ | first { $_ } grep { $_ ne 'NEXT' } map { eval { $_->{version} || '' } } $self->changelog->{releases}->@*, { version => 'v0.0.0' }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Condition50%1/2
$$_{'version'} || ''
MC/DC0%0/1
$$_{'version'} || ''
$$_{'version'}
Truth table50%1/2
A
A= $$_{'version'}
| |||||||||||||||||||||||||||||
| 17 | } | ||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 2 | ▶ | sub next_version($self) { | ||||||||||||||||||||||||||
|
Subroutine
next_version: called CC=8 SCAR=22.4
Pod
undocumented
| |||||||||||||||||||||||||||||
| 20 | 2 | ▶ | my $version = Version::Dotted::Semantic->new($self->latest_version // '0.0.0'); | ||||||||||||||||||||||||||
|
Condition50%1/2
$self->latest_version // "0.0.0"
MC/DC0%0/1
$self->latest_version // "0.0.0"
$self->latest_version
Truth table50%1/2
A
A= $self->latest_version
| |||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 2 | my $upcoming = $self->changelog->{releases}[0]; | |||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | 2 | ▶ | if( $upcoming->{version} and $upcoming->{version} ne 'NEXT') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$$upcoming{"version"} and $$upcoming{"version"} ne "NEXT"
MC/DC0%0/2
$$upcoming{"version"} and $$upcoming{"version"} ne "NEXT"
$$upcoming{"version"}
$$upcoming{"version"} ne "NEXT"
Truth table33%1/3
A and B
A= $$upcoming{"version"}B= $$upcoming{"version"} ne "NEXT"
| |||||||||||||||||||||||||||||
| 25 | 0 | $upcoming = { changes => [] }; | |||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | my %mapping = map { | ||||||||||||||||||||||||||||
| 29 | 2 | my $level = $_->{level}; | |||||||||||||||||||||||||||
| 30 | 12 | map { $_ => $level } $_->{keywords}->@* | |||||||||||||||||||||||||||
| 31 | 8 | } $self->change_types->@*; | |||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 8 | ▶ | no warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 34 | 1 | ▶ | my $bump =min 2, map { $_ eq 'major' ? 0 : $_ eq 'minor' ? 1 : 2 } map { $mapping{$_->{type}} || 'patch' } | ||||||||||||||||||||||||||
|
Branch: 2 branches
Condition50%1/2
$mapping{$$_{'type'}} || 'patch'
MC/DC0%0/1
$mapping{$$_{'type'}} || 'patch'
$mapping{$$_{'type'}}
Truth table50%1/2
A
A= $mapping{$$_{'type'}}
| |||||||||||||||||||||||||||||
| 35 | 1 | ▶ | map { ref ? $_ : { desc => $_ } } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 36 | 2 | $upcoming->{changes}->@*; | |||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 2 | $version->bump($bump); | |||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 2 | return $version->normal; | |||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | 0 | ▶ | sub is_next($self,$release) { | ||||||||||||||||||||||||||
|
Subroutine
is_next: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 44 | 0 | my $version = $release->{version}; | |||||||||||||||||||||||||||
| 45 | 0 | ▶ | return !$version || $version eq 'NEXT'; | ||||||||||||||||||||||||||
|
Condition0%0/3
!$version || $version eq 'NEXT'
MC/DC0%0/2
!$version || $version eq 'NEXT'
!$version
$version eq 'NEXT'
Truth table0%0/3
not(A) || B
A= !$versionB= $version eq 'NEXT'
| |||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 0 | ▶ | sub next_release($self) { | ||||||||||||||||||||||||||
|
Subroutine
next_release: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 49 | 0 | my $changelog = $self->changelog; | |||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | 0 | my $release = $changelog->{releases}[0]; | |||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | 0 | ▶ | unless( $self->is_next($release) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 54 | unshift $changelog->{releases}->@*, | ||||||||||||||||||||||||||||
| 55 | 0 | $release = { | |||||||||||||||||||||||||||
| 56 | version => 'NEXT', | ||||||||||||||||||||||||||||
| 57 | changes => [], | ||||||||||||||||||||||||||||
| 58 | }; | ||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | 0 | return $release; | |||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | 8 | 1; | |||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | __END__ | ||||||||||||||||||||||||||||