CompareML/DocBook.pm

filter: Statementstmt 19.7% 14 / 71 Branchbran 0.0% 0 / 16 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 26.6% 4 / 15 Podpod n/a totaltotal 17.6% 18 / 102 CC 10 SCAR 26.2
CC
10
Cov
16%
_render_section_start
30.0
_html_to_docbook
30.0
_render_section_end
6.0
CRAP 13.8
↑ Summary CompareML/ConfigData.pm »
1 package XML::CompareML::DocBook;
2 2 $XML::CompareML::DocBook::VERSION = '0.2.13';
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6  
7 2 ▶use XML::LibXML::Common qw(:w3c);
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 2 ▶use parent 'XML::CompareML::Base';
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 sub _print_header
12 0 ▶{
Subroutine _print_header: not called CC=1 SCAR=6.9
13 0 my $self = shift;
14 0 my $o = $self->{o};
15 0 print { *{$o} } <<"EOF";
16 <?xml version="1.0" encoding="iso-8859-1"?>
17 <!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
18 "/usr/share/sgml/docbook/xml-dtd-4.1.2/docbookx.dtd"[
19 ]>
20 <article>
21  
22 EOF
23 }
24  
25 # Do Nothing
26 sub _start_rendering
27 0 ▶{
Subroutine _start_rendering: not called CC=1 SCAR=0.0
28 }
29  
30 # Do Nothing
31 sub _finish_rendering
32 0 ▶{
Subroutine _finish_rendering: not called CC=1 SCAR=0.0
33 }
34  
35 sub _print_footer
36 0 ▶{
Subroutine _print_footer: not called CC=1 SCAR=6.9
37 0 my $self = shift;
38 0 print { *{ $self->{o} } } "</article>\n";
39 }
40  
41 sub _render_section_start
42 0 ▶{
Subroutine _render_section_start: not called CC=5 SCAR=34.0
43 0 my $self = shift;
44 0 my %args = (@_);
45  
46 0 my $depth = $args{depth};
47 0 my $id = $args{id};
48 0 my $title_string = $args{title_string};
49 0 my $expl = $args{expl};
50 0 my $sub_sections = $args{sub_sections};
51  
52 0 ▶ if ($depth)
Branch: 1 branch
BranchTrueFalseTotal
if ($depth) 0 0 0
53 {
54 0 $self->_out("<section id=\"$id\">\n");
55 }
56  
57 0 $self->_out("<title>$title_string</title>\n");
58  
59 0 ▶ if ( $depth == 0 )
Branch: 1 branch
BranchTrueFalseTotal
if ($depth == 0) 0 0 0
60 {
61 0 ▶ if ( defined( $self->_timestamp() ) )
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->_timestamp) 0 0 0
62 {
63 0 $self->_out( "<articleinfo><date>"
64 . $self->_timestamp()
65 . "</date></articleinfo>\n" );
66 }
67 }
68  
69 0 ▶ if ($expl)
Branch: 1 branch
BranchTrueFalseTotal
if ($expl) 0 0 0
70 {
71 0 $self->_out( "<para>\n"
72 . $self->_xml_node_contents_to_string($expl)
73 . "\n</para>\n" );
74 }
75 }
76  
77 sub _render_sys_table_start
78 0 ▶{
Subroutine _render_sys_table_start: not called CC=1 SCAR=6.9
79 0 my ( $self, %args ) = @_;
80  
81 0 my $title_string = $args{title_string};
82  
83 0 $self->_out(<<"EOF");
84 <table frame=\"all\">
85 <title>Comparison - $title_string</title>
86 <tgroup cols=\"2\" align=\"left\" colsep=\"1\" rowsep=\"1\">
87 <colspec colname=\"system\" />
88 <colspec colname=\"description\" />
89 <thead>
90 <row>
91 <entry><emphasis>System</emphasis></entry>
92 <entry><emphasis>Description</emphasis></entry>
93 </row>
94 </thead>
95 <tbody>
96 EOF
97 }
98  
99 sub _html_to_docbook
100 0 ▶{
Subroutine _html_to_docbook: not called CC=5 SCAR=34.0
101 0 my $parent_node = shift;
102 0 my $not_first = shift;
103 0 my @child_nodes = $parent_node->childNodes();
104 0 my $ret = "";
105  
106 0 foreach my $node (@child_nodes)
107 {
108 0 ▶ if ( $node->nodeType() == ELEMENT_NODE() )
Branch: 1 branch
BranchTrueFalseTotal
if ($node->nodeType == 1) { } 0 0 0
109 {
110 0 ▶ if ( $node->nodeName() eq "a" )
Branch: 1 branch
BranchTrueFalseTotal
if ($node->nodeName eq 'a') { } 0 0 0
111 {
112 0 $ret .= "<ulink url=\"" . $node->getAttribute("href") . "\">";
113 }
114 else
115 {
116 0 my @attrs = $node->attributes();
117 $ret .= "<"
118 . $node->nodeName() . " "
119 . join( " ",
120 0 map { "$_=\"" . $node->getAttribute($_) . "\"" } @attrs )
121 . ">";
122 }
123 0 $ret .= _html_to_docbook( $node, 1 );
124  
125 0 ▶ if ( $node->nodeName() eq "a" )
Branch: 1 branch
BranchTrueFalseTotal
if ($node->nodeName eq 'a') { } 0 0 0
126 {
127 0 $ret .= "</ulink>";
128 }
129 else
130 {
131 0 $ret .= "</" . $node->nodeName() . ">";
132 }
133 }
134 else
135 {
136 0 $ret .= $node->toString();
137 }
138 }
139  
140 # Remove leading and trailing space.
141 0 if (1)
142 {
143 0 $ret =~ s!^\s+!!mg;
144 0 $ret =~ s/\s+$//mg;
145 }
146 0 return $ret;
147 }
148  
149 sub _render_s_elem
150 0 ▶{
Subroutine _render_s_elem: not called CC=1 SCAR=6.9
151 0 my ( $self, $s_elem ) = @_;
152 0 return _html_to_docbook($s_elem);
153 }
154  
155 sub _render_sys_table_row
156 0 ▶{
Subroutine _render_sys_table_row: not called CC=1 SCAR=6.9
157 0 my ( $self, %args ) = @_;
158  
159 $self->_out( "<row>\n<entry>"
160 . $args{name}
161 . "</entry>\n"
162 . "<entry>\n"
163 . $args{desc}
164 0 . "\n</entry>\n</row>\n" );
165 }
166  
167 sub _render_sys_table_end
168 0 ▶{
Subroutine _render_sys_table_end: not called CC=1 SCAR=6.9
169 0 my $self = shift;
170 0 $self->_out("</tbody>\n</tgroup>\n</table>\n");
171 }
172  
173 sub _render_section_end
174 0 ▶{
Subroutine _render_section_end: not called CC=2 SCAR=17.9
175 0 my ( $self, %args ) = @_;
176  
177 0 my $depth = $args{depth};
178  
179 0 ▶ if ($depth)
Branch: 1 branch
BranchTrueFalseTotal
if ($depth) 0 0 0
180 {
181 0 $self->_out("</section>\n");
182 }
183 }
184  
185  
186 2 1;
187  
188 __END__
↑ Summary CompareML/ConfigData.pm »