lib/BioX/Workflow/Command/run/Rules/Directives/Types/CSV.pm

filter: Statementstmt 46.8% 15 / 32 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 66.6% 4 / 6 Podpod 0.0% 0 / 1 totaltotal 44.1% 19 / 43 CC 3 SCAR 16.6
CC
3
Cov
42%
process_directive_csv
12.0
__ANON__
2.0
BEGIN
1.0
CRAP 5.2
« lib/BioX/Workflow/Command.pm ↑ Summary lib/BioX/Workflow/Command/run/Rules/Directives/Functions.pm »
1 package BioX::Workflow::Command::run::Rules::Directives::Types::CSV;
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::CSV::Slurp;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 with 'BioX::Workflow::Command::run::Rules::Directives::Types::Roles::File';
9  
10 0 ▶after 'BUILD' => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
11 0 my $self = shift;
12  
13 0 $self->set_register_types(
14 'csv',
15 {
16 builder => 'create_reg_attr',
17 lookup => ['.*csv$']
18 }
19 );
20  
21 0 $self->set_register_process_directives( 'csv',
22 { builder => 'process_directive_csv', lookup => ['.*_csv$'] } );
23 1 };
24  
25 0 ▶sub process_directive_csv {
Subroutine process_directive_csv: not called CC=3 SCAR=24.8
Pod undocumented
26 0 my $self = shift;
27 0 my $k = shift;
28 0 my $v = shift;
29  
30 0 my $file = $self->check_file_exists( $k, $v );
31 0 ▶ return unless $file;
Branch: 1 branch
BranchTrueFalseTotal
unless $file 0 0 0
32  
33 0 my $data = Text::CSV::Slurp->load( file => $file );
34  
35 0 ▶ if ( exists $v->{key} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $v->{"key"}) 0 0 0
36 0 my $key = $v->{key};
37 0 my %hoh = map { $_->{$key} => $_ } @{$data};
38 0 $self->$k( \%hoh );
39 0 return;
40 }
41  
42 0 $self->$k($data);
43 }
44  
45 1 ▶no Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
46  
47 1 1;
« lib/BioX/Workflow/Command.pm ↑ Summary lib/BioX/Workflow/Command/run/Rules/Directives/Functions.pm »