Directory/String.pm

filter: Statementstmt 55.9% 52 / 93 Branchbran 35.0% 7 / 20 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 66.6% 12 / 18 Podpod 0.0% 0 / 11 totaltotal 48.9% 72 / 147 CC 12 SCAR 12.2
CC
12
Cov
52%
doError
12.0
_doctype
6.0
_ns_prefix
3.6
CRAP 3.4
« Directory/SAX.pm ↑ Summary
1 package XML::Directory::String;
2  
3 1 require 5.005_03;
4 1 ▶BEGIN { require warnings if $] >= 5.006; }
Subroutine BEGIN: called CC=2 SCAR=7.6
Branch: 1 branch
BranchTrueFalseTotal
if $] >= "5.006" 1 0 1
5  
6 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use File::Spec::Functions ();
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use XML::Directory;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 1 @XML::Directory::String::ISA = qw(XML::Directory);
12  
13 1 ▶sub parse_dir {
Subroutine parse_dir: called CC=1 SCAR=0.0
Pod undocumented
14 1 my $self = shift;
15 1 $self->SUPER::parse;
16 1 return scalar @{$self->{xml}};
17 }
18  
19 0 ▶sub parse {
Subroutine parse: not called CC=1 SCAR=6.9
Pod undocumented
20 0 my $self = shift;
21 0 $self->SUPER::parse;
22 0 return scalar @{$self->{xml}};
23 }
24  
25 0 ▶sub get_arrayref {
Subroutine get_arrayref: not called CC=1 SCAR=6.9
Pod undocumented
26 0 my $self = shift;
27 0 return $self->{xml};
28 }
29  
30 0 ▶sub get_array {
Subroutine get_array: not called CC=1 SCAR=6.9
Pod undocumented
31 0 my $self = shift;
32 0 my $xml = $self->{xml};
33 0 return @$xml;
34 }
35  
36 0 ▶sub get_string {
Subroutine get_string: not called CC=1 SCAR=6.9
Pod undocumented
37 0 my $self = shift;
38 0 my $xml = $self->{xml};
39 0 return join "\n", @$xml, '';
40 }
41  
42 1 ▶sub doStartDocument {
Subroutine doStartDocument: called CC=2 SCAR=7.8
Pod undocumented
43 1 my $self = shift;
44 1 $self->{xml} = [];
45 1 $self->{level} = 0;
46 1 push @{$self->{xml}},
47 "<?xml version=\"1.0\" encoding=\"$self->{encoding}\"?>";
48  
49 1 ▶ if ($self->{doctype}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"doctype"}) 0 1 1
50 0 my $doctype = $self->_doctype;
51 0 push @{$self->{xml}}, $doctype;
52 }
53 }
54  
55 1 ▶sub doEndDocument {
Subroutine doEndDocument: called CC=1 SCAR=0.0
Pod undocumented
56 }
57  
58 2 ▶sub doStartElement {
Subroutine doStartElement: called CC=2 SCAR=7.0
Pod undocumented
59 2 my ($self, $tag, $attr, $qname) = @_;
60 2 my $pref = '';
61 2 ▶ $pref = $self->_ns_prefix unless $qname;
Branch: 1 branch
BranchTrueFalseTotal
unless $qname 2 0 2
62 2 push @{$self->{xml}},
63 ' ' x $self->{level}++
64 . "<$pref"
65 . "$tag "
66 2 . join(' ', map {qq/$_->[0]="$_->[1]"/} @$attr)
67 . ">";
68 }
69  
70 2 ▶sub doEndElement {
Subroutine doEndElement: called CC=2 SCAR=7.0
Pod undocumented
71 2 my ($self, $tag, $qname) = @_;
72 2 my $pref = '';
73 2 ▶ $pref = $self->_ns_prefix unless $qname;
Branch: 1 branch
BranchTrueFalseTotal
unless $qname 2 0 2
74 2 push @{$self->{xml}},
75 ' ' x --$self->{level}
76 2 . "</$pref"
77 . "$tag>"
78 ;
79 }
80  
81 8 ▶sub doElement {
Subroutine doElement: called CC=3 SCAR=11.1
Pod undocumented
82 8 my ($self, $tag, $attr, $value, $qname) = @_;
83 8 my $pref = '';
84 8 ▶ $pref = $self->_ns_prefix unless $qname;
Branch: 1 branch
BranchTrueFalseTotal
unless $qname 8 0 8
85 my $element = ' ' x $self->{level}
86 . "<$pref"
87 . "$tag "
88 8 . join(' ', map {qq/$_->[0]="$_->[1]"/} @$attr)
89 . '>';
90 8 $element =~ s/ >$/>/;
91 8 ▶ $element .= $value if defined $value;
Branch: 1 branch
BranchTrueFalseTotal
if defined $value 0 8 8
92 8 $element .= "</$pref";
93 8 $element .= "$tag>";
94 8 push @{$self->{xml}}, $element;
95 }
96  
97 0 ▶sub doError {
Subroutine doError: not called CC=3 SCAR=24.8
Pod undocumented
98 0 my ($self, $n, $par) = @_;
99 0 my $msg = $self->_msg($n);
100 0 $msg = "[Error $n] $msg: $par";
101  
102 0 ▶ unless ($self->{catch_error}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'catch_error'}) { } 0 0 0
103 0 croak "$msg\n"
104  
105 } else {
106
107 0 $self->doStartDocument;
108  
109 0 ▶ if ($self->{ns_enabled}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'ns_enabled'}) { } 0 0 0
110 0 my @attr = ();
111 0 my $decl = $self->_ns_declaration;
112 0 push @attr, [$decl => $self->{ns_uri}];
113 0 $self->doStartElement('dirtree', \@attr);
114 } else {
115 0 $self->doStartElement('dirtree', undef);
116 }
117  
118 0 my @attr2 = ([number => $n]);
119 0 $msg =~ s/&/&amp;/g;
120 0 $msg =~ s/</&lt;/g;
121 0 $msg =~ s/>/&gt;/g;
122 0 $self->doElement('error', \@attr2, $msg);
123  
124 0 $self->doEndElement('dirtree');
125 0 $self->{error} = $n;
126 }
127 }
128  
129 12 ▶sub _ns_prefix {
Subroutine _ns_prefix: called CC=3 SCAR=12.7
130 12 my $self = shift;
131
132 12 my $pref = '';
133 12 ▶ if ($self->{ns_enabled} && $self->{ns_prefix}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"ns_enabled"} and $self->{"ns_prefix"}) 0 12 12
Condition33%1/3
$self->{"ns_enabled"} and $self->{"ns_prefix"}
!ll&&!rl&&r
1200
MC/DC0%0/2
$self->{"ns_enabled"} and $self->{"ns_prefix"}
$self->{"ns_enabled"} $self->{"ns_prefix"}
Truth table33%1/3
A and B
A= $self->{"ns_enabled"}B= $self->{"ns_prefix"}
ABresult
0X0
100
111
134 0 $pref = "$self->{ns_prefix}:";
135 }
136 12 return $pref;
137 }
138  
139 0 ▶sub _doctype {
Subroutine _doctype: not called CC=2 SCAR=17.9
140 0 my $self = shift;
141  
142 0 my $doctype = '<!DOCTYPE dirtree PUBLIC '
143 . '"-//GA//DTD XML-Directory 1.0 Level_DET_//EN"'
144 . "\n "
145 . '"http://www.gingerall.org/dtd/XML-Directory/1.0/'
146 . 'dirtree-level_DET_.dtd">';
147  
148 0 ▶ if ($self->{details}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'details'}) { } 0 0 0
149 0 $doctype =~ s/_DET_/$self->{details}/g;
150 } else {
151 0 $doctype =~ s/_DET_/2/g;
152 }
153 0 return $doctype;
154 }
155  
156 1 1;
157  
158 __END__
« Directory/SAX.pm ↑ Summary