PRANG/Graph/Node.pm

filter: Statementstmt 100% 15 / 15 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 3 / 3 Podpod 0.0% 0 / 2 totaltotal 90.9% 20 / 22 SCAR 6.9
CC
2
Cov
100%
createTextNode
2.0
BEGIN
1.0
accept_many
1.0
CRAP 2.0
« PRANG/Graph/Class.pm ↑ Summary PRANG/Cookbook/Book.pm »
1  
2 package PRANG::Graph::Node;
3 11 $PRANG::Graph::Node::VERSION = '0.19';
4 11 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 88 ▶sub accept_many {0}
Subroutine accept_many: called CC=1 SCAR=0.0
Pod undocumented
7  
8 #method accept( XML::LibXML::Node $node, PRANG::Graph::Context $ctx )
9 # returns ($key, $value, $nodeNameIfAmbiguous)
10 11 requires 'accept';
11  
12 #method complete( PRANG::Graph::Context $ctx )
13 # returns Bool
14 11 requires 'complete';
15  
16 #method expected( PRANG::Graph::Context $ctx )
17 # returns (@Str)
18 11 requires 'expected';
19  
20 # method output ( Object $item, XML::LibXML::Element $node, HashRef $xsi )
21 11 requires 'output';
22  
23 sub createTextNode {
24 89 ▶ my $self = shift;
Subroutine createTextNode: called CC=2 SCAR=6.9
Pod undocumented
25 89 my $doc = shift;
26 89 my $text = shift;
27
28 89 ▶ my $method = $PRANG::EMIT_CDATA ? 'createCDATASection' : 'createTextNode';
Branch: 1 branch
BranchTrueFalseTotal
$PRANG::EMIT_CDATA ? : 1 88 89
29
30 89 my $tn = $doc->$method($text);
31 }
32  
33 11 1;
34  
35 __END__
36  
37 =head1 NAME
38  
39 PRANG::Graph::Node - role for nodes in XML Graph machinery
40  
41 =head1 SYNOPSIS
42  
43 package PRANG::Graph::Foo;
44 with 'PRANG::Graph::Node';
45  
46 =head1 DESCRIPTION
47  
48 This role is essentially an interface which different types of
49 acceptors/emitted in the marshalling machinery must implement.
50  
51 You should hopefully not have to implement or poke into this class,
52 but if you do end up there while debugging then this documentation is
53 for you.
54  
55 =head1 REQUIRED METHODS
56  
57 Currently there are four methods required;
58  
59 =head2 B<accept( XML::LibXML::Node $node, PRANG::Graph::Context $ctx ) returns ($key, $value, $nodeNameIfAmbiguous)>
60  
61 Given an XML node, completely and recursively parse that node,
62 construct an object and return that object along with the name of the
63 node if the schema requires it.
64  
65 Updates C<$ctx> with any parse state affected by the operation.
66  
67 =head2 B<complete( PRANG::Graph::Context $ctx ) returns Bool>
68  
69 Returns true if the acceptor could be happy with the amount of parsing
70 that has been recorded in C<$ctx> or not.
71  
72 =head2 B<expected( PRANG::Graph::Context $ctx ) returns (@Str)>
73  
74 If there has not been enough accepted, then this function returns
75 something useful for building a helpful exception message.
76  
77 =head2 B<output( Object $item, XML::LibXML::Element $node, HashRef $xsi)>
78  
79 Given the item C<$item>, marshall to XML by constructing new LibXML nodes and attaching to C<$node>; C<$xsi> is the current XML namespaces mapping.
80  
81 =head1 SEE ALSO
82  
83 L<PRANG::Graph::Meta::Class>, L<PRANG::Graph::Meta::Attr>,
84 L<PRANG::Graph::Meta::Element>, L<PRANG::Marshaller>,
85 L<PRANG::Graph::Context>
86  
87 Implementations:
88  
89 L<PRANG::Graph::Seq>, L<PRANG::Graph::Quant>, L<PRANG::Graph::Choice>,
90 L<PRANG::Graph::Element>, L<PRANG::Graph::Text>
91  
92 =head1 AUTHOR AND LICENCE
93  
94 Development commissioned by NZ Registry Services, and carried out by
95 Catalyst IT - L<http://www.catalyst.net.nz/>
96  
97 Copyright 2009, 2010, NZ Registry Services. This module is licensed
98 under the Artistic License v2.0, which permits relicensing under other
99 Free Software licenses.
100  
101 =cut
102  
« PRANG/Graph/Class.pm ↑ Summary PRANG/Cookbook/Book.pm »