line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Forest::Tree::Writer::ASCIIWithBranches; |
2
|
2
|
|
|
2
|
|
5748
|
use Moose; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
20
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
our $VERSION = '0.10'; |
5
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:STEVAN'; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
with 'Forest::Tree::Writer', |
8
|
|
|
|
|
|
|
'Forest::Tree::Roles::HasNodeFormatter'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub as_string { |
11
|
2
|
|
|
2
|
0
|
769
|
my ($self) = @_; |
12
|
|
|
|
|
|
|
|
13
|
2
|
|
|
|
|
4
|
my $out = ''; |
14
|
2
|
|
|
|
|
5
|
my @vert_dashes; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
$self->tree->traverse(sub { |
17
|
22
|
|
|
22
|
|
34
|
my $t = shift; |
18
|
22
|
|
|
|
|
63
|
$out .= $self->_process_node($t, \@vert_dashes); |
19
|
2
|
|
|
|
|
98
|
}); |
20
|
|
|
|
|
|
|
|
21
|
2
|
|
|
|
|
31
|
return $out; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub _process_node { |
25
|
22
|
|
|
22
|
|
34
|
my ($self, $t, $vert_dashes) = @_; |
26
|
|
|
|
|
|
|
|
27
|
22
|
|
|
|
|
69
|
my $depth = $t->depth; |
28
|
22
|
50
|
|
|
|
80
|
my $sibling_count = $t->is_root ? 1 : $t->parent->child_count; |
29
|
|
|
|
|
|
|
|
30
|
36
|
50
|
|
|
|
142
|
my @indent = map { |
31
|
22
|
|
|
|
|
69
|
$vert_dashes->[$_] || " " |
32
|
|
|
|
|
|
|
} 0 .. $depth - 1; |
33
|
|
|
|
|
|
|
|
34
|
22
|
100
|
|
|
|
85
|
@$vert_dashes = ( |
35
|
|
|
|
|
|
|
@indent, |
36
|
|
|
|
|
|
|
($sibling_count == 1 |
37
|
|
|
|
|
|
|
? (" ") |
38
|
|
|
|
|
|
|
: (" |")) |
39
|
|
|
|
|
|
|
); |
40
|
|
|
|
|
|
|
|
41
|
22
|
100
|
|
|
|
86
|
if ($sibling_count == ($t->get_index_in_siblings + 1)) { |
42
|
14
|
|
|
|
|
30
|
$vert_dashes->[$depth] = " "; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
22
|
100
|
|
|
|
230
|
return ((join "" => @indent[1 .. $#indent]) |
46
|
|
|
|
|
|
|
. ($depth ? " |---" : "") |
47
|
|
|
|
|
|
|
. $self->format_node($t) |
48
|
|
|
|
|
|
|
. "\n"); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
52
|
|
|
|
|
|
|
|
53
|
2
|
|
|
2
|
|
17986
|
no Moose; 1; |
|
2
|
|
|
|
|
11
|
|
|
2
|
|
|
|
|
14
|
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
__END__ |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=pod |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head1 NAME |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Forest::Tree::Writer::ASCIIWithBranches - A slightly more complex ASCII writer |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 SYNOPSIS |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
use Forest::Tree::Writer::ASCIIWithBranches; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
my $w = Forest::Tree::Writer::ASCIIWithBranches->new(tree => $tree); |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
print $w->as_string; # outputs .... |
70
|
|
|
|
|
|
|
# root |
71
|
|
|
|
|
|
|
# |---1.0 |
72
|
|
|
|
|
|
|
# | |---1.1 |
73
|
|
|
|
|
|
|
# | |---1.2 |
74
|
|
|
|
|
|
|
# | |---1.2.1 |
75
|
|
|
|
|
|
|
# |---2.0 |
76
|
|
|
|
|
|
|
# | |---2.1 |
77
|
|
|
|
|
|
|
# |---3.0 |
78
|
|
|
|
|
|
|
# |---4.0 |
79
|
|
|
|
|
|
|
# |---4.1 |
80
|
|
|
|
|
|
|
# |---4.1.1 |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 DESCRIPTION |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 METHODS |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=over 4 |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=item B<> |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=back |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 BUGS |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
All complex software has bugs lurking in it, and this module is no |
95
|
|
|
|
|
|
|
exception. If you find a bug please either email me, or add the bug |
96
|
|
|
|
|
|
|
to cpan-RT. |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head1 AUTHOR |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
Stevan Little E<lt>stevan.little@iinteractive.comE<gt> |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
Copyright 2008-2014 Infinity Interactive, Inc. |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
L<http://www.iinteractive.com> |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
109
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=cut |