lib/AutoCode/AttributeType.pm

filter: Statementstmt 62.5% 25 / 40 Branchbran 50.0% 6 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 71.4% 5 / 7 Podpod 0.0% 0 / 1 totaltotal 60.0% 36 / 60 CC 7 SCAR 15.3
CC
7
Cov
60%
classify
7.0
_initialize
6.0
_classify_self
2.0
CRAP 4.6
« lib/AutoCode/AccessorMaker.pm ↑ Summary lib/AutoCode/Root0.pm »
1 package AutoCode::AttributeType;
2 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 5 ▶use AutoCode::Root;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 5 our @ISA=qw(AutoCode::Root);
6  
7 5 ▶use AutoCode::AccessorMaker(
Subroutine BEGIN: called CC=1 SCAR=0.0
8 5 '$'=>[qw(string context category content required)]
9 5 );
10  
11 5 our $PRIMITIVE_TYPE='cvidft';
12  
13 0 ▶sub _initialize {
Subroutine _initialize: not called CC=2 SCAR=17.9
14 0 my ($self, @args)=@_;
15 0 my ($string)= $self->_rearrange([qw(string)], @args);
16 0 ▶ defined $string or $self->throw("string is definitely required");
Branch: 1 branch
BranchTrueFalseTotal
defined $string or $self->throw("string is definitely required") 0 0 0
17 0 $self->string($string);
18 0 $self->_classify_self;
19 }
20  
21 0 ▶sub _classify_self {
Subroutine _classify_self: not called CC=1 SCAR=6.9
22 0 my $self=shift;
23 0 my $string = $self->string;
24 0 my ($context, $category, $content, $required)=$self->_classify($string);
25 0 $self->context($context);
26 0 $self->catogory($category);
27 0 $self->content($content);
28 0 $self->required($required);
29 }
30  
31 39 ▶sub classify {
Subroutine classify: called CC=6 SCAR=19.5
Pod undocumented
32 39 my ($self, $string)=@_;
33
34 39 ▶ $self->throw("[$string] must start with [%@\$]")
Branch: 1 branch
BranchTrueFalseTotal
unless $string =~ s/^([\%\@\$])// 0 39 39
35 unless $string =~ s/^([\%\@\$])//;
36 39 my $context=$1;
37 39 my $required=$string=~s/\!$//;
38  
39 39 my ($category, $content);
40 39 local $_=$string;
41 39 ▶ if(/^$/){
Branch: 4 branches
BranchTrueFalseTotal
if (/^$/) { } 24 15 39
elsif (/^([$AutoCode::AttributeType::PRIMITIVE_TYPE])(([\+\^]?[\d]+)(\.\d+)?)?(U?)$/) { } 0 15 15
elsif (/^\{([^}]+)\}$/) { } 0 15 15
elsif (/^([_A-Z]\w+)$/) { } 15 0 15
42 24 ($category, $content)=('P', 'v255'); # Default
43 }elsif(/^([$PRIMITIVE_TYPE])(([\+\^]?[\d]+)(\.\d+)?)?(U?)$/){
44 0 ($category, $content)=('P', $string);
45 }elsif(/^\{([^}]+)\}$/){
46 0 ($category, $content)=('E', $1);
47 }elsif(/^([_A-Z]\w+)$/){
48 15 ($category, $content)=('M', $1);
49 }else{
50 0 $self->throw("[$string] does not match any kind of pattern");
51 }
52 39 return ($context, $category, $content, $required);
53 }
54  
55 5 1;
« lib/AutoCode/AccessorMaker.pm ↑ Summary lib/AutoCode/Root0.pm »