line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MojoX::Routes::AsGraph; |
2
|
|
|
|
|
|
|
$MojoX::Routes::AsGraph::VERSION = '0.05'; |
3
|
2
|
|
|
2
|
|
168813
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
64
|
|
4
|
2
|
|
|
2
|
|
10
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
39
|
|
5
|
2
|
|
|
2
|
|
2217
|
use Graph::Easy; |
|
2
|
|
|
|
|
234042
|
|
|
2
|
|
|
|
|
703
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub graph { |
8
|
1
|
|
|
1
|
1
|
1533
|
my ($self, $r) = @_; |
9
|
1
|
50
|
|
|
|
4
|
return unless $r; |
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
|
|
8
|
my $g = Graph::Easy->new; |
12
|
1
|
|
|
|
|
106
|
_new_node($g, $r, {}); |
13
|
|
|
|
|
|
|
|
14
|
1
|
|
|
|
|
3
|
return $g; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub _new_node { |
18
|
11
|
|
|
11
|
|
17
|
my ($g, $r, $s) = @_; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
### collect cool stuff |
21
|
11
|
|
|
|
|
26
|
my $name = $r->name; |
22
|
11
|
|
|
|
|
63
|
my $is_endpoint = $r->is_endpoint; |
23
|
11
|
|
|
|
|
128
|
my $pattern = $r->pattern; |
24
|
|
|
|
|
|
|
|
25
|
11
|
|
|
|
|
45
|
my $ctrl_actn; |
26
|
11
|
50
|
|
|
|
23
|
if ($pattern) { |
27
|
11
|
|
|
|
|
25
|
my $controller = $pattern->defaults->{controller}; |
28
|
11
|
|
|
|
|
57
|
my $action = $pattern->defaults->{action}; |
29
|
|
|
|
|
|
|
|
30
|
11
|
|
100
|
|
|
60
|
$ctrl_actn = $controller || ''; |
31
|
11
|
100
|
|
|
|
26
|
$ctrl_actn .= "->$action" if $action; |
32
|
|
|
|
|
|
|
|
33
|
11
|
|
|
|
|
26
|
$pattern = $pattern->unparsed; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
### Create node |
37
|
11
|
100
|
|
|
|
49
|
my @node_name = ($is_endpoint? '*' : ''); |
38
|
|
|
|
|
|
|
|
39
|
11
|
100
|
100
|
|
|
46
|
if (!$pattern && !$ctrl_actn) { |
40
|
1
|
|
|
|
|
3
|
my $n = ++$s->{empty}; |
41
|
1
|
|
|
|
|
3
|
push @node_name, ""; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
else { |
44
|
10
|
100
|
|
|
|
23
|
push @node_name, "'$pattern'" if $pattern; |
45
|
10
|
50
|
|
|
|
25
|
push @node_name, "[$ctrl_actn]" if $ctrl_actn; |
46
|
|
|
|
|
|
|
} |
47
|
11
|
100
|
|
|
|
25
|
push @node_name, "($name)" if $name; |
48
|
11
|
|
|
|
|
40
|
my $node = $g->add_node(join(' ', @node_name)); |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
### Draw my children |
51
|
11
|
|
|
|
|
469
|
for my $child (@{$r->children}) { |
|
11
|
|
|
|
|
24
|
|
52
|
10
|
|
|
|
|
437
|
my $child_node = _new_node($g, $child, $s); |
53
|
10
|
|
|
|
|
28
|
$g->add_edge($node, $child_node); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
11
|
|
|
|
|
267
|
return $node; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
1; # End of MojoX::Routes::AsGraph |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
__END__ |