| 1 | |||||||||||||||||||||||||||||
| 2 | package PRANG::Graph::Seq; | ||||||||||||||||||||||||||||
| 3 | 11 | $PRANG::Graph::Seq::VERSION = '0.21'; | |||||||||||||||||||||||||||
| 4 | 11 | ▶ | use Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 11 | ▶ | use MooseX::Params::Validate; | ||||||||||||||||||||||||||
|
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 | 11 | ; | |||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 252 | ▶ | sub accept { | ||||||||||||||||||||||||||
|
Subroutine
accept: called CC=6 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 14 | 252 | my $self = shift; | |||||||||||||||||||||||||||
| 15 | 252 | my ( $node, $ctx, $lax ) = pos_validated_list( | |||||||||||||||||||||||||||
| 16 | \@_, | ||||||||||||||||||||||||||||
| 17 | { isa => 'XML::LibXML::Node' }, | ||||||||||||||||||||||||||||
| 18 | { isa => 'PRANG::Graph::Context' }, | ||||||||||||||||||||||||||||
| 19 | { isa => 'Bool' }, | ||||||||||||||||||||||||||||
| 20 | ); | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 252 | my $pos = $ctx->seq_pos; | |||||||||||||||||||||||||||
| 23 | 252 | my ($key, $val, $x, $ns, $member); | |||||||||||||||||||||||||||
| 24 | 252 | ▶ | do { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 25 | 535 | $member = $self->members->[$pos-1]; | |||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 535 | ▶ | if (! $member) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 28 | 7 | ▶ | $ctx->exception("unexpected element", $node) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 29 | unless $lax; | ||||||||||||||||||||||||||||
| 30 | 3 | return; | |||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 528 | ($key, $val, $x, $ns) = $member->accept($node, $ctx, $lax); | |||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 513 | ▶ | if (!$key or !$member->accept_many ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$key and $member->accept_many
MC/DC100%2/2
$key and $member->accept_many
$key
$member->accept_many
Truth table100%3/3
A and B
A= $keyB= $member->accept_many
| |||||||||||||||||||||||||||||
| 36 | 377 | $ctx->seq_pos(++$pos); | |||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||
| 38 | } until ($key); | ||||||||||||||||||||||||||||
| 39 | 230 | ($key, $val, $x, $ns); | |||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 99 | ▶ | sub complete { | ||||||||||||||||||||||||||
|
Subroutine
complete: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 43 | 99 | my $self = shift; | |||||||||||||||||||||||||||
| 44 | 99 | my ( $ctx ) = pos_validated_list( | |||||||||||||||||||||||||||
| 45 | \@_, | ||||||||||||||||||||||||||||
| 46 | { isa => 'PRANG::Graph::Context' }, | ||||||||||||||||||||||||||||
| 47 | ); | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 99 | my $pos = $ctx->seq_pos; | |||||||||||||||||||||||||||
| 50 | 99 | my $member; | |||||||||||||||||||||||||||
| 51 | my $done; | ||||||||||||||||||||||||||||
| 52 | 99 | ▶ | while ( !$done ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 53 | 474 | $member = $self->members->[$pos-1]; | |||||||||||||||||||||||||||
| 54 | 474 | ▶ | if ( $member and $member->complete($ctx) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$member and $member->complete($ctx)
MC/DC100%2/2
$member and $member->complete($ctx)
$member
$member->complete($ctx)
Truth table100%3/3
A and B
A= $memberB= $member->complete($ctx)
| |||||||||||||||||||||||||||||
| 55 | 375 | $ctx->seq_pos(++$pos); | |||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||
| 57 | else { | ||||||||||||||||||||||||||||
| 58 | 99 | $done = 1; | |||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||
| 61 | 99 | my $cmp = $pos-1 <=> @{$self->members}; | |||||||||||||||||||||||||||
| 62 | 99 | ▶ | if ( $cmp == 1 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 63 | 0 | warn "Accepted too much!!"; | |||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||
| 65 | 99 | return ( $cmp != -1 ); | |||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | 2 | ▶ | sub expected { | ||||||||||||||||||||||||||
|
Subroutine
expected: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 69 | 2 | my $self = shift; | |||||||||||||||||||||||||||
| 70 | 2 | my ( $ctx ) = pos_validated_list( | |||||||||||||||||||||||||||
| 71 | \@_, | ||||||||||||||||||||||||||||
| 72 | { isa => 'PRANG::Graph::Context' }, | ||||||||||||||||||||||||||||
| 73 | ); | ||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | 2 | my $pos = $ctx->seq_pos; | |||||||||||||||||||||||||||
| 76 | 2 | my $member = $self->members->[$pos-1]; | |||||||||||||||||||||||||||
| 77 | 2 | ▶ | if ($member) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 78 | 2 | return $member->expected($ctx); | |||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||
| 80 | else { | ||||||||||||||||||||||||||||
| 81 | 0 | return "er... nothing?"; | |||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | 58 | ▶ | sub output { | ||||||||||||||||||||||||||
|
Subroutine
output: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 86 | 58 | my $self = shift; | |||||||||||||||||||||||||||
| 87 | 58 | my ( $item, $node, $ctx ) = pos_validated_list( | |||||||||||||||||||||||||||
| 88 | \@_, | ||||||||||||||||||||||||||||
| 89 | { isa => 'Item' }, | ||||||||||||||||||||||||||||
| 90 | { isa => 'XML::LibXML::Element' }, | ||||||||||||||||||||||||||||
| 91 | { isa => 'PRANG::Graph::Context' }, | ||||||||||||||||||||||||||||
| 92 | ); | ||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | 58 | for my $member ( @{ $self->members } ) { | |||||||||||||||||||||||||||
| 95 | 388 | $member->output($item,$node,$ctx); | |||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | 11 | with 'PRANG::Graph::Node'; | |||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | 11 | 1; | |||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | __END__ | ||||||||||||||||||||||||||||