blib/lib/Dist/Zilla/Plugin/CheckStrictVersion.pm

filter: Statementstmt 96.4% 27 / 28 Branchbran 70.0% 7 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 1 totaltotal 88.8% 40 / 45 CC 6 SCAR 13.6
CC
6
Cov
89%
before_release
6.3
BEGIN
1.0
BEGIN
1.0
CRAP 3.9
↑ Summary
1 1 ▶use 5.008001;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 package Dist::Zilla::Plugin::CheckStrictVersion;
6 # ABSTRACT: BeforeRelease plugin to check for a strict version number
7 1 our $VERSION = '0.001'; # VERSION
8  
9 1 ▶use Moose 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use version ();
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 1 with 'Dist::Zilla::Role::BeforeRelease';
13  
14 #pod =attr decimal_only
15 #pod
16 #pod If true, only a decimal (non-tuple) version is allowed. Default is false.
17 #pod
18 #pod =cut
19  
20 1 has decimal_only => (
21 is => 'ro',
22 isa => 'Bool',
23 default => 0,
24 );
25  
26 #pod =attr tuple_only
27 #pod
28 #pod If true, only a tuple (a.k.a. 'dotted-decimal') version is allowed. Default is
29 #pod false.
30 #pod
31 #pod =cut
32  
33 1 has tuple_only => (
34 is => 'ro',
35 isa => 'Bool',
36 default => 0,
37 );
38  
39 # methods
40  
41 6 ▶sub before_release {
Subroutine before_release: called CC=6 SCAR=18.5
Pod undocumented
42 6 my $self = shift;
43 6 my $ver = $self->zilla->version;
44  
45 6 $ver = version->parse($ver);
46  
47 6 ▶ $self->log_fatal("version $ver fails version::is_strict")
Branch: 1 branch
BranchTrueFalseTotal
unless version::is_strict("$ver") 4 2 6
48 unless version::is_strict("$ver");
49  
50 2 ▶ if ( $self->decimal_only ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->decimal_only) 1 1 2
51 1 ▶ $self->log_fatal("version $ver is not a decimal type version")
Branch: 1 branch
BranchTrueFalseTotal
if $ver->is_qv 1 0 1
52 if $ver->is_qv;
53 }
54  
55 1 ▶ if ( $self->tuple_only ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->tuple_only) 1 0 1
56 1 ▶ $self->log_fatal("version $ver is not a tuple type version")
Branch: 1 branch
BranchTrueFalseTotal
unless $ver->is_qv 1 0 1
57 unless $ver->is_qv;
58 }
59  
60 0 return;
61 }
62  
63 1 1;
64  
65  
66 # vim: ts=4 sts=4 sw=4 et:
67  
68 __END__
↑ Summary