| 1 | package Dist::Zilla::Plugin::PreviousVersion::Changelog; | ||||||||||
| 2 | 2 | our $AUTHORITY = 'cpan:YANICK'; | |||||||||
| 3 | # ABSTRACT: extract previous version from changelog | ||||||||||
| 4 | 2 | $Dist::Zilla::Plugin::PreviousVersion::Changelog::VERSION = '0.2.6'; | |||||||||
| 5 | |||||||||||
| 6 | 2 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 2 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | 2 | ▶ | use CPAN::Changes; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 2 | ▶ | use List::Util qw/ first /; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | |||||||||||
| 12 | 2 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | |||||||||||
| 14 | 2 | with qw/ | |||||||||
| 15 | Dist::Zilla::Role::Plugin | ||||||||||
| 16 | Dist::Zilla::Role::YANICK::PreviousVersionProvider | ||||||||||
| 17 | /; | ||||||||||
| 18 | |||||||||||
| 19 | 2 | has filename => ( is => 'ro', isa=>'Str', default => 'Changes' ); | |||||||||
| 20 | |||||||||||
| 21 | has changelog => ( | ||||||||||
| 22 | is => 'ro', | ||||||||||
| 23 | isa => 'CPAN::Changes', | ||||||||||
| 24 | lazy => 1, | ||||||||||
| 25 | 6 | ▶ | default => sub { | ||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.2
| |||||||||||
| 26 | 6 | my $self = shift; | |||||||||
| 27 | 9 | ▶ | my $changes_file = first { $_->name eq $self->filename } | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 28 | 6 | ▶ | @{ $self->zilla->files } | ||||||||
|
Branch: 1 branch
| |||||||||||
| 29 | or $self->log_fatal( | ||||||||||
| 30 | 0 | "changelog '@{[ $self->filename ]}' not found" ); | |||||||||
| 31 | |||||||||||
| 32 | 6 | CPAN::Changes->load_string( | |||||||||
| 33 | $changes_file->content, | ||||||||||
| 34 | next_token => qr/\{\{\$NEXT\}\}/ | ||||||||||
| 35 | ); | ||||||||||
| 36 | }, | ||||||||||
| 37 | 2 | ); | |||||||||
| 38 | |||||||||||
| 39 | 6 | ▶ | sub provide_previous_version { | ||||||||
|
Subroutine
provide_previous_version: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 40 | 6 | my $self = shift; | |||||||||
| 41 | |||||||||||
| 42 | # TODO {{$NEXT}} not generic enough | ||||||||||
| 43 | 12 | ▶ | return first { $_ ne '{{$NEXT}}' } | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 44 | 6 | map { $_->version } | |||||||||
| 45 | reverse $self->changelog->releases; | ||||||||||
| 46 | } | ||||||||||
| 47 | |||||||||||
| 48 | 2 | __PACKAGE__->meta->make_immutable; | |||||||||
| 49 | |||||||||||
| 50 | 2 | 1; | |||||||||
| 51 | |||||||||||
| 52 | __END__ | ||||||||||