| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
Condition40%2/5
($ENV{"PLACK_ENV"} || "") eq "development" or not /^Can't locate /
$ENV{'PLACK_ENV'} || ''
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 /
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
Condition0%0/3
$ENV{"PLACK_ENV"} and $ENV{"PLACK_ENV"} eq "development"
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"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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 ||= $_
MC/DC0%0/2
$error ||= $_
$error
$_
Truth table33%1/3
A ||= B
A= $errorB= $_
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 39 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 39 | ▶ | if ($server_class) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | ▶ | if ($env->{PHP_FCGI_CHILDREN} || $env->{FCGI_ROLE} || $env->{FCGI_SOCKET_PATH}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 5 branches
Condition0%0/6
$env->{"PHP_FCGI_CHILDREN"} or $env->{"FCGI_ROLE"} or $env->{"FCGI_SOCKET_PATH"}
$env->{"PHP_FCGI_CHILDREN"} or $env->{"FCGI_ROLE"}
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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||