| 1 | package PLS::Server::Cache; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 13 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 13 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 13 | ▶ | use feature 'state'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 13 | ▶ | use ExtUtils::Installed; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 13 | ▶ | use Module::CoreList; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 13 | ▶ | use PLS::Parser::Pod; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | sub warm_up | ||||||||||||||||||||||||||||
| 14 | 4 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
warm_up: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 15 | 4 | get_builtin_variables(); | |||||||||||||||||||||||||||
| 16 | 4 | get_core_modules(); | |||||||||||||||||||||||||||
| 17 | 4 | get_ext_modules(); | |||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 4 | return; | |||||||||||||||||||||||||||
| 20 | } ## end sub warm_up | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | sub get_ext_modules | ||||||||||||||||||||||||||||
| 23 | 4 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
get_ext_modules: called CC=12 SCAR=25.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 24 | 4 | state $include = []; | |||||||||||||||||||||||||||
| 25 | 4 | state $modules = []; | |||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 4 | my $curr_include = join ':', @{$include}; | |||||||||||||||||||||||||||
| 28 | 4 | my $clean_inc = PLS::Parser::Pod->get_clean_inc(); | |||||||||||||||||||||||||||
| 29 | 4 | my $updated_include = join ':', @{$clean_inc}; | |||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 0 | ▶ | if ($curr_include ne $updated_include or not scalar @{$modules}) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$curr_include ne $updated_include or not scalar @{$modules;}
MC/DC0%0/2
$curr_include ne $updated_include or not scalar @{$modules;}
$curr_include ne $updated_include
not scalar @{$modules;}
Truth table33%1/3
A or not(B)
A= $curr_include ne $updated_includeB= not scalar @{$modules;}
| |||||||||||||||||||||||||||||
| 32 | { | ||||||||||||||||||||||||||||
| 33 | 4 | $include = $clean_inc; | |||||||||||||||||||||||||||
| 34 | 4 | my $installed = ExtUtils::Installed->new(inc_override => $clean_inc); | |||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 4 | foreach my $module ($installed->modules) | |||||||||||||||||||||||||||
| 37 | { | ||||||||||||||||||||||||||||
| 38 | 792 | my @files = $installed->files($module); | |||||||||||||||||||||||||||
| 39 | 792 | $module =~ s/::/\//g; | |||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | # Find all the packages that are part of this module | ||||||||||||||||||||||||||||
| 42 | 792 | foreach my $file (@files) | |||||||||||||||||||||||||||
| 43 | { | ||||||||||||||||||||||||||||
| 44 | 46492 | ▶ | next if ($file !~ /\.pm$/); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 45 | 8700 | my $valid = 0; | |||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | 8700 | foreach my $path (@{$clean_inc}) | |||||||||||||||||||||||||||
| 48 | { | ||||||||||||||||||||||||||||
| 49 | 69600 | ▶ | $valid = 1 if ($file =~ s/^\Q$path\E\/?(?:auto\/)?//); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | 8700 | ▶ | next unless ($valid); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 53 | 8700 | ▶ | next unless (length $file); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 54 | 8700 | $file =~ s/\.pm$//; | |||||||||||||||||||||||||||
| 55 | 8700 | my $mod_package = $file =~ s/\//::/gr; | |||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | # Skip private packages | ||||||||||||||||||||||||||||
| 58 | 8700 | ▶ | next if ($mod_package =~ /^_/ or $mod_package =~ /::_/); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$mod_package =~ /^_/ or $mod_package =~ /::_/
MC/DC100%2/2
$mod_package =~ /^_/ or $mod_package =~ /::_/
$mod_package =~ /^_/
$mod_package =~ /::_/
Truth table100%3/3
A or B
A= $mod_package =~ /^_/B= $mod_package =~ /::_/
| |||||||||||||||||||||||||||||
| 59 | 8604 | push @{$modules}, $mod_package; | |||||||||||||||||||||||||||
| 60 | } ## end foreach my $file (@files) | ||||||||||||||||||||||||||||
| 61 | } ## end foreach my $module ($installed...) | ||||||||||||||||||||||||||||
| 62 | } ## end if ($curr_include ne $updated_include...) | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | 4 | return $modules; | |||||||||||||||||||||||||||
| 65 | } ## end sub get_ext_modules | ||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | sub get_core_modules | ||||||||||||||||||||||||||||
| 68 | 4 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
get_core_modules: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 69 | 4 | state $core_modules = [Module::CoreList->find_modules(qr//, $])]; | |||||||||||||||||||||||||||
| 70 | 4 | return $core_modules; | |||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | sub get_builtin_variables | ||||||||||||||||||||||||||||
| 74 | 4 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
get_builtin_variables: called CC=8 SCAR=20.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 75 | 4 | my $perldoc = PLS::Parser::Pod->get_perldoc_location(); | |||||||||||||||||||||||||||
| 76 | 4 | state $builtin_variables = []; | |||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | 4 | ▶ | return $builtin_variables if (scalar @{$builtin_variables}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | 4 | ▶ | if (open my $fh, '-|', $perldoc, '-Tu', 'perlvar') | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 81 | { | ||||||||||||||||||||||||||||
| 82 | 4 | ▶ | while (my $line = <$fh>) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 83 | { | ||||||||||||||||||||||||||||
| 84 | 10892 | ▶ | if ($line =~ /=item\s*(C<)?([\$\@\%]\S+)\s*/) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 85 | { | ||||||||||||||||||||||||||||
| 86 | # If variable started with pod sequence "C<" remove ">" from the end | ||||||||||||||||||||||||||||
| 87 | 636 | my $variable = $2; | |||||||||||||||||||||||||||
| 88 | 636 | ▶ | $variable = substr $variable, 0, -1 if (length $1); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | # Remove variables indicated by pod sequences | ||||||||||||||||||||||||||||
| 91 | 636 | ▶ | next if ($variable =~ /^\$</ and $variable ne '$<'); ## no critic (RequireInterpolationOfMetachars) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$variable =~ /^\$</ and $variable ne "\$<"
MC/DC100%2/2
$variable =~ /^\$</ and $variable ne "\$<"
$variable =~ /^\$</
$variable ne "\$<"
Truth table100%3/3
A and B
A= $variable =~ /^\$</B= $variable ne "\$<"
| |||||||||||||||||||||||||||||
| 92 | 632 | push @{$builtin_variables}, $variable; | |||||||||||||||||||||||||||
| 93 | } ## end if ($line =~ /=item\s*(C<)?([\$\@\%]\S+)\s*/...) | ||||||||||||||||||||||||||||
| 94 | } ## end while (my $line = <$fh>) | ||||||||||||||||||||||||||||
| 95 | } ## end if (open my $fh, '-|',...) | ||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | 4 | return $builtin_variables; | |||||||||||||||||||||||||||
| 98 | } ## end sub get_builtin_variables | ||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | 13 | 1; | |||||||||||||||||||||||||||