lib/CatalystX/Dispatcher/AsGraph.pm

filter: Statementstmt 78.4% 51 / 65 Branchbran 50.0% 2 / 4 Conditioncond 25.0% 1 / 4 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 93.3% 14 / 15 Podpod n/a totaltotal 75.5% 68 / 90 CC 9 SCAR 15.7
CC
9
Cov
74%
__ANON__
9.8
_new_node
9.8
BEGIN
1.0
CRAP 4.8
↑ Summary script/catalyst_graph_dispatcher.pl »
1 package CatalystX::Dispatcher::AsGraph;
2  
3 # ABSTRACT: Create a graph from Catalyst dispatcher
4  
5 2 ▶use MooseX::Declare;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 our $VERSION = '0.03';
8  
9 2 ▶class CatalystX::Dispatcher::AsGraph {
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.3
10  
11 2 ▶ use Graph::Easy;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 2 with 'MooseX::Getopt';
13  
14 2 has [qw/appname output/] => (is => 'ro', isa => 'Str', required => 1);
15  
16 has graph => (
17 traits => ['NoGetopt'],
18 is => 'ro',
19 1 ▶ default => sub { Graph::Easy->new }
Subroutine __ANON__: called CC=1 SCAR=0.0
20 2 );
21 has app => (
22 traits => ['NoGetopt'],
23 is => 'rw',
24 isa => 'Object',
25 lazy => 1,
26 handles => [qw/dispatcher/],
27 1 ▶ default => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
28 1 my $self = shift;
29 1 Class::MOP::load_class($self->appname);
30 1 my $app = $self->appname->new;
31 1 $app;
32 }
33 2 );
34  
35 2 ▶ method run{
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
36 1 my $routes = $self->dispatcher->_tree;
37 1 $self->_new_node($routes, '');
38 2 }
39  
40 0 ▶ method _new_node($parent, $prefix) {
Subroutine BEGIN: called CC=1 SCAR=0.4
Subroutine __ANON__: not called CC=5 SCAR=22.8
Subroutine _new_node: called CC=5 SCAR=22.8
41 0 ▶ my $name = $prefix . $parent->getNodeValue || '';
Condition25%1/4
$prefix . $parent->getNodeValue || ''
l!l
00
$prefix . $parent->getNodeValue || ''
l!l
10
MC/DC0%0/1
$prefix . $parent->getNodeValue || ''
$prefix . $parent->getNodeValue
MC/DC0%0/1
$prefix . $parent->getNodeValue || ''
$prefix . $parent->getNodeValue
Truth table0%0/2
A
A= $prefix . $parent->getNodeValue
Aresult
11
00
Truth table50%1/2
A
A= $prefix . $parent->getNodeValue
Aresult
11
00
42 0 my $node = $self->graph->add_node($name);
43  
44 0 my $actions = $parent->getNodeValue->actions;
45 0 for my $action ( keys %{$actions} ) {
46 0 ▶ next if ( ( $action =~ /^_.*/ ) );
Branch: 2 branches
BranchTrueFalseTotal
if $action =~ /^_.*/ 0 0 0
if $action =~ /^_.*/ 5 5 10
47 0 $self->graph->add_edge( $node, "[action] " . $action);
48 }
49 0 for my $child ( $parent->getAllChildren ) {
50 0 my $child_node = $self->_new_node( $child, $name . ' -> ' );
51 0 $self->graph->add_edge( $node, $child_node );
52 }
53 0 return $node;
54 2 }
55 2 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
56  
57 1 1;
58  
59  
60 __END__
↑ Summary script/catalyst_graph_dispatcher.pl »