lib/Web/ComposableRequest/Role/Static.pm

filter: Statementstmt 83.3% 40 / 48 Branchbran 55.0% 11 / 20 Conditioncond 54.5% 6 / 11 MC/DCmcdc 50.0% 3 / 6 Subroutinesub 100% 8 / 8 Podpod 100% 1 / 1 totaltotal 73.4% 69 / 94 CC 16 SCAR 28.8
CC
16
Cov
72%
__ANON__
30.3
__ANON__
2.0
__ANON__
2.0
CRAP 17.8
↑ Summary lib/Web/ComposableRequest/Base.pm »
1 package Web::ComposableRequest::Role::Static;
2  
3 1 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 ▶use Web::ComposableRequest::Constants qw( FALSE NUL TRUE );
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Web::ComposableRequest::Util qw( first_char is_arrayref
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 is_hashref new_uri );
8 1 ▶use Moo::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 requires qw( locale path query_params scheme _base );
11  
12 3 ▶around '_build__base' => sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
13 3 ▶ my ($orig, $self) = @_; $self->mode eq 'static' or return $orig->( $self );
Branch: 1 branch
BranchTrueFalseTotal
$self->mode eq "static" or return &$orig($self) 1 2 3
14  
15 1 my $count = () = split m{ / }mx, $self->path, -1;
16  
17 1 return '../' x $count;
18 1 };
19  
20 2 ▶around '_build_uri' => sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
21 2 ▶ my ($orig, $self) = @_; $self->mode eq 'static' or return $orig->( $self );
Branch: 1 branch
BranchTrueFalseTotal
$self->mode eq "static" or return &$orig($self) 1 1 2
22  
23 1 my $path = $self->_base.$self->locale.'/'.$self->path.'.html';
24  
25 1 return new_uri $self->scheme, $path;
26 1 };
27  
28 4 ▶around 'uri_for' => sub {
Subroutine __ANON__: called CC=13 SCAR=34.1
29 4 ▶ my ($orig, $self, $path, @args) = @_; $path //= NUL;
Condition100%2/2
$path //= ""
l!l
22
MC/DC100%1/1
$path //= ""
$path
Truth table100%2/2
A
A= $path
Aresult
11
00
30  
31 4 ▶ ($self->mode eq 'static' and '/' ne substr $path, -1, 1)
Branch: 1 branch
BranchTrueFalseTotal
$self->mode eq "static" and "/" ne substr($path, -1, 1) or return &$orig($self, $path, @args) 1 3 4
Condition66%2/3
$self->mode eq "static" and "/" ne substr($path, -1, 1)
!ll&&!rl&&r
301
MC/DC50%1/2
$self->mode eq "static" and "/" ne substr($path, -1, 1)
$self->mode eq "static" "/" ne substr($path, -1, 1)
Truth table66%2/3
A and B
A= $self->mode eq "static"B= "/" ne substr($path, -1, 1)
ABresult
0X0
100
111
32 or return $orig->( $self, $path, @args );
33  
34 1 my $base = $self->_base; my $extn = '.html';
35  
36 1 my @query_params = (); my $uri_params = [];
37  
38 1 ▶ if (is_arrayref $args[ 0 ]) {
Branch: 2 branches
BranchTrueFalseTotal
if (&is_arrayref($args[0])) { } 0 1 1
elsif (&is_hashref($args[0])) { } 0 1 1
39 0 $uri_params = shift @args; @query_params = @args;
40 }
41 elsif (is_hashref $args[ 0 ]) {
42 0 ▶ $uri_params = $args[ 0 ]->{uri_params } // [];
Condition0%0/2
$args[0]{"uri_params"} // []
l!l
00
MC/DC0%0/1
$args[0]{"uri_params"} // []
$args[0]{"uri_params"}
Truth table0%0/2
A
A= $args[0]{"uri_params"}
Aresult
11
00
43 0 ▶ @query_params = @{ $args[ 0 ]->{query_params} // [] };
Condition0%0/2
$args[0]{"query_params"} // []
l!l
00
MC/DC0%0/1
$args[0]{"query_params"} // []
$args[0]{"query_params"}
Truth table0%0/2
A
A= $args[0]{"query_params"}
Aresult
11
00
44 0 ▶ $args[ 0 ]->{base } and $base = $args[ 0 ]->{base };
Branch: 1 branch
BranchTrueFalseTotal
$args[0]{"base"} and $base = $args[0]{"base"} 0 0 0
45 0 ▶ $args[ 0 ]->{extension} and $extn = $args[ 0 ]->{extension};
Branch: 1 branch
BranchTrueFalseTotal
$args[0]{"extension"} and $extn = $args[0]{"extension"} 0 0 0
46 }
47  
48 1 ▶ $path or $path = 'index'; $path = $base.$self->locale."/${path}";
Branch: 1 branch
BranchTrueFalseTotal
$path or $path = "index" 0 1 1
49  
50 0 ▶ $uri_params->[ 0 ] and $path = join '/', $path, @{ $uri_params };
Branch: 1 branch
BranchTrueFalseTotal
$uri_params->[0] and $path = join("/", $path, @{$uri_params;}) 0 1 1
51  
52 1 my $uri = new_uri $self->scheme, $path.$extn;
53  
54 1 ▶ $query_params[ 0 ] and $uri->query_form( @query_params );
Branch: 1 branch
BranchTrueFalseTotal
$query_params[0] and $uri->query_form(@query_params) 0 1 1
55  
56 1 return $uri;
57 1 };
58  
59 9 ▶sub mode {
Subroutine mode: called CC=2 SCAR=6.9
Pod documented
60 9 ▶ return $_[ 0 ]->query_params->( 'mode', { optional => TRUE } ) // 'online';
Condition100%2/2
$_[0]->query_params->("mode", {"optional", 1}) // "online"
l!l
36
MC/DC100%1/1
$_[0]->query_params->("mode", {"optional", 1}) // "online"
$_[0]->query_params->("mode", {"optional", 1})
Truth table100%2/2
A
A= $_[0]->query_params->("mode", {"optional", 1})
Aresult
11
00
61 }
62  
63 1 1;
64  
65 __END__
↑ Summary lib/Web/ComposableRequest/Base.pm »