blib/lib/Test2/Tools/GenTemp.pm

filter: Statementstmt 100% 33 / 33 Branchbran 66.6% 4 / 6 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 7 / 7 Podpod 50.0% 1 / 2 totaltotal 90.2% 46 / 51 CC 6 SCAR 10.5
CC
6
Cov
93%
gen_dir
5.0
gen_temp
2.0
BEGIN
1.0
CRAP 2.9
« blib/lib/Test2/Compare/Scalar.pm ↑ Summary blib/lib/Test2/Compare/Custom.pm »
1 package Test2::Tools::GenTemp;
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 our $VERSION = '1.302226';
7  
8 1 ▶use File::Temp qw/tempdir/;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use File::Spec;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 1 our @EXPORT = qw{gen_temp};
12 1 ▶use base 'Exporter';
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 1 ▶sub gen_temp {
Subroutine gen_temp: called CC=2 SCAR=7.0
Pod documented
15 1 my %args = @_;
16  
17 1 ▶ my $tempdir_args = delete $args{'-tempdir'} || [CLEANUP => 1, TMPDIR => 1];
Condition50%1/2
delete $args{'-tempdir'} || ['CLEANUP', 1, 'TMPDIR', 1]
l!l
10
MC/DC0%0/1
delete $args{'-tempdir'} || ['CLEANUP', 1, 'TMPDIR', 1]
delete $args{'-tempdir'}
Truth table50%1/2
A
A= delete $args{'-tempdir'}
Aresult
11
00
18  
19 1 my $tmp = tempdir(@$tempdir_args);
20  
21 1 gen_dir($tmp, \%args);
22  
23 1 return $tmp;
24 }
25  
26 3 ▶sub gen_dir {
Subroutine gen_dir: called CC=5 SCAR=16.2
Pod undocumented
27 3 my ($dir, $content) = @_;
28  
29 3 for my $path (keys %$content) {
30 6 my $fq = File::Spec->catfile($dir, $path);
31 6 my $inside = $content->{$path};
32  
33 6 ▶ if (ref $inside) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $inside) { } 2 4 6
34 # Subdirectory
35 2 ▶ mkdir($fq) or die "Could not make dir '$fq': $!";
Branch: 1 branch
BranchTrueFalseTotal
mkdir $fq or die "Could not make dir '${fq}': $!" 2 0 2
36 2 gen_dir($fq, $inside);
37 }
38 else {
39 4 ▶ open(my $fh, '>', $fq) or die "Could not open file '$fq' for writing: $!";
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, ">", $fq or die "Could not open file '${fq}' for writing: $!" 4 0 4
40 4 print $fh $inside;
41 4 close($fh);
42 }
43 }
44 }
45  
46 1 1;
47  
48 __END__
« blib/lib/Test2/Compare/Scalar.pm ↑ Summary blib/lib/Test2/Compare/Custom.pm »