| 1 | package Enbld::Target::Attribute::Version; | ||||||||||
| 2 | |||||||||||
| 3 | 3 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 3 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 3 | ▶ | use version; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 3 | ▶ | use Carp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | 3 | ▶ | use parent qw/Enbld::Target::AttributeExtension::Word/; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | |||||||||||
| 11 | sub initialize { | ||||||||||
| 12 | 55 | ▶ | my ( $self, $param ) = @_; | ||||||||
|
Subroutine
initialize: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||
| 13 | |||||||||||
| 14 | 55 | ▶ | if ( ! defined $param ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 15 | $self->{callback} = sub { | ||||||||||
| 16 | 34 | ▶ | my $attributes = shift; | ||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||
| 17 | |||||||||||
| 18 | 34 | my $list = $attributes->SortedVersionList; | |||||||||
| 19 | |||||||||||
| 20 | 34 | ▶ | if ( $attributes->VersionCondition eq 'latest' ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 21 | 20 | return $list->[-1]; | |||||||||
| 22 | } | ||||||||||
| 23 | |||||||||||
| 24 | 14 | ▶ | if ( grep { $attributes->VersionCondition eq $_ } @{ $list} ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 25 | 13 | return $attributes->VersionCondition; | |||||||||
| 26 | } | ||||||||||
| 27 | |||||||||||
| 28 | 1 | my $err = "Invalid Version Condition:" . | |||||||||
| 29 | $attributes->VersionCondition . ", ". | ||||||||||
| 30 | "please check install condition"; | ||||||||||
| 31 | 1 | require Enbld::Error; | |||||||||
| 32 | 1 | croak( Enbld::Error->new( $err )); | |||||||||
| 33 | 47 | }; | |||||||||
| 34 | |||||||||||
| 35 | 47 | return $self; | |||||||||
| 36 | } | ||||||||||
| 37 | |||||||||||
| 38 | 8 | ▶ | if ( $param ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 39 | 7 | $self->SUPER::initialize( $param ); | |||||||||
| 40 | 7 | return $self; | |||||||||
| 41 | } | ||||||||||
| 42 | |||||||||||
| 43 | 1 | require Enbld::Exception; | |||||||||
| 44 | 1 | my $err = "Attribute 'Version' isn't defined"; | |||||||||
| 45 | 1 | croak( Enbld::Exception->new( $err )); | |||||||||
| 46 | } | ||||||||||
| 47 | |||||||||||
| 48 | sub validate { | ||||||||||
| 49 | 96 | ▶ | my ( $self, $string ) = @_; | ||||||||
|
Subroutine
validate: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||
| 50 | |||||||||||
| 51 | 96 | $self->SUPER::validate( $string ); | |||||||||
| 52 | |||||||||||
| 53 | 93 | my $form = $self->{attributes}->VersionForm; | |||||||||
| 54 | 93 | ▶ | unless ( $string =~ /^$form$/ ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 55 | 1 | my $err = 'Attribute Version is NOT valid version string.'; | |||||||||
| 56 | 1 | require Enbld::Exception; | |||||||||
| 57 | 1 | croak( Enbld::Exception->new( $err, $string )); | |||||||||
| 58 | } | ||||||||||
| 59 | |||||||||||
| 60 | 92 | return $string; | |||||||||
| 61 | } | ||||||||||
| 62 | |||||||||||
| 63 | 3 | 1; | |||||||||