blib/lib/Plack/Loader.pm

filter: Statementstmt 69.5% 32 / 46 Branchbran 20.0% 4 / 20 Conditioncond 17.6% 3 / 17 MC/DCmcdc 0.0% 0 / 9 Subroutinesub 75.0% 12 / 16 Podpod 0.0% 0 / 8 totaltotal 43.9% 51 / 116 CC 17 SCAR 33.8
CC
17
Cov
47%
guess
90.0
__ANON__
16.7
auto
2.5
CRAP 29.3
« blib/lib/Plack/Handler/Apache2.pm ↑ Summary blib/lib/Plack/Runner.pm »
1 package Plack::Loader;
2 59 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 59 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
4 59 ▶use Plack::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 59 ▶use Try::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 39 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
8 39 my $class = shift;
9 39 bless {}, $class;
10 }
11  
12 0 ▶sub watch {
Subroutine watch: not called CC=1 SCAR=0.0
Pod undocumented
13 # do nothing. Override in subclass
14 }
15  
16 1 ▶sub auto {
Subroutine auto: called CC=2 SCAR=9.2
Pod undocumented
17 1 my($class, @args) = @_;
18  
19 1 ▶ my $backend = $class->guess
Branch: 1 branch
BranchTrueFalseTotal
my $backend = $class->guess or Carp::croak("Couldn't auto-guess server server implementation. Set it with PLACK_SERVER") 1 0 1
20 or Carp::croak("Couldn't auto-guess server server implementation. Set it with PLACK_SERVER");
21  
22 1 ▶ my $server = try {
Subroutine __ANON__: called CC=1 SCAR=0.0
23 1 $class->load($backend, @args);
24 1 ▶ } catch {
Subroutine __ANON__: called CC=6 SCAR=28.1
25 1 ▶ if (($ENV{PLACK_ENV}||'') eq 'development' or !/^Can't locate /) {
Branch: 1 branch
BranchTrueFalseTotal
if (($ENV{"PLACK_ENV"} || "") eq "development" or not /^Can't locate /) 0 1 1
Condition40%2/5
($ENV{"PLACK_ENV"} || "") eq "development" or not /^Can't locate /
l!l&&r!l&&!r
001
$ENV{'PLACK_ENV'} || ''
l!l
01
MC/DC0%0/2
($ENV{"PLACK_ENV"} || "") eq "development" or not /^Can't locate /
$ENV{'PLACK_ENV'} not /^Can't locate /
Truth table33%1/3
A or not(B)
A= $ENV{'PLACK_ENV'}B= not /^Can't locate /
ABresult
1X1
011
000
26 warn "Autoloading '$backend' backend failed. Falling back to the Standalone. ",
27 "(You might need to install Plack::Handler::$backend from CPAN. Caught error was: $_)\n"
28 0 ▶ if $ENV{PLACK_ENV} && $ENV{PLACK_ENV} eq 'development';
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"PLACK_ENV"} and $ENV{"PLACK_ENV"} eq "development" 0 0 0
Condition0%0/3
$ENV{"PLACK_ENV"} and $ENV{"PLACK_ENV"} eq "development"
!ll&&!rl&&r
000
MC/DC0%0/2
$ENV{"PLACK_ENV"} and $ENV{"PLACK_ENV"} eq "development"
$ENV{"PLACK_ENV"} $ENV{"PLACK_ENV"} eq "development"
Truth table0%0/3
A and B
A= $ENV{"PLACK_ENV"}B= $ENV{"PLACK_ENV"} eq "development"
ABresult
0X0
100
111
29 }
30 1 $class->load('Standalone' => @args);
31 1 };
32  
33 1 return $server;
34 }
35  
36 39 ▶sub load {
Subroutine load: called CC=2 SCAR=7.0
Pod undocumented
37 39 my($class, $server, @args) = @_;
38  
39 39 my($server_class, $error);
40 39 ▶ try {
Subroutine __ANON__: called CC=1 SCAR=0.0
41 39 $server_class = Plack::Util::load_class($server, 'Plack::Handler');
42 1 ▶ } catch {
Subroutine __ANON__: called CC=2 SCAR=9.2
43 1 ▶ $error ||= $_;
Condition33%1/3
$error ||= $_
l!l&&r!l&&!r
010
MC/DC0%0/2
$error ||= $_
$error $_
Truth table33%1/3
A ||= B
A= $errorB= $_
ABresult
1X1
011
000
44 39 };
45  
46 39 ▶ if ($server_class) {
Branch: 1 branch
BranchTrueFalseTotal
if ($server_class) { } 38 1 39
47 38 $server_class->new(@args);
48 } else {
49 1 die $error;
50 }
51 }
52  
53 2 ▶sub preload_app {
Subroutine preload_app: called CC=1 SCAR=0.0
Pod undocumented
54 2 my($self, $builder) = @_;
55 2 $self->{app} = $builder->();
56 }
57  
58 0 ▶sub guess {
Subroutine guess: not called CC=9 SCAR=45.0
Pod undocumented
59 0 my $class = shift;
60  
61 0 my $env = $class->env;
62  
63 0 ▶ return $env->{PLACK_SERVER} if $env->{PLACK_SERVER};
Branch: 1 branch
BranchTrueFalseTotal
if $env->{"PLACK_SERVER"} 0 0 0
64  
65 0 ▶ if ($env->{PHP_FCGI_CHILDREN} || $env->{FCGI_ROLE} || $env->{FCGI_SOCKET_PATH}) {
Branch: 5 branches
BranchTrueFalseTotal
if ($env->{'PHP_FCGI_CHILDREN'} or $env->{'FCGI_ROLE'} or $env->{'FCGI_SOCKET_PATH'}) { } 0 0 0
elsif ($env->{'GATEWAY_INTERFACE'}) { } 0 0 0
elsif (exists $INC{'Coro.pm'}) { } 0 0 0
elsif (exists $INC{'AnyEvent.pm'}) { } 0 0 0
elsif (exists $INC{'POE.pm'}) { } 0 0 0
Condition0%0/6
$env->{"PHP_FCGI_CHILDREN"} or $env->{"FCGI_ROLE"} or $env->{"FCGI_SOCKET_PATH"}
l!l&&r!l&&!r
000
$env->{"PHP_FCGI_CHILDREN"} or $env->{"FCGI_ROLE"}
l!l&&r!l&&!r
000
MC/DC0%0/3
$env->{"PHP_FCGI_CHILDREN"} or $env->{"FCGI_ROLE"} or $env->{"FCGI_SOCKET_PATH"}
$env->{"PHP_FCGI_CHILDREN"} $env->{"FCGI_ROLE"} $env->{"FCGI_SOCKET_PATH"}
Truth table0%0/4
A or B or C
A= $env->{"PHP_FCGI_CHILDREN"}B= $env->{"FCGI_ROLE"}C= $env->{"FCGI_SOCKET_PATH"}
ABCresult
1XX1
01X1
0011
0000
66 0 return "FCGI";
67 } elsif ($env->{GATEWAY_INTERFACE}) {
68 0 return "CGI";
69 } elsif (exists $INC{"Coro.pm"}) {
70 0 return "Corona";
71 } elsif (exists $INC{"AnyEvent.pm"}) {
72 0 return "Twiggy";
73 } elsif (exists $INC{"POE.pm"}) {
74 0 return "POE";
75 } else {
76 0 return "Standalone";
77 }
78 }
79  
80 0 ▶sub env { \%ENV }
Subroutine env: not called CC=1 SCAR=6.9
Pod undocumented
81  
82 0 ▶sub run {
Subroutine run: not called CC=1 SCAR=6.9
Pod undocumented
83 0 my($self, $server) = @_;
84 0 $server->run($self->{app});
85 }
86  
87 59 1;
88  
89 __END__
« blib/lib/Plack/Handler/Apache2.pm ↑ Summary blib/lib/Plack/Runner.pm »