| 1 | package CPAN::Maker::Role::FileUtils; | ||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use CLI::Simple::Constants qw(:booleans :chars); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use CLI::Simple::Utils qw(slurp); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use CPAN::Maker::Utils; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use Cwd qw(getcwd); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use File::Basename qw(fileparse); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 12 | 1 | ▶ | use File::Find qw(find); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 13 | 1 | ▶ | use File::Temp qw(tempfile); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 14 | 1 | ▶ | use Scalar::Util qw(reftype); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||
| 16 | 1 | ▶ | use Role::Tiny; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||
| 18 | 1 | our $VERSION = '2.0.13'; | |||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||
| 20 | ######################################################################## | ||||||||||||||||||||||||||||||||
| 21 | 0 | ▶ | sub fetch_file_list { | ||||||||||||||||||||||||||||||
|
Subroutine
fetch_file_list: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 22 | ######################################################################## | ||||||||||||||||||||||||||||||||
| 23 | 0 | my ( $self, %args ) = @_; | |||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||
| 25 | 0 | my ( $file_list, $destdir, $project_root, $exclude ) = @args{qw(file_list destination project_root exclude)}; | |||||||||||||||||||||||||||||||
| 26 | 0 | ▶ | $project_root ||= getcwd; | ||||||||||||||||||||||||||||||
|
Condition0%0/3
$project_root ||= getcwd()
MC/DC0%0/2
$project_root ||= getcwd()
$project_root
getcwd()
Truth table0%0/3
A ||= B
A= $project_rootB= getcwd()
| |||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||
| 28 | 0 | $self->get_logger->debug( Dumper( [ args => \%args, project_root => $project_root ] ) ); | |||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||
| 30 | 0 | my @expanded_list; | |||||||||||||||||||||||||||||||
| 31 | 0 | ▶ | my @exclude = ( @{ $exclude // [] }, grep {/^!/xsm} @{$file_list} ); | ||||||||||||||||||||||||||||||
|
Condition0%0/2
$exclude // []
MC/DC0%0/1
$exclude // []
$exclude
Truth table0%0/2
A
A= $exclude
| |||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||
| 33 | 0 | foreach (@exclude) { | |||||||||||||||||||||||||||||||
| 34 | 0 | s/^!//xsm; | |||||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||
| 37 | 0 | foreach my $f ( grep { !/^!/xsm } @{$file_list} ) { | |||||||||||||||||||||||||||||||
| 38 | 0 | my $fqp = sprintf '%s/%s', $project_root, $f; | |||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||
| 40 | 0 | $self->get_logger->debug( Dumper( [ 'fetch_file_list:', $fqp ] ) ); | |||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||
| 42 | # no recurse of directories! | ||||||||||||||||||||||||||||||||
| 43 | 0 | my $cwd = getcwd(); | |||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||
| 45 | 0 | ▶ | if ( -d $fqp ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 46 | 0 | eval { | |||||||||||||||||||||||||||||||
| 47 | find( | ||||||||||||||||||||||||||||||||
| 48 | { follow => $TRUE, | ||||||||||||||||||||||||||||||||
| 49 | 0 | ▶ | wanted => sub { | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=8 SCAR=42.8
| |||||||||||||||||||||||||||||||||
| 50 | return | ||||||||||||||||||||||||||||||||
| 51 | 0 | ▶ | if /^[.]/xsm || -d $_; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
/^[.]/msx or -d $_
MC/DC0%0/2
/^[.]/msx or -d $_
/^[.]/msx
-d $_
Truth table0%0/3
A or B
A= /^[.]/msxB= -d $_
| |||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||
| 53 | 0 | ▶ | die 'done' | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 54 | if getcwd() ne $fqp; | ||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||
| 56 | 0 | my $name = $_; | |||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||
| 58 | 0 | foreach my $e (@exclude) { | |||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||
| 60 | 0 | ▶ | if ( $e =~ /^\/([^\/]+)\/$/xsm ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 61 | 0 | my $pat = qr/$1/xsm; | |||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||
| 63 | 0 | ▶ | if ( $name =~ /$pat/ ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 64 | 0 | return; | |||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||
| 68 | return | ||||||||||||||||||||||||||||||||
| 69 | 0 | ▶ | if $e eq $name; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||
| 72 | 0 | push @expanded_list, "$File::Find::name $destdir/$name"; | |||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||
| 74 | }, | ||||||||||||||||||||||||||||||||
| 75 | 0 | $fqp | |||||||||||||||||||||||||||||||
| 76 | ); | ||||||||||||||||||||||||||||||||
| 77 | }; | ||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||
| 79 | 0 | chdir $cwd; | |||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||
| 81 | # remove project root since bash script will add it | ||||||||||||||||||||||||||||||||
| 82 | #for (@expanded_list) { | ||||||||||||||||||||||||||||||||
| 83 | # s/^$project_root//xsm; | ||||||||||||||||||||||||||||||||
| 84 | #} | ||||||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||||||
| 86 | else { | ||||||||||||||||||||||||||||||||
| 87 | # the intent is to cp files to root of distribution (not | ||||||||||||||||||||||||||||||||
| 88 | # to install the files during package installation...the | ||||||||||||||||||||||||||||||||
| 89 | # exception being if items are installed into share | ||||||||||||||||||||||||||||||||
| 90 | # directory | ||||||||||||||||||||||||||||||||
| 91 | 0 | ▶ | die "ERROR: missing file in list ($fqp) - check your `extra-files` section\n" | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 92 | if !-e $fqp; | ||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||
| 94 | 0 | my ( $name, $path, $ext ) = fileparse( $fqp, qr/[.][^.]+/xsm ); | |||||||||||||||||||||||||||||||
| 95 | 0 | push @expanded_list, sprintf '%s %s/%s%s', $f, $destdir, $name, $ext; | |||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||||||
| 98 | 0 | $self->get_logger->debug( Dumper( [ expanded_list => \@expanded_list ] ) ); | |||||||||||||||||||||||||||||||
| 99 | 0 | return @expanded_list; | |||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||
| 102 | ######################################################################## | ||||||||||||||||||||||||||||||||
| 103 | 0 | ▶ | sub write_extra_files { | ||||||||||||||||||||||||||||||
|
Subroutine
write_extra_files: not called CC=12 SCAR=50.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 104 | ######################################################################## | ||||||||||||||||||||||||||||||||
| 105 | 0 | my ( $self, %params ) = @_; | |||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||
| 107 | 0 | $self->get_logger->debug('writing extra-files'); | |||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||
| 109 | 0 | my ( $extra_files, $extra, $project_root ) = @params{qw(extra_files extra project_root)}; | |||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||
| 111 | 0 | ▶ | $extra_files //= []; | ||||||||||||||||||||||||||||||
|
Condition0%0/2
$extra_files //= []
MC/DC0%0/1
$extra_files //= []
$extra_files
Truth table0%0/2
A
A= $extra_files
| |||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||
| 113 | 0 | ▶ | die "ERROR: extra-files must be an array!\n" . Dumper( [ $extra_files, \%params ] ) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 114 | if !is_array($extra_files); | ||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||
| 116 | 0 | ▶ | my $extra_files_path = $extra || 'extra-files'; | ||||||||||||||||||||||||||||||
|
Condition0%0/2
$extra || 'extra-files'
MC/DC0%0/1
$extra || 'extra-files'
$extra
Truth table0%0/2
A
A= $extra
| |||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||
| 118 | 0 | my @file_list; | |||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||
| 120 | 0 | foreach my $e ( @{$extra_files} ) { | |||||||||||||||||||||||||||||||
| 121 | 0 | $self->get_logger->debug( Dumper( [ extra => $e ] ) ); | |||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||
| 123 | 0 | ▶ | if ( !ref $e ) { # file or directory | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 124 | 0 | push @file_list, | |||||||||||||||||||||||||||||||
| 125 | $self->fetch_file_list( | ||||||||||||||||||||||||||||||||
| 126 | file_list => [$e], | ||||||||||||||||||||||||||||||||
| 127 | destination => $EMPTY, | ||||||||||||||||||||||||||||||||
| 128 | project_root => $project_root, | ||||||||||||||||||||||||||||||||
| 129 | ); | ||||||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||||
| 131 | elsif ( is_hash($e) ) { | ||||||||||||||||||||||||||||||||
| 132 | # if the extra-files entry is a hash, then the key of that hash | ||||||||||||||||||||||||||||||||
| 133 | # represents the destination directory. The value must be an | ||||||||||||||||||||||||||||||||
| 134 | # array of scalars that can represent individual files within | ||||||||||||||||||||||||||||||||
| 135 | # the project or whole directories within the project that | ||||||||||||||||||||||||||||||||
| 136 | # should be written to the destination directory | ||||||||||||||||||||||||||||||||
| 137 | # | ||||||||||||||||||||||||||||||||
| 138 | # DO NOT DO THIS... | ||||||||||||||||||||||||||||||||
| 139 | # extra-files: | ||||||||||||||||||||||||||||||||
| 140 | # - t: foo.t | ||||||||||||||||||||||||||||||||
| 141 | # | ||||||||||||||||||||||||||||||||
| 142 | # DO THIS INSTEAD... | ||||||||||||||||||||||||||||||||
| 143 | # extra-files: | ||||||||||||||||||||||||||||||||
| 144 | # - t: | ||||||||||||||||||||||||||||||||
| 145 | # - foo.t | ||||||||||||||||||||||||||||||||
| 146 | # | ||||||||||||||||||||||||||||||||
| 147 | # | ||||||||||||||||||||||||||||||||
| 148 | 0 | my ($destdir) = keys %{$e}; | |||||||||||||||||||||||||||||||
| 149 | 0 | my $file_list = $e->{$destdir}; | |||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||
| 151 | 0 | ▶ | die "ERROR: directory args for extra-files must be an array!\n" | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 152 | if !is_array($file_list); | ||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||
| 154 | 0 | push @file_list, | |||||||||||||||||||||||||||||||
| 155 | $self->fetch_file_list( | ||||||||||||||||||||||||||||||||
| 156 | file_list => $file_list, | ||||||||||||||||||||||||||||||||
| 157 | destination => $destdir, | ||||||||||||||||||||||||||||||||
| 158 | project_root => $project_root, | ||||||||||||||||||||||||||||||||
| 159 | ); | ||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||
| 164 | return | ||||||||||||||||||||||||||||||||
| 165 | 0 | ▶ | if !@file_list; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||
| 167 | 0 | ▶ | open my $fh, '>', $extra_files_path | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 168 | or die "ERROR: could not append to $extra_files_path\n"; | ||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||
| 170 | 0 | foreach my $f (@file_list) { | |||||||||||||||||||||||||||||||
| 171 | 0 | print {$fh} "$f\n"; | |||||||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||
| 174 | 0 | ▶ | close $fh | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 175 | or die "ERROR: could not close $extra_files_path\n"; | ||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||
| 177 | # NOTE: 'extra' (the extra-files output path) has no corresponding | ||||||||||||||||||||||||||||||||
| 178 | # CLI::Simple accessor (not in option_specs, no extra_options | ||||||||||||||||||||||||||||||||
| 179 | # declared) -- there is currently nowhere valid to apply this | ||||||||||||||||||||||||||||||||
| 180 | # value. The file is still written to $extra_files_path above; | ||||||||||||||||||||||||||||||||
| 181 | # only the tracking of that path is unapplied here. | ||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||
| 183 | 0 | return; | |||||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||
| 186 | ######################################################################## | ||||||||||||||||||||||||||||||||
| 187 | 0 | ▶ | sub parse_path { | ||||||||||||||||||||||||||||||
|
Subroutine
parse_path: not called CC=13 SCAR=52.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 188 | ######################################################################## | ||||||||||||||||||||||||||||||||
| 189 | 0 | my ( $self, $project_root, $path ) = @_; | |||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||
| 191 | 0 | ▶ | if ($path) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 192 | 0 | ▶ | if ( $path->{recurse} | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
$path->{"recurse"} and $path->{"recurse"} =~ /(yes|no)/imsx
MC/DC0%0/2
$path->{"recurse"} and $path->{"recurse"} =~ /(yes|no)/imsx
$path->{"recurse"}
$path->{"recurse"} =~ /(yes|no)/imsx
Truth table0%0/3
A and B
A= $path->{"recurse"}B= $path->{"recurse"} =~ /(yes|no)/imsx
| |||||||||||||||||||||||||||||||||
| 193 | && $path->{recurse} =~ /(yes|no)/ixsm ) { | ||||||||||||||||||||||||||||||||
| 194 | 0 | ▶ | $self->set_recurse( $path->{recurse} eq 'yes' ? $TRUE : $FALSE ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||||||
| 196 | elsif ( $path->{recurse} ) { | ||||||||||||||||||||||||||||||||
| 197 | 0 | die "ERROR: use only yes or no for 'recurse' option\n"; | |||||||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||
| 200 | 0 | ▶ | if ( $path->{'pm-module'} ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 201 | 0 | $self->set_module_path( $path->{'pm-module'} ); | |||||||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||
| 204 | # NOTE: 'exclude-files' has no corresponding CLI::Simple accessor | ||||||||||||||||||||||||||||||||
| 205 | # (not in option_specs, no extra_options declared) -- there is | ||||||||||||||||||||||||||||||||
| 206 | # currently nowhere valid to apply this buildspec.yml value. Left | ||||||||||||||||||||||||||||||||
| 207 | # unapplied rather than guessing at an attribute name that | ||||||||||||||||||||||||||||||||
| 208 | # doesn't exist. | ||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||
| 210 | 0 | ▶ | if ( $path->{'exe-files'} ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 211 | 0 | ▶ | if ( $self->check_path( $project_root, $path->{'exe-files'}, 'exe-files' ) ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 212 | 0 | $self->set_exec_path( $path->{'exe-files'} ); | |||||||||||||||||||||||||||||||
| 213 | } | ||||||||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||
| 216 | 0 | ▶ | if ( $path->{scripts} ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 217 | 0 | ▶ | if ( $self->check_path( $project_root, $path->{scripts}, 'scripts' ) ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 218 | 0 | $self->set_scripts_path( $path->{scripts} ); | |||||||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||
| 222 | 0 | ▶ | if ( $path->{tests} ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 223 | 0 | ▶ | if ( $self->check_path( $project_root, $path->{tests}, 'tests' ) ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 224 | 0 | $self->set_tests_path( $path->{tests} ); | |||||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||
| 229 | 0 | return; | |||||||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||
| 232 | ######################################################################## | ||||||||||||||||||||||||||||||||
| 233 | 0 | ▶ | sub check_path { | ||||||||||||||||||||||||||||||
|
Subroutine
check_path: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 234 | ######################################################################## | ||||||||||||||||||||||||||||||||
| 235 | 0 | my ( $self, $project_root, $path, $option_name ) = @_; | |||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||
| 237 | 0 | ▶ | die sprintf "ERROR: '%s' must be a scalar representing a path not %s\n", $option_name, reftype($path) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 238 | if ref $path; | ||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||
| 240 | 0 | ▶ | my $exists = $path =~ /^\//xsm ? -d $path : -d "$project_root/$path"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||
| 242 | 0 | ▶ | if ( !$exists ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 243 | 0 | warn "WARNING: ** `$path` does not exist or is inaccessible.\n"; | |||||||||||||||||||||||||||||||
| 244 | 0 | warn "WARNING: ** paths should be absolute or relative to $project_root\n"; | |||||||||||||||||||||||||||||||
| 245 | 0 | warn "WARNING: ** Consider removing entry from your buildspec.yml file if this is expected.\n"; | |||||||||||||||||||||||||||||||
| 246 | 0 | return $FALSE; | |||||||||||||||||||||||||||||||
| 247 | } | ||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||
| 249 | 0 | return $TRUE; | |||||||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||
| 252 | ######################################################################## | ||||||||||||||||||||||||||||||||
| 253 | 0 | ▶ | sub create_temp_filelist { | ||||||||||||||||||||||||||||||
|
Subroutine
create_temp_filelist: not called CC=8 SCAR=42.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 254 | ######################################################################## | ||||||||||||||||||||||||||||||||
| 255 | 0 | my ( $self, $project_root, $filelist ) = @_; | |||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||
| 257 | 0 | ▶ | if ( ref $filelist && reftype($filelist) eq 'ARRAY' ) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
ref $filelist and builtin::reftype($filelist) eq "ARRAY"
MC/DC0%0/2
ref $filelist and builtin::reftype($filelist) eq "ARRAY"
ref $filelist
builtin::reftype($filelist) eq "ARRAY"
Truth table0%0/3
A and B
A= ref $filelistB= builtin::reftype($filelist) eq "ARRAY"
| |||||||||||||||||||||||||||||||||
| 258 | 0 | my ( $fh, $filename ) = tempfile( 'make-cpan-dist-XXXXX', TMPDIR => $TRUE ); | |||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||
| 260 | 0 | foreach my $file ( @{$filelist} ) { | |||||||||||||||||||||||||||||||
| 261 | 0 | ▶ | my $path = $file =~ /^\//xsm ? $file : "$project_root/$file"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||
| 263 | 0 | ▶ | die "ERROR: no such file $path\n" | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 264 | if !-e $path; | ||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||
| 266 | 0 | print {$fh} "$path\n"; | |||||||||||||||||||||||||||||||
| 267 | } | ||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||
| 269 | 0 | close $fh; | |||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||
| 271 | 0 | return $filename; | |||||||||||||||||||||||||||||||
| 272 | } | ||||||||||||||||||||||||||||||||
| 273 | elsif ( !ref $filelist ) { | ||||||||||||||||||||||||||||||||
| 274 | 0 | ▶ | return $filelist | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 275 | if -e $filelist; | ||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||
| 277 | 0 | die "ERROR: no such file $filelist\n"; | |||||||||||||||||||||||||||||||
| 278 | } | ||||||||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||
| 281 | ######################################################################## | ||||||||||||||||||||||||||||||||
| 282 | 0 | ▶ | sub fetch_relative_filelist { | ||||||||||||||||||||||||||||||
|
Subroutine
fetch_relative_filelist: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 283 | ######################################################################## | ||||||||||||||||||||||||||||||||
| 284 | 0 | my ( $self, $project_root, $file ) = @_; | |||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||
| 286 | 0 | my @file_list = grep { !!$_ } split /\n/xsm, slurp($file); | |||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||
| 288 | 0 | foreach (@file_list) { | |||||||||||||||||||||||||||||||
| 289 | 0 | s/$project_root\/?//xsm; | |||||||||||||||||||||||||||||||
| 290 | } | ||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||
| 292 | 0 | return \@file_list; | |||||||||||||||||||||||||||||||
| 293 | } | ||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||
| 295 | 1 | 1; | |||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||
| 297 | __END__ | ||||||||||||||||||||||||||||||||