line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Hyper::Developer::Model::Viewer; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
3823
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
44
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
32
|
|
5
|
1
|
|
|
1
|
|
4
|
use version; our $VERSION = qv(0.1); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
1186
|
use Class::Std; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use Graph::Easy; |
9
|
|
|
|
|
|
|
use Hyper::Functions; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
my %for_class_of :ATTR(:name); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub _get_config :PRIVATE { |
14
|
|
|
|
|
|
|
my $self = shift; |
15
|
|
|
|
|
|
|
my $for_class = $self->get_for_class(); |
16
|
|
|
|
|
|
|
my ($type) = $for_class =~ m{\A[^:]+::Control::([^:]+)::}xms; |
17
|
|
|
|
|
|
|
my $config_class = "Hyper\::Config\::Reader\::$type"; |
18
|
|
|
|
|
|
|
eval "use $config_class; 1;" or die $@; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
return $config_class->new({ |
21
|
|
|
|
|
|
|
config_for => $for_class, |
22
|
|
|
|
|
|
|
}); |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub create_graph { |
26
|
|
|
|
|
|
|
my $self = shift; |
27
|
|
|
|
|
|
|
my $graph = Graph::Easy->new(); |
28
|
|
|
|
|
|
|
my $config = $self->_get_config(); |
29
|
|
|
|
|
|
|
my $step_ref = $config->get_steps(); |
30
|
|
|
|
|
|
|
my $control_ref = $config->get_controls(); |
31
|
|
|
|
|
|
|
my $i = 0; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
for my $name ( keys %{$step_ref} ) { |
34
|
|
|
|
|
|
|
my $step = $graph->add_node($name); |
35
|
|
|
|
|
|
|
$step->set_attributes({ |
36
|
|
|
|
|
|
|
fill => '#CCFF66', |
37
|
|
|
|
|
|
|
}); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# Check for embedded controls |
40
|
|
|
|
|
|
|
#my @embedded_controls = map { |
41
|
|
|
|
|
|
|
# my $class = Hyper::Functions::fix_class_name( |
42
|
|
|
|
|
|
|
# $control_ref->{$_}->get_class() |
43
|
|
|
|
|
|
|
# ); |
44
|
|
|
|
|
|
|
# $class =~ m{\A[^:]+::Control::(?: Flow|Container)::}xms |
45
|
|
|
|
|
|
|
# ? $class |
46
|
|
|
|
|
|
|
# : (); |
47
|
|
|
|
|
|
|
#} @{$step_ref->{$name}->get_controls() || []}; |
48
|
|
|
|
|
|
|
#for my $class ( @embedded_controls ) { |
49
|
|
|
|
|
|
|
# warn $class; |
50
|
|
|
|
|
|
|
# $graph->add_edge( |
51
|
|
|
|
|
|
|
# $step, |
52
|
|
|
|
|
|
|
# Hyper::Developer::Model::Viewer->new({ |
53
|
|
|
|
|
|
|
# for_class => $class, |
54
|
|
|
|
|
|
|
# })->create_graph($graph), |
55
|
|
|
|
|
|
|
# ); |
56
|
|
|
|
|
|
|
#} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
my $transition_counter; |
59
|
|
|
|
|
|
|
for my $transition ( @{$step_ref->{$name}->get_transitions()} ) { |
60
|
|
|
|
|
|
|
my $source = $transition->get_source(); |
61
|
|
|
|
|
|
|
my $destination = $transition->get_destination(); |
62
|
|
|
|
|
|
|
my $condition = $transition->get_condition(); |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
# fix transition names |
65
|
|
|
|
|
|
|
s{=}{_}xmsg for ($source, $destination); |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
if ( $condition ) { |
68
|
|
|
|
|
|
|
my $decision = $graph->add_node("$source $destination"); |
69
|
|
|
|
|
|
|
$decision->set_attributes({ |
70
|
|
|
|
|
|
|
shape => 'diamond', |
71
|
|
|
|
|
|
|
label => ++$transition_counter, |
72
|
|
|
|
|
|
|
fill => '#FFB2B2', |
73
|
|
|
|
|
|
|
}); |
74
|
|
|
|
|
|
|
$graph->add_edge($source, $decision)->set_attribute(flow => 'down'); |
75
|
|
|
|
|
|
|
$graph->add_edge( |
76
|
|
|
|
|
|
|
$decision, |
77
|
|
|
|
|
|
|
$destination, |
78
|
|
|
|
|
|
|
$condition, |
79
|
|
|
|
|
|
|
)->set_attributes({ |
80
|
|
|
|
|
|
|
flow => 'left', |
81
|
|
|
|
|
|
|
}); |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
else { |
84
|
|
|
|
|
|
|
$graph->add_edge( |
85
|
|
|
|
|
|
|
$source, |
86
|
|
|
|
|
|
|
$destination, |
87
|
|
|
|
|
|
|
)->set_attribute(flow => 'down'); |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
REMOVE_BROKEN_NODES: |
93
|
|
|
|
|
|
|
for my $node ( $graph->nodes() ) { |
94
|
|
|
|
|
|
|
$node->edges() and next REMOVE_BROKEN_NODES; |
95
|
|
|
|
|
|
|
$graph->del_node($node); |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
return $graph; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
1; |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
# ToDo: add pod |