HiD/Server.pm

filter: Statementstmt 57.8% 11 / 19 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 8 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 75.0% 3 / 4 Podpod 100% 1 / 1 totaltotal 34.8% 15 / 43 CC 7 SCAR 36.8
CC
7
Cov
33%
locate_file
56.0
BEGIN
1.0
BEGIN
1.0
CRAP 39.5
« HiD/App/Command/publish.pm ↑ Summary HiD/Generator/AtomFeed.pm »
1 # ABSTRACT: Helper for 'hid server'
2  
3  
4 package HiD::Server;
5 6 our $AUTHORITY = 'cpan:GENEHACK';
6 6 $HiD::Server::VERSION = '1.96';
7 6 ▶use 5.014; # strict, unicode_strings
Subroutine BEGIN: called CC=1 SCAR=0.0
8 6 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 6 ▶use parent 'Plack::App::File';
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12  
13 sub locate_file {
14 0 ▶ my ($self, $env) = @_;
Subroutine locate_file: not called CC=7 SCAR=40.3
Pod documented
15  
16 0 ▶ my $path = $env->{PATH_INFO} || '';
Condition0%0/2
$env->{'PATH_INFO'} || ''
l!l
00
MC/DC0%0/1
$env->{'PATH_INFO'} || ''
$env->{'PATH_INFO'}
Truth table0%0/2
A
A= $env->{'PATH_INFO'}
Aresult
11
00
17  
18 0 ▶ $path =~ s|^/|| unless $path eq '/';
Branch: 1 branch
BranchTrueFalseTotal
unless $path eq "/" 0 0 0
19  
20 0 ▶ if ( -e -d $path and $path !~ m|/$| ) {
Branch: 1 branch
BranchTrueFalseTotal
if (-e -d $path and not $path =~ m[/$]u) 0 0 0
Condition0%0/3
-e -d $path and not $path =~ m[/$]u
!ll&&!rl&&r
000
MC/DC0%0/2
-e -d $path and not $path =~ m[/$]u
-e -d $path not $path =~ m[/$]u
Truth table0%0/3
A and not(B)
A= -e -d $pathB= not $path =~ m[/$]u
ABresult
0X0
100
111
21 0 $path .= '/';
22 0 $env->{PATH_INFO} .= '/';
23 }
24  
25 0 ▶ $env->{PATH_INFO} .= 'index.html'
Branch: 1 branch
BranchTrueFalseTotal
if $path and $path =~ m[/$]u 0 0 0
Condition0%0/3
$path and $path =~ m[/$]u
!ll&&!rl&&r
000
MC/DC0%0/2
$path and $path =~ m[/$]u
$path $path =~ m[/$]u
Truth table0%0/3
A and B
A= $pathB= $path =~ m[/$]u
ABresult
0X0
100
111
26 if ( $path && $path =~ m|/$| );
27  
28 0 return $self->SUPER::locate_file( $env );
29 }
30  
31 6 1;
32  
33 __END__
34  
35 =pod
36  
37 =encoding UTF-8
38  
39 =head1 NAME
40  
41 HiD::Server - Helper for 'hid server'
42  
43 =head1 DESCRIPTION
44  
45 Helper for C<hid server>
46  
47 =head1 METHODS
48  
49 =head2 locate_file
50  
51 Overrides L<Plack::App::File>'s method of the same name to handle '/' and
52 '/index.html' cases
53  
54 =head1 VERSION
55  
56 version 1.96
57  
58 =head1 AUTHOR
59  
60 John SJ Anderson <genehack@genehack.org>
61  
62 =head1 COPYRIGHT AND LICENSE
63  
64 This software is copyright (c) 2015 by John SJ Anderson.
65  
66 This is free software; you can redistribute it and/or modify it under
67 the same terms as the Perl 5 programming language system itself.
68  
69 =cut
« HiD/App/Command/publish.pm ↑ Summary HiD/Generator/AtomFeed.pm »