blib/lib/XML/XSS/Document.pm

filter: Statementstmt 100% 26 / 26 Branchbran 75.0% 3 / 4 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 6 / 6 Podpod n/a totaltotal 92.3% 36 / 39 CC 4 SCAR 8.6
CC
4
Cov
94%
apply
4.1
BEGIN
1.0
BEGIN
1.0
CRAP 2.4
« blib/lib/XML/XSS.pm ↑ Summary blib/lib/XML/XSS/ProcessingInstruction.pm »
1 package XML::XSS::Document;
2 BEGIN {
3 15 ▶ $XML::XSS::Document::AUTHORITY = 'cpan:YANICK';
Subroutine BEGIN: called CC=1 SCAR=0.0
4 }
5 {
6 15 $XML::XSS::Document::VERSION = '0.3.4';
7 }
8 # ABSTRACT: XML::XSS document stylesheet rule
9  
10  
11 15 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 15 ▶use MooseX::SemiAffordanceAccessor;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 15 ▶use MooseX::Clone;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 15 with 'XML::XSS::Role::Renderer', 'MooseX::Clone';
16  
17 15 ▶no warnings qw/ uninitialized /;
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19  
20 15 has use_clean_stash => (
21 default => 1,
22 is => 'rw',
23 traits => [ 'Clone' ],
24 );
25  
26 15 has [ qw/ content pre post / ] => ( traits => [ qw/ XML::XSS::Role::StyleAttribute
27 Clone / ] );
28  
29  
30 sub apply {
31 48 ▶ my ( $self, $node, $args ) = @_;
Subroutine apply: called CC=4 SCAR=14.0
32 48 ▶ $args ||= {};
Condition50%1/2
$args ||= {}
l!l
480
MC/DC0%0/1
$args ||= {}
$args
Truth table50%1/2
A
A= $args
Aresult
11
00
33  
34 48 ▶ $self->stylesheet->clear_stash if $self->use_clean_stash;
Branch: 1 branch
BranchTrueFalseTotal
if $self->use_clean_stash 48 0 48
35  
36 48 my $output = $self->_render( 'pre', $node, $args );
37  
38 48 ▶ $output .= $self->has_content
Branch: 1 branch
BranchTrueFalseTotal
$self->has_content ? : 1 47 48
39 ? $self->_render( 'content', $node, $args )
40 : $self->render( $node->childNodes, $args )
41 ;
42  
43 48 $output .= $self->_render( 'post', $node, $args );
44  
45 48 return $output;
46 }
47  
48 15 1;
49  
50 __END__
51  
52 =pod
53  
54 =head1 NAME
55  
56 XML::XSS::Document - XML::XSS document stylesheet rule
57  
58 =head1 VERSION
59  
60 version 0.3.4
61  
62 =head1 SYNOPSIS
63  
64 use XML::XSS;
65  
66 my $xss = XML::XSS->new;
67  
68 my $doc_style = $xss->document;
69  
70 $doc_style->set_pre( "=pod\n" );
71 $doc_style->set_post( "=cut\n" );
72  
73 print $xss->render( '<doc>yadah yadah</doc>' );
74  
75 =head1 DESCRIPTION
76  
77 A C<XML::XSS> rule that matches against the document to
78 be rendered.
79  
80 Note that this is the C<XML::LibXML::Document> object,
81 and not the document root element.
82  
83 =head1 ATTRIBUTES
84  
85 =head2 use_clean_stash
86  
87 If set to true, which is the default, the stash cleared before a new
88 document is rendered.
89  
90 =head3 use_clean_stash()
91  
92 Accessor getter.
93  
94 =head3 set_use_clean_stash($bool)
95  
96 Accessor setter.
97  
98 =head1 RENDERING ATTRIBUTES
99  
100 For a document, the displayed attributes follow the template:
101  
102 pre
103 [document nodes]
104 post
105  
106 =head2 pre
107  
108 Printed before the document's nodes.
109  
110 =head2 post
111  
112 Printed after the document nodes.
113  
114 =head2 content
115  
116 If defined, will be used instead of the child nodes of the document.
117  
118 =head2 METHODS
119  
120 =head3 set( %attrs )
121  
122 A shortcut to the attribute setters.
123  
124 $doc_style->set(
125 pre => 'foo',
126 post => 'bar',
127 );
128 # equivalent to
129 $doc_style->set_pre( 'foo' );
130 $doc_style->set_post( 'bar' );
131  
132 =head3 apply( $node, $args )
133  
134 Applies the rule to the C<$node>, passing along the optional C<$args>,
135 and returns the resulting string.
136  
137 =head1 AUTHOR
138  
139 Yanick Champoux <yanick@cpan.org>
140  
141 =head1 COPYRIGHT AND LICENSE
142  
143 This software is copyright (c) 2013 by Yanick Champoux.
144  
145 This is free software; you can redistribute it and/or modify it under
146 the same terms as the Perl 5 programming language system itself.
147  
148 =cut
« blib/lib/XML/XSS.pm ↑ Summary blib/lib/XML/XSS/ProcessingInstruction.pm »