File Coverage

blib/lib/Plack/App/WWW.pm
Criterion Covered Total %
statement 27 27 100.0
branch 5 6 83.3
condition 1 3 33.3
subroutine 7 7 100.0
pod 0 1 0.0
total 40 44 90.9


line stmt bran cond sub pod time code
1             package Plack::App::WWW;
2 2     2   78896 use strict;
  2         15  
  2         119  
3 2     2   13 use warnings;
  2         5  
  2         81  
4 2     2   539 use parent qw/Plack::App::CGIBin/;
  2         330  
  2         11  
5 2     2   174808 use Plack::App::File;
  2         5  
  2         52  
6 2     2   11 use Plack::App::WrapCGI;
  2         6  
  2         477  
7              
8             our $VERSION = '0.01';
9              
10             sub serve_path {
11 3     3 0 26424 my($self, $env, $file) = @_;
12              
13 3         10 local @{$env}{qw(SCRIPT_NAME PATH_INFO)} = @{$env}{qw( plack.file.SCRIPT_NAME plack.file.PATH_INFO )};
  3         13  
  3         13  
14              
15 3 100       14 if ($self->_valid_file_perl($file)) {
16 2   33     29 my $app = $self->{_compiled}->{$file} ||= Plack::App::WrapCGI->new(
17             script => $file, execute => $self->would_exec($file)
18             )->to_app;
19 2         2038 $app->($env);
20             } else {
21 1         19 Plack::App::File->new(file => $file)->to_app->($env);
22             }
23             }
24              
25             sub _valid_file_perl {
26 3     3   10 my ($self, $file) = @_;
27              
28 3 100       62 return 1 if $file =~ /.(pl|cgi)$/i;
29 1 50       8 return 1 if $self->shebang_for($file) =~ /^\#\!.*perl/;
30              
31 1         106 return;
32             }
33              
34             1;
35              
36             __END__