Connector/Role/LocalPath.pm

filter: Statementstmt 93.7% 30 / 32 Branchbran 66.6% 8 / 12 Conditioncond 50.0% 2 / 4 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 4 / 4 Podpod n/a totaltotal 81.4% 44 / 54 CC 9 SCAR 20.4
CC
9
Cov
83%
_render_local_path
10.0
BEGIN
1.0
BEGIN
1.0
CRAP 7.7
« Connector/Proxy/Proc/SafeExec.pm ↑ Summary Connector/Builtin/Memory.pm »
1 package Connector::Role::LocalPath;
2 4 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 4 ▶use Template;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 4 requires 'DELIMITER';
7  
8 4 has file => (
9 is => 'rw',
10 isa => 'Str',
11 );
12  
13 4 has path => (
14 is => 'rw',
15 isa => 'Str',
16 );
17  
18  
19 25 ▶sub _render_local_path {
Subroutine _render_local_path: called CC=9 SCAR=23.0
20  
21 25 my $self = shift;
22 25 ▶ my $args = shift || [];
Condition50%1/2
shift() || []
l!l
250
MC/DC0%0/1
shift() || []
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
23 25 my $data = shift;
24  
25 25 my $file;
26 25 ▶ if ($self->path()) {
Branch: 3 branches
BranchTrueFalseTotal
if ($self->path) { } 1 24 25
elsif ($self->file) { } 22 2 24
elsif (ref $args and scalar @{$args;}) { } 2 0 2
27 1 my $pattern = $self->path();
28 1 $self->log()->debug('Process template ' . $pattern);
29 1 ▶ Template->new({})->process( \$pattern, { ARGS => $args, DATA => $data }, \$file) || die "Error processing file template.";
Branch: 1 branch
BranchTrueFalseTotal
"Template"->new({})->process(\$pattern, {"ARGS", $args, "DATA", $data}, \$file) or die "Error processing file template." 1 0 1
30 # yes we allow paths here
31 1 $file =~ s/[^\s\w\.\-\/\\]//g;
32 } elsif ($self->file()) {
33 22 my $pattern = $self->file();
34 22 $self->log()->debug('Process template ' . $pattern);
35 22 ▶ Template->new({})->process( \$pattern, { ARGS => $args, DATA => $data }, \$file) || die "Error processing argument template.";
Branch: 1 branch
BranchTrueFalseTotal
"Template"->new({})->process(\$pattern, {"ARGS", $args, "DATA", $data}, \$file) or die "Error processing argument template." 22 0 22
36 22 ▶ if ($file =~ m{[^\s\w\.\-]}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($file =~ /[^\s\w\.\-]/) 0 22 22
37 0 $self->log()->error('Target file name contains disallowed characters! Consider using path instead.');
38 0 die "Target file name contains disallowed seperator! Consider using path instead.";
39 }
40 2 ▶ } elsif (ref $args && scalar @{$args}) {
Condition50%1/2
ref $args and scalar @{$args;}
!ll
02
MC/DC0%0/1
ref $args and scalar @{$args;}
ref $args
Truth table50%1/2
A
A= ref $args
Aresult
00
11
41 2 $file = join $self->DELIMITER(), @{$args};
42 }
43  
44 25 return $file;
45 }
46  
47 4 1;
48  
49 __END__;
« Connector/Proxy/Proc/SafeExec.pm ↑ Summary Connector/Builtin/Memory.pm »