| 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
| |||||||||||
| 48 | unless version::is_strict("$ver"); | ||||||||||
| 49 | |||||||||||
| 50 | 2 | ▶ | if ( $self->decimal_only ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 51 | 1 | ▶ | $self->log_fatal("version $ver is not a decimal type version") | ||||||||
|
Branch: 1 branch
| |||||||||||
| 52 | if $ver->is_qv; | ||||||||||
| 53 | } | ||||||||||
| 54 | |||||||||||
| 55 | 1 | ▶ | if ( $self->tuple_only ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 56 | 1 | ▶ | $self->log_fatal("version $ver is not a tuple type version") | ||||||||
|
Branch: 1 branch
| |||||||||||
| 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__ | ||||||||||