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