File Coverage

blib/lib/Dist/Zilla/Plugin/EnsureMinimumPerl.pm
Criterion Covered Total %
statement 17 17 100.0
branch 1 2 50.0
condition n/a
subroutine 3 3 100.0
pod 0 1 0.0
total 21 23 91.3


line stmt bran cond sub pod time code
1             package Dist::Zilla::Plugin::EnsureMinimumPerl;
2              
3 1     1   2724549 use Moose;
  1         3  
  1         6  
4             with qw(
5             Dist::Zilla::Role::BeforeRelease
6             );
7 1     1   5791 use namespace::autoclean;
  1         2  
  1         8  
8              
9             our $VERSION = '0.02';
10              
11             sub before_release {
12 2     2 0 334810 my $self = shift;
13 2         99 my $prereqs = $self->zilla->prereqs->as_string_hash;
14              
15 2         1349 foreach my $phase (keys %{$prereqs}) {
  2         22  
16 1         12 foreach my $type (keys %{$prereqs->{$phase}}) {
  1         14  
17 1         7 my $found = grep { $_ eq 'perl' } keys %{$prereqs->{$phase}{$type}};
  1         8  
  1         11  
18 1 50       9 return if $found;
19             }
20             }
21              
22 1         15 $self->log_fatal('No minimum required version of Perl specified.');
23             }
24              
25             __PACKAGE__->meta->make_immutable;
26             1;
27              
28             =head1 NAME
29              
30             Dist::Zilla::Plugin::EnsureMinimumPerl - Ensure that you have specified a minimum version of Perl
31              
32             =head1 SYNOPSIS
33              
34             # In your dist.ini
35             [EnsureMinimumPerl]
36              
37             =head1 DESCRIPTION
38              
39             This C<Dist::Zilla> plugin checks to ensure that you have specified a minimum
40             required version of Perl, before allowing you to perform a release.
41              
42             I kept forgetting to be explicit about this in my own releases, and so I
43             whipped this up to force me to do it.
44              
45             =head1 AUTHOR
46              
47             Graham TerMarsch (cpan@howlingfrog.com)
48              
49             =head1 COPYRIGHT
50              
51             Copyright (C) 2021-, Graham TerMarsch. All Rights Reserved.
52              
53             This is free software; you can redistribute it and/or modify it under the same
54             license as Perl itself.
55              
56             =head1 SEE ALSO
57              
58             =over
59              
60             =item L<Dist::Zilla>
61              
62             =back
63              
64             =cut