| 1 | package Devel::Examine::Subs; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 60 | ▶ | use 5.008; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 3 | 60 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 60 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | 60 | our $VERSION = '1.74'; | |||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | 60 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 60 | ▶ | use Data::Compare; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 60 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 60 | ▶ | use Devel::Examine::Subs::Engine; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 60 | ▶ | use Devel::Examine::Subs::Preprocessor; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 60 | ▶ | use Devel::Examine::Subs::Postprocessor; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | 60 | ▶ | use File::Basename; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | 60 | ▶ | use File::Copy; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | 60 | ▶ | use File::Edit::Portable; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | 60 | ▶ | use PPI; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | 60 | ▶ | use Symbol qw(delete_package); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||
| 20 | 60 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=2 SCAR=7.4
| |||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||
| 22 | # we need to do some trickery for Devel::Trace::Subs due to circular | ||||||||||||||||||||||||||||||||||||||||||
| 23 | # referencing, which broke CPAN installs. DTS does nothing if not presented, | ||||||||||||||||||||||||||||||||||||||||||
| 24 | # per this code | ||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||
| 26 | 60 | eval { | |||||||||||||||||||||||||||||||||||||||||
| 27 | 60 | require Devel::Trace::Subs; | |||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | import Devel::Trace::Subs qw(trace); | |||||||||||||||||||||||||||||||||||||||||
| 29 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||
| 31 | 60 | ▶ | if (! defined &trace){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 32 | 60 | ▶ | *trace = sub {}; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||
| 36 | # | ||||||||||||||||||||||||||||||||||||||||||
| 37 | # public methods | ||||||||||||||||||||||||||||||||||||||||||
| 38 | # | ||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||
| 40 | 142 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||
| 42 | # set up for tracing | ||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||
| 44 | 142 | ▶ | if ($ENV{DES_TRACE}){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 45 | 3 | $ENV{DTS_ENABLE} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 46 | 3 | $ENV{TRACE} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||
| 49 | 142 | ▶ | trace() if $ENV{TRACE}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||
| 51 | 141 | my $self = {}; | |||||||||||||||||||||||||||||||||||||||||
| 52 | 141 | bless $self, shift; | |||||||||||||||||||||||||||||||||||||||||
| 53 | 141 | my $p = $self->_params(@_); | |||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||
| 55 | # default configs | ||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||
| 57 | 141 | $self->{namespace} = __PACKAGE__; | |||||||||||||||||||||||||||||||||||||||||
| 58 | 141 | $self->{params}{regex} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 59 | 141 | $self->{params}{backup} = 0; | |||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||
| 61 | 141 | $self->_config($p); | |||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||
| 63 | 141 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||
| 65 | 27 | ▶ | sub all { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
all: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||
| 67 | 27 | ▶ | trace() if $ENV{TRACE}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||
| 69 | 26 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 70 | 26 | my $p = $self->_params(@_); | |||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||
| 72 | 26 | $self->{params}{engine} = 'all'; | |||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||
| 74 | 26 | $self->run($p); | |||||||||||||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||||||||||||
| 76 | 38 | ▶ | sub has { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
has: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||
| 78 | 38 | ▶ | trace() if $ENV{TRACE}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||
| 80 | 37 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 81 | 37 | my $p = $self->_params(@_); | |||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||
| 83 | 37 | $self->{params}{post_proc} = 'file_lines_contain'; | |||||||||||||||||||||||||||||||||||||||||
| 84 | 37 | $self->{params}{engine} = 'has'; | |||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||
| 86 | 37 | $self->run($p); | |||||||||||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||||||||||||
| 88 | 8 | ▶ | sub missing { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
missing: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||
| 90 | 8 | ▶ | trace() if $ENV{TRACE}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||
| 92 | 7 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 93 | 7 | my $p = $self->_params(@_); | |||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||
| 95 | 7 | $self->{params}{engine} = 'missing'; | |||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||
| 97 | 7 | $self->run($p); | |||||||||||||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||||||||||||
| 99 | 6 | ▶ | sub lines { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
lines: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||
| 101 | 6 | ▶ | trace() if $ENV{TRACE}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||
| 103 | 5 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 104 | 5 | my $p = $self->_params(@_); | |||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||
| 106 | 5 | $self->{params}{engine} = 'lines'; | |||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||
| 108 | 5 | ▶ | if ($self->{params}{search} || $p->{search}){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->{"params"}{"search"} or $p->{"search"}
MC/DC50%1/2
$self->{"params"}{"search"} or $p->{"search"}
$self->{"params"}{"search"}
$p->{"search"}
Truth table66%2/3
A or B
A= $self->{"params"}{"search"}B= $p->{"search"}
| |||||||||||||||||||||||||||||||||||||||||||
| 109 | 3 | $self->{params}{post_proc} = 'file_lines_contain'; | |||||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||
| 112 | 5 | $self->run($p); | |||||||||||||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||||||||||||
| 114 | 12 | ▶ | sub module { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
module: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||
| 116 | 12 | ▶ | trace() if $ENV{TRACE}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||
| 118 | 11 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||
| 120 | 11 | my $p; | |||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||
| 122 | # allow for single string value | ||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||
| 124 | 11 | ▶ | if (@_ == 1){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 125 | 4 | my %p; | |||||||||||||||||||||||||||||||||||||||||
| 126 | 4 | $p{module} = shift; | |||||||||||||||||||||||||||||||||||||||||
| 127 | 4 | $p = $self->_params(%p); | |||||||||||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||||||||||||
| 129 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 130 | 7 | $p = $self->_params(@_); | |||||||||||||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||
| 133 | # set the preprocessor up, and have it return before | ||||||||||||||||||||||||||||||||||||||||||
| 134 | # the building/compiling of file data happens | ||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||
| 136 | 11 | $self->{params}{pre_proc} = 'module'; | |||||||||||||||||||||||||||||||||||||||||
| 137 | 11 | $self->{params}{pre_proc_return} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||
| 139 | 11 | $self->{params}{engine} = 'module'; | |||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||
| 141 | 11 | $self->run($p); | |||||||||||||||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||||||||||||||||
| 143 | 15 | ▶ | sub objects { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
objects: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||
| 145 | 15 | ▶ | trace() if $ENV{TRACE}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||
| 147 | 14 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 148 | 14 | my $p = $self->_params(@_); | |||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||
| 150 | 14 | $self->{params}{post_proc} = 'subs'; | |||||||||||||||||||||||||||||||||||||||||
| 151 | 14 | $self->{params}{engine} = 'objects'; | |||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||
| 153 | 14 | $self->run($p); | |||||||||||||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||||||||||||
| 155 | 8 | ▶ | sub search_replace { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
search_replace: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||
| 157 | 8 | ▶ | trace() if $ENV{TRACE}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||
| 159 | 7 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 160 | 7 | my $p = $self->_params(@_); | |||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||
| 162 | $self->{params}{post_proc} | ||||||||||||||||||||||||||||||||||||||||||
| 163 | 7 | = ['file_lines_contain', 'subs', 'objects']; | |||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||
| 165 | 7 | $self->{params}{engine} = 'search_replace'; | |||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||
| 167 | 7 | $self->run($p); | |||||||||||||||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||||||||||||||||
| 169 | 9 | ▶ | sub replace { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
replace: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||
| 171 | 9 | ▶ | trace() if $ENV{TRACE}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||
| 173 | 8 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 174 | 8 | my $p = $self->_params(@_); | |||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||
| 176 | 8 | $self->{params}{pre_proc} = 'replace'; | |||||||||||||||||||||||||||||||||||||||||
| 177 | 8 | $self->{params}{pre_proc_return} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||
| 179 | 8 | $self->run($p); | |||||||||||||||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||||||||||||||||
| 181 | 8 | ▶ | sub inject_after { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
inject_after: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||
| 183 | 8 | ▶ | trace() if $ENV{TRACE}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||
| 185 | 7 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 186 | 7 | my $p = $self->_params(@_); | |||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||
| 188 | 7 | ▶ | if (! $p->{injects} && ! $self->{params}{injects}){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$p->{"injects"} or $self->{"params"}{"injects"}
MC/DC100%2/2
$p->{"injects"} or $self->{"params"}{"injects"}
$p->{"injects"}
$self->{"params"}{"injects"}
Truth table100%3/3
A or B
A= $p->{"injects"}B= $self->{"params"}{"injects"}
| |||||||||||||||||||||||||||||||||||||||||||
| 189 | 3 | $p->{injects} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||
| 192 | $self->{params}{post_proc} | ||||||||||||||||||||||||||||||||||||||||||
| 193 | 7 | = ['file_lines_contain', 'subs', 'objects']; | |||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||
| 195 | 7 | $self->{params}{engine} = 'inject_after'; | |||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||
| 197 | 7 | $self->run($p); | |||||||||||||||||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||||||||||||||||
| 199 | 8 | ▶ | sub inject { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
inject: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 200 | 8 | ▶ | trace() if $ENV{TRACE}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 201 | 7 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 202 | 7 | my $p = $self->_params(@_); | |||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||
| 204 | # inject_use/inject_after_sub_def are preprocs | ||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||
| 206 | 7 | ▶ | if ( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$p->{"inject_use"} or $p->{"inject_after_sub_def"} or defined $p->{"line_num"}
$p->{"inject_use"} or $p->{"inject_after_sub_def"}
MC/DC100%3/3
$p->{"inject_use"} or $p->{"inject_after_sub_def"} or defined $p->{"line_num"}
$p->{"inject_use"}
$p->{"inject_after_sub_def"}
defined $p->{"line_num"}
Truth table100%4/4
A or B or C
A= $p->{"inject_use"}B= $p->{"inject_after_sub_def"}C= defined $p->{"line_num"}
| |||||||||||||||||||||||||||||||||||||||||||
| 207 | $p->{inject_use} || $p->{inject_after_sub_def} || defined $p->{line_num} | ||||||||||||||||||||||||||||||||||||||||||
| 208 | ){ | ||||||||||||||||||||||||||||||||||||||||||
| 209 | 6 | $self->{params}{pre_proc} = 'inject'; | |||||||||||||||||||||||||||||||||||||||||
| 210 | 6 | $self->{params}{pre_proc_return} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||
| 213 | 7 | $self->run($p); | |||||||||||||||||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||||||||||||||||
| 215 | 3 | ▶ | sub remove { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
remove: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 216 | 3 | ▶ | trace() if $ENV{TRACE}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||
| 218 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 219 | 2 | my $p = $self->_params(@_); | |||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||
| 221 | 2 | $self->{params}{pre_proc} = 'remove'; | |||||||||||||||||||||||||||||||||||||||||
| 222 | 2 | $self->{params}{pre_proc_return} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||
| 224 | 2 | $self->run($p); | |||||||||||||||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||||||||||||||||
| 226 | 4 | ▶ | sub order { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
order: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 227 | 4 | ▶ | trace() if $ENV{TRACE}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||
| 229 | 3 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||
| 231 | 3 | ▶ | if ($self->{params}{directory}){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 232 | 1 | confess "\norder() can only be called on an individual file, not " . | |||||||||||||||||||||||||||||||||||||||||
| 233 | "a directory at this time\n\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||
| 236 | 2 | return @{ $self->{order} }; | |||||||||||||||||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||||||||||||||||
| 238 | 2 | ▶ | sub backup { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
backup: called CC=4 SCAR=14.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 239 | 2 | ▶ | trace() if $ENV{TRACE}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||
| 241 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 242 | 2 | ▶ | my $state = shift || 0; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
shift() || 0
MC/DC100%1/1
shift() || 0
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||||||
| 244 | 2 | ▶ | $self->{params}{backup} = $state if defined $state; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 245 | 2 | return $self->{params}{backup}; | |||||||||||||||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||
| 248 | # | ||||||||||||||||||||||||||||||||||||||||||
| 249 | # publicly available semi-private developer methods | ||||||||||||||||||||||||||||||||||||||||||
| 250 | # | ||||||||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||||||
| 252 | 7 | ▶ | sub add_functionality { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_functionality: called CC=14 SCAR=26.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||
| 254 | 7 | ▶ | trace() if $ENV{TRACE}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||
| 256 | 6 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 257 | 6 | my $p = $self->_params(@_); | |||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||
| 259 | 6 | $self->_config($p); | |||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||
| 261 | 6 | my $to_add = $self->{params}{add_functionality}; | |||||||||||||||||||||||||||||||||||||||||
| 262 | 6 | my $in_prod = $self->{params}{add_functionality_prod}; | |||||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||||
| 264 | 6 | my @allowed = qw( | |||||||||||||||||||||||||||||||||||||||||
| 265 | pre_proc | ||||||||||||||||||||||||||||||||||||||||||
| 266 | post_proc | ||||||||||||||||||||||||||||||||||||||||||
| 267 | engine | ||||||||||||||||||||||||||||||||||||||||||
| 268 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||||||
| 270 | 6 | my $is_allowed = 0; | |||||||||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||||||||||
| 272 | 6 | for (@allowed){ | |||||||||||||||||||||||||||||||||||||||||
| 273 | 15 | ▶ | if ($_ eq $to_add){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 274 | 5 | $is_allowed = 1; | |||||||||||||||||||||||||||||||||||||||||
| 275 | 5 | last; | |||||||||||||||||||||||||||||||||||||||||
| 276 | } | ||||||||||||||||||||||||||||||||||||||||||
| 277 | } | ||||||||||||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||||||||||||
| 279 | 6 | ▶ | if (! $is_allowed){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 280 | 1 | confess "Adding a non-allowed piece of functionality...\n"; | |||||||||||||||||||||||||||||||||||||||||
| 281 | } | ||||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||
| 283 | my %dt = ( | ||||||||||||||||||||||||||||||||||||||||||
| 284 | 1 | ▶ | pre_proc => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=12.0
| |||||||||||||||||||||||||||||||||||||||||||
| 285 | 1 | ▶ | trace() if $ENV{TRACE}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 286 | return $in_prod | ||||||||||||||||||||||||||||||||||||||||||
| 287 | 1 | ▶ | ? $INC{'Devel/Examine/Subs/Preprocessor.pm'} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 288 | : 'lib/Devel/Examine/Subs/Preprocessor.pm'; | ||||||||||||||||||||||||||||||||||||||||||
| 289 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||||||||
| 291 | 1 | ▶ | post_proc => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=12.0
| |||||||||||||||||||||||||||||||||||||||||||
| 292 | 1 | ▶ | trace() if $ENV{TRACE}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 293 | return $in_prod | ||||||||||||||||||||||||||||||||||||||||||
| 294 | 1 | ▶ | ? $INC{'Devel/Examine/Subs/Postprocessor.pm'} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 295 | : 'lib/Devel/Examine/Subs/Postprocessor.pm'; | ||||||||||||||||||||||||||||||||||||||||||
| 296 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||||||||||
| 298 | 3 | ▶ | engine => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=12.0
| |||||||||||||||||||||||||||||||||||||||||||
| 299 | 3 | ▶ | trace() if $ENV{TRACE}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 300 | return $in_prod | ||||||||||||||||||||||||||||||||||||||||||
| 301 | 3 | ▶ | ? $INC{'Devel/Examine/Subs/Engine.pm'} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 302 | : 'lib/Devel/Examine/Subs/Engine.pm'; | ||||||||||||||||||||||||||||||||||||||||||
| 303 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 304 | 5 | ); | |||||||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||||||
| 306 | 5 | my $caller = (caller)[1]; | |||||||||||||||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||||||||||||||||
| 308 | 5 | ▶ | open my $fh, '<', $caller | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 309 | or confess "can't open the caller file $caller: $!"; | ||||||||||||||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||||||||||||||
| 311 | 5 | my $code_found = 0; | |||||||||||||||||||||||||||||||||||||||||
| 312 | 5 | my @code; | |||||||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||||||||
| 314 | 5 | ▶ | while (<$fh>){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 315 | 137 | chomp; | |||||||||||||||||||||||||||||||||||||||||
| 316 | 137 | ▶ | if (m|^#(.*)<des>|){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 317 | 5 | $code_found = 1; | |||||||||||||||||||||||||||||||||||||||||
| 318 | 5 | next; | |||||||||||||||||||||||||||||||||||||||||
| 319 | } | ||||||||||||||||||||||||||||||||||||||||||
| 320 | 132 | ▶ | next if ! $code_found; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 321 | 39 | ▶ | last if m|^#(.*)</des>|; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 322 | 34 | push @code, $_; | |||||||||||||||||||||||||||||||||||||||||
| 323 | } | ||||||||||||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||||||||||||
| 325 | 5 | my $file = $dt{$to_add}->(); | |||||||||||||||||||||||||||||||||||||||||
| 326 | 5 | my $copy = $self->{params}{copy}; | |||||||||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||||||||||
| 328 | 5 | ▶ | if ($copy) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 329 | 5 | ▶ | copy $file, $copy or die $!; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 330 | 5 | $file = $copy; | |||||||||||||||||||||||||||||||||||||||||
| 331 | } | ||||||||||||||||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||||||||||||||||
| 333 | 5 | my $sub_name; | |||||||||||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||||||||||||
| 335 | 5 | ▶ | if ($code[0] =~ /sub\s+(\w+)/){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 336 | 4 | $sub_name = $1; | |||||||||||||||||||||||||||||||||||||||||
| 337 | } | ||||||||||||||||||||||||||||||||||||||||||
| 338 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 339 | 1 | confess "couldn't extract the sub name"; | |||||||||||||||||||||||||||||||||||||||||
| 340 | } | ||||||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||||||
| 342 | 4 | my $des = Devel::Examine::Subs->new(file => $file); | |||||||||||||||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||||||||||||||||
| 344 | 4 | my $existing_subs = $des->all; | |||||||||||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||||||||||||
| 346 | 4 | ▶ | if (grep { $sub_name eq $_ } @$existing_subs) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 347 | 1 | confess "the sub you're trying to add already exists"; | |||||||||||||||||||||||||||||||||||||||||
| 348 | } | ||||||||||||||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||||||||||||||
| 350 | 3 | $des = Devel::Examine::Subs->new( | |||||||||||||||||||||||||||||||||||||||||
| 351 | file => $file, | ||||||||||||||||||||||||||||||||||||||||||
| 352 | engine => 'objects', | ||||||||||||||||||||||||||||||||||||||||||
| 353 | post_proc => [qw(subs end_of_last_sub)], | ||||||||||||||||||||||||||||||||||||||||||
| 354 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||||||||||||||||
| 356 | 3 | $p = { | |||||||||||||||||||||||||||||||||||||||||
| 357 | engine => 'objects', | ||||||||||||||||||||||||||||||||||||||||||
| 358 | post_proc => [qw(subs end_of_last_sub)], | ||||||||||||||||||||||||||||||||||||||||||
| 359 | post_proc_return => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 360 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||||||||||||
| 362 | 3 | my $start_writing = $des->run($p); | |||||||||||||||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||||||||||||||||
| 364 | 3 | my $rw = File::Edit::Portable->new; | |||||||||||||||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||||||||||||||||
| 366 | 3 | $rw->splice(file => $file, insert => \@code, line => $start_writing); | |||||||||||||||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||||||||||||||||
| 368 | # the weird spaces are required for layout... they're not erroneous | ||||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||
| 370 | 3 | my @insert = (" $sub_name => \\&$sub_name,"); | |||||||||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||||||||||
| 372 | 3 | $rw->splice( | |||||||||||||||||||||||||||||||||||||||||
| 373 | file => $file, | ||||||||||||||||||||||||||||||||||||||||||
| 374 | find => 'my\s+\$dt\s+=\s+\{', | ||||||||||||||||||||||||||||||||||||||||||
| 375 | insert => \@insert, | ||||||||||||||||||||||||||||||||||||||||||
| 376 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||||||||||||||||
| 378 | 3 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 379 | } | ||||||||||||||||||||||||||||||||||||||||||
| 380 | 3 | ▶ | sub engines { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
engines: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||||||||||||||||
| 382 | 3 | ▶ | trace() if $ENV{TRACE}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||||||||||||||||
| 384 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 385 | 2 | my $module = $self->{namespace} . "::Engine"; | |||||||||||||||||||||||||||||||||||||||||
| 386 | 2 | my $engine = $module->new; | |||||||||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||||||||||
| 388 | 2 | my @engines; | |||||||||||||||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||||||||||||||||
| 390 | 2 | for (keys %{$engine->_dt}){ | |||||||||||||||||||||||||||||||||||||||||
| 391 | 20 | ▶ | push @engines, $_ if $_ !~ /^_/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 392 | } | ||||||||||||||||||||||||||||||||||||||||||
| 393 | 2 | return @engines; | |||||||||||||||||||||||||||||||||||||||||
| 394 | } | ||||||||||||||||||||||||||||||||||||||||||
| 395 | 2 | ▶ | sub pre_procs { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pre_procs: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||||||||||||
| 397 | 2 | ▶ | trace() if $ENV{TRACE}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||||||||||||||||
| 399 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 400 | 1 | my $module = $self->{namespace} . "::Preprocessor"; | |||||||||||||||||||||||||||||||||||||||||
| 401 | 1 | my $pre_proc = $module->new; | |||||||||||||||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||||||||||||||||
| 403 | 1 | my @pre_procs; | |||||||||||||||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||||||||||||||||
| 405 | 1 | for (keys %{ $pre_proc->_dt }){ | |||||||||||||||||||||||||||||||||||||||||
| 406 | 5 | ▶ | push @pre_procs, $_ if $_ !~ /^_/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 407 | } | ||||||||||||||||||||||||||||||||||||||||||
| 408 | 1 | return @pre_procs; | |||||||||||||||||||||||||||||||||||||||||
| 409 | } | ||||||||||||||||||||||||||||||||||||||||||
| 410 | 3 | ▶ | sub post_procs { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
post_procs: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||||||||||||||||
| 412 | 3 | ▶ | trace() if $ENV{TRACE}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||||||||||||||||
| 414 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 415 | 2 | my $module = $self->{namespace} . "::Postprocessor"; | |||||||||||||||||||||||||||||||||||||||||
| 416 | 2 | my $post_proc = $module->new; | |||||||||||||||||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||||||||||||||||
| 418 | 2 | my @post_procs; | |||||||||||||||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||||||||||||||||
| 420 | 2 | for (keys %{ $post_proc->_dt }){ | |||||||||||||||||||||||||||||||||||||||||
| 421 | 14 | ▶ | push @post_procs, $_ if $_ !~ /^_/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 422 | } | ||||||||||||||||||||||||||||||||||||||||||
| 423 | 2 | return @post_procs; | |||||||||||||||||||||||||||||||||||||||||
| 424 | } | ||||||||||||||||||||||||||||||||||||||||||
| 425 | 177 | ▶ | sub run { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||||||||||||||||
| 427 | 177 | ▶ | trace() if $ENV{TRACE}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||||||||||||||||
| 429 | 176 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 430 | 176 | my $p = shift; | |||||||||||||||||||||||||||||||||||||||||
| 431 | |||||||||||||||||||||||||||||||||||||||||||
| 432 | 176 | $self->_config($p); | |||||||||||||||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||||||||||||||||
| 434 | 173 | $self->_run_end(0); | |||||||||||||||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||||||||||||||||
| 436 | 173 | my $struct; | |||||||||||||||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||||||||||||||||
| 438 | 173 | ▶ | if ($self->{params}{directory}){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 439 | 9 | $struct = $self->_run_directory; | |||||||||||||||||||||||||||||||||||||||||
| 440 | } | ||||||||||||||||||||||||||||||||||||||||||
| 441 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 442 | 164 | $struct = $self->_core; | |||||||||||||||||||||||||||||||||||||||||
| 443 | 131 | ▶ | $self->_write_file if $self->{write_file_contents}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 444 | } | ||||||||||||||||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||||||||||||||||
| 446 | 138 | $self->_run_end(1); | |||||||||||||||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||||||||||||||||
| 448 | 138 | return $struct; | |||||||||||||||||||||||||||||||||||||||||
| 449 | } | ||||||||||||||||||||||||||||||||||||||||||
| 450 | 789 | ▶ | sub rw { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
rw: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 451 | 789 | ▶ | trace() if $ENV{TRACE}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||||||||||||||||
| 453 | # Insert a File::Edit::Portable object into self | ||||||||||||||||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||||||||||||||||
| 455 | 789 | my ($self, $rw) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 456 | |||||||||||||||||||||||||||||||||||||||||||
| 457 | 789 | ▶ | $self->{rw} = $rw if defined $rw; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||||||||||||||||
| 459 | 789 | return $self->{rw}; | |||||||||||||||||||||||||||||||||||||||||
| 460 | } | ||||||||||||||||||||||||||||||||||||||||||
| 461 | 7 | ▶ | sub tempfile { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
tempfile: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 462 | 7 | ▶ | trace() if $ENV{TRACE}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 463 | |||||||||||||||||||||||||||||||||||||||||||
| 464 | # Insert a File::Edit::Portable::tempfile object into self | ||||||||||||||||||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||||||||||||||||
| 466 | 7 | my ($self, $tempfile) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 467 | 7 | ▶ | $self->{tempfile} = $tempfile if defined $tempfile; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 468 | 7 | return $self->{tempfile}; | |||||||||||||||||||||||||||||||||||||||||
| 469 | } | ||||||||||||||||||||||||||||||||||||||||||
| 470 | 3 | ▶ | sub valid_params { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
valid_params: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 471 | 3 | ▶ | trace() if $ENV{TRACE}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 472 | 2 | return %{ $_[0]->{valid_params} }; | |||||||||||||||||||||||||||||||||||||||||
| 473 | } | ||||||||||||||||||||||||||||||||||||||||||
| 474 | |||||||||||||||||||||||||||||||||||||||||||
| 475 | # | ||||||||||||||||||||||||||||||||||||||||||
| 476 | # private methods | ||||||||||||||||||||||||||||||||||||||||||
| 477 | # | ||||||||||||||||||||||||||||||||||||||||||
| 478 | |||||||||||||||||||||||||||||||||||||||||||
| 479 | 30 | ▶ | sub _cache { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_cache: called CC=8 SCAR=20.8
| |||||||||||||||||||||||||||||||||||||||||||
| 480 | |||||||||||||||||||||||||||||||||||||||||||
| 481 | 30 | ▶ | trace() if $ENV{TRACE}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 482 | |||||||||||||||||||||||||||||||||||||||||||
| 483 | 29 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 484 | 29 | my $file = shift; | |||||||||||||||||||||||||||||||||||||||||
| 485 | 29 | my $struct = shift; | |||||||||||||||||||||||||||||||||||||||||
| 486 | |||||||||||||||||||||||||||||||||||||||||||
| 487 | 29 | ▶ | if ($self->{params}{cache_dump}){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 488 | |||||||||||||||||||||||||||||||||||||||||||
| 489 | 1 | print Dumper $self->{cache}; | |||||||||||||||||||||||||||||||||||||||||
| 490 | |||||||||||||||||||||||||||||||||||||||||||
| 491 | 1 | ▶ | if ($self->{params}{cache_dump} > 1){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 492 | 1 | exit; | |||||||||||||||||||||||||||||||||||||||||
| 493 | } | ||||||||||||||||||||||||||||||||||||||||||
| 494 | } | ||||||||||||||||||||||||||||||||||||||||||
| 495 | |||||||||||||||||||||||||||||||||||||||||||
| 496 | 28 | ▶ | if (! $struct && $file){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not $struct and $file
MC/DC100%2/2
not $struct and $file
not $struct
$file
Truth table100%3/3
not(A) and B
A= not $structB= $file
| |||||||||||||||||||||||||||||||||||||||||||
| 497 | 25 | return $self->{cache}{$file}; | |||||||||||||||||||||||||||||||||||||||||
| 498 | } | ||||||||||||||||||||||||||||||||||||||||||
| 499 | 3 | ▶ | if ($file && $struct){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$file and $struct
MC/DC50%1/2
$file and $struct
$file
$struct
Truth table66%2/3
A and B
A= $fileB= $struct
| |||||||||||||||||||||||||||||||||||||||||||
| 500 | 2 | $self->{cache}{$file} = $struct; | |||||||||||||||||||||||||||||||||||||||||
| 501 | } | ||||||||||||||||||||||||||||||||||||||||||
| 502 | } | ||||||||||||||||||||||||||||||||||||||||||
| 503 | 769 | ▶ | sub _cache_enabled { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_cache_enabled: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 504 | |||||||||||||||||||||||||||||||||||||||||||
| 505 | 769 | ▶ | trace() if $ENV{TRACE}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 506 | |||||||||||||||||||||||||||||||||||||||||||
| 507 | 768 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 508 | 768 | return $self->{params}{cache}; | |||||||||||||||||||||||||||||||||||||||||
| 509 | } | ||||||||||||||||||||||||||||||||||||||||||
| 510 | 358 | ▶ | sub _cache_safe { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_cache_safe: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 511 | |||||||||||||||||||||||||||||||||||||||||||
| 512 | 358 | ▶ | trace() if $ENV{TRACE}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 513 | |||||||||||||||||||||||||||||||||||||||||||
| 514 | 357 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 515 | 357 | my $value = shift; | |||||||||||||||||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||||||||||||||||
| 517 | 357 | ▶ | $self->{cache_safe} = $value if defined $value; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||||||||||||||||
| 519 | 357 | return $self->{cache_safe}; | |||||||||||||||||||||||||||||||||||||||||
| 520 | } | ||||||||||||||||||||||||||||||||||||||||||
| 521 | 328 | ▶ | sub _clean_config { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_clean_config: called CC=7 SCAR=19.5
| |||||||||||||||||||||||||||||||||||||||||||
| 522 | |||||||||||||||||||||||||||||||||||||||||||
| 523 | 328 | ▶ | trace() if $ENV{TRACE}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 524 | |||||||||||||||||||||||||||||||||||||||||||
| 525 | 327 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 526 | 327 | my $config_vars = shift; # href of valid params | |||||||||||||||||||||||||||||||||||||||||
| 527 | 327 | my $p = shift; # href of params passed in | |||||||||||||||||||||||||||||||||||||||||
| 528 | |||||||||||||||||||||||||||||||||||||||||||
| 529 | 327 | for my $var (keys %$config_vars){ | |||||||||||||||||||||||||||||||||||||||||
| 530 | |||||||||||||||||||||||||||||||||||||||||||
| 531 | 2246 | ▶ | last if ! $self->_run_end; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 532 | |||||||||||||||||||||||||||||||||||||||||||
| 533 | # skip if it's a persistent var | ||||||||||||||||||||||||||||||||||||||||||
| 534 | |||||||||||||||||||||||||||||||||||||||||||
| 535 | 1968 | ▶ | next if $config_vars->{$var} == 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 536 | |||||||||||||||||||||||||||||||||||||||||||
| 537 | 1392 | delete $self->{params}{$var}; | |||||||||||||||||||||||||||||||||||||||||
| 538 | } | ||||||||||||||||||||||||||||||||||||||||||
| 539 | |||||||||||||||||||||||||||||||||||||||||||
| 540 | # delete non-valid params | ||||||||||||||||||||||||||||||||||||||||||
| 541 | |||||||||||||||||||||||||||||||||||||||||||
| 542 | 327 | for my $param (keys %$p){ | |||||||||||||||||||||||||||||||||||||||||
| 543 | 439 | ▶ | if (! exists $config_vars->{$param}){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 544 | 5 | print "\n\nDES::_clean_config() deleting invalid param: $param\n"; | |||||||||||||||||||||||||||||||||||||||||
| 545 | 5 | delete $p->{$param}; | |||||||||||||||||||||||||||||||||||||||||
| 546 | } | ||||||||||||||||||||||||||||||||||||||||||
| 547 | } | ||||||||||||||||||||||||||||||||||||||||||
| 548 | } | ||||||||||||||||||||||||||||||||||||||||||
| 549 | 141 | ▶ | sub _clean_core_config { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_clean_core_config: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 550 | |||||||||||||||||||||||||||||||||||||||||||
| 551 | 141 | ▶ | trace() if $ENV{TRACE}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 552 | |||||||||||||||||||||||||||||||||||||||||||
| 553 | 140 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 554 | |||||||||||||||||||||||||||||||||||||||||||
| 555 | # delete params we collected after _clean_config() | ||||||||||||||||||||||||||||||||||||||||||
| 556 | |||||||||||||||||||||||||||||||||||||||||||
| 557 | 140 | delete $self->{params}{file_contents}; | |||||||||||||||||||||||||||||||||||||||||
| 558 | 140 | delete $self->{params}{order}; | |||||||||||||||||||||||||||||||||||||||||
| 559 | |||||||||||||||||||||||||||||||||||||||||||
| 560 | 140 | my @core_phases = qw( | |||||||||||||||||||||||||||||||||||||||||
| 561 | pre_proc | ||||||||||||||||||||||||||||||||||||||||||
| 562 | post_proc | ||||||||||||||||||||||||||||||||||||||||||
| 563 | engine | ||||||||||||||||||||||||||||||||||||||||||
| 564 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 565 | |||||||||||||||||||||||||||||||||||||||||||
| 566 | 140 | for (@core_phases){ | |||||||||||||||||||||||||||||||||||||||||
| 567 | 420 | delete $self->{params}{$_}; | |||||||||||||||||||||||||||||||||||||||||
| 568 | } | ||||||||||||||||||||||||||||||||||||||||||
| 569 | } | ||||||||||||||||||||||||||||||||||||||||||
| 570 | 327 | ▶ | sub _config { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_config: called CC=9 SCAR=22.0
| |||||||||||||||||||||||||||||||||||||||||||
| 571 | |||||||||||||||||||||||||||||||||||||||||||
| 572 | 327 | ▶ | trace() if $ENV{TRACE}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 573 | |||||||||||||||||||||||||||||||||||||||||||
| 574 | 326 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 575 | 326 | my $p = shift; | |||||||||||||||||||||||||||||||||||||||||
| 576 | |||||||||||||||||||||||||||||||||||||||||||
| 577 | 326 | my %valid_params = ( | |||||||||||||||||||||||||||||||||||||||||
| 578 | |||||||||||||||||||||||||||||||||||||||||||
| 579 | # persistent | ||||||||||||||||||||||||||||||||||||||||||
| 580 | |||||||||||||||||||||||||||||||||||||||||||
| 581 | backup => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 582 | cache => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 583 | copy => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 584 | diff => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 585 | extensions => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 586 | file => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 587 | maxdepth => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 588 | no_indent => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 589 | regex => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 590 | |||||||||||||||||||||||||||||||||||||||||||
| 591 | # persistent - core phases | ||||||||||||||||||||||||||||||||||||||||||
| 592 | |||||||||||||||||||||||||||||||||||||||||||
| 593 | pre_proc => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 594 | post_proc => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 595 | engine => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 596 | |||||||||||||||||||||||||||||||||||||||||||
| 597 | # transient | ||||||||||||||||||||||||||||||||||||||||||
| 598 | |||||||||||||||||||||||||||||||||||||||||||
| 599 | directory => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 600 | search => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 601 | replace => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 602 | injects => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 603 | code => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 604 | include => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 605 | exclude => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 606 | lines => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 607 | module => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 608 | objects_in_hash => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 609 | pre_proc_dump => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 610 | post_proc_dump => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 611 | engine_dump => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 612 | core_dump => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 613 | pre_proc_return => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 614 | post_proc_return => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 615 | engine_return => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 616 | config_dump => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 617 | cache_dump => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 618 | inject_use => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 619 | inject_after_sub_def => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 620 | delete => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 621 | file_contents => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 622 | exec => 0, # replace(), search_replace() | ||||||||||||||||||||||||||||||||||||||||||
| 623 | limit => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 624 | line_num => 0, # inject() | ||||||||||||||||||||||||||||||||||||||||||
| 625 | add_functionality => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 626 | add_functionality_prod => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 627 | order => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 628 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 629 | |||||||||||||||||||||||||||||||||||||||||||
| 630 | 326 | $self->{valid_params} = \%valid_params; | |||||||||||||||||||||||||||||||||||||||||
| 631 | |||||||||||||||||||||||||||||||||||||||||||
| 632 | # store previous run's config | ||||||||||||||||||||||||||||||||||||||||||
| 633 | |||||||||||||||||||||||||||||||||||||||||||
| 634 | 326 | %{$self->{previous_run_config}} = %{$self->{params}}; | |||||||||||||||||||||||||||||||||||||||||
| 635 | |||||||||||||||||||||||||||||||||||||||||||
| 636 | # clean config | ||||||||||||||||||||||||||||||||||||||||||
| 637 | |||||||||||||||||||||||||||||||||||||||||||
| 638 | 326 | $self->_clean_config(\%valid_params, $p); | |||||||||||||||||||||||||||||||||||||||||
| 639 | |||||||||||||||||||||||||||||||||||||||||||
| 640 | 326 | for my $param (keys %$p){ | |||||||||||||||||||||||||||||||||||||||||
| 641 | |||||||||||||||||||||||||||||||||||||||||||
| 642 | # validate the file | ||||||||||||||||||||||||||||||||||||||||||
| 643 | |||||||||||||||||||||||||||||||||||||||||||
| 644 | 433 | ▶ | if ($param eq 'file'){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 645 | 137 | $self->_file($p); | |||||||||||||||||||||||||||||||||||||||||
| 646 | 134 | next; | |||||||||||||||||||||||||||||||||||||||||
| 647 | } | ||||||||||||||||||||||||||||||||||||||||||
| 648 | |||||||||||||||||||||||||||||||||||||||||||
| 649 | 296 | $self->{params}{$param} = $p->{$param}; | |||||||||||||||||||||||||||||||||||||||||
| 650 | } | ||||||||||||||||||||||||||||||||||||||||||
| 651 | |||||||||||||||||||||||||||||||||||||||||||
| 652 | # check if we can cache | ||||||||||||||||||||||||||||||||||||||||||
| 653 | |||||||||||||||||||||||||||||||||||||||||||
| 654 | 323 | ▶ | if ($self->_cache_enabled) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 655 | |||||||||||||||||||||||||||||||||||||||||||
| 656 | my @unsafe_cache_params | ||||||||||||||||||||||||||||||||||||||||||
| 657 | 16 | = qw(file extensions include exclude search); | |||||||||||||||||||||||||||||||||||||||||
| 658 | |||||||||||||||||||||||||||||||||||||||||||
| 659 | 16 | my $current = $self->{params}; | |||||||||||||||||||||||||||||||||||||||||
| 660 | 16 | my $previous = $self->{previous_run_config}; | |||||||||||||||||||||||||||||||||||||||||
| 661 | |||||||||||||||||||||||||||||||||||||||||||
| 662 | 16 | for (@unsafe_cache_params) { | |||||||||||||||||||||||||||||||||||||||||
| 663 | 57 | ▶ | my $safe = Compare($current->{$_}, $previous->{$_}) || 0; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
Compare($current->{$_}, $previous->{$_}) || 0
MC/DC100%1/1
Compare($current->{$_}, $previous->{$_}) || 0
Compare($current->{$_}, $previous->{$_})
Truth table100%2/2
A
A= Compare($current->{$_}, $previous->{$_})
| |||||||||||||||||||||||||||||||||||||||||||
| 664 | |||||||||||||||||||||||||||||||||||||||||||
| 665 | 57 | $self->_cache_safe($safe); | |||||||||||||||||||||||||||||||||||||||||
| 666 | |||||||||||||||||||||||||||||||||||||||||||
| 667 | 57 | ▶ | last if !$self->_cache_safe; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 668 | } | ||||||||||||||||||||||||||||||||||||||||||
| 669 | } | ||||||||||||||||||||||||||||||||||||||||||
| 670 | |||||||||||||||||||||||||||||||||||||||||||
| 671 | 323 | ▶ | if ($self->{params}{config_dump}){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 672 | 1 | print Dumper $self->{params}; | |||||||||||||||||||||||||||||||||||||||||
| 673 | } | ||||||||||||||||||||||||||||||||||||||||||
| 674 | } | ||||||||||||||||||||||||||||||||||||||||||
| 675 | 140 | ▶ | sub _file { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_file: called CC=11 SCAR=24.0
| |||||||||||||||||||||||||||||||||||||||||||
| 676 | |||||||||||||||||||||||||||||||||||||||||||
| 677 | 140 | ▶ | trace() if $ENV{TRACE}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 678 | |||||||||||||||||||||||||||||||||||||||||||
| 679 | 139 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 680 | 139 | my $p = shift; | |||||||||||||||||||||||||||||||||||||||||
| 681 | |||||||||||||||||||||||||||||||||||||||||||
| 682 | $self->{params}{file} = defined $p->{file} | ||||||||||||||||||||||||||||||||||||||||||
| 683 | ? $p->{file} | ||||||||||||||||||||||||||||||||||||||||||
| 684 | 139 | ▶ | : $self->{params}{file}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 685 | |||||||||||||||||||||||||||||||||||||||||||
| 686 | # if a module was passed in, dig up the file | ||||||||||||||||||||||||||||||||||||||||||
| 687 | |||||||||||||||||||||||||||||||||||||||||||
| 688 | 139 | ▶ | if ($self->{params}{file} =~ /::/){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 689 | |||||||||||||||||||||||||||||||||||||||||||
| 690 | 3 | my $module = $self->{params}{file}; | |||||||||||||||||||||||||||||||||||||||||
| 691 | 3 | (my $file = $module) =~ s|::|/|g; | |||||||||||||||||||||||||||||||||||||||||
| 692 | 3 | $file .= '.pm'; | |||||||||||||||||||||||||||||||||||||||||
| 693 | |||||||||||||||||||||||||||||||||||||||||||
| 694 | 3 | my $module_is_loaded; | |||||||||||||||||||||||||||||||||||||||||
| 695 | |||||||||||||||||||||||||||||||||||||||||||
| 696 | 3 | ▶ | if (! $INC{$file}){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 697 | 2 | my $import_ok = eval { | |||||||||||||||||||||||||||||||||||||||||
| 698 | 2 | require $file; | |||||||||||||||||||||||||||||||||||||||||
| 699 | 1 | import $module; | |||||||||||||||||||||||||||||||||||||||||
| 700 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 701 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 702 | |||||||||||||||||||||||||||||||||||||||||||
| 703 | 2 | ▶ | if (! $import_ok){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 704 | 1 | $@ = "\nDevel::Examine::Subs::_file() speaking ... " . | |||||||||||||||||||||||||||||||||||||||||
| 705 | "Can't transform module to a file name\n\n" | ||||||||||||||||||||||||||||||||||||||||||
| 706 | . $@; | ||||||||||||||||||||||||||||||||||||||||||
| 707 | 1 | confess $@; | |||||||||||||||||||||||||||||||||||||||||
| 708 | } | ||||||||||||||||||||||||||||||||||||||||||
| 709 | } | ||||||||||||||||||||||||||||||||||||||||||
| 710 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 711 | 1 | $module_is_loaded = 1; | |||||||||||||||||||||||||||||||||||||||||
| 712 | } | ||||||||||||||||||||||||||||||||||||||||||
| 713 | |||||||||||||||||||||||||||||||||||||||||||
| 714 | # set the file param | ||||||||||||||||||||||||||||||||||||||||||
| 715 | |||||||||||||||||||||||||||||||||||||||||||
| 716 | 2 | $self->{params}{file} = $INC{$file}; | |||||||||||||||||||||||||||||||||||||||||
| 717 | |||||||||||||||||||||||||||||||||||||||||||
| 718 | 2 | ▶ | if (! $module_is_loaded){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 719 | 1 | delete_package $module; | |||||||||||||||||||||||||||||||||||||||||
| 720 | 1 | delete $INC{$file}; | |||||||||||||||||||||||||||||||||||||||||
| 721 | } | ||||||||||||||||||||||||||||||||||||||||||
| 722 | } | ||||||||||||||||||||||||||||||||||||||||||
| 723 | |||||||||||||||||||||||||||||||||||||||||||
| 724 | # configure directory searching for run() | ||||||||||||||||||||||||||||||||||||||||||
| 725 | |||||||||||||||||||||||||||||||||||||||||||
| 726 | 138 | ▶ | if (-d $self->{params}{file}){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 727 | 10 | $self->{params}{directory} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 728 | $self->{params}{extensions} | ||||||||||||||||||||||||||||||||||||||||||
| 729 | 10 | ▶ | = defined $p->{extensions} ? $p->{extensions} : [qw(*.pm *.pl)]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 730 | } | ||||||||||||||||||||||||||||||||||||||||||
| 731 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 732 | 128 | ▶ | if (! $self->{params}{file} || ! -f $self->{params}{file}){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->{"params"}{"file"} and -f $self->{"params"}{"file"}
MC/DC100%2/2
$self->{"params"}{"file"} and -f $self->{"params"}{"file"}
$self->{"params"}{"file"}
-f $self->{"params"}{"file"}
Truth table100%3/3
A and B
A= $self->{"params"}{"file"}B= -f $self->{"params"}{"file"}
| |||||||||||||||||||||||||||||||||||||||||||
| 733 | 3 | die "Invalid file supplied: $self->{params}{file} $!"; | |||||||||||||||||||||||||||||||||||||||||
| 734 | } | ||||||||||||||||||||||||||||||||||||||||||
| 735 | } | ||||||||||||||||||||||||||||||||||||||||||
| 736 | |||||||||||||||||||||||||||||||||||||||||||
| 737 | 135 | return $self->{params}{file}; | |||||||||||||||||||||||||||||||||||||||||
| 738 | } | ||||||||||||||||||||||||||||||||||||||||||
| 739 | 280 | ▶ | sub _params { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_params: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 740 | 280 | ▶ | trace() if $ENV{TRACE}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 741 | 279 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 742 | 279 | my %params = @_; | |||||||||||||||||||||||||||||||||||||||||
| 743 | 279 | return \%params; | |||||||||||||||||||||||||||||||||||||||||
| 744 | } | ||||||||||||||||||||||||||||||||||||||||||
| 745 | 282 | ▶ | sub _read_file { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_read_file: called CC=10 SCAR=23.0
| |||||||||||||||||||||||||||||||||||||||||||
| 746 | |||||||||||||||||||||||||||||||||||||||||||
| 747 | # this sub prepares a temp copy of the original file, | ||||||||||||||||||||||||||||||||||||||||||
| 748 | # recseps changed to local platform for PPI | ||||||||||||||||||||||||||||||||||||||||||
| 749 | |||||||||||||||||||||||||||||||||||||||||||
| 750 | 282 | ▶ | trace() if $ENV{TRACE}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 751 | |||||||||||||||||||||||||||||||||||||||||||
| 752 | 281 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 753 | 281 | my $p = shift; | |||||||||||||||||||||||||||||||||||||||||
| 754 | |||||||||||||||||||||||||||||||||||||||||||
| 755 | 281 | my $file = $p->{file}; | |||||||||||||||||||||||||||||||||||||||||
| 756 | |||||||||||||||||||||||||||||||||||||||||||
| 757 | 281 | ▶ | return if ! $file; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 758 | |||||||||||||||||||||||||||||||||||||||||||
| 759 | 248 | ▶ | if ($self->{params}{backup}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 760 | 3 | my $basename = basename($file); | |||||||||||||||||||||||||||||||||||||||||
| 761 | 3 | my $bak = "$basename.bak"; | |||||||||||||||||||||||||||||||||||||||||
| 762 | |||||||||||||||||||||||||||||||||||||||||||
| 763 | 3 | ▶ | copy $file, $bak | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 764 | or confess "DES::_read_file() can't create backup copy $bak!"; | ||||||||||||||||||||||||||||||||||||||||||
| 765 | } | ||||||||||||||||||||||||||||||||||||||||||
| 766 | |||||||||||||||||||||||||||||||||||||||||||
| 767 | 247 | ▶ | die "Can't call method \"serialize\" on an undefined file\n" if ! -f $file; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 768 | |||||||||||||||||||||||||||||||||||||||||||
| 769 | 246 | $self->rw(File::Edit::Portable->new); | |||||||||||||||||||||||||||||||||||||||||
| 770 | |||||||||||||||||||||||||||||||||||||||||||
| 771 | 246 | my $ppi_doc; | |||||||||||||||||||||||||||||||||||||||||
| 772 | |||||||||||||||||||||||||||||||||||||||||||
| 773 | 246 | ▶ | if ($self->rw()->recsep($file, 'hex') ne $self->rw()->platform_recsep('hex') || $ENV{ISSUE_31_TEST}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->rw->recsep($file, "hex") ne $self->rw->platform_recsep("hex") or $ENV{"ISSUE_31_TEST"}
MC/DC50%1/2
$self->rw->recsep($file, "hex") ne $self->rw->platform_recsep("hex") or $ENV{"ISSUE_31_TEST"}
$self->rw->recsep($file, "hex") ne $self->rw->platform_recsep("hex")
$ENV{"ISSUE_31_TEST"}
Truth table66%2/3
A or B
A= $self->rw->recsep($file, "hex") ne $self->rw->platform_recsep("hex")B= $ENV{"ISSUE_31_TEST"}
| |||||||||||||||||||||||||||||||||||||||||||
| 774 | 1 | my $fh = $self->rw()->read($file); | |||||||||||||||||||||||||||||||||||||||||
| 775 | |||||||||||||||||||||||||||||||||||||||||||
| 776 | 1 | $self->tempfile($self->rw()->tempfile); | |||||||||||||||||||||||||||||||||||||||||
| 777 | 1 | my $tempfile_name = $self->tempfile()->filename; | |||||||||||||||||||||||||||||||||||||||||
| 778 | 1 | my $platform_recsep = $self->rw()->platform_recsep; | |||||||||||||||||||||||||||||||||||||||||
| 779 | |||||||||||||||||||||||||||||||||||||||||||
| 780 | 1 | $self->rw()->write( | |||||||||||||||||||||||||||||||||||||||||
| 781 | copy => $tempfile_name, | ||||||||||||||||||||||||||||||||||||||||||
| 782 | contents => $fh, | ||||||||||||||||||||||||||||||||||||||||||
| 783 | recsep => $platform_recsep | ||||||||||||||||||||||||||||||||||||||||||
| 784 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 785 | |||||||||||||||||||||||||||||||||||||||||||
| 786 | 1 | $ppi_doc = PPI::Document->new($tempfile_name); | |||||||||||||||||||||||||||||||||||||||||
| 787 | |||||||||||||||||||||||||||||||||||||||||||
| 788 | 1 | close $self->tempfile; | |||||||||||||||||||||||||||||||||||||||||
| 789 | 1 | ▶ | unlink $tempfile_name or die "Can't delete temp file $tempfile_name: $!"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 790 | } | ||||||||||||||||||||||||||||||||||||||||||
| 791 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 792 | 245 | $ppi_doc = PPI::Document->new($file); | |||||||||||||||||||||||||||||||||||||||||
| 793 | } | ||||||||||||||||||||||||||||||||||||||||||
| 794 | |||||||||||||||||||||||||||||||||||||||||||
| 795 | 246 | @{ $p->{file_contents} } = split /\n/, $ppi_doc->serialize; | |||||||||||||||||||||||||||||||||||||||||
| 796 | |||||||||||||||||||||||||||||||||||||||||||
| 797 | 246 | ▶ | if (! $p->{file_contents}->[0]){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 798 | 2 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 799 | } | ||||||||||||||||||||||||||||||||||||||||||
| 800 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 801 | 244 | $self->{params}{file_contents} = $p->{file_contents}; | |||||||||||||||||||||||||||||||||||||||||
| 802 | 244 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 803 | } | ||||||||||||||||||||||||||||||||||||||||||
| 804 | } | ||||||||||||||||||||||||||||||||||||||||||
| 805 | 11 | ▶ | sub _run_directory { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_run_directory: called CC=7 SCAR=19.5
| |||||||||||||||||||||||||||||||||||||||||||
| 806 | |||||||||||||||||||||||||||||||||||||||||||
| 807 | 11 | ▶ | trace() if $ENV{TRACE}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 808 | |||||||||||||||||||||||||||||||||||||||||||
| 809 | 10 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 810 | 10 | my $p = shift; | |||||||||||||||||||||||||||||||||||||||||
| 811 | |||||||||||||||||||||||||||||||||||||||||||
| 812 | 10 | my $dir = $self->{params}{file}; | |||||||||||||||||||||||||||||||||||||||||
| 813 | |||||||||||||||||||||||||||||||||||||||||||
| 814 | 10 | $self->rw(File::Edit::Portable->new); | |||||||||||||||||||||||||||||||||||||||||
| 815 | |||||||||||||||||||||||||||||||||||||||||||
| 816 | my @files = $self->rw()->dir( | ||||||||||||||||||||||||||||||||||||||||||
| 817 | dir => $dir, | ||||||||||||||||||||||||||||||||||||||||||
| 818 | maxdepth => $self->{params}{maxdepth} || 0, | ||||||||||||||||||||||||||||||||||||||||||
| 819 | types => $self->{params}{extensions}, | ||||||||||||||||||||||||||||||||||||||||||
| 820 | 10 | ▶ | list => 1, | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{'params'}{'maxdepth'} || 0
MC/DC0%0/1
$self->{'params'}{'maxdepth'} || 0
$self->{'params'}{'maxdepth'}
Truth table50%1/2
A
A= $self->{'params'}{'maxdepth'}
| |||||||||||||||||||||||||||||||||||||||||||
| 821 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 822 | |||||||||||||||||||||||||||||||||||||||||||
| 823 | 9 | my %struct; | |||||||||||||||||||||||||||||||||||||||||
| 824 | |||||||||||||||||||||||||||||||||||||||||||
| 825 | 9 | for my $file (@files){ | |||||||||||||||||||||||||||||||||||||||||
| 826 | |||||||||||||||||||||||||||||||||||||||||||
| 827 | 108 | $self->{params}{file} = $file; | |||||||||||||||||||||||||||||||||||||||||
| 828 | 108 | my $data = $self->_core($p); | |||||||||||||||||||||||||||||||||||||||||
| 829 | |||||||||||||||||||||||||||||||||||||||||||
| 830 | 108 | ▶ | $self->_write_file if $self->{write_file_contents}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 831 | |||||||||||||||||||||||||||||||||||||||||||
| 832 | 107 | ▶ | if (ref $data eq 'HASH' || ref $data eq 'ARRAY'){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
ref $data eq "HASH" or ref $data eq "ARRAY"
MC/DC50%1/2
ref $data eq "HASH" or ref $data eq "ARRAY"
ref $data eq "HASH"
ref $data eq "ARRAY"
Truth table66%2/3
A or B
A= ref $data eq "HASH"B= ref $data eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||
| 833 | 84 | $struct{$file} = $data; | |||||||||||||||||||||||||||||||||||||||||
| 834 | } | ||||||||||||||||||||||||||||||||||||||||||
| 835 | } | ||||||||||||||||||||||||||||||||||||||||||
| 836 | |||||||||||||||||||||||||||||||||||||||||||
| 837 | 8 | return \%struct; | |||||||||||||||||||||||||||||||||||||||||
| 838 | } | ||||||||||||||||||||||||||||||||||||||||||
| 839 | 2562 | ▶ | sub _run_end { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_run_end: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||
| 840 | |||||||||||||||||||||||||||||||||||||||||||
| 841 | 2562 | ▶ | trace() if $ENV{TRACE}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 842 | |||||||||||||||||||||||||||||||||||||||||||
| 843 | 2561 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 844 | 2561 | my $value = shift; | |||||||||||||||||||||||||||||||||||||||||
| 845 | |||||||||||||||||||||||||||||||||||||||||||
| 846 | 2561 | ▶ | $self->{run_end} = $value if defined $value; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 847 | |||||||||||||||||||||||||||||||||||||||||||
| 848 | # we clean core_config here | ||||||||||||||||||||||||||||||||||||||||||
| 849 | |||||||||||||||||||||||||||||||||||||||||||
| 850 | 2561 | ▶ | $self->_clean_core_config if $value; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 851 | |||||||||||||||||||||||||||||||||||||||||||
| 852 | 2561 | return $self->{run_end}; | |||||||||||||||||||||||||||||||||||||||||
| 853 | } | ||||||||||||||||||||||||||||||||||||||||||
| 854 | 27 | ▶ | sub _write_file { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_write_file: called CC=12 SCAR=24.9
| |||||||||||||||||||||||||||||||||||||||||||
| 855 | |||||||||||||||||||||||||||||||||||||||||||
| 856 | 27 | ▶ | trace() if $ENV{TRACE}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 857 | |||||||||||||||||||||||||||||||||||||||||||
| 858 | 26 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 859 | |||||||||||||||||||||||||||||||||||||||||||
| 860 | 26 | my $copy = $self->{params}{copy}; | |||||||||||||||||||||||||||||||||||||||||
| 861 | |||||||||||||||||||||||||||||||||||||||||||
| 862 | 26 | my $file = $self->{params}{file}; | |||||||||||||||||||||||||||||||||||||||||
| 863 | 26 | my $contents = $self->{write_file_contents}; | |||||||||||||||||||||||||||||||||||||||||
| 864 | |||||||||||||||||||||||||||||||||||||||||||
| 865 | 26 | ▶ | return if ! $file; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 866 | |||||||||||||||||||||||||||||||||||||||||||
| 867 | 25 | ▶ | if ($self->{params}{directory} && $copy && ! -d $copy){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$self->{"params"}{"directory"} and $copy and not -d $copy
$self->{"params"}{"directory"} and $copy
MC/DC100%3/3
$self->{"params"}{"directory"} and $copy and not -d $copy
$self->{"params"}{"directory"}
$copy
not -d $copy
Truth table100%4/4
A and B and not(C)
A= $self->{"params"}{"directory"}B= $copyC= not -d $copy
| |||||||||||||||||||||||||||||||||||||||||||
| 868 | 2 | warn "\n\nin directory mode, all files are copied to the dir named " . | |||||||||||||||||||||||||||||||||||||||||
| 869 | "in the copy param, which is $copy\n\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 870 | |||||||||||||||||||||||||||||||||||||||||||
| 871 | 2 | ▶ | mkdir $copy or confess "can't create directory $copy"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 872 | } | ||||||||||||||||||||||||||||||||||||||||||
| 873 | 24 | ▶ | if ($copy && -d $copy){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%3/3
$copy and -d $copy
MC/DC100%2/2
$copy and -d $copy
$copy
-d $copy
Truth table100%3/3
A and B
A= $copyB= -d $copy
| |||||||||||||||||||||||||||||||||||||||||||
| 874 | 4 | copy $file, $copy; | |||||||||||||||||||||||||||||||||||||||||
| 875 | 4 | my $filename = basename $file; | |||||||||||||||||||||||||||||||||||||||||
| 876 | 4 | $file = "$copy/$filename"; | |||||||||||||||||||||||||||||||||||||||||
| 877 | } | ||||||||||||||||||||||||||||||||||||||||||
| 878 | elsif ($copy) { | ||||||||||||||||||||||||||||||||||||||||||
| 879 | 17 | $file = $copy; | |||||||||||||||||||||||||||||||||||||||||
| 880 | } | ||||||||||||||||||||||||||||||||||||||||||
| 881 | |||||||||||||||||||||||||||||||||||||||||||
| 882 | 24 | my $write_response; | |||||||||||||||||||||||||||||||||||||||||
| 883 | |||||||||||||||||||||||||||||||||||||||||||
| 884 | 24 | my $write_ok = eval { | |||||||||||||||||||||||||||||||||||||||||
| 885 | 24 | $write_response | |||||||||||||||||||||||||||||||||||||||||
| 886 | = $self->rw()->write(file => $file, contents => $contents); | ||||||||||||||||||||||||||||||||||||||||||
| 887 | 22 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 888 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 889 | |||||||||||||||||||||||||||||||||||||||||||
| 890 | 24 | ▶ | if (! $write_ok || ! $write_response){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$write_ok && $write_response
MC/DC50%1/2
$write_ok && $write_response
$write_ok
$write_response
Truth table66%2/3
A && B
A= $write_okB= $write_response
| |||||||||||||||||||||||||||||||||||||||||||
| 891 | 2 | $@ = "\nDevel::Examine::Subs::_write_file() speaking...\n\n" . | |||||||||||||||||||||||||||||||||||||||||
| 892 | "File::Edit::Portable::write() returned a failure status.\n\n" . | ||||||||||||||||||||||||||||||||||||||||||
| 893 | $@; | ||||||||||||||||||||||||||||||||||||||||||
| 894 | 2 | confess $@; | |||||||||||||||||||||||||||||||||||||||||
| 895 | } | ||||||||||||||||||||||||||||||||||||||||||
| 896 | } | ||||||||||||||||||||||||||||||||||||||||||
| 897 | |||||||||||||||||||||||||||||||||||||||||||
| 898 | # | ||||||||||||||||||||||||||||||||||||||||||
| 899 | # private methods for core phases | ||||||||||||||||||||||||||||||||||||||||||
| 900 | # | ||||||||||||||||||||||||||||||||||||||||||
| 901 | |||||||||||||||||||||||||||||||||||||||||||
| 902 | 274 | ▶ | sub _core { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_core: called CC=17 SCAR=28.3
| |||||||||||||||||||||||||||||||||||||||||||
| 903 | |||||||||||||||||||||||||||||||||||||||||||
| 904 | 274 | ▶ | trace() if $ENV{TRACE}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 905 | |||||||||||||||||||||||||||||||||||||||||||
| 906 | 273 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 907 | 273 | my $p = $self->{params}; | |||||||||||||||||||||||||||||||||||||||||
| 908 | |||||||||||||||||||||||||||||||||||||||||||
| 909 | 273 | $self->_read_file($p); | |||||||||||||||||||||||||||||||||||||||||
| 910 | |||||||||||||||||||||||||||||||||||||||||||
| 911 | # pre processor | ||||||||||||||||||||||||||||||||||||||||||
| 912 | |||||||||||||||||||||||||||||||||||||||||||
| 913 | 273 | my $data; | |||||||||||||||||||||||||||||||||||||||||
| 914 | |||||||||||||||||||||||||||||||||||||||||||
| 915 | 273 | ▶ | if ($self->{params}{pre_proc}){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 916 | 43 | my $pre_proc = $self->_pre_proc; | |||||||||||||||||||||||||||||||||||||||||
| 917 | |||||||||||||||||||||||||||||||||||||||||||
| 918 | 38 | $data = $pre_proc->($p, $data); | |||||||||||||||||||||||||||||||||||||||||
| 919 | |||||||||||||||||||||||||||||||||||||||||||
| 920 | 26 | ▶ | if ($self->{params}{pre_proc_dump}){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 921 | 1 | print Dumper $data; | |||||||||||||||||||||||||||||||||||||||||
| 922 | 1 | exit; | |||||||||||||||||||||||||||||||||||||||||
| 923 | } | ||||||||||||||||||||||||||||||||||||||||||
| 924 | |||||||||||||||||||||||||||||||||||||||||||
| 925 | 25 | ▶ | if ($p->{write_file_contents}){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 926 | 13 | $self->{write_file_contents} = $p->{write_file_contents}; | |||||||||||||||||||||||||||||||||||||||||
| 927 | } | ||||||||||||||||||||||||||||||||||||||||||
| 928 | |||||||||||||||||||||||||||||||||||||||||||
| 929 | # for things that don't need to process files | ||||||||||||||||||||||||||||||||||||||||||
| 930 | # (such as 'module'), return early | ||||||||||||||||||||||||||||||||||||||||||
| 931 | |||||||||||||||||||||||||||||||||||||||||||
| 932 | 25 | ▶ | if ($self->{params}{pre_proc_return}){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 933 | 23 | return $data; | |||||||||||||||||||||||||||||||||||||||||
| 934 | } | ||||||||||||||||||||||||||||||||||||||||||
| 935 | } | ||||||||||||||||||||||||||||||||||||||||||
| 936 | |||||||||||||||||||||||||||||||||||||||||||
| 937 | # processor | ||||||||||||||||||||||||||||||||||||||||||
| 938 | |||||||||||||||||||||||||||||||||||||||||||
| 939 | 232 | my $subs = $data; | |||||||||||||||||||||||||||||||||||||||||
| 940 | |||||||||||||||||||||||||||||||||||||||||||
| 941 | # bypass the proc if cache | ||||||||||||||||||||||||||||||||||||||||||
| 942 | |||||||||||||||||||||||||||||||||||||||||||
| 943 | 232 | my $cache_enabled = $self->_cache_enabled; | |||||||||||||||||||||||||||||||||||||||||
| 944 | 232 | my $cache_safe = $self->_cache_safe; | |||||||||||||||||||||||||||||||||||||||||
| 945 | |||||||||||||||||||||||||||||||||||||||||||
| 946 | 232 | ▶ | if ($cache_enabled && $cache_safe && $self->_cache($p->{file})){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$cache_enabled and $cache_safe and $self->_cache($p->{"file"})
$cache_enabled and $cache_safe
MC/DC66%2/3
$cache_enabled and $cache_safe and $self->_cache($p->{"file"})
$cache_enabled
$cache_safe
$self->_cache($p->{"file"})
Truth table75%3/4
A and B and C
A= $cache_enabledB= $cache_safeC= $self->_cache($p->{"file"})
| |||||||||||||||||||||||||||||||||||||||||||
| 947 | 6 | $subs = $self->_cache($p->{file}); | |||||||||||||||||||||||||||||||||||||||||
| 948 | } | ||||||||||||||||||||||||||||||||||||||||||
| 949 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 950 | 226 | $subs = $self->_proc($p); | |||||||||||||||||||||||||||||||||||||||||
| 951 | } | ||||||||||||||||||||||||||||||||||||||||||
| 952 | |||||||||||||||||||||||||||||||||||||||||||
| 953 | 232 | ▶ | return if ! $subs; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 954 | |||||||||||||||||||||||||||||||||||||||||||
| 955 | # write to cache | ||||||||||||||||||||||||||||||||||||||||||
| 956 | |||||||||||||||||||||||||||||||||||||||||||
| 957 | 212 | ▶ | if ($self->_cache_enabled && ! $self->_cache($p->{file})){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->_cache_enabled and not $self->_cache($p->{"file"})
MC/DC100%2/2
$self->_cache_enabled and not $self->_cache($p->{"file"})
$self->_cache_enabled
not $self->_cache($p->{"file"})
Truth table100%3/3
A and not(B)
A= $self->_cache_enabledB= not $self->_cache($p->{"file"})
| |||||||||||||||||||||||||||||||||||||||||||
| 958 | 2 | $self->_cache($p->{file}, $subs); | |||||||||||||||||||||||||||||||||||||||||
| 959 | } | ||||||||||||||||||||||||||||||||||||||||||
| 960 | |||||||||||||||||||||||||||||||||||||||||||
| 961 | # post processor | ||||||||||||||||||||||||||||||||||||||||||
| 962 | |||||||||||||||||||||||||||||||||||||||||||
| 963 | 211 | ▶ | if ($self->{params}{post_proc}){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 964 | 91 | for my $post_proc ($self->_post_proc($p, $subs)){ | |||||||||||||||||||||||||||||||||||||||||
| 965 | 123 | $subs = $post_proc->($p, $subs); | |||||||||||||||||||||||||||||||||||||||||
| 966 | 123 | $self->{write_file_contents} = $p->{write_file_contents}; | |||||||||||||||||||||||||||||||||||||||||
| 967 | } | ||||||||||||||||||||||||||||||||||||||||||
| 968 | } | ||||||||||||||||||||||||||||||||||||||||||
| 969 | |||||||||||||||||||||||||||||||||||||||||||
| 970 | 205 | ▶ | if ($self->{params}{post_proc_return}){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 971 | 5 | return $subs; | |||||||||||||||||||||||||||||||||||||||||
| 972 | } | ||||||||||||||||||||||||||||||||||||||||||
| 973 | |||||||||||||||||||||||||||||||||||||||||||
| 974 | # engine | ||||||||||||||||||||||||||||||||||||||||||
| 975 | |||||||||||||||||||||||||||||||||||||||||||
| 976 | 200 | my $engine = $self->_engine($p, $subs); | |||||||||||||||||||||||||||||||||||||||||
| 977 | |||||||||||||||||||||||||||||||||||||||||||
| 978 | 197 | ▶ | if ($self->{params}{engine}){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 979 | 185 | $subs = $engine->($p, $subs); | |||||||||||||||||||||||||||||||||||||||||
| 980 | 180 | $self->{write_file_contents} = $p->{write_file_contents}; | |||||||||||||||||||||||||||||||||||||||||
| 981 | } | ||||||||||||||||||||||||||||||||||||||||||
| 982 | |||||||||||||||||||||||||||||||||||||||||||
| 983 | # core dump | ||||||||||||||||||||||||||||||||||||||||||
| 984 | |||||||||||||||||||||||||||||||||||||||||||
| 985 | 192 | ▶ | if ($self->{params}{core_dump}){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 986 | 1 | print "\n\t Core Dump called...\n\n"; | |||||||||||||||||||||||||||||||||||||||||
| 987 | 1 | print "\n\n\t Dumping data... \n\n"; | |||||||||||||||||||||||||||||||||||||||||
| 988 | 1 | print Dumper $subs; | |||||||||||||||||||||||||||||||||||||||||
| 989 | |||||||||||||||||||||||||||||||||||||||||||
| 990 | 1 | print "\n\n\t Dumping instance...\n\n"; | |||||||||||||||||||||||||||||||||||||||||
| 991 | 1 | print Dumper $self; | |||||||||||||||||||||||||||||||||||||||||
| 992 | |||||||||||||||||||||||||||||||||||||||||||
| 993 | 1 | exit; | |||||||||||||||||||||||||||||||||||||||||
| 994 | } | ||||||||||||||||||||||||||||||||||||||||||
| 995 | |||||||||||||||||||||||||||||||||||||||||||
| 996 | 191 | return $subs; | |||||||||||||||||||||||||||||||||||||||||
| 997 | } | ||||||||||||||||||||||||||||||||||||||||||
| 998 | 47 | ▶ | sub _pre_proc { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_pre_proc: called CC=9 SCAR=22.0
| |||||||||||||||||||||||||||||||||||||||||||
| 999 | |||||||||||||||||||||||||||||||||||||||||||
| 1000 | 47 | ▶ | trace() if $ENV{TRACE}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1001 | |||||||||||||||||||||||||||||||||||||||||||
| 1002 | 46 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1003 | 46 | my $p = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1004 | 46 | my $subs = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1005 | |||||||||||||||||||||||||||||||||||||||||||
| 1006 | 46 | my $pre_proc = $self->{params}{pre_proc}; | |||||||||||||||||||||||||||||||||||||||||
| 1007 | |||||||||||||||||||||||||||||||||||||||||||
| 1008 | 46 | ▶ | if (not $pre_proc or $pre_proc eq ''){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not $pre_proc or $pre_proc eq ""
MC/DC50%1/2
not $pre_proc or $pre_proc eq ""
not $pre_proc
$pre_proc eq ""
Truth table66%2/3
not(A) or B
A= not $pre_procB= $pre_proc eq ""
| |||||||||||||||||||||||||||||||||||||||||||
| 1009 | 1 | return $subs; | |||||||||||||||||||||||||||||||||||||||||
| 1010 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1011 | |||||||||||||||||||||||||||||||||||||||||||
| 1012 | # tell _core() to return directly from the pre_processor | ||||||||||||||||||||||||||||||||||||||||||
| 1013 | # if necessary, and bypass post_proc and engine | ||||||||||||||||||||||||||||||||||||||||||
| 1014 | |||||||||||||||||||||||||||||||||||||||||||
| 1015 | 45 | ▶ | if ($pre_proc eq 'module'){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1016 | 11 | $self->{params}{pre_proc_return} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 1017 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1018 | |||||||||||||||||||||||||||||||||||||||||||
| 1019 | 45 | my $cref; | |||||||||||||||||||||||||||||||||||||||||
| 1020 | |||||||||||||||||||||||||||||||||||||||||||
| 1021 | 45 | ▶ | if (not ref($pre_proc) eq 'CODE'){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1022 | 44 | my $pre_proc_module = $self->{namespace} . "::Preprocessor"; | |||||||||||||||||||||||||||||||||||||||||
| 1023 | 44 | my $compiler = $pre_proc_module->new; | |||||||||||||||||||||||||||||||||||||||||
| 1024 | |||||||||||||||||||||||||||||||||||||||||||
| 1025 | 44 | ▶ | if (! $compiler->exists($pre_proc)){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1026 | 1 | confess "Devel::Examine::Subs::_pre_proc() speaking...\n\n" . | |||||||||||||||||||||||||||||||||||||||||
| 1027 | "pre_processor '$pre_proc' is not implemented.\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 1028 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1029 | |||||||||||||||||||||||||||||||||||||||||||
| 1030 | 43 | my $compiled_ok = eval { | |||||||||||||||||||||||||||||||||||||||||
| 1031 | 43 | $cref = $compiler->{pre_procs}{$pre_proc}->(); | |||||||||||||||||||||||||||||||||||||||||
| 1032 | 39 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 1033 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 1034 | |||||||||||||||||||||||||||||||||||||||||||
| 1035 | 43 | ▶ | if (! $compiled_ok){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1036 | 4 | $@ = "\n[Devel::Examine::Subs speaking] " . | |||||||||||||||||||||||||||||||||||||||||
| 1037 | "dispatch table in Devel::Examine::Subs::Preprocessor " . | ||||||||||||||||||||||||||||||||||||||||||
| 1038 | "has a mistyped function as a value, but the key is ok\n\n" | ||||||||||||||||||||||||||||||||||||||||||
| 1039 | . $@; | ||||||||||||||||||||||||||||||||||||||||||
| 1040 | 4 | confess $@; | |||||||||||||||||||||||||||||||||||||||||
| 1041 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1042 | |||||||||||||||||||||||||||||||||||||||||||
| 1043 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1044 | |||||||||||||||||||||||||||||||||||||||||||
| 1045 | 40 | ▶ | if (ref($pre_proc) eq 'CODE'){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1046 | 1 | $cref = $pre_proc; | |||||||||||||||||||||||||||||||||||||||||
| 1047 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1048 | |||||||||||||||||||||||||||||||||||||||||||
| 1049 | 40 | return $cref; | |||||||||||||||||||||||||||||||||||||||||
| 1050 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1051 | 228 | ▶ | sub _proc { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_proc: called CC=12 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 1052 | |||||||||||||||||||||||||||||||||||||||||||
| 1053 | # this method is the core data collection/manipulation | ||||||||||||||||||||||||||||||||||||||||||
| 1054 | # routine (aka the 'Processor phase') for all of DES | ||||||||||||||||||||||||||||||||||||||||||
| 1055 | |||||||||||||||||||||||||||||||||||||||||||
| 1056 | # make sure all unit tests are successful after any change | ||||||||||||||||||||||||||||||||||||||||||
| 1057 | # to this subroutine | ||||||||||||||||||||||||||||||||||||||||||
| 1058 | |||||||||||||||||||||||||||||||||||||||||||
| 1059 | # if you want the data structure to look differently before | ||||||||||||||||||||||||||||||||||||||||||
| 1060 | # reaching here, use a pre_proc. If you want it different | ||||||||||||||||||||||||||||||||||||||||||
| 1061 | # afterwards, use a post_proc or an engine | ||||||||||||||||||||||||||||||||||||||||||
| 1062 | |||||||||||||||||||||||||||||||||||||||||||
| 1063 | 228 | ▶ | trace() if $ENV{TRACE}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1064 | |||||||||||||||||||||||||||||||||||||||||||
| 1065 | 227 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1066 | 227 | my $p = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1067 | |||||||||||||||||||||||||||||||||||||||||||
| 1068 | 227 | my $file = $self->{params}{file}; | |||||||||||||||||||||||||||||||||||||||||
| 1069 | |||||||||||||||||||||||||||||||||||||||||||
| 1070 | 227 | ▶ | return {} if ! $file; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1071 | |||||||||||||||||||||||||||||||||||||||||||
| 1072 | 216 | my $PPI_doc = PPI::Document->new($file); | |||||||||||||||||||||||||||||||||||||||||
| 1073 | 216 | my $PPI_subs = $PPI_doc->find('PPI::Statement::Sub'); | |||||||||||||||||||||||||||||||||||||||||
| 1074 | |||||||||||||||||||||||||||||||||||||||||||
| 1075 | 216 | ▶ | return if ! $PPI_subs; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1076 | |||||||||||||||||||||||||||||||||||||||||||
| 1077 | 196 | my %subs; | |||||||||||||||||||||||||||||||||||||||||
| 1078 | 196 | $subs{$file} = {}; | |||||||||||||||||||||||||||||||||||||||||
| 1079 | 196 | my @sub_order; | |||||||||||||||||||||||||||||||||||||||||
| 1080 | |||||||||||||||||||||||||||||||||||||||||||
| 1081 | 196 | for my $PPI_sub (@{$PPI_subs}){ | |||||||||||||||||||||||||||||||||||||||||
| 1082 | |||||||||||||||||||||||||||||||||||||||||||
| 1083 | my $include | ||||||||||||||||||||||||||||||||||||||||||
| 1084 | 1518 | ▶ | = defined $self->{params}{include} ? $self->{params}{include} : []; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1085 | my $exclude | ||||||||||||||||||||||||||||||||||||||||||
| 1086 | 1518 | ▶ | = defined $self->{params}{exclude} ? $self->{params}{exclude} : []; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1087 | |||||||||||||||||||||||||||||||||||||||||||
| 1088 | 1518 | ▶ | delete $self->{params}{include} if $exclude->[0]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1089 | |||||||||||||||||||||||||||||||||||||||||||
| 1090 | 1518 | my $name = $PPI_sub->name; | |||||||||||||||||||||||||||||||||||||||||
| 1091 | |||||||||||||||||||||||||||||||||||||||||||
| 1092 | 1518 | push @sub_order, $name; | |||||||||||||||||||||||||||||||||||||||||
| 1093 | |||||||||||||||||||||||||||||||||||||||||||
| 1094 | # skip over excluded (or not included) subs | ||||||||||||||||||||||||||||||||||||||||||
| 1095 | |||||||||||||||||||||||||||||||||||||||||||
| 1096 | 1518 | ▶ | next if grep {$name eq $_ } @$exclude; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1097 | |||||||||||||||||||||||||||||||||||||||||||
| 1098 | 1510 | ▶ | if ($include->[0]){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1099 | 127 | ▶ | next if (! grep {$_ && $name eq $_} @$include); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$_ && $name eq $_
MC/DC50%1/2
$_ && $name eq $_
$_
$name eq $_
Truth table66%2/3
A && B
A= $_B= $name eq $_
| |||||||||||||||||||||||||||||||||||||||||||
| 1100 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1101 | |||||||||||||||||||||||||||||||||||||||||||
| 1102 | 1415 | $subs{$file}{subs}{$name}{start} = $PPI_sub->line_number; | |||||||||||||||||||||||||||||||||||||||||
| 1103 | 1415 | $subs{$file}{subs}{$name}{start}--; | |||||||||||||||||||||||||||||||||||||||||
| 1104 | |||||||||||||||||||||||||||||||||||||||||||
| 1105 | # yep, its a hard to find thing 'y' is :) | ||||||||||||||||||||||||||||||||||||||||||
| 1106 | |||||||||||||||||||||||||||||||||||||||||||
| 1107 | 1415 | my $lines = $PPI_sub =~ y/\n//; | |||||||||||||||||||||||||||||||||||||||||
| 1108 | |||||||||||||||||||||||||||||||||||||||||||
| 1109 | $subs{$file}{subs}{$name}{end} | ||||||||||||||||||||||||||||||||||||||||||
| 1110 | 1415 | = $subs{$file}{subs}{$name}{start} + $lines; | |||||||||||||||||||||||||||||||||||||||||
| 1111 | |||||||||||||||||||||||||||||||||||||||||||
| 1112 | 1415 | my $count_start = $subs{$file}{subs}{$name}{start}; | |||||||||||||||||||||||||||||||||||||||||
| 1113 | 1415 | $count_start--; | |||||||||||||||||||||||||||||||||||||||||
| 1114 | |||||||||||||||||||||||||||||||||||||||||||
| 1115 | my $sub_line_count | ||||||||||||||||||||||||||||||||||||||||||
| 1116 | 1415 | = $subs{$file}{subs}{$name}{end} - $count_start; | |||||||||||||||||||||||||||||||||||||||||
| 1117 | |||||||||||||||||||||||||||||||||||||||||||
| 1118 | 1415 | $subs{$file}{subs}{$name}{num_lines} = $sub_line_count; | |||||||||||||||||||||||||||||||||||||||||
| 1119 | |||||||||||||||||||||||||||||||||||||||||||
| 1120 | 1415 | @{ $subs{$file}{subs}{$name}{code} } = split /\n/, $PPI_sub->content; | |||||||||||||||||||||||||||||||||||||||||
| 1121 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1122 | |||||||||||||||||||||||||||||||||||||||||||
| 1123 | 196 | @{ $p->{order} } = @sub_order; | |||||||||||||||||||||||||||||||||||||||||
| 1124 | 196 | @{ $self->{order} } = @sub_order; | |||||||||||||||||||||||||||||||||||||||||
| 1125 | |||||||||||||||||||||||||||||||||||||||||||
| 1126 | 196 | return \%subs; | |||||||||||||||||||||||||||||||||||||||||
| 1127 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1128 | 93 | ▶ | sub _post_proc { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_post_proc: called CC=13 SCAR=25.7
| |||||||||||||||||||||||||||||||||||||||||||
| 1129 | |||||||||||||||||||||||||||||||||||||||||||
| 1130 | 93 | ▶ | trace() if $ENV{TRACE}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1131 | |||||||||||||||||||||||||||||||||||||||||||
| 1132 | 92 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1133 | 92 | my $p = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1134 | 92 | my $struct = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1135 | |||||||||||||||||||||||||||||||||||||||||||
| 1136 | 92 | my $post_proc = $self->{params}{post_proc}; | |||||||||||||||||||||||||||||||||||||||||
| 1137 | |||||||||||||||||||||||||||||||||||||||||||
| 1138 | 92 | my $post_proc_dump = $self->{params}{post_proc_dump}; | |||||||||||||||||||||||||||||||||||||||||
| 1139 | |||||||||||||||||||||||||||||||||||||||||||
| 1140 | 92 | my @post_procs; | |||||||||||||||||||||||||||||||||||||||||
| 1141 | |||||||||||||||||||||||||||||||||||||||||||
| 1142 | 92 | ▶ | if ($post_proc){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1143 | |||||||||||||||||||||||||||||||||||||||||||
| 1144 | 91 | my @post_proc_list; | |||||||||||||||||||||||||||||||||||||||||
| 1145 | |||||||||||||||||||||||||||||||||||||||||||
| 1146 | 91 | ▶ | if (ref $post_proc ne 'ARRAY'){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1147 | 66 | push @post_proc_list, $post_proc; | |||||||||||||||||||||||||||||||||||||||||
| 1148 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1149 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 1150 | 25 | @post_proc_list = @{$post_proc}; | |||||||||||||||||||||||||||||||||||||||||
| 1151 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1152 | |||||||||||||||||||||||||||||||||||||||||||
| 1153 | 91 | for my $pf (@post_proc_list){ | |||||||||||||||||||||||||||||||||||||||||
| 1154 | |||||||||||||||||||||||||||||||||||||||||||
| 1155 | 131 | my $cref; | |||||||||||||||||||||||||||||||||||||||||
| 1156 | |||||||||||||||||||||||||||||||||||||||||||
| 1157 | 131 | ▶ | if (ref $pf ne 'CODE'){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1158 | |||||||||||||||||||||||||||||||||||||||||||
| 1159 | 126 | my $post_proc_module = $self->{namespace} . "::Postprocessor"; | |||||||||||||||||||||||||||||||||||||||||
| 1160 | 126 | my $compiler = $post_proc_module->new; | |||||||||||||||||||||||||||||||||||||||||
| 1161 | |||||||||||||||||||||||||||||||||||||||||||
| 1162 | # post_proc isn't in the dispatch table | ||||||||||||||||||||||||||||||||||||||||||
| 1163 | |||||||||||||||||||||||||||||||||||||||||||
| 1164 | 126 | ▶ | if (! $compiler->exists($pf)){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1165 | 3 | confess "\nDevel::Examine::Subs::_post_proc() " . | |||||||||||||||||||||||||||||||||||||||||
| 1166 | "speaking...\n\npost_proc '$pf' is not " . | ||||||||||||||||||||||||||||||||||||||||||
| 1167 | "implemented. '$post_proc' was sent in.\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 1168 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1169 | |||||||||||||||||||||||||||||||||||||||||||
| 1170 | 123 | my $compiled_ok = eval { | |||||||||||||||||||||||||||||||||||||||||
| 1171 | 123 | $cref = $compiler->{post_procs}{$pf}->(); | |||||||||||||||||||||||||||||||||||||||||
| 1172 | 122 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 1173 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 1174 | |||||||||||||||||||||||||||||||||||||||||||
| 1175 | 123 | ▶ | if (! $compiled_ok){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1176 | 1 | $@ = "\n[Devel::Examine::Subs speaking] " . | |||||||||||||||||||||||||||||||||||||||||
| 1177 | "dispatch table in " . | ||||||||||||||||||||||||||||||||||||||||||
| 1178 | "Devel::Examine::Subs::Postprocessor has a mistyped " . | ||||||||||||||||||||||||||||||||||||||||||
| 1179 | "function as a value, but the key is ok\n\n" | ||||||||||||||||||||||||||||||||||||||||||
| 1180 | . $@; | ||||||||||||||||||||||||||||||||||||||||||
| 1181 | 1 | confess $@; | |||||||||||||||||||||||||||||||||||||||||
| 1182 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1183 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1184 | 127 | ▶ | if (ref($pf) eq 'CODE'){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1185 | 5 | $cref = $pf; | |||||||||||||||||||||||||||||||||||||||||
| 1186 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1187 | |||||||||||||||||||||||||||||||||||||||||||
| 1188 | 127 | ▶ | if ($post_proc_dump && $post_proc_dump > 1){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$post_proc_dump and $post_proc_dump > 1
MC/DC100%2/2
$post_proc_dump and $post_proc_dump > 1
$post_proc_dump
$post_proc_dump > 1
Truth table100%3/3
A and B
A= $post_proc_dumpB= $post_proc_dump > 1
| |||||||||||||||||||||||||||||||||||||||||||
| 1189 | 1 | $self->{params}{post_proc_dump}--; | |||||||||||||||||||||||||||||||||||||||||
| 1190 | 1 | $post_proc_dump = $self->{params}{post_proc_dump}; | |||||||||||||||||||||||||||||||||||||||||
| 1191 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1192 | |||||||||||||||||||||||||||||||||||||||||||
| 1193 | 127 | ▶ | if ($post_proc_dump && $post_proc_dump == 1){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$post_proc_dump and $post_proc_dump == 1
MC/DC50%1/2
$post_proc_dump and $post_proc_dump == 1
$post_proc_dump
$post_proc_dump == 1
Truth table66%2/3
A and B
A= $post_proc_dumpB= $post_proc_dump == 1
| |||||||||||||||||||||||||||||||||||||||||||
| 1194 | 2 | my $subs = $cref->($p, $struct); | |||||||||||||||||||||||||||||||||||||||||
| 1195 | 2 | print Dumper $subs; | |||||||||||||||||||||||||||||||||||||||||
| 1196 | 2 | exit; | |||||||||||||||||||||||||||||||||||||||||
| 1197 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1198 | 125 | push @post_procs, $cref; | |||||||||||||||||||||||||||||||||||||||||
| 1199 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1200 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1201 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 1202 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||
| 1203 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1204 | 85 | return @post_procs; | |||||||||||||||||||||||||||||||||||||||||
| 1205 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1206 | 205 | ▶ | sub _engine { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_engine: called CC=10 SCAR=23.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1207 | |||||||||||||||||||||||||||||||||||||||||||
| 1208 | 205 | ▶ | trace() if $ENV{TRACE}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1209 | |||||||||||||||||||||||||||||||||||||||||||
| 1210 | 204 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1211 | 204 | my $p = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1212 | 204 | my $struct = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1213 | |||||||||||||||||||||||||||||||||||||||||||
| 1214 | my $engine | ||||||||||||||||||||||||||||||||||||||||||
| 1215 | 204 | ▶ | = defined $p->{engine} ? $p->{engine} : $self->{params}{engine}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1216 | |||||||||||||||||||||||||||||||||||||||||||
| 1217 | 204 | ▶ | if (not $engine or $engine eq ''){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not $engine or $engine eq ""
MC/DC50%1/2
not $engine or $engine eq ""
not $engine
$engine eq ""
Truth table66%2/3
not(A) or B
A= not $engineB= $engine eq ""
| |||||||||||||||||||||||||||||||||||||||||||
| 1218 | 13 | return $struct; | |||||||||||||||||||||||||||||||||||||||||
| 1219 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1220 | |||||||||||||||||||||||||||||||||||||||||||
| 1221 | 191 | my $cref; | |||||||||||||||||||||||||||||||||||||||||
| 1222 | |||||||||||||||||||||||||||||||||||||||||||
| 1223 | 191 | ▶ | if (not ref($engine) eq 'CODE'){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1224 | |||||||||||||||||||||||||||||||||||||||||||
| 1225 | # engine is a name | ||||||||||||||||||||||||||||||||||||||||||
| 1226 | |||||||||||||||||||||||||||||||||||||||||||
| 1227 | 190 | my $engine_module = $self->{namespace} . "::Engine"; | |||||||||||||||||||||||||||||||||||||||||
| 1228 | 190 | my $compiler = $engine_module->new; | |||||||||||||||||||||||||||||||||||||||||
| 1229 | |||||||||||||||||||||||||||||||||||||||||||
| 1230 | # engine isn't in the dispatch table | ||||||||||||||||||||||||||||||||||||||||||
| 1231 | |||||||||||||||||||||||||||||||||||||||||||
| 1232 | 190 | ▶ | if (! $compiler->exists($engine)){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1233 | 1 | confess "engine '$engine' is not implemented.\n"; | |||||||||||||||||||||||||||||||||||||||||
| 1234 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1235 | |||||||||||||||||||||||||||||||||||||||||||
| 1236 | 189 | my $compiled_ok = eval { | |||||||||||||||||||||||||||||||||||||||||
| 1237 | 189 | $cref = $compiler->{engines}{$engine}->(); | |||||||||||||||||||||||||||||||||||||||||
| 1238 | 188 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 1239 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 1240 | |||||||||||||||||||||||||||||||||||||||||||
| 1241 | # engine has bad func val in dispatch table, but key is ok | ||||||||||||||||||||||||||||||||||||||||||
| 1242 | |||||||||||||||||||||||||||||||||||||||||||
| 1243 | 189 | ▶ | if (! $compiled_ok){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1244 | 1 | $@ = "\n[Devel::Examine::Subs speaking] " . | |||||||||||||||||||||||||||||||||||||||||
| 1245 | "dispatch table in Devel::Examine::Subs::Engine " . | ||||||||||||||||||||||||||||||||||||||||||
| 1246 | "has a mistyped function as a value, but the key is ok\n\n" | ||||||||||||||||||||||||||||||||||||||||||
| 1247 | . $@; | ||||||||||||||||||||||||||||||||||||||||||
| 1248 | 1 | confess $@; | |||||||||||||||||||||||||||||||||||||||||
| 1249 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1250 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1251 | |||||||||||||||||||||||||||||||||||||||||||
| 1252 | 189 | ▶ | if (ref($engine) eq 'CODE'){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1253 | 1 | $cref = $engine; | |||||||||||||||||||||||||||||||||||||||||
| 1254 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1255 | |||||||||||||||||||||||||||||||||||||||||||
| 1256 | 189 | ▶ | if ($self->{params}{engine_dump}){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1257 | 1 | my $subs = $cref->($p, $struct); | |||||||||||||||||||||||||||||||||||||||||
| 1258 | 1 | print Dumper $subs; | |||||||||||||||||||||||||||||||||||||||||
| 1259 | 1 | exit; | |||||||||||||||||||||||||||||||||||||||||
| 1260 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1261 | |||||||||||||||||||||||||||||||||||||||||||
| 1262 | 188 | return $cref; | |||||||||||||||||||||||||||||||||||||||||
| 1263 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1264 | |||||||||||||||||||||||||||||||||||||||||||
| 1265 | # | ||||||||||||||||||||||||||||||||||||||||||
| 1266 | # pod | ||||||||||||||||||||||||||||||||||||||||||
| 1267 | # | ||||||||||||||||||||||||||||||||||||||||||
| 1268 | |||||||||||||||||||||||||||||||||||||||||||
| 1269 | 1 | ▶ | sub _pod{1;} #vim placeholder | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_pod: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1270 | 60 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 1271 | __END__ | ||||||||||||||||||||||||||||||||||||||||||