OX/Request.pm

filter: Statementstmt 100% 26 / 26 Branchbran 87.5% 7 / 8 Conditioncond 100% 2 / 2 MC/DCmcdc 100% 1 / 1 Subroutinesub 100% 8 / 8 Podpod 100% 4 / 4 totaltotal 97.9% 48 / 49 CC 6 SCAR 9.9
CC
6
Cov
97%
uri_for
5.0
mapping
2.0
BEGIN
1.0
CRAP 2.7
« OX/Meta/Role/HasRoutes.pm ↑ Summary OX/Application/Role/Sugar.pm »
1 package OX::Request;
2 42 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
3 42 $OX::Request::AUTHORITY = 'cpan:STEVAN';
4 }
5 42 $OX::Request::VERSION = '0.14';
6 42 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 42 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 # ABSTRACT: request object for OX
9  
10 42 extends 'Web::Request' => { -version => 0.05 };
11  
12  
13 211 ▶sub default_encoding { 'UTF-8' }
Subroutine default_encoding: called CC=1 SCAR=0.0
Pod documented
14 406 ▶sub response_class { 'OX::Response' }
Subroutine response_class: called CC=1 SCAR=0.0
Pod documented
15  
16 32 ▶sub _router { (shift)->env->{'ox.router'} }
Subroutine _router: called CC=1 SCAR=0.0
17  
18  
19 104 ▶sub mapping {
Subroutine mapping: called CC=2 SCAR=7.0
Pod documented
20 104 my $self = shift;
21 104 my $match = $self->env->{'plack.router.match'};
22 104 ▶ return unless $match;
Branch: 1 branch
BranchTrueFalseTotal
unless $match 0 104 104
23 104 return $match->mapping;
24 }
25  
26  
27 28 ▶sub uri_for {
Subroutine uri_for: called CC=5 SCAR=16.1
Pod documented
28 28 my ($self, $route) = @_;
29  
30 28 ▶ my $uri_base = $self->script_name || '/';
Condition100%2/2
$self->script_name || '/'
l!l
226
MC/DC100%1/1
$self->script_name || '/'
$self->script_name
Truth table100%2/2
A
A= $self->script_name
Aresult
11
00
31 28 ▶ $uri_base .= '/' unless $uri_base =~ m+/$+;
Branch: 1 branch
BranchTrueFalseTotal
unless $uri_base =~ m[/$] 2 26 28
32  
33 28 ▶ if (!ref($route)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $route) 6 22 28
34 6 $route = { name => $route };
35 }
36  
37 28 my $path_info = $self->_router->uri_for( %$route );
38  
39 28 ▶ confess "No URI found for route"
Branch: 1 branch
BranchTrueFalseTotal
unless defined $path_info 2 26 28
40 unless defined($path_info);
41  
42 26 return $uri_base . $path_info;
43 }
44  
45 42 __PACKAGE__->meta->make_immutable;
46  
47  
48 42 1;
49  
50 __END__
« OX/Meta/Role/HasRoutes.pm ↑ Summary OX/Application/Role/Sugar.pm »