blib/lib/Language/Homespring/Visualise/GraphViz.pm

filter: Statementstmt 47.6% 20 / 42 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 8 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 66.6% 6 / 9 Podpod 66.6% 2 / 3 totaltotal 40.0% 28 / 70 CC 8 SCAR 27.0
CC
8
Cov
37%
new
30.0
add_node
20.0
do
2.0
CRAP 14.9
↑ Summary
1 package Language::Homespring::Visualise::GraphViz;
2  
3 1 $VERSION = 0.04;
4  
5 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use GraphViz;
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 0 ▶sub new {
Subroutine new: not called CC=5 SCAR=34.0
Pod documented
10 0 my $class = shift;
11 0 my $self = bless {}, $class;
12  
13 0 my $options = shift;
14 0 $self->{interp} = $options->{interp};
15 0 ▶ $self->{spring_col} = $options->{spring_col} || '#C0C0FF';
Condition0%0/2
$options->{'spring_col'} || '#C0C0FF'
l!l
00
MC/DC0%0/1
$options->{'spring_col'} || '#C0C0FF'
$options->{'spring_col'}
Truth table0%0/2
A
A= $options->{'spring_col'}
Aresult
11
00
16 0 ▶ $self->{node_col} = $options->{node_col} || 'white';
Condition0%0/2
$options->{'node_col'} || 'white'
l!l
00
MC/DC0%0/1
$options->{'node_col'} || 'white'
$options->{'node_col'}
Truth table0%0/2
A
A= $options->{'node_col'}
Aresult
11
00
17  
18 0 ▶ $self->{fontname} = $options->{fontname} || 'Times';
Condition0%0/2
$options->{'fontname'} || 'Times'
l!l
00
MC/DC0%0/1
$options->{'fontname'} || 'Times'
$options->{'fontname'}
Truth table0%0/2
A
A= $options->{'fontname'}
Aresult
11
00
19 0 ▶ $self->{fontsize} = $options->{fontsize} || '12';
Condition0%0/2
$options->{'fontsize'} || '12'
l!l
00
MC/DC0%0/1
$options->{'fontsize'} || '12'
$options->{'fontsize'}
Truth table0%0/2
A
A= $options->{'fontsize'}
Aresult
11
00
20  
21 0 return $self;
22 }
23  
24 0 ▶sub do {
Subroutine do: not called CC=1 SCAR=6.9
Pod documented
25 0 my ($self) = @_;
26
27 0 $self->{graph} = GraphViz->new(
28 directed => 0,
29 layout => 'dot',
30 rankdir => 1,
31 epsilon => 1,
32 );
33  
34 0 $self->add_node($self->{interp}->{root_node}, 1);
35  
36 0 return $self->{graph};
37 }
38  
39 0 ▶sub add_node {
Subroutine add_node: not called CC=4 SCAR=30.0
Pod undocumented
40 0 my ($self, $node, $rank) = @_;
41  
42 0 for(@{$node->{child_nodes}}){
43 0 my $label = $_->{node_name_safe};
44 0 $label =~ s/\\/\\\\/g;
45  
46 0 ▶ my $fillcolor = $_->{spring}?$self->{spring_col}:$self->{node_col};
Branch: 1 branch
BranchTrueFalseTotal
$_->{'spring'} ? : 0 0 0
47  
48 $self->{graph}->add_node(
49 $_->{uid},
50 label => $label,
51 rank => $rank,
52 fillcolor => $fillcolor,
53 style => 'filled',
54 fontname => $self->{fontname},
55 fontsize => $self->{fontsize},
56 0 );
57  
58 $self->{graph}->add_edge(
59 $node->{uid} => $_->{uid},
60 arrowtail => 'normal',
61 0 ▶ ) if ($node->{uid} != $self->{interp}->{root_node}->{uid});
Branch: 1 branch
BranchTrueFalseTotal
if $node->{"uid"} != $self->{"interp"}{"root_node"}{"uid"} 0 0 0
62  
63 0 $self->add_node($_, $rank+1);
64 }
65 }
66  
67 __END__
↑ Summary