Forest/Tree/Writer/ASCIIWithBranches.pm

filter: Statementstmt 100% 27 / 27 Branchbran 87.5% 7 / 8 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 5 / 5 Podpod 0.0% 0 / 1 totaltotal 90.9% 40 / 44 CC 6 SCAR 13.9
CC
6
Cov
95%
_process_node
6.0
BEGIN
1.0
as_string
1.0
CRAP 4.0
« Forest/Tree/Roles/MetaData.pm ↑ Summary Forest/Tree.pm »
1 package Forest::Tree::Writer::ASCIIWithBranches;
2 2 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 2 our $VERSION = '0.10';
5 2 our $AUTHORITY = 'cpan:STEVAN';
6  
7 2 with 'Forest::Tree::Writer',
8 'Forest::Tree::Roles::HasNodeFormatter';
9  
10 2 ▶sub as_string {
Subroutine as_string: called CC=1 SCAR=0.0
Pod undocumented
11 2 my ($self) = @_;
12  
13 2 my $out = '';
14 2 my @vert_dashes;
15  
16 22 ▶ $self->tree->traverse(sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
17 22 my $t = shift;
18 22 $out .= $self->_process_node($t, \@vert_dashes);
19 2 });
20  
21 2 return $out;
22 }
23  
24 22 ▶sub _process_node {
Subroutine _process_node: called CC=6 SCAR=18.0
25 22 my ($self, $t, $vert_dashes) = @_;
26  
27 22 my $depth = $t->depth;
28 22 ▶ my $sibling_count = $t->is_root ? 1 : $t->parent->child_count;
Branch: 1 branch
BranchTrueFalseTotal
$t->is_root ? : 0 22 22
29  
30 my @indent = map {
31 22 ▶ $vert_dashes->[$_] || " "
Condition50%1/2
$vert_dashes->[$_] || ' '
l!l
360
MC/DC0%0/1
$vert_dashes->[$_] || ' '
$vert_dashes->[$_]
Truth table50%1/2
A
A= $vert_dashes->[$_]
Aresult
11
00
32 } 0 .. $depth - 1;
33  
34 22 ▶ @$vert_dashes = (
Branch: 1 branch
BranchTrueFalseTotal
$sibling_count == 1 ? : 10 12 22
35 @indent,
36 ($sibling_count == 1
37 ? (" ")
38 : (" |"))
39 );
40  
41 22 ▶ if ($sibling_count == ($t->get_index_in_siblings + 1)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($sibling_count == $t->get_index_in_siblings + 1) 14 8 22
42 14 $vert_dashes->[$depth] = " ";
43 }
44  
45 22 ▶ return ((join "" => @indent[1 .. $#indent])
Branch: 1 branch
BranchTrueFalseTotal
$depth ? : 20 2 22
46 . ($depth ? " |---" : "")
47 . $self->format_node($t)
48 . "\n");
49 }
50  
51 2 __PACKAGE__->meta->make_immutable;
52  
53 2 ▶no Moose; 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
54  
55 __END__
« Forest/Tree/Roles/MetaData.pm ↑ Summary Forest/Tree.pm »