File Coverage

blib/lib/Plack/App/DirectoryIndex.pm
Criterion Covered Total %
statement 18 18 100.0
branch 2 2 100.0
condition 6 8 75.0
subroutine 5 5 100.0
pod 0 1 0.0
total 31 34 91.1


line stmt bran cond sub pod time code
1             package Plack::App::DirectoryIndex;
2              
3 1     1   106212 use parent qw[Plack::App::Directory];
  1         2  
  1         6  
4              
5 1     1   96467 use strict;
  1         3  
  1         21  
6 1     1   5 use warnings;
  1         4  
  1         28  
7              
8 1     1   5 use Plack::Util::Accessor 'dir_index';
  1         2  
  1         10  
9              
10             our $VERSION = '0.0.3';
11              
12             sub serve_path {
13 4     4 0 26892 my $self = shift;
14 4         12 my ($env, $dir) = @_;
15              
16 4   100     12 my $dir_index = $self->dir_index // 'index.html';
17              
18 4 100 66     134 if (-d $dir and $dir_index and -f "$dir$dir_index") {
      66        
19 3         12 $dir .= $dir_index;
20             }
21              
22 4         35 return $self->SUPER::serve_path($env, $dir);
23             }
24              
25             1;
26              
27             __END__