YAX/Builder.pm

filter: Statementstmt 86.4% 32 / 37 Branchbran 87.5% 7 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 80.0% 8 / 10 Podpod 66.6% 4 / 6 totaltotal 83.6% 51 / 61 CC 6 SCAR 9.6
CC
6
Cov
87%
node
5.0
build
2.0
new
2.0
CRAP 2.6
« YAX/Element.pm ↑ Summary YAX/Text.pm »
1 package YAX::Builder;
2  
3 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 3 ▶use YAX::Text;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 3 ▶use YAX::Element;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 3 ▶use YAX::Fragment;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
Pod undocumented
10 0 my ( $class ) = @_;
11 0 my $self = bless { }, $class;
12 0 $self;
13 }
14  
15 5 ▶sub build {
Subroutine build: called CC=2 SCAR=7.0
Pod documented
16 5 my ( $self, @specs ) = @_;
17 5 my @nodes = map { $self->node( $_ ) } @specs;
18 5 ▶ return wantarray ? @nodes : $nodes[0];
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 5 0 5
19 }
20  
21 10 ▶sub node {
Subroutine node: called CC=5 SCAR=16.1
Pod documented
22 10 my ( $self, $spec ) = @_;
23 10 ▶ if ( ref $spec eq 'ARRAY' ) {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $spec eq 'ARRAY') { } 5 5 10
elsif (UNIVERSAL::isa($spec, 'YAX::Node')) { } 2 3 5
24 5 my @copy = @$spec;
25 5 my $name = splice @copy, 0, 1;
26 5 ▶ my %atts = ref $copy[0] eq 'HASH' ? %{ splice @copy, 0, 1 } : ( );
Branch: 1 branch
BranchTrueFalseTotal
ref $copy[0] eq 'HASH' ? : 2 3 5
27  
28 5 my $node = $self->element( $name, %atts );
29 5 $node->append( $_ ) for $self->build( @copy );
30 5 return $node;
31 }
32 elsif ( UNIVERSAL::isa( $spec, 'YAX::Node' ) ) {
33 2 return $spec;
34 }
35 else {
36 3 return $self->text( $spec );
37 }
38 }
39  
40 3 ▶sub text {
Subroutine text: called CC=1 SCAR=0.0
Pod documented
41 3 my $self = shift;
42 3 YAX::Text->new(@_);
43 }
44  
45 5 ▶sub element {
Subroutine element: called CC=1 SCAR=0.0
Pod undocumented
46 5 my ( $self, $name, %atts ) = @_;
47 5 YAX::Element->new( $name, %atts );
48 }
49  
50 0 ▶sub fragment {
Subroutine fragment: not called CC=1 SCAR=6.9
Pod documented
51 0 my ( $self, @kids ) = @_;
52 0 YAX::Fragment->new( $self->build( @kids ) );
53 }
54  
55 3 1;
56 __END__
« YAX/Element.pm ↑ Summary YAX/Text.pm »