lib/APISchema/Generator/Router/Simple.pm

filter: Statementstmt 100% 32 / 32 Branchbran n/a Conditioncond 83.3% 5 / 6 MC/DCmcdc 66.6% 2 / 3 Subroutinesub 100% 8 / 8 Podpod 0.0% 0 / 2 totaltotal 92.1% 47 / 51 CC 5 SCAR 7.7
CC
5
Cov
97%
inject_routes
4.0
generate_router
2.0
BEGIN
1.0
CRAP 2.2
« lib/Plack/Middleware/APISchema/ResponseValidator.pm ↑ Summary lib/Plack/Middleware/APISchema/RequestValidator.pm »
1 package APISchema::Generator::Router::Simple;
2 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 4 ▶use Hash::Merge::Simple qw(merge);
Subroutine BEGIN: called CC=1 SCAR=0.0
6 4 ▶use Class::Load qw(load_class);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 4 ▶use Class::Accessor::Lite (
Subroutine BEGIN: called CC=1 SCAR=0.0
8 4 new => 1,
9 ro => [qw(router_class)],
10 4 );
11  
12 4 ▶use constant ROUTER_CLASS => 'Router::Simple';
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 17 ▶sub generate_router {
Subroutine generate_router: called CC=2 SCAR=6.9
Pod undocumented
15 17 my ($self, $schema) = @_;
16  
17 17 ▶ my $router_class = $self->router_class // ROUTER_CLASS;
Condition100%2/2
$self->router_class // "Router::Simple"
l!l
116
MC/DC100%1/1
$self->router_class // "Router::Simple"
$self->router_class
Truth table100%2/2
A
A= $self->router_class
Aresult
11
00
18 17 my $router = load_class($router_class)->new;
19  
20 17 $self->inject_routes($schema, $router);
21 }
22  
23 18 ▶sub inject_routes {
Subroutine inject_routes: called CC=4 SCAR=13.9
Pod undocumented
24 18 my ($self, $schema, $router) = @_;
25  
26 18 my $router_class = ref $router;
27  
28 18 for my $route (@{$schema->get_routes}) {
29 25 ▶ my $option = $route->option // {};
Condition100%2/2
$route->option // {}
l!l
916
MC/DC100%1/1
$route->option // {}
$route->option
Truth table100%2/2
A
A= $route->option
Aresult
11
00
30 25 ▶ $option = merge $option, $option->{$router_class} // {};
Condition50%1/2
$option->{$router_class} // {}
l!l
025
MC/DC0%0/1
$option->{$router_class} // {}
$option->{$router_class}
Truth table50%1/2
A
A= $option->{$router_class}
Aresult
11
00
31 $router->connect($route->title, $route->route => $route->destination, {
32 method => $route->method,
33 25 map { $_ => $option->{$_} } qw(host on_match),
34 });
35 }
36  
37 18 $router;
38 }
39  
40 4 1;
« lib/Plack/Middleware/APISchema/ResponseValidator.pm ↑ Summary lib/Plack/Middleware/APISchema/RequestValidator.pm »