| 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() || []
MC/DC0%0/1
shift() || []
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||
| 23 | 25 | my $data = shift; | |||||||||||||||||
| 24 | |||||||||||||||||||
| 25 | 25 | my $file; | |||||||||||||||||
| 26 | 25 | ▶ | if ($self->path()) { | ||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||
| 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
| |||||||||||||||||||
| 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
| |||||||||||||||||||
| 36 | 22 | ▶ | if ($file =~ m{[^\s\w\.\-]}) { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 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;}
MC/DC0%0/1
ref $args and scalar @{$args;}
ref $args
Truth table50%1/2
A
A= ref $args
| |||||||||||||||||||
| 41 | 2 | $file = join $self->DELIMITER(), @{$args}; | |||||||||||||||||
| 42 | } | ||||||||||||||||||
| 43 | |||||||||||||||||||
| 44 | 25 | return $file; | |||||||||||||||||
| 45 | } | ||||||||||||||||||
| 46 | |||||||||||||||||||
| 47 | 4 | 1; | |||||||||||||||||
| 48 | |||||||||||||||||||
| 49 | __END__; | ||||||||||||||||||