Enbld/Target/Attribute/VersionList.pm

filter: Statementstmt 100% 46 / 46 Branchbran 100% 8 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 8 / 8 Podpod 0.0% 0 / 3 totaltotal 95.3% 62 / 65 SCAR 17.9
CC
6
Cov
100%
validate
4.0
initialize
3.0
BEGIN
1.0
CRAP 6.0
« Enbld/Definition/Python.pm ↑ Summary Enbld/Target/Attribute/Version.pm »
1 package Enbld::Target::Attribute::VersionList;
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 Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 3 ▶use parent qw/Enbld::Target::AttributeExtension::Word/;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 3 require Enbld::Exception;
11  
12 sub initialize {
13 54 ▶ my ( $self, $param ) = @_;
Subroutine initialize: called CC=3 SCAR=11.0
Pod undocumented
14  
15 54 ▶ if ( ! defined $param ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $param) 48 6 54
16 $self->{callback} = sub {
17 35 ▶ my $attributes = shift;
Subroutine __ANON__: called CC=1 SCAR=0.0
18  
19 35 require Enbld::HTTP;
20 35 my $html = Enbld::HTTP->get_html( $attributes->IndexSite );
21 35 my $list = $html->parse_version(
22 $attributes->IndexParserForm,
23 $attributes->VersionForm
24 );
25  
26 35 return $list;
27 48 };
28  
29 48 return $self;
30 };
31  
32 6 ▶ if ( $param ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($param) 5 1 6
33 5 $self->SUPER::initialize( $param );
34 5 return $self;
35 }
36  
37 1 my $err = "Attribute 'VersionList' isn't defined";
38 1 croak( Enbld::Exception->new( $err ));
39 }
40  
41 sub validate {
42 40 ▶ my ( $self, $value ) = @_;
Subroutine validate: called CC=4 SCAR=13.9
Pod undocumented
43  
44 40 ▶ unless ( ref( $value ) eq 'ARRAY' ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $value eq "ARRAY") 1 39 40
45 1 my $type = ref( $self );
46 1 $type =~ s/.*:://;
47  
48 1 my $err = "Attribute 'VersionList' isn't ARRAY reference";
49 1 croak( Enbld::Exception->new( $err, $value ));
50 }
51  
52 39 ▶ if ( ! @{ $value } ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@{$value;}) 1 38 39
53 1 my $err = "Attribute 'VersionList' is no version list";
54 1 croak( Enbld::Exception->new( $err ));
55 }
56  
57 38 foreach my $string ( @{ $value } ) {
58 74 $self->SUPER::validate( $string );
59 }
60  
61 37 return $value;
62 }
63  
64 sub to_value {
65 40 ▶ my $self = shift;
Subroutine to_value: called CC=1 SCAR=0.0
Pod undocumented
66  
67 40 my $value = $self->evaluate;
68  
69 40 $self->validate( $value );
70  
71 37 return $value;
72 }
73  
74 3 1;
« Enbld/Definition/Python.pm ↑ Summary Enbld/Target/Attribute/Version.pm »