XSS/Stylesheet/HTML2TD.pm

filter: Statementstmt 42.1% 16 / 38 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 37.5% 3 / 8 Podpod 0.0% 0 / 2 totaltotal 36.5% 19 / 52 CC 4 SCAR 16.5
CC
4
Cov
38%
pre_attrs
12.0
__ANON__
6.0
__ANON__
2.0
CRAP 5.2
« XSS/Template.pm ↑ Summary XSS/Text.pm »
1 package XML::XSS::Stylesheet::HTML2TD;
2 1 our $AUTHORITY = 'cpan:YANICK';
3 1 $XML::XSS::Stylesheet::HTML2TD::VERSION = '0.3.5';
4 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use XML::XSS;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Perl::Tidy;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 extends 'XML::XSS';
9  
10 1 style '*' => (
11 pre => \&pre_element,
12 post => '};',
13 );
14  
15 style '#text' => (
16 0 ▶ process => sub { $_[1]->data =~ /\S/ },
Subroutine __ANON__: not called CC=1 SCAR=6.9
17 pre => "outs '",
18 post => "';",
19 0 ▶ filter => sub { s/'/\\'/g; s/^\s+|\s+$//gm; $_ },
Subroutine __ANON__: not called CC=1 SCAR=6.9
20 1 );
21  
22 style '#document' => (
23 0 ▶ content => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
24 0 my ( $self, $node, $args ) = @_;
25 0 my $raw = $self->stylesheet->render( $node->childNodes );
26  
27 0 my $output;
28 my $err;
29 0 eval {
30 0 Perl::Tidy::perltidy(
31 source => \$raw,
32 destination => \$output,
33 errorfile => \$err,
34 )
35 };
36  
37 # send the raw output if Tidy failed
38 0 ▶ return $err ? $raw : $output;
Branch: 1 branch
BranchTrueFalseTotal
$err ? : 0 0 0
39 },
40 1 );
41  
42 0 ▶sub pre_element {
Subroutine pre_element: not called CC=1 SCAR=6.9
Pod undocumented
43 0 my ( $self, $node ) = @_;
44  
45 0 my $name = $node->nodeName;
46  
47 0 return "$name {" . pre_attrs( $node );
48 }
49  
50 0 ▶sub pre_attrs {
Subroutine pre_attrs: not called CC=3 SCAR=24.8
Pod undocumented
51 0 my $node = shift;
52  
53 0 ▶ my @attr = $node->attributes or return '';
Branch: 1 branch
BranchTrueFalseTotal
my(@attr) = $node->attributes or return "" 0 0 0
54  
55 0 my $output = 'attr { ';
56  
57 0 for ( @attr ) {
58 0 my $value = $_->value;
59 0 $value =~ s/'/'/g;
60 0 $output .= $_->nodeName . ' => ' . "'$value'" . ', ';
61 }
62  
63 0 $output .= '};';
64  
65 0 return $output;
66 }
67  
68 1 1;
69  
70 __END__
« XSS/Template.pm ↑ Summary XSS/Text.pm »