blib/lib/Dist/Zilla/Plugin/DBIO/RequireCoreVersion.pm

filter: Statementstmt 96.3% 26 / 27 Branchbran 83.3% 5 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod 0.0% 0 / 1 totaltotal 92.3% 36 / 39 CC 5 SCAR 8.9
CC
5
Cov
94%
_minimum
3.3
before_release
3.0
BEGIN
1.0
CRAP 2.4
« blib/lib/Pod/Weaver/PluginBundle/DBIO.pm ↑ Summary blib/lib/Dist/Zilla/Plugin/DBIO/LicenseFile.pm »
1 package Dist::Zilla::Plugin::DBIO::RequireCoreVersion;
2 # ABSTRACT: Stop a release whose runtime prereq on DBIO lags behind the dist's own version
3 7 our $VERSION = '0.900007';
4 7 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 7 ▶use version ();
Subroutine BEGIN: called CC=1 SCAR=0.0
6 7 with 'Dist::Zilla::Role::BeforeRelease';
7  
8  
9 6 ▶sub before_release {
Subroutine before_release: called CC=3 SCAR=11.0
Pod undocumented
10 6 my ($self) = @_;
11 6 my $want = $self->zilla->version;
12 my $have = $self->zilla->prereqs->requirements_for('runtime', 'requires')
13 6 ->as_string_hash->{DBIO};
14 6 my $line = "requires 'DBIO', '$want';";
15  
16 6 ▶ unless (defined $have) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $have) 1 5 6
17 1 $self->log_debug('no runtime prereq on DBIO, nothing to check');
18 1 return;
19 }
20  
21 5 my $min = $self->_minimum($have);
22 5 ▶ $self->log_fatal("the cpanfile requires DBIO $have, below this dist's version $want -- change the cpanfile line to $line")
Branch: 1 branch
BranchTrueFalseTotal
if "version"->parse($min) < "version"->parse($want) 3 2 5
23 if version->parse($min) < version->parse($want);
24  
25 2 $self->log_debug("DBIO $have required, dist version $want");
26 }
27  
28 # The lowest version a requirement string allows: "0.9" or ">= 0.9, < 2" give
29 # 0.9, a string without a lower bound gives 0.
30 5 ▶sub _minimum {
Subroutine _minimum: called CC=3 SCAR=12.0
31 5 my ($self, $req) = @_;
32 5 for my $part (split /\s*,\s*/, $req) {
33 5 ▶ return $1 if $part =~ /^(?:>=\s*)?([0-9][0-9._]*)\z/;
Branch: 1 branch
BranchTrueFalseTotal
if $part =~ /^(?:>=\s*)?([0-9][0-9._]*)\z/ 5 0 5
34 }
35 0 return 0;
36 }
37  
38 7 __PACKAGE__->meta->make_immutable;
39 7 ▶no Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
40 7 1;
41  
42 __END__
« blib/lib/Pod/Weaver/PluginBundle/DBIO.pm ↑ Summary blib/lib/Dist/Zilla/Plugin/DBIO/LicenseFile.pm »