| 1 | package App::Changelord::Command::Add; | ||||||||||||||||||||
| 2 | 2 | our $AUTHORITY = 'cpan:YANICK'; | |||||||||||||||||||
| 3 | 2 | $App::Changelord::Command::Add::VERSION = '0.0.2'; | |||||||||||||||||||
| 4 | 2 | ▶ | use 5.36.0; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | |||||||||||||||||||||
| 6 | 2 | ▶ | use Moo; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | use CLI::Osprey | ||||||||||||||||||||
| 8 | 2 | ▶ | desc => 'add a change to the NEXT release', | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 9 | 2 | description_pod => <<'END'; | |||||||||||||||||||
| 10 | Add a change entry to the NEXT release. | ||||||||||||||||||||
| 11 | END | ||||||||||||||||||||
| 12 | |||||||||||||||||||||
| 13 | 2 | ▶ | use PerlX::Maybe; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 14 | 2 | ▶ | use Path::Tiny; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 15 | 2 | ▶ | use App::Changelord::Command::Init; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 16 | |||||||||||||||||||||
| 17 | 2 | with 'App::Changelord::Role::Changelog'; | |||||||||||||||||||
| 18 | |||||||||||||||||||||
| 19 | # TODO validate the type | ||||||||||||||||||||
| 20 | 2 | option type => ( | |||||||||||||||||||
| 21 | format => 's', | ||||||||||||||||||||
| 22 | doc => 'type of change', | ||||||||||||||||||||
| 23 | is => 'ro', | ||||||||||||||||||||
| 24 | ); | ||||||||||||||||||||
| 25 | |||||||||||||||||||||
| 26 | 2 | option ticket => ( | |||||||||||||||||||
| 27 | format => 's', | ||||||||||||||||||||
| 28 | doc => 'associated ticket', | ||||||||||||||||||||
| 29 | is => 'ro', | ||||||||||||||||||||
| 30 | ); | ||||||||||||||||||||
| 31 | |||||||||||||||||||||
| 32 | 0 | ▶ | sub is_next($self,$release) { | ||||||||||||||||||
|
Subroutine
is_next: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||
| 33 | 0 | my $version = $release->{version}; | |||||||||||||||||||
| 34 | 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'
| |||||||||||||||||||||
| 35 | } | ||||||||||||||||||||
| 36 | |||||||||||||||||||||
| 37 | 0 | ▶ | sub next_release($self) { | ||||||||||||||||||
|
Subroutine
next_release: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||
| 38 | 0 | my $changelog = $self->changelog; | |||||||||||||||||||
| 39 | |||||||||||||||||||||
| 40 | 0 | my $release = $changelog->{releases}[0]; | |||||||||||||||||||
| 41 | |||||||||||||||||||||
| 42 | 0 | ▶ | unless( $self->is_next($release) ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 43 | unshift $changelog->{releases}->@*, | ||||||||||||||||||||
| 44 | 0 | $release = { | |||||||||||||||||||
| 45 | version => 'NEXT', | ||||||||||||||||||||
| 46 | changes => [], | ||||||||||||||||||||
| 47 | }; | ||||||||||||||||||||
| 48 | } | ||||||||||||||||||||
| 49 | |||||||||||||||||||||
| 50 | 0 | return $release; | |||||||||||||||||||
| 51 | } | ||||||||||||||||||||
| 52 | |||||||||||||||||||||
| 53 | 0 | ▶ | sub save_changelog($self) { | ||||||||||||||||||
|
Subroutine
save_changelog: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 54 | 0 | my $src = $self->source; | |||||||||||||||||||
| 55 | |||||||||||||||||||||
| 56 | 0 | path($src)->spew( App::Changelord::Command::Init::serialize_changelog($self) ); | |||||||||||||||||||
| 57 | } | ||||||||||||||||||||
| 58 | |||||||||||||||||||||
| 59 | 0 | ▶ | sub run ($self) { | ||||||||||||||||||
|
Subroutine
run: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 60 | 0 | my $version = $self->next_release; | |||||||||||||||||||
| 61 | |||||||||||||||||||||
| 62 | push $version->{changes}->@*, { | ||||||||||||||||||||
| 63 | 0 | maybe type => $self->type, | |||||||||||||||||||
| 64 | maybe ticket => $self->ticket, | ||||||||||||||||||||
| 65 | desc => join ' ', @ARGV, | ||||||||||||||||||||
| 66 | }; | ||||||||||||||||||||
| 67 | |||||||||||||||||||||
| 68 | 0 | $self->save_changelog; | |||||||||||||||||||
| 69 | |||||||||||||||||||||
| 70 | 0 | say "change added to the changelog"; | |||||||||||||||||||
| 71 | } | ||||||||||||||||||||
| 72 | |||||||||||||||||||||
| 73 | 2 | 'end of App::Changelog::Command::Add'; | |||||||||||||||||||
| 74 | |||||||||||||||||||||
| 75 | __END__ | ||||||||||||||||||||