File Coverage

blib/lib/BioX/Workflow/Command/run/Rules/Directives/Types/Mustache.pm
Criterion Covered Total %
statement 18 32 56.2
branch 0 2 0.0
condition n/a
subroutine 6 9 66.6
pod 0 3 0.0
total 24 46 52.1


line stmt bran cond sub pod time code
1             package BioX::Workflow::Command::run::Rules::Directives::Types::Mustache;
2              
3 1     1   1234 use Moose::Role;
  1         4  
  1         8  
4 1     1   4482 use namespace::autoclean;
  1         3  
  1         6  
5              
6 1     1   446 use Template::Mustache;
  1         147799  
  1         46  
7 1     1   535 use Template::Mustache::Trait;
  1         8358  
  1         45  
8 1     1   11 use File::Glob;
  1         3  
  1         62  
9 1     1   8 use File::Basename;
  1         4  
  1         327  
10              
11             after 'BUILD' => sub {
12             my $self = shift;
13              
14             $self->set_register_types(
15             'mustache',
16             {
17             builder => 'create_reg_attr',
18             lookup => ['.*_mustache$']
19             }
20             );
21              
22             $self->set_register_process_directives( 'mustache',
23             { builder => 'process_directive_mustache', lookup => ['.*_mustache$'] }
24             );
25             };
26              
27             sub process_directive_mustache {
28 0     0 0   my $self = shift;
29 0           my $k = shift;
30 0           my $v = shift;
31              
32 0           return $v;
33             }
34              
35             sub create_mustache_attr {
36 0     0 0   my $self = shift;
37 0           my $meta = shift;
38 0           my $k = shift;
39              
40 0           $meta->add_attribute(
41             $k => (
42             is => 'rw',
43             traits => ['Mustache'],
44             handles => {
45             'render_' . $k => 'render',
46             },
47             lazy_build => 1,
48             )
49             );
50             }
51              
52             sub render_mustache {
53 0     0 0   my $self = shift;
54 0           my $template = shift;
55 0           my $print = shift;
56              
57 0           my $text = Template::Mustache->render( $template, $self );
58 0 0         print $text if $print;
59 0           return $text;
60             }
61              
62             1;