« blib/lib/BioX/Workflow/Command/Exceptions.pm
↑ Summary
blib/lib/BioX/Workflow/Command/run/Utils/Samples.pm »
| 1 | package BioX::Workflow::Command::run::Rules::Directives::Interpolate::Text; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use Moose::Role; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use Text::Template; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use Try::Tiny; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use Safe; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use Storable qw(dclone); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use File::Spec; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use Memoize; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 1 | ▶ | use File::Basename; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 1 | our $c = new Safe; | |||||||||||||||||||||||||||
| 15 | 1 | my $TEMPLATE_ERROR = 0; | |||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | sub interpol_directive { | ||||||||||||||||||||||||||||
| 18 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
interpol_directive: not called CC=8 SCAR=42.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 19 | 0 | my $source = shift; | |||||||||||||||||||||||||||
| 20 | 0 | my $text = ''; | |||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 0 | $TEMPLATE_ERROR = 0; | |||||||||||||||||||||||||||
| 23 | #The $ is not always at the beginning | ||||||||||||||||||||||||||||
| 24 | 0 | ▶ | if ( exists $self->interpol_directive_cache->{$source} && $source !~ m/{/ ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
exists $self->interpol_directive_cache->{$source} and not $source =~ /{/
MC/DC0%0/2
exists $self->interpol_directive_cache->{$source} and not $source =~ /{/
exists $self->interpol_directive_cache->{$source}
not $source =~ /{/
Truth table0%0/3
A and not(B)
A= exists $self->interpol_directive_cache->{$source}B= not $source =~ /{/
| |||||||||||||||||||||||||||||
| 25 | { | ||||||||||||||||||||||||||||
| 26 | 0 | return $self->interpol_directive_cache->{$source}; | |||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | 0 | ▶ | if ( $source !~ m/{/ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 30 | 0 | $self->interpol_directive_cache->{$source} = $source; | |||||||||||||||||||||||||||
| 31 | 0 | return $source; | |||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 0 | my $template = Text::Template->new( | |||||||||||||||||||||||||||
| 35 | TYPE => 'STRING', | ||||||||||||||||||||||||||||
| 36 | SOURCE => $source, | ||||||||||||||||||||||||||||
| 37 | SAFE => $c, | ||||||||||||||||||||||||||||
| 38 | ); | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 0 | my $fill_in = { self => \$self }; | |||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 0 | ▶ | $fill_in->{sample} = $self->sample if $self->has_sample; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 0 | $text = $template->fill_in( | |||||||||||||||||||||||||||
| 45 | HASH => $fill_in, | ||||||||||||||||||||||||||||
| 46 | BROKEN => \&my_broken, | ||||||||||||||||||||||||||||
| 47 | PREPEND => "use File::Glob; use File::Slurp; use File::Basename;\n" | ||||||||||||||||||||||||||||
| 48 | ); | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | 0 | ▶ | if($TEMPLATE_ERROR){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 51 | 0 | $self->_ERROR(1); | |||||||||||||||||||||||||||
| 52 | 0 | ▶ | if($source =~ m/self/ && $source !~ m/\$self/){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$source =~ /self/ and not $source =~ /\$self/
MC/DC0%0/2
$source =~ /self/ and not $source =~ /\$self/
$source =~ /self/
not $source =~ /\$self/
Truth table0%0/3
A and not(B)
A= $source =~ /self/B= not $source =~ /\$self/
| |||||||||||||||||||||||||||||
| 53 | 0 | $text .= "######################################\nFound use of self without \$\n\n"; | |||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||
| 56 | 0 | $self->interpol_directive_cache->{$source} = $text; | |||||||||||||||||||||||||||
| 57 | 0 | return $text; | |||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | # memoize('my_broken'); | ||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | sub my_broken { | ||||||||||||||||||||||||||||
| 63 | 0 | ▶ | my %args = @_; | ||||||||||||||||||||||||||
|
Subroutine
my_broken: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 64 | 0 | my $err_ref = $args{arg}; | |||||||||||||||||||||||||||
| 65 | 0 | my $text = $args{text}; | |||||||||||||||||||||||||||
| 66 | 0 | my $error = $args{error}; | |||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | 0 | $TEMPLATE_ERROR = 1; | |||||||||||||||||||||||||||
| 69 | 0 | $error =~ s/via package.*//g; | |||||||||||||||||||||||||||
| 70 | 0 | chomp($error); | |||||||||||||||||||||||||||
| 71 | 0 | ▶ | if ( $error =~ m/Can't locate object method/ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 72 | 0 | $error .= "\n# Did you declare $text?"; | |||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | 0 | return <<EOF; | |||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | ################################################### | ||||||||||||||||||||||||||||
| 78 | # The following errors were encountered: | ||||||||||||||||||||||||||||
| 79 | # $text | ||||||||||||||||||||||||||||
| 80 | # $error | ||||||||||||||||||||||||||||
| 81 | #################################################### | ||||||||||||||||||||||||||||
| 82 | EOF | ||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | 1 | 1; | |||||||||||||||||||||||||||