Resolver/ExtendedCompRoot.pm

filter: Statementstmt 32.3% 11 / 34 Branchbran 0.0% 0 / 14 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 50.0% 3 / 6 Podpod 100% 2 / 2 totaltotal 24.2% 16 / 66 CC 11 SCAR 45.1
CC
11
Cov
20%
get_info
132.0
apache_request_to_comp_path
2.0
__ANON__
2.0
CRAP 91.2
« Request/ExtendedCompRoot.pm ↑ Summary
1 # This software is copyright (c) 2004 Alex Robinson.
2 # It is free software and can be used under the same terms as perl,
3 # i.e. either the GNU Public Licence or the Artistic License.
4  
5 package MasonX::Resolver::ExtendedCompRoot;
6  
7 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 1 our $VERSION = '0.03';
10  
11 1 ▶use base qw(HTML::Mason::Resolver::File);
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 1 ▶use HTML::Mason::Tools qw(read_file_ref);
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 #
16 # call ApacheHandler's apache_request_to_comp_path in a way
17 # that doesn't cause standalone invocations to choke
18 #
19 sub apache_request_to_comp_path
20 {
21 0 ▶ return HTML::Mason::Resolver::File::ApacheHandler::apache_request_to_comp_path(@_);
Subroutine apache_request_to_comp_path: not called CC=1 SCAR=6.9
Pod documented
22 }
23  
24 #
25 # override HTML::Mason::Resolver::File's get_info
26 # which this method simply replicates and adds several lines to
27 # additional lines marked #ecr
28 #
29 sub get_info {
30 0 ▶ my ($self, $path) = @_;
Subroutine get_info: not called CC=11 SCAR=48.8
Pod documented
31  
32 0 my $specified_comp_root; #ecr
33 0 ▶ if (index($path,'=>') != -1) { #ecr
Branch: 1 branch
BranchTrueFalseTotal
if (index($path, "=>") != -1) 0 0 0
34 0 my ($comp_root,$comp_path) = split('=>',$path,2); #ecr
35 0 $specified_comp_root = $comp_root; #ecr
36 0 $specified_comp_root =~ s|^/||; #ecr
37 0 $path = $comp_path; #ecr
38 } #ecr
39  
40 0 foreach my $pair ($self->comp_root_array) {
41  
42 0 ▶ next if ($specified_comp_root and ($pair->[0] ne $specified_comp_root)); #ecr
Branch: 1 branch
BranchTrueFalseTotal
if $specified_comp_root and $pair->[0] ne $specified_comp_root 0 0 0
Condition0%0/3
$specified_comp_root and $pair->[0] ne $specified_comp_root
!ll&&!rl&&r
000
MC/DC0%0/2
$specified_comp_root and $pair->[0] ne $specified_comp_root
$specified_comp_root $pair->[0] ne $specified_comp_root
Truth table0%0/3
A and B
A= $specified_comp_rootB= $pair->[0] ne $specified_comp_root
ABresult
0X0
100
111
43  
44 0 my $srcfile = File::Spec->canonpath( File::Spec->catfile( $pair->[1], $path ) );
45 0 ▶ next unless -f $srcfile;
Branch: 1 branch
BranchTrueFalseTotal
unless -f $srcfile 0 0 0
46  
47 0 my $key = $pair->[0];
48  
49 0 my $modified = (stat _)[9];
50 0 ▶ my $base = $key eq 'MAIN' ? '' : "/$key";
Branch: 1 branch
BranchTrueFalseTotal
$key eq 'MAIN' ? : 0 0 0
51 0 ▶ $key = undef if $key eq 'MAIN';
Branch: 1 branch
BranchTrueFalseTotal
if $key eq "MAIN" 0 0 0
52  
53 return
54 HTML::Mason::ComponentSource->new
55 ( friendly_name => $srcfile,
56 comp_id => "$base$path",
57 last_modified => $modified,
58 comp_path => $path,
59 comp_class => 'HTML::Mason::Component::FileBased',
60 extra => { comp_root => $key },
61 0 ▶ source_callback => sub { read_file_ref($srcfile) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
62 0 );
63 }
64  
65 0 ▶ if ( $path ne '/' )
Branch: 1 branch
BranchTrueFalseTotal
if ($path ne "/") 0 0 0
66 {
67 # see if path corresponds to real filesystem path, a common new user mistake
68 0 my $fs_path = File::Spec->catfile( split /\//, $path );
69 0 ▶ if ( defined $fs_path && -e $fs_path )
Branch: 1 branch
BranchTrueFalseTotal
if (defined $fs_path and -e $fs_path) 0 0 0
Condition0%0/3
defined $fs_path and -e $fs_path
!ll&&!rl&&r
000
MC/DC0%0/2
defined $fs_path and -e $fs_path
defined $fs_path -e $fs_path
Truth table0%0/3
A and B
A= defined $fs_pathB= -e $fs_path
ABresult
0X0
100
111
70 {
71 0 warn "Your component path ($path) matches a real file on disk ($fs_path). Have you read about the component root in the Administrator's Manual (HTML::Mason::Admin)?";
72 }
73 }
74  
75 0 return;
76 }
77  
78 1 1;
79  
80  
81 __END__
« Request/ExtendedCompRoot.pm ↑ Summary