blib/lib/Plack/Component.pm

filter: Statementstmt 89.4% 34 / 38 Branchbran 75.0% 3 / 4 Conditioncond 36.3% 4 / 11 MC/DCmcdc 14.2% 1 / 7 Subroutinesub 91.6% 11 / 12 Podpod 66.6% 4 / 6 totaltotal 73.0% 57 / 78 CC 7 SCAR 10.0
CC
7
Cov
77%
mk_accessors
6.0
new
4.1
to_app_auto
3.8
CRAP 2.7
« blib/lib/Plack/Middleware/Recursive.pm ↑ Summary blib/lib/Plack/Builder.pm »
1 package Plack::Component;
2 108 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 108 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 108 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
5 108 ▶use Plack::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 108 ▶use overload '&{}' => \&to_app_auto, fallback => 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 290 ▶sub new {
Subroutine new: called CC=4 SCAR=14.1
Pod documented
9 290 my $proto = shift;
10 290 ▶ my $class = ref $proto || $proto;
Condition33%1/3
ref $proto || $proto
l!l&&r!l&&!r
02900
MC/DC0%0/2
ref $proto || $proto
ref $proto $proto
Truth table33%1/3
A || B
A= ref $protoB= $proto
ABresult
1X1
011
000
11  
12 290 my $self;
13 290 ▶ if (@_ == 1 && ref $_[0] eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 1 and ref $_[0] eq 'HASH') { } 213 77 290
Condition66%2/3
@_ == 1 and ref $_[0] eq "HASH"
!ll&&!rl&&r
770213
MC/DC50%1/2
@_ == 1 and ref $_[0] eq "HASH"
@_ == 1 ref $_[0] eq "HASH"
Truth table66%2/3
A and B
A= @_ == 1B= ref $_[0] eq "HASH"
ABresult
0X0
100
111
14 213 $self = bless {%{$_[0]}}, $class;
15 } else {
16 77 $self = bless {@_}, $class;
17 }
18  
19 290 $self;
20 }
21  
22 134 ▶sub to_app_auto {
Subroutine to_app_auto: called CC=3 SCAR=13.3
Pod undocumented
23 134 my $self = shift;
24 134 ▶ if (($ENV{PLACK_ENV} || '') eq 'development') {
Branch: 1 branch
BranchTrueFalseTotal
if (($ENV{"PLACK_ENV"} || "") eq "development") 0 134 134
Condition50%1/2
$ENV{'PLACK_ENV'} || ''
l!l
0134
MC/DC0%0/1
$ENV{'PLACK_ENV'} || ''
$ENV{'PLACK_ENV'}
Truth table50%1/2
A
A= $ENV{'PLACK_ENV'}
Aresult
11
00
25 0 my $class = ref($self);
26 0 warn "WARNING: Automatically converting $class instance to a PSGI code reference. " .
27 "If you see this warning for each request, you probably need to explicitly call " .
28 "to_app() i.e. $class->new(...)->to_app in your PSGI file.\n";
29 }
30 134 $self->to_app(@_);
31 }
32  
33 # NOTE:
34 # this is for back-compat only,
35 # future modules should use
36 # Plack::Util::Accessor directly
37 # or their own favorite accessor
38 # generator.
39 # - SL
40 0 ▶sub mk_accessors {
Subroutine mk_accessors: not called CC=2 SCAR=17.9
Pod undocumented
41 0 my $self = shift;
42 0 ▶ Plack::Util::Accessor::mk_accessors( ref( $self ) || $self, @_ )
Condition0%0/3
ref $self || $self
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $self || $self
ref $self $self
Truth table0%0/3
A || B
A= ref $selfB= $self
ABresult
1X1
011
000
43 }
44  
45 292 ▶sub prepare_app { return }
Subroutine prepare_app: called CC=1 SCAR=0.0
Pod documented
46  
47 351 ▶sub to_app {
Subroutine to_app: called CC=1 SCAR=0.0
Pod documented
48 351 my $self = shift;
49 351 $self->prepare_app;
50 351 ▶ return sub { $self->call(@_) };
Subroutine __ANON__: called CC=1 SCAR=0.0
51 }
52  
53  
54 765 ▶sub response_cb {
Subroutine response_cb: called CC=1 SCAR=0.0
Pod documented
55 765 my($self, $res, $cb) = @_;
56 765 Plack::Util::response_cb($res, $cb);
57 }
58  
59 108 1;
60  
61 __END__
« blib/lib/Plack/Middleware/Recursive.pm ↑ Summary blib/lib/Plack/Builder.pm »