| 1 | |||||||||||||||||||||||||||||
| 2 | package | ||||||||||||||||||||||||||||
| 3 | ASP4::PageLoader; | ||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 14 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 14 | ▶ | use warnings 'all'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 14 | ▶ | use ASP4::PageParser; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 14 | ▶ | use ASP4::ConfigLoader; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 14 | ▶ | use ASP4::HandlerResolver; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 14 | ▶ | use File::stat; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 14 | my %FileTimes = ( ); | |||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | sub discover | ||||||||||||||||||||||||||||
| 15 | 6225 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
discover: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 16 | 6225 | my ($class, %args) = @_; | |||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 6225 | my $web = ASP4::ConfigLoader->load()->web; | |||||||||||||||||||||||||||
| 19 | 6225 | my $filename = $web->www_root . $args{script_name}; | |||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | # Expand /folder/ to /folder/index.asp | ||||||||||||||||||||||||||||
| 22 | 6225 | ▶ | if( -d $filename ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 23 | { | ||||||||||||||||||||||||||||
| 24 | 3 | $filename =~ s{/$}{}; | |||||||||||||||||||||||||||
| 25 | 3 | $args{script_name} .= "/index.asp"; | |||||||||||||||||||||||||||
| 26 | 3 | $filename .= "/index.asp"; | |||||||||||||||||||||||||||
| 27 | }# end if() | ||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | 6225 | ▶ | if( $filename =~ m/\.asp$/ ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 30 | { | ||||||||||||||||||||||||||||
| 31 | 6217 | (my $package = $args{script_name}) =~ s/[^a-z0-9]/_/ig; | |||||||||||||||||||||||||||
| 32 | 6217 | $package = $web->application_name . '::' . $package; | |||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 6217 | (my $compiled_as = "$package.pm") =~ s/::/\//g; | |||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | return { | ||||||||||||||||||||||||||||
| 37 | script_name => $args{script_name}, | ||||||||||||||||||||||||||||
| 38 | 6217 | 'package' => $package, | |||||||||||||||||||||||||||
| 39 | filename => $filename, | ||||||||||||||||||||||||||||
| 40 | compiled_as => $compiled_as, | ||||||||||||||||||||||||||||
| 41 | saved_to => $web->page_cache_root . "/$compiled_as", | ||||||||||||||||||||||||||||
| 42 | }; | ||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||
| 44 | else | ||||||||||||||||||||||||||||
| 45 | { | ||||||||||||||||||||||||||||
| 46 | return { | ||||||||||||||||||||||||||||
| 47 | 8 | filename => $filename, | |||||||||||||||||||||||||||
| 48 | is_static => 1, | ||||||||||||||||||||||||||||
| 49 | }; | ||||||||||||||||||||||||||||
| 50 | }# end if() | ||||||||||||||||||||||||||||
| 51 | }# end discover() | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | sub load | ||||||||||||||||||||||||||||
| 55 | 3057 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
load: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 56 | 3057 | my ($class, %args) = @_; | |||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | 3057 | my $info = $class->discover( script_name => $args{script_name} ); | |||||||||||||||||||||||||||
| 59 | 3057 | ▶ | my $key = ($ENV{DOCUMENT_ROOT}||"") . ":$info->{filename}"; | ||||||||||||||||||||||||||
|
Condition100%2/2
$ENV{'DOCUMENT_ROOT'} || ''
MC/DC100%1/1
$ENV{'DOCUMENT_ROOT'} || ''
$ENV{'DOCUMENT_ROOT'}
Truth table100%2/2
A
A= $ENV{'DOCUMENT_ROOT'}
| |||||||||||||||||||||||||||||
| 60 | 3057 | ▶ | if( $class->needs_recompile( $info->{saved_to}, $info->{filename} ) ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 61 | { | ||||||||||||||||||||||||||||
| 62 | 19 | my $page = ASP4::PageParser->new( script_name => $info->{script_name} )->parse(); | |||||||||||||||||||||||||||
| 63 | 19 | $FileTimes{ $key } = stat($info->{filename})->mtime; | |||||||||||||||||||||||||||
| 64 | 19 | return $page; | |||||||||||||||||||||||||||
| 65 | }# end if() | ||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | 3038 | my $config = ASP4::ConfigLoader->load(); | |||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | # Deal with changes all the way up the master/child chain: | ||||||||||||||||||||||||||||
| 70 | 3038 | ASP4::HandlerResolver->_forget_package( $info->{compiled_as}, $info->{package} ); | |||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | 3038 | $config->load_class( $info->{package} ); | |||||||||||||||||||||||||||
| 73 | 3038 | ▶ | $FileTimes{ $key } ||= stat($info->{filename})->mtime; | ||||||||||||||||||||||||||
|
Condition66%2/3
$FileTimes{$key} ||= &ASP4::PageLoader::stat($info->{"filename"})->mtime
MC/DC0%0/2
$FileTimes{$key} ||= &ASP4::PageLoader::stat($info->{"filename"})->mtime
$FileTimes{$key}
&ASP4::PageLoader::stat($info->{"filename"})->mtime
Truth table66%2/3
A ||= B
A= $FileTimes{$key}B= &ASP4::PageLoader::stat($info->{"filename"})->mtime
| |||||||||||||||||||||||||||||
| 74 | 3038 | return $info->{package}->new(); | |||||||||||||||||||||||||||
| 75 | }# end load() | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | sub needs_recompile | ||||||||||||||||||||||||||||
| 79 | 3057 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
needs_recompile: called CC=5 SCAR=16.2
Pod
undocumented
| |||||||||||||||||||||||||||||
| 80 | 3057 | my ($class, $compiled_as, $filename) = @_; | |||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | 3057 | ▶ | return 1 unless $compiled_as && -f $compiled_as; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$compiled_as and -f $compiled_as
MC/DC50%1/2
$compiled_as and -f $compiled_as
$compiled_as
-f $compiled_as
Truth table66%2/3
A and B
A= $compiled_asB= -f $compiled_as
| |||||||||||||||||||||||||||||
| 83 | 3038 | ▶ | my $key = ($ENV{DOCUMENT_ROOT}||"") . ":$filename"; | ||||||||||||||||||||||||||
|
Condition100%2/2
$ENV{'DOCUMENT_ROOT'} || ''
MC/DC100%1/1
$ENV{'DOCUMENT_ROOT'} || ''
$ENV{'DOCUMENT_ROOT'}
Truth table100%2/2
A
A= $ENV{'DOCUMENT_ROOT'}
| |||||||||||||||||||||||||||||
| 84 | 3038 | ▶ | return stat($filename)->mtime > ( $FileTimes{ $key } || stat($compiled_as)->mtime ); | ||||||||||||||||||||||||||
|
Condition66%2/3
$FileTimes{$key} || &ASP4::PageLoader::stat($compiled_as)->mtime
MC/DC0%0/2
$FileTimes{$key} || &ASP4::PageLoader::stat($compiled_as)->mtime
$FileTimes{$key}
&ASP4::PageLoader::stat($compiled_as)->mtime
Truth table66%2/3
A || B
A= $FileTimes{$key}B= &ASP4::PageLoader::stat($compiled_as)->mtime
| |||||||||||||||||||||||||||||
| 85 | }# end needs_recompile() | ||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | 14 | 1;# return true: | |||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||