| 1 | package Pod::Simple::DumpAsXML; | ||||||||||||||||||||||||||||
| 2 | 30 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 30 | our $VERSION = '3.48'; | |||||||||||||||||||||||||||
| 4 | 30 | ▶ | use Pod::Simple (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 30 | ▶ | BEGIN {our @ISA = ('Pod::Simple')} | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 30 | ▶ | use Carp (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 30 | ▶ | use Text::Wrap qw(wrap); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 30 | ▶ | BEGIN { *DEBUG = \&Pod::Simple::DEBUG unless defined &DEBUG } | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=2 SCAR=7.6
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 150 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||
| 13 | 150 | my $self = shift; | |||||||||||||||||||||||||||
| 14 | 150 | my $new = $self->SUPER::new(@_); | |||||||||||||||||||||||||||
| 15 | 150 | ▶ | $new->{'output_fh'} ||= *STDOUT{IO}; | ||||||||||||||||||||||||||
|
Condition50%1/2
$new->{"output_fh"} ||= *STDOUT{"IO"}
MC/DC0%0/1
$new->{"output_fh"} ||= *STDOUT{"IO"}
$new->{"output_fh"}
Truth table50%1/2
A
A= $new->{"output_fh"}
| |||||||||||||||||||||||||||||
| 16 | 150 | $new->accept_codes('VerbatimFormatted'); | |||||||||||||||||||||||||||
| 17 | 150 | $new->keep_encoding_directive(1); | |||||||||||||||||||||||||||
| 18 | 150 | return $new; | |||||||||||||||||||||||||||
| 19 | } | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ | ||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 804 | ▶ | sub _handle_element_start { | ||||||||||||||||||||||||||
|
Subroutine
_handle_element_start: called CC=6 SCAR=17.9
| |||||||||||||||||||||||||||||
| 24 | # ($self, $element_name, $attr_hash_r) | ||||||||||||||||||||||||||||
| 25 | 804 | my $fh = $_[0]{'output_fh'}; | |||||||||||||||||||||||||||
| 26 | 804 | my($key, $value); | |||||||||||||||||||||||||||
| 27 | 804 | DEBUG and print STDERR "++ $_[1]\n"; | |||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | 804 | ▶ | print $fh ' ' x ($_[0]{'indent'} || 0), "<", $_[1]; | ||||||||||||||||||||||||||
|
Condition100%2/2
$_[0]{'indent'} || 0
MC/DC100%1/1
$_[0]{'indent'} || 0
$_[0]{'indent'}
Truth table100%2/2
A
A= $_[0]{'indent'}
| |||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 804 | foreach my $key (sort keys %{$_[2]}) { | |||||||||||||||||||||||||||
| 32 | 1054 | ▶ | unless($key =~ m/^~/s) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 33 | 925 | ▶ | next if $key eq 'start_line' and $_[0]{'hide_line_numbers'}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$key eq "start_line" and $_[0]{"hide_line_numbers"}
MC/DC100%2/2
$key eq "start_line" and $_[0]{"hide_line_numbers"}
$key eq "start_line"
$_[0]{"hide_line_numbers"}
Truth table100%3/3
A and B
A= $key eq "start_line"B= $_[0]{"hide_line_numbers"}
| |||||||||||||||||||||||||||||
| 34 | 651 | _xml_escape($value = $_[2]{$key}); | |||||||||||||||||||||||||||
| 35 | 651 | print $fh ' ', $key, '="', $value, '"'; | |||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 804 | print $fh ">\n"; | |||||||||||||||||||||||||||
| 41 | 804 | $_[0]{'indent'}++; | |||||||||||||||||||||||||||
| 42 | 804 | return; | |||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | 627 | ▶ | sub _handle_text { | ||||||||||||||||||||||||||
|
Subroutine
_handle_text: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 46 | 627 | DEBUG and print STDERR "== \"$_[1]\"\n"; | |||||||||||||||||||||||||||
| 47 | 627 | ▶ | if(length $_[1]) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 48 | 626 | my $indent = ' ' x $_[0]{'indent'}; | |||||||||||||||||||||||||||
| 49 | 626 | my $text = $_[1]; | |||||||||||||||||||||||||||
| 50 | 626 | _xml_escape($text); | |||||||||||||||||||||||||||
| 51 | 626 | local $Text::Wrap::huge = 'overflow'; | |||||||||||||||||||||||||||
| 52 | 626 | $text = wrap('', $indent, $text); | |||||||||||||||||||||||||||
| 53 | 626 | print {$_[0]{'output_fh'}} $indent, $text, "\n"; | |||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||
| 55 | 627 | return; | |||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | 804 | ▶ | sub _handle_element_end { | ||||||||||||||||||||||||||
|
Subroutine
_handle_element_end: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 59 | 804 | DEBUG and print STDERR "-- $_[1]\n"; | |||||||||||||||||||||||||||
| 60 | 804 | print {$_[0]{'output_fh'}} | |||||||||||||||||||||||||||
| 61 | 804 | ' ' x --$_[0]{'indent'}, "</", $_[1], ">\n"; | |||||||||||||||||||||||||||
| 62 | 804 | return; | |||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | # . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . | ||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | 1277 | ▶ | sub _xml_escape { | ||||||||||||||||||||||||||
|
Subroutine
_xml_escape: called CC=3 SCAR=12.0
| |||||||||||||||||||||||||||||
| 68 | 1277 | foreach my $x (@_) { | |||||||||||||||||||||||||||
| 69 | # Escape things very cautiously: | ||||||||||||||||||||||||||||
| 70 | 1277 | ▶ | if ("$]" >= 5.007_003) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 71 | 1277 | $x =~ s/([^-\n\t !\#\$\%\(\)\*\+,\.\~\/\:\;=\?\@\[\\\]\^_\`\{\|\}abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789])/'&#'.(utf8::native_to_unicode(ord($1))).';'/eg; | |||||||||||||||||||||||||||
| 72 | } else { # Is broken for non-ASCII platforms on early perls | ||||||||||||||||||||||||||||
| 73 | 0 | $x =~ s/([^-\n\t !\#\$\%\(\)\*\+,\.\~\/\:\;=\?\@\[\\\]\^_\`\{\|\}abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789])/'&#'.(ord($1)).';'/eg; | |||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||
| 75 | # Yes, stipulate the list without a range, so that this can work right on | ||||||||||||||||||||||||||||
| 76 | # all charsets that this module happens to run under. | ||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||
| 78 | 1277 | return; | |||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ | ||||||||||||||||||||||||||||
| 82 | 30 | 1; | |||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | __END__ | ||||||||||||||||||||||||||||