Simple/DumpAsText.pm

filter: Statementstmt 90.2% 46 / 51 Branchbran 60.0% 6 / 10 Conditioncond 44.4% 4 / 9 MC/DCmcdc 20.0% 1 / 5 Subroutinesub 100% 10 / 10 Podpod 100% 1 / 1 totaltotal 79.0% 68 / 86 CC 11 SCAR 14.5
CC
11
Cov
80%
_handle_element_start
9.0
BEGIN
2.1
_perly_escape
2.1
CRAP 4.2
« Simple/TranscodeDumb.pm ↑ Summary Simple/TiedOutFH.pm »
1 package Pod::Simple::DumpAsText;
2 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 our $VERSION = '3.48';
4 2 ▶use Pod::Simple ();
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶BEGIN { our @ISA = ('Pod::Simple')}
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 2 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 2 ▶BEGIN { *DEBUG = \&Pod::Simple::DEBUG unless defined &DEBUG }
Subroutine BEGIN: called CC=2 SCAR=7.6
Branch: 1 branch
BranchTrueFalseTotal
unless defined &Pod::Simple::DumpAsText::DEBUG 2 0 2
10  
11 2 ▶sub new {
Subroutine new: called CC=2 SCAR=7.0
Pod documented
12 2 my $self = shift;
13 2 my $new = $self->SUPER::new(@_);
14 2 ▶ $new->{'output_fh'} ||= *STDOUT{IO};
Condition50%1/2
$new->{"output_fh"} ||= *STDOUT{"IO"}
l!l
02
MC/DC0%0/1
$new->{"output_fh"} ||= *STDOUT{"IO"}
$new->{"output_fh"}
Truth table50%1/2
A
A= $new->{"output_fh"}
Aresult
11
00
15 2 $new->accept_codes('VerbatimFormatted');
16 2 $new->keep_encoding_directive(1);
17 2 return $new;
18 }
19  
20 #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
21  
22 2 ▶sub _handle_element_start {
Subroutine _handle_element_start: called CC=7 SCAR=22.0
23 # ($self, $element_name, $attr_hash_r)
24 2 my $fh = $_[0]{'output_fh'};
25 2 my($key, $value);
26 2 DEBUG and print STDERR "++ $_[1]\n";
27  
28 2 ▶ print $fh ' ' x ($_[0]{'indent'} || 0), "++", $_[1], "\n";
Condition100%2/2
$_[0]{'indent'} || 0
l!l
11
MC/DC100%1/1
$_[0]{'indent'} || 0
$_[0]{'indent'}
Truth table100%2/2
A
A= $_[0]{'indent'}
Aresult
11
00
29 2 $_[0]{'indent'}++;
30 2 ▶ while(($key,$value) = each %{$_[2]}) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %{$_[2];}) 2 2 4
31 2 ▶ unless($key =~ m/^~/s) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($key =~ /^~/s) 2 0 2
32 2 ▶ next if $key eq 'start_line' and $_[0]{'hide_line_numbers'};
Branch: 1 branch
BranchTrueFalseTotal
if $key eq "start_line" and $_[0]{"hide_line_numbers"} 2 0 2
Condition33%1/3
$key eq "start_line" and $_[0]{"hide_line_numbers"}
!ll&&!rl&&r
002
MC/DC0%0/2
$key eq "start_line" and $_[0]{"hide_line_numbers"}
$key eq "start_line" $_[0]{"hide_line_numbers"}
Truth table33%1/3
A and B
A= $key eq "start_line"B= $_[0]{"hide_line_numbers"}
ABresult
0X0
100
111
33 0 _perly_escape($key);
34 0 _perly_escape($value);
35 printf $fh qq{%s \\ "%s" => "%s"\n},
36 0 ▶ ' ' x ($_[0]{'indent'} || 0), $key, $value;
Condition0%0/2
$_[0]{'indent'} || 0
l!l
00
MC/DC0%0/1
$_[0]{'indent'} || 0
$_[0]{'indent'}
Truth table0%0/2
A
A= $_[0]{'indent'}
Aresult
11
00
37 }
38 }
39 2 return;
40 }
41  
42 1 ▶sub _handle_text {
Subroutine _handle_text: called CC=2 SCAR=6.9
43 1 DEBUG and print STDERR "== \"$_[1]\"\n";
44  
45 1 ▶ if(length $_[1]) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $_[1]) 1 0 1
46 1 my $indent = ' ' x $_[0]{'indent'};
47 1 my $text = $_[1];
48 1 _perly_escape($text);
49 1 $text =~ # A not-totally-brilliant wrapping algorithm:
50 s/(
51 [^\n]{55} # Snare some characters from a line
52 [^\n\ ]{0,50} # and finish any current word
53 )
54 \ {1,10}(?!\n) # capture some spaces not at line-end
55 /$1"\n$indent . "/gx # => line-break here
56 ;
57  
58 1 print {$_[0]{'output_fh'}} $indent, '* "', $text, "\"\n";
59 }
60 1 return;
61 }
62  
63 2 ▶sub _handle_element_end {
Subroutine _handle_element_end: called CC=1 SCAR=0.0
64 2 DEBUG and print STDERR "-- $_[1]\n";
65 2 print {$_[0]{'output_fh'}}
66 2 ' ' x --$_[0]{'indent'}, "--", $_[1], "\n";
67 2 return;
68 }
69  
70 # . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
71  
72 1 ▶sub _perly_escape {
Subroutine _perly_escape: called CC=2 SCAR=7.6
73 1 foreach my $x (@_) {
74 0 $x =~ s/([^\x00-\xFF])/sprintf'\x{%X}',ord($1)/eg;
75 # Escape things very cautiously:
76 0 $x =~ s/([^-\n\t \&\<\>\'!\#\%\(\)\*\+,\.\/\:\;=\?\~\[\]\^_\`\{\|\}abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789])/sprintf'\x%02X',ord($1)/eg;
77 }
78 1 return;
79 }
80  
81 #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
82 2 1;
83  
84  
85 __END__
« Simple/TranscodeDumb.pm ↑ Summary Simple/TiedOutFH.pm »