Pickles/Controller.pm

filter: Statementstmt 70.0% 28 / 40 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 80.0% 8 / 10 Podpod 0.0% 0 / 4 totaltotal 66.0% 37 / 56 CC 3 SCAR 3.9
CC
3
Cov
69%
BEGIN
2.1
execute
2.0
REPLY
2.0
CRAP 1.5
« Pickles/Util.pm ↑ Summary Pickles.pm »
1 package Pickles::Controller;
2 10 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 10 ▶use Class::Trigger qw(pre_action post_action);
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 3 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
6 3 my( $class ) = @_;
7 3 my $self = bless {}, $class;
8 3 $self;
9 }
10  
11 1 ▶sub init {
Subroutine init: called CC=1 SCAR=0.0
Pod undocumented
12 1 my( $self, $c ) = @_;
13 }
14  
15 4 ▶sub execute {
Subroutine execute: called CC=2 SCAR=7.1
Pod undocumented
16 4 my( $self, $action, $c ) = @_;
17 4 my $config = $c->config;
18 4 ▶ if ( my $prefix = $config->{'ACTION_PREFIX'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $prefix = $config->{"ACTION_PREFIX"}) 0 4 4
19 0 $action = $prefix. $action;
20 }
21 4 $self->call_trigger( 'pre_action', $c, $action );
22 4 $self->$action( $c );
23 4 $self->call_trigger( 'post_action', $c, $action );
24 4 return 1;
25 }
26  
27 0 ▶sub REPLY {
Subroutine REPLY: not called CC=1 SCAR=6.9
Pod undocumented
28 0 my ($self, $c, $status) = @_;
29  
30 0 require HTTP::Status;
31 0 my $res = $c->res;
32 0 $res->status( $status );
33 0 $res->content_type('text/plain');
34 0 $res->body( HTTP::Status::status_message( $status ) );
35 0 return $res;
36 }
37  
38 10 ▶BEGIN {
Subroutine BEGIN: called CC=2 SCAR=7.4
39 10 foreach my $code (403, 404, 500) {
40 10 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
41 10 ▶ no warnings 'redefine';
Subroutine BEGIN: called CC=1 SCAR=0.0
42 30 my $method = "res$code";
43 30 ▶ *{$method} = sub {
Subroutine __ANON__: not called CC=1 SCAR=4.1
44 0 my ($self, $c) = @_;
45 0 $self->REPLY($c, $code);
46 0 $c->finished(1);
47 0 $c->abort();
48 30 };
49 }
50 }
51  
52 10 1;
53  
54 __END__
« Pickles/Util.pm ↑ Summary Pickles.pm »