PRANG/Graph/Seq.pm

filter: Statementstmt 34.0% 17 / 50 Branchbran 0.0% 0 / 14 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 54.5% 6 / 11 Podpod n/a totaltotal 27.0% 23 / 85 CC 11 SCAR 26.3
CC
11
Cov
24%
__ANON__
26.9
__ANON__
26.3
__ANON__
4.8
CRAP 13.9
« PRANG/Graph/Quantity.pm ↑ Summary PRANG/Graph/Text.pm »
1  
2 package PRANG::Graph::Seq;
3  
4 9 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 9 ▶use MooseX::Method::Signatures;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 has 'members' =>
8 is => "ro",
9 isa => "ArrayRef[PRANG::Graph::Node]",
10 0 ▶ default => sub { [] },
Subroutine __ANON__: not called CC=1 SCAR=6.9
11 9 ;
12  
13 9 ▶method accept( XML::LibXML::Node $node, PRANG::Graph::Context $ctx ) {
Subroutine BEGIN: called CC=1 SCAR=1.2
Subroutine __ANON__: not called CC=5 SCAR=32.7
14 0 my $pos = $ctx->seq_pos;
15 0 my ($key, $val, $x, $ns, $member);
16 0 ▶ do {
Branch: 1 branch
BranchTrueFalseTotal
$key or do { do { $member = $self->members->[$pos - 1] or $ctx->exception("unexpected element", $node); () = $member->accept($node, $ctx); unless ($key and $member->accept_many) { $ctx->seq_pos(++$pos); } } } 0 0 0
17 0 ▶ $member = $self->members->[$pos-1]
Branch: 1 branch
BranchTrueFalseTotal
$member = $self->members->[$pos - 1] or $ctx->exception("unexpected element", $node) 0 0 0
18 or $ctx->exception("unexpected element", $node);
19 0 ($key, $val, $x, $ns) = $member->accept($node, $ctx);
20 0 ▶ if (!$key or !$member->accept_many ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($key and $member->accept_many) 0 0 0
Condition0%0/3
$key and $member->accept_many
!ll&&!rl&&r
000
MC/DC0%0/2
$key and $member->accept_many
$key $member->accept_many
Truth table0%0/3
A and B
A= $keyB= $member->accept_many
ABresult
0X0
100
111
21 0 $ctx->seq_pos(++$pos);
22 }
23 } until ($key);
24 0 ($key, $val, $x, $ns);
25 9 }
26  
27 9 ▶method complete( PRANG::Graph::Context $ctx ) {
Subroutine BEGIN: called CC=1 SCAR=1.2
Subroutine __ANON__: not called CC=5 SCAR=32.9
28 0 my $pos = $ctx->seq_pos;
29 0 my $member;
30 my $done;
31 0 ▶ while ( !$done ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($done) 0 0 0
32 0 $member = $self->members->[$pos-1];
33 0 ▶ if ( $member and $member->complete($ctx) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($member and $member->complete($ctx)) { } 0 0 0
Condition0%0/3
$member and $member->complete($ctx)
!ll&&!rl&&r
000
MC/DC0%0/2
$member and $member->complete($ctx)
$member $member->complete($ctx)
Truth table0%0/3
A and B
A= $memberB= $member->complete($ctx)
ABresult
0X0
100
111
34 0 $ctx->seq_pos(++$pos);
35 }
36 else {
37 0 $done = 1;
38 }
39 }
40 0 my $cmp = $pos-1 <=> @{$self->members};
41 0 ▶ if ( $cmp == 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmp == 1) 0 0 0
42 0 warn "Accepted too much!!";
43 }
44 0 return ( $cmp != -1 );
45 9 }
46  
47 9 ▶method expected( PRANG::Graph::Context $ctx ) {
Subroutine BEGIN: called CC=1 SCAR=1.2
Subroutine __ANON__: not called CC=2 SCAR=15.7
48 0 my $pos = $ctx->seq_pos;
49 0 my $member = $self->members->[$pos-1];
50 0 ▶ if ( $member ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($member) { } 0 0 0
51 0 return $member->expected($ctx);
52 }
53 else {
54 0 return "er... nothing?";
55 }
56 9 }
57  
58 9 ▶method output ( Item $item, XML::LibXML::Element $node, PRANG::Graph::Context $ctx ) {
Subroutine BEGIN: called CC=1 SCAR=1.2
Subroutine __ANON__: not called CC=2 SCAR=14.0
59 0 for my $member ( @{ $self->members } ) {
60 0 $member->output($item,$node,$ctx);
61 }
62 9 }
63  
64 9 with 'PRANG::Graph::Node';
65  
66 9 1;
67  
68 __END__
69  
70 =head1 NAME
71  
72 PRANG::Graph::Seq - a sequence of graph nodes
73  
74 =head1 SYNOPSIS
75  
76 See L<PRANG::Graph::Meta::Element> source and
77 L<PRANG::Graph::Node> for examples and information.
78  
79 =head1 DESCRIPTION
80  
81 This graph node specifies that the XML graph at this point has a
82 sequence of text nodes, elements, element choices or quantities
83 thereof, depending on the type of entries in the B<members> property.
84  
85 Classes with only one element defined do not have one of these objects
86 in their graph. Typically there is one members entry per element
87 defined in the class.
88  
89 =head1 ATTRIBUTES
90  
91 =over
92  
93 =item B<ArrayRef[PRANG::Graph::Node] members>
94  
95 The B<members> property provides the next portion of the XML Graph.
96 Depending on the type of entry, it will accept and emit nodes in a
97 particular way.
98  
99 Entries must be one of L<PRANG::Graph::Quant>, L<PRANG::Graph::Choice>,
100 L<PRANG::Graph::Element>, or L<PRANG::Graph::Text>.
101  
102 =back
103  
104 =head1 SEE ALSO
105  
106 L<PRANG::Graph::Meta::Class>, L<PRANG::Graph::Meta::Element>,
107 L<PRANG::Graph::Context>, L<PRANG::Graph::Node>
108  
109 Lower order L<PRANG::Graph::Node> types:
110  
111 L<PRANG::Graph::Quant>, L<PRANG::Graph::Choice>,
112 L<PRANG::Graph::Element>, L<PRANG::Graph::Text>
113  
114 =head1 AUTHOR AND LICENCE
115  
116 Development commissioned by NZ Registry Services, and carried out by
117 Catalyst IT - L<http://www.catalyst.net.nz/>
118  
119 Copyright 2009, 2010, NZ Registry Services. This module is licensed
120 under the Artistic License v2.0, which permits relicensing under other
121 Free Software licenses.
122  
123 =cut
124  
« PRANG/Graph/Quantity.pm ↑ Summary PRANG/Graph/Text.pm »