Plugin/PreviousVersion/Changelog.pm

filter: Statementstmt 96.8% 31 / 32 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 9 / 9 Podpod 0.0% 0 / 1 totaltotal 93.1% 41 / 44 CC 2 SCAR 1.9
CC
2
Cov
94%
__ANON__
2.1
BEGIN
1.0
BEGIN
1.0
CRAP 1.2
« Plugin/NextVersion/Semantic.pm ↑ Summary Role/YANICK/PreviousVersionProvider.pm »
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
BranchTrueFalseTotal
my $changes_file = &first(sub { $_->name eq $self->filename; } , @{$self->zilla->files;}) or $self->log_fatal("changelog '@{[$self->filename];}' not found") 6 0 6
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__
« Plugin/NextVersion/Semantic.pm ↑ Summary Role/YANICK/PreviousVersionProvider.pm »