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