blib/lib/Clustericious/Controller.pm

filter: Statementstmt 65.7% 25 / 38 Branchbran 33.3% 2 / 6 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 87.5% 7 / 8 Podpod 100% 2 / 2 totaltotal 62.7% 37 / 59 CC 5 SCAR 11.8
CC
5
Cov
60%
redirect_to
6.0
url_for
5.3
BEGIN
1.0
CRAP 3.3
« blib/lib/Clustericious/Command/which.pm ↑ Summary blib/lib/Clustericious/App.pm »
1 package Clustericious::Controller;
2  
3 45 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 45 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 45 ▶use Clustericious::Config;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 45 ▶use Clustericious::Log;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 45 ▶use Carp qw( carp );
Subroutine BEGIN: called CC=1 SCAR=0.0
8 45 ▶use base 'Mojolicious::Controller';
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 # ABSTRACT: Clustericious controller base class
11 45 our $VERSION = '1.29'; # VERSION
12  
13  
14 4 ▶sub url_for {
Subroutine url_for: called CC=4 SCAR=16.6
Pod documented
15 4 my $c = shift;
16  
17 # NOTE: the only place it looks like we need to use this bizzarely
18 # customized url_for is in Restmd. If we can confirm/deny that we
19 # do/don't need it there, then we can probably remove this special case
20 # NOTE2: also used in the function below.
21  
22 # Note: This dos not seem to be the case anymore:
23 # Original Comment: link_to calls url_for on a Mojo::URL which for some reason
24 # causes /a/b?c=d to not work properly (? is escaped)
25 4 ▶ return $_[0] if @_==1 && ref($_[0]) eq "Mojo::URL";
Branch: 1 branch
BranchTrueFalseTotal
if @_ == 1 and ref $_[0] eq "Mojo::URL" 0 4 4
Condition33%1/3
@_ == 1 and ref $_[0] eq "Mojo::URL"
!ll&&!rl&&r
040
MC/DC0%0/2
@_ == 1 and ref $_[0] eq "Mojo::URL"
@_ == 1 ref $_[0] eq "Mojo::URL"
Truth table33%1/3
A and B
A= @_ == 1B= ref $_[0] eq "Mojo::URL"
ABresult
0X0
100
111
26  
27 4 my $base = $c->config->url_base( default => '' );
28 4 my $url = $c->SUPER::url_for(@_);
29 4 ▶ return $url unless $base;
Branch: 1 branch
BranchTrueFalseTotal
unless $base 4 0 4
30 0 $url->base->parse($base);
31 0 return $url;
32 }
33  
34  
35 0 ▶sub redirect_to {
Subroutine redirect_to: not called CC=2 SCAR=17.9
Pod documented
36 0 my $self = shift;
37  
38 # Response
39 0 my $res = $self->res;
40  
41 # Code
42 0 $res->code(302);
43  
44 # Headers
45 0 my $headers = $res->headers;
46 0 my $loc = $self->url_for(@_);
47  
48 0 ▶ if (my $url_base = Clustericious::Config->new(ref $self->app)->url_base(default => '')) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $url_base = "Clustericious::Config"->new(ref $self->app)->url_base("default", "")) 0 0 0
49 0 $loc->base->parse($url_base);
50 }
51  
52 0 $headers->location($loc->to_abs);
53 0 $headers->content_length(0);
54  
55 # Rendered
56 0 $self->rendered;
57  
58 0 return $self;
59 }
60  
61 45 1;
62  
63 __END__
« blib/lib/Clustericious/Command/which.pm ↑ Summary blib/lib/Clustericious/App.pm »