| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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 //= ""
MC/DC100%1/1
$path //= ""
$path
Truth table100%2/2
A
A= $path
| |||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 4 | ▶ | ($self->mode eq 'static' and '/' ne substr $path, -1, 1) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->mode eq "static" and "/" ne substr($path, -1, 1)
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)
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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"} // []
MC/DC0%0/1
$args[0]{"uri_params"} // []
$args[0]{"uri_params"}
Truth table0%0/2
A
A= $args[0]{"uri_params"}
| |||||||||||||||||||||||||||||
| 43 | 0 | ▶ | @query_params = @{ $args[ 0 ]->{query_params} // [] }; | ||||||||||||||||||||||||||
|
Condition0%0/2
$args[0]{"query_params"} // []
MC/DC0%0/1
$args[0]{"query_params"} // []
$args[0]{"query_params"}
Truth table0%0/2
A
A= $args[0]{"query_params"}
| |||||||||||||||||||||||||||||
| 44 | 0 | ▶ | $args[ 0 ]->{base } and $base = $args[ 0 ]->{base }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 45 | 0 | ▶ | $args[ 0 ]->{extension} and $extn = $args[ 0 ]->{extension}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 1 | ▶ | $path or $path = 'index'; $path = $base.$self->locale."/${path}"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | 0 | ▶ | $uri_params->[ 0 ] and $path = join '/', $path, @{ $uri_params }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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"
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})
| |||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | 1 | 1; | |||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | __END__ | ||||||||||||||||||||||||||||