blib/lib/XML/XSS/Stylesheet/HTML2TD.pm

filter: Statementstmt 43.5% 17 / 39 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 44.4% 4 / 9 Podpod 0.0% 0 / 2 totaltotal 38.8% 21 / 54 CC 4 SCAR 15.8
CC
4
Cov
40%
pre_attrs
12.0
__ANON__
6.0
__ANON__
2.0
CRAP 4.8
« blib/lib/XML/XSS/Template.pm ↑ Summary Build »
1 package XML::XSS::Stylesheet::HTML2TD;
2 BEGIN {
3 1 ▶ $XML::XSS::Stylesheet::HTML2TD::AUTHORITY = 'cpan:YANICK';
Subroutine BEGIN: called CC=1 SCAR=0.0
4 }
5 {
6 1 $XML::XSS::Stylesheet::HTML2TD::VERSION = '0.3.4';
7 }
8  
9 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use XML::XSS;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use Perl::Tidy;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 1 extends 'XML::XSS';
14  
15 1 style '*' => (
16 pre => \&pre_element,
17 post => '};',
18 );
19  
20 style '#text' => (
21 0 ▶ process => sub { $_[1]->data =~ /\S/ },
Subroutine __ANON__: not called CC=1 SCAR=6.9
22 pre => "outs '",
23 post => "';",
24 0 ▶ filter => sub { s/'/\\'/g; s/^\s+|\s+$//gm; $_ },
Subroutine __ANON__: not called CC=1 SCAR=6.9
25 1 );
26  
27 style '#document' => (
28 content => sub {
29 0 ▶ my ( $self, $node, $args ) = @_;
Subroutine __ANON__: not called CC=2 SCAR=17.9
30 0 my $raw = $self->stylesheet->render( $node->childNodes );
31  
32 0 my $output;
33 my $err;
34 0 eval {
35 0 Perl::Tidy::perltidy(
36 source => \$raw,
37 destination => \$output,
38 errorfile => \$err,
39 )
40 };
41  
42 # send the raw output if Tidy failed
43 0 ▶ return $err ? $raw : $output;
Branch: 1 branch
BranchTrueFalseTotal
$err ? : 0 0 0
44 },
45 1 );
46  
47 sub pre_element {
48 0 ▶ my ( $self, $node ) = @_;
Subroutine pre_element: not called CC=1 SCAR=6.9
Pod undocumented
49  
50 0 my $name = $node->nodeName;
51  
52 0 return "$name {" . pre_attrs( $node );
53 }
54  
55 sub pre_attrs {
56 0 ▶ my $node = shift;
Subroutine pre_attrs: not called CC=3 SCAR=24.8
Pod undocumented
57  
58 0 ▶ my @attr = $node->attributes or return '';
Branch: 1 branch
BranchTrueFalseTotal
my(@attr) = $node->attributes or return "" 0 0 0
59  
60 0 my $output = 'attr { ';
61  
62 0 for ( @attr ) {
63 0 my $value = $_->value;
64 0 $value =~ s/'/'/g;
65 0 $output .= $_->nodeName . ' => ' . "'$value'" . ', ';
66 }
67  
68 0 $output .= '};';
69  
70 0 return $output;
71 }
72  
73 1 1;
74  
75 __END__
76  
77 =pod
78  
79 =head1 NAME
80  
81 XML::XSS::Stylesheet::HTML2TD
82  
83 =head1 VERSION
84  
85 version 0.3.4
86  
87 =head1 AUTHOR
88  
89 Yanick Champoux <yanick@cpan.org>
90  
91 =head1 COPYRIGHT AND LICENSE
92  
93 This software is copyright (c) 2013 by Yanick Champoux.
94  
95 This is free software; you can redistribute it and/or modify it under
96 the same terms as the Perl 5 programming language system itself.
97  
98 =cut
« blib/lib/XML/XSS/Template.pm ↑ Summary Build »