blib/lib/BioX/Workflow/Command/run/Rules/Directives/Interpolate/Text.pm

filter: Statementstmt 50.8% 30 / 59 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 81.8% 9 / 11 Podpod 0.0% 0 / 2 totaltotal 41.4% 39 / 94 CC 9 SCAR 34.5
CC
9
Cov
39%
interpol_directive
72.0
my_broken
6.0
BEGIN
1.0
CRAP 31.4
« 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
BranchTrueFalseTotal
if (exists $self->interpol_directive_cache->{$source} and not $source =~ /{/) 0 0 0
Condition0%0/3
exists $self->interpol_directive_cache->{$source} and not $source =~ /{/
!ll&&!rl&&r
000
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 =~ /{/
ABresult
0X0
100
111
25 {
26 0 return $self->interpol_directive_cache->{$source};
27 }
28  
29 0 ▶ if ( $source !~ m/{/ ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($source =~ /{/) 0 0 0
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
BranchTrueFalseTotal
if $self->has_sample 0 0 0
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
BranchTrueFalseTotal
if ($TEMPLATE_ERROR) 0 0 0
51 0 $self->_ERROR(1);
52 0 ▶ if($source =~ m/self/ && $source !~ m/\$self/){
Branch: 1 branch
BranchTrueFalseTotal
if ($source =~ /self/ and not $source =~ /\$self/) 0 0 0
Condition0%0/3
$source =~ /self/ and not $source =~ /\$self/
!ll&&!rl&&r
000
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/
ABresult
0X0
100
111
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
BranchTrueFalseTotal
if ($error =~ /Can't locate object method/) 0 0 0
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;
« blib/lib/BioX/Workflow/Command/Exceptions.pm ↑ Summary blib/lib/BioX/Workflow/Command/run/Utils/Samples.pm »