| 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]
MC/DC0%0/1
delete $args{'-tempdir'} || ['CLEANUP', 1, 'TMPDIR', 1]
delete $args{'-tempdir'}
Truth table50%1/2
A
A= delete $args{'-tempdir'}
| |||||||||||||
| 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
| |||||||||||||
| 34 | # Subdirectory | ||||||||||||
| 35 | 2 | ▶ | mkdir($fq) or die "Could not make dir '$fq': $!"; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 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
| |||||||||||||
| 40 | 4 | print $fh $inside; | |||||||||||
| 41 | 4 | close($fh); | |||||||||||
| 42 | } | ||||||||||||
| 43 | } | ||||||||||||
| 44 | } | ||||||||||||
| 45 | |||||||||||||
| 46 | 1 | 1; | |||||||||||
| 47 | |||||||||||||
| 48 | __END__ | ||||||||||||