Parser/Style/Elemental.pm

filter: Statementstmt 18.0% 11 / 61 Branchbran 0.0% 0 / 22 Conditioncond 0.0% 0 / 25 MC/DCmcdc 0.0% 0 / 15 Subroutinesub 33.3% 3 / 9 Podpod 0.0% 0 / 6 totaltotal 10.1% 14 / 138 CC 22 SCAR 38.7
CC
22
Cov
10%
Char
90.0
Init
56.0
ns_qualify
30.0
CRAP 48.0
↑ Summary Elemental/Node.pm »
1 # Copyright (c) 2004-2005 Timothy Appnel
2 # http://www.timaoutloud.org/
3 # This code is released under the Artistic License.
4 #
5 # XML::Parser::Style::Elemental - A flexible and extensible object
6 # tree style for XML::Parser. DEPRECATED.
7 #
8  
9 package XML::Parser::Style::Elemental;
10 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 1 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 $VERSION = '0.72';
15  
16 0 ▶sub Init {
Subroutine Init: not called CC=7 SCAR=40.3
Pod undocumented
17 0 my $xp = shift;
18 0 ▶ $xp->{Elemental} ||= {};
Condition0%0/2
$xp->{"Elemental"} ||= {}
l!l
00
MC/DC0%0/1
$xp->{"Elemental"} ||= {}
$xp->{"Elemental"}
Truth table0%0/2
A
A= $xp->{"Elemental"}
Aresult
11
00
19 0 my $e = $xp->{Elemental};
20 0 ▶ if ($xp->{Pkg} eq 'main' || !defined $xp->{Pkg}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($xp->{"Pkg"} eq "main" or not defined $xp->{"Pkg"}) 0 0 0
Condition0%0/3
$xp->{"Pkg"} eq "main" or not defined $xp->{"Pkg"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$xp->{"Pkg"} eq "main" or not defined $xp->{"Pkg"}
$xp->{"Pkg"} eq "main" not defined $xp->{"Pkg"}
Truth table0%0/3
A or not(B)
A= $xp->{"Pkg"} eq "main"B= not defined $xp->{"Pkg"}
ABresult
1X1
011
000
21 0 ▶ $e->{Document} ||= 'XML::Elemental::Document';
Condition0%0/2
$e->{"Document"} ||= "XML::Elemental::Document"
l!l
00
MC/DC0%0/1
$e->{"Document"} ||= "XML::Elemental::Document"
$e->{"Document"}
Truth table0%0/2
A
A= $e->{"Document"}
Aresult
11
00
22 0 ▶ $e->{Element} ||= 'XML::Elemental::Element';
Condition0%0/2
$e->{"Element"} ||= "XML::Elemental::Element"
l!l
00
MC/DC0%0/1
$e->{"Element"} ||= "XML::Elemental::Element"
$e->{"Element"}
Truth table0%0/2
A
A= $e->{"Element"}
Aresult
11
00
23 0 ▶ $e->{Characters} ||= 'XML::Elemental::Characters';
Condition0%0/2
$e->{"Characters"} ||= "XML::Elemental::Characters"
l!l
00
MC/DC0%0/1
$e->{"Characters"} ||= "XML::Elemental::Characters"
$e->{"Characters"}
Truth table0%0/2
A
A= $e->{"Characters"}
Aresult
11
00
24 }
25 0 map { eval "use $e->{$_}" } qw( Document Element Characters);
26 0 $xp->{__doc} = $e->{Document}->new;
27 0 push(@{$xp->{__stack}}, $xp->{__doc});
28 }
29  
30 0 ▶sub Start {
Subroutine Start: not called CC=4 SCAR=30.0
Pod undocumented
31 0 my $xp = shift;
32 0 my $tag = shift;
33 0 my $node = $xp->{Elemental}->{Element}->new();
34 0 $node->name(ns_qualify($xp, $tag));
35 0 $node->parent($xp->{__stack}->[-1]);
36 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
37 0 $node->attributes({});
38 0 ▶ while (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
39 0 my ($key, $value) = (shift @_, shift @_);
40 0 $node->attributes->{ns_qualify($xp, $key, $tag)} = $value;
41 }
42 }
43 0 ▶ $node->parent->contents([]) unless $node->parent->contents;
Branch: 1 branch
BranchTrueFalseTotal
unless $node->parent->contents 0 0 0
44 0 push(@{$node->parent->contents}, $node);
45 0 push(@{$xp->{__stack}}, $node);
46 }
47  
48 0 ▶sub Char {
Subroutine Char: not called CC=9 SCAR=45.0
Pod undocumented
49 0 my ($xp, $data) = @_;
50 0 my $parent = $xp->{__stack}->[-1];
51 0 ▶ $parent->contents([]) unless $parent->contents;
Branch: 1 branch
BranchTrueFalseTotal
unless $parent->contents 0 0 0
52 0 my $contents = $parent->contents();
53 0 my $class = $xp->{Elemental}->{Characters};
54 0 ▶ unless ($contents && ref($contents->[-1]) eq $class) {
Branch: 1 branch
BranchTrueFalseTotal
if ($contents and ref $contents->[-1] eq $class) { } 0 0 0
Condition0%0/3
$contents and ref $contents->[-1] eq $class
!ll&&!rl&&r
000
MC/DC0%0/2
$contents and ref $contents->[-1] eq $class
$contents ref $contents->[-1] eq $class
Truth table0%0/3
A and B
A= $contentsB= ref $contents->[-1] eq $class
ABresult
0X0
100
111
55 0 ▶ return if ($xp->{Elemental}->{No_Whitespace} && $data !~ /\S/);
Branch: 1 branch
BranchTrueFalseTotal
if $xp->{"Elemental"}{"No_Whitespace"} and not $data =~ /\S/ 0 0 0
Condition0%0/3
$xp->{"Elemental"}{"No_Whitespace"} and not $data =~ /\S/
!ll&&!rl&&r
000
MC/DC0%0/2
$xp->{"Elemental"}{"No_Whitespace"} and not $data =~ /\S/
$xp->{"Elemental"}{"No_Whitespace"} not $data =~ /\S/
Truth table0%0/3
A and not(B)
A= $xp->{"Elemental"}{"No_Whitespace"}B= not $data =~ /\S/
ABresult
0X0
100
111
56 0 my $node = $class->new();
57 0 $node->parent($parent);
58 0 $node->data($data);
59 0 push(@{$contents}, $node);
60 }
61 else {
62 0 ▶ my $d = $contents->[-1]->data() || '';
Condition0%0/2
$contents->[-1]->data || ''
l!l
00
MC/DC0%0/1
$contents->[-1]->data || ''
$contents->[-1]->data
Truth table0%0/2
A
A= $contents->[-1]->data
Aresult
11
00
63 0 ▶ return if ($xp->{Elemental}->{No_Whitespace} && $d !~ /\S/);
Branch: 1 branch
BranchTrueFalseTotal
if $xp->{"Elemental"}{"No_Whitespace"} and not $d =~ /\S/ 0 0 0
Condition0%0/3
$xp->{"Elemental"}{"No_Whitespace"} and not $d =~ /\S/
!ll&&!rl&&r
000
MC/DC0%0/2
$xp->{"Elemental"}{"No_Whitespace"} and not $d =~ /\S/
$xp->{"Elemental"}{"No_Whitespace"} not $d =~ /\S/
Truth table0%0/3
A and not(B)
A= $xp->{"Elemental"}{"No_Whitespace"}B= not $d =~ /\S/
ABresult
0X0
100
111
64 0 $contents->[-1]->data("$d$data");
65 }
66 }
67  
68 0 ▶sub End { pop(@{$_[0]->{__stack}}) }
Subroutine End: not called CC=1 SCAR=6.9
Pod undocumented
69  
70 0 ▶sub Final {
Subroutine Final: not called CC=1 SCAR=6.9
Pod undocumented
71 0 delete $_[0]->{__stack};
72 0 $_[0]->{__doc};
73 }
74  
75 0 ▶sub ns_qualify {
Subroutine ns_qualify: not called CC=5 SCAR=34.0
Pod undocumented
76 0 ▶ return $_[1] unless $_[0]->{Namespaces};
Branch: 1 branch
BranchTrueFalseTotal
unless $_[0]{"Namespaces"} 0 0 0
77 0 ▶ my $ns = $_[0]->namespace($_[1]) || $_[0]->namespace($_[2]);
Condition0%0/3
$_[0]->namespace($_[1]) || $_[0]->namespace($_[2])
l!l&&r!l&&!r
000
MC/DC0%0/2
$_[0]->namespace($_[1]) || $_[0]->namespace($_[2])
$_[0]->namespace($_[1]) $_[0]->namespace($_[2])
Truth table0%0/3
A || B
A= $_[0]->namespace($_[1])B= $_[0]->namespace($_[2])
ABresult
1X1
011
000
78 0 ▶ return $_[1] unless $ns;
Branch: 1 branch
BranchTrueFalseTotal
unless $ns 0 0 0
79 0 ▶ $ns =~ m!(/|#)$! ? "$ns$_[1]" : "$ns/$_[1]";
Branch: 1 branch
BranchTrueFalseTotal
$ns =~ m[(/|#)$] ? : 0 0 0
80 }
81  
82 1 1;
83  
84 __END__
↑ Summary Elemental/Node.pm »