lib/Convert/Pheno/Operations.pm

filter: Statementstmt 100% 65 / 65 Branchbran 55.5% 20 / 36 Conditioncond 39.2% 11 / 28 MC/DCmcdc 0.0% 0 / 16 Subroutinesub 100% 14 / 14 Podpod 0.0% 0 / 6 totaltotal 66.6% 110 / 165 CC 12 SCAR 13.6
CC
12
Cov
74%
registry_metadata
9.4
is_public_conversion
4.4
is_http_conversion
3.2
CRAP 3.9
« lib/Convert/Pheno/BFF/Biosample.pm ↑ Summary lib/Convert/Pheno/CDISC/ODM/V1.pm »
1 package Convert::Pheno::Operations;
2  
3 136 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 136 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 136 ▶use Exporter 'import';
Subroutine BEGIN: called CC=1 SCAR=0.0
7 136 ▶use File::ShareDir::ProjectDistDir qw(dist_dir);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 136 ▶use File::Spec::Functions qw(catfile);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 136 ▶use JSON::XS qw(decode_json);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 136 ▶use Path::Tiny qw(path);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 136 ▶use Storable qw(dclone);
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 136 our @EXPORT_OK = qw(
14 conversion_spec
15 http_request_fields
16 is_http_conversion
17 is_public_conversion
18 public_conversions
19 registry_metadata
20 );
21  
22 136 my $registry_file =
23 catfile( dist_dir('Convert-Pheno'), 'schema', 'public-conversions.json' );
24 136 my $registry = decode_json( path($registry_file)->slurp_raw );
25 136 ▶die "Public conversion registry <$registry_file> must contain an object\n"
Branch: 1 branch
BranchTrueFalseTotal
unless ref $registry eq "HASH" 0 136 136
26 unless ref($registry) eq 'HASH';
27 die "Public conversion registry <$registry_file> has an unsupported schema version\n"
28 136 ▶ unless $registry->{schema_version} && $registry->{schema_version} == 1;
Branch: 1 branch
BranchTrueFalseTotal
unless $registry->{"schema_version"} and $registry->{"schema_version"} == 1 0 136 136
Condition33%1/3
$registry->{"schema_version"} and $registry->{"schema_version"} == 1
!ll&&!rl&&r
00136
MC/DC0%0/2
$registry->{"schema_version"} and $registry->{"schema_version"} == 1
$registry->{"schema_version"} $registry->{"schema_version"} == 1
Truth table33%1/3
A and B
A= $registry->{"schema_version"}B= $registry->{"schema_version"} == 1
ABresult
0X0
100
111
29 die "Public conversion registry <$registry_file> must define conversions\n"
30 136 ▶ unless ref( $registry->{conversions} ) eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $registry->{"conversions"} eq "HASH" 0 136 136
31 die "Public conversion registry <$registry_file> must define HTTP request fields\n"
32 136 ▶ unless ref( $registry->{http_request_fields} ) eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $registry->{"http_request_fields"} eq "HASH" 0 136 136
33  
34 136 my %PUBLIC_CONVERSION = %{ $registry->{conversions} };
35  
36 136 for my $name ( keys %PUBLIC_CONVERSION ) {
37 5984 my $spec = $PUBLIC_CONVERSION{$name};
38 5984 ▶ die "Conversion <$name> must contain an object specification\n"
Branch: 1 branch
BranchTrueFalseTotal
unless ref $spec eq "HASH" 0 5984 5984
39 unless ref($spec) eq 'HASH';
40  
41 5984 for my $field (qw(source target operation pipeline resources entities streaming http_enabled)) {
42 die "Conversion <$name> is missing registry field <$field>\n"
43 47872 ▶ unless exists $spec->{$field};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $spec->{$field} 0 47872 47872
44 }
45  
46 die "Conversion <$name> has an invalid operation type\n"
47 5984 ▶ unless $spec->{operation} =~ /\A(?:bundle|direct|pipeline)\z/;
Branch: 1 branch
BranchTrueFalseTotal
unless $spec->{"operation"} =~ /\A(?:bundle|direct|pipeline)\z/ 0 5984 5984
48 die "Conversion <$name> must define a non-empty pipeline\n"
49 5984 ▶ unless ref( $spec->{pipeline} ) eq 'ARRAY' && @{ $spec->{pipeline} };
Branch: 1 branch
BranchTrueFalseTotal
unless ref $spec->{"pipeline"} eq "ARRAY" and @{$spec->{"pipeline"};} 0 5984 5984
Condition33%1/3
ref $spec->{"pipeline"} eq "ARRAY" and @{$spec->{"pipeline"};}
!ll&&!rl&&r
005984
MC/DC0%0/2
ref $spec->{"pipeline"} eq "ARRAY" and @{$spec->{"pipeline"};}
ref $spec->{"pipeline"} eq "ARRAY" @{$spec->{"pipeline"};}
Truth table33%1/3
A and B
A= ref $spec->{"pipeline"} eq "ARRAY"B= @{$spec->{"pipeline"};}
ABresult
0X0
100
111
50 die "Conversion <$name> must define SQLite resource requirements\n"
51 unless ref( $spec->{resources} ) eq 'HASH'
52 5984 ▶ && exists $spec->{resources}{sqlite};
Branch: 1 branch
BranchTrueFalseTotal
unless ref $spec->{"resources"} eq "HASH" and exists $spec->{"resources"}{"sqlite"} 0 5984 5984
Condition33%1/3
ref $spec->{"resources"} eq "HASH" and exists $spec->{"resources"}{"sqlite"}
!ll&&!rl&&r
005984
MC/DC0%0/2
ref $spec->{"resources"} eq "HASH" and exists $spec->{"resources"}{"sqlite"}
ref $spec->{"resources"} eq "HASH" exists $spec->{"resources"}{"sqlite"}
Truth table33%1/3
A and B
A= ref $spec->{"resources"} eq "HASH"B= exists $spec->{"resources"}{"sqlite"}
ABresult
0X0
100
111
53 die "Conversion <$name> must define entity capabilities\n"
54 unless ref( $spec->{entities} ) eq 'HASH'
55 && ref( $spec->{entities}{default} ) eq 'ARRAY'
56 5984 ▶ && ref( $spec->{entities}{supported} ) eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $spec->{"entities"} eq "HASH" and ref $spec->{"entities"}{"default"} eq "ARRAY" and ref $spec->{"entities"}{"supported"} eq "ARRAY" 0 5984 5984
Condition33%2/6
ref $spec->{"entities"} eq "HASH" and ref $spec->{"entities"}{"default"} eq "ARRAY" and ref $spec->{"entities"}{"supported"} eq "ARRAY"
!ll&&!rl&&r
005984
ref $spec->{"entities"} eq "HASH" and ref $spec->{"entities"}{"default"} eq "ARRAY"
!ll&&!rl&&r
005984
MC/DC0%0/3
ref $spec->{"entities"} eq "HASH" and ref $spec->{"entities"}{"default"} eq "ARRAY" and ref $spec->{"entities"}{"supported"} eq "ARRAY"
ref $spec->{"entities"} eq "HASH" ref $spec->{"entities"}{"default"} eq "ARRAY" ref $spec->{"entities"}{"supported"} eq "ARRAY"
Truth table25%1/4
A and B and C
A= ref $spec->{"entities"} eq "HASH"B= ref $spec->{"entities"}{"default"} eq "ARRAY"C= ref $spec->{"entities"}{"supported"} eq "ARRAY"
ABCresult
0XX0
10X0
1100
1111
57 }
58  
59 136 for my $section (qw(input output options)) {
60 die "HTTP request registry section <$section> must contain an array\n"
61 408 ▶ unless ref( $registry->{http_request_fields}{$section} ) eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $registry->{"http_request_fields"}{$section} eq "ARRAY" 0 408 408
62 }
63  
64 136 for my $name ( keys %PUBLIC_CONVERSION ) {
65 5984 for my $stage ( @{ $PUBLIC_CONVERSION{$name}{pipeline} } ) {
66 die "Conversion <$name> references unknown pipeline stage <$stage>\n"
67 9112 ▶ unless exists $PUBLIC_CONVERSION{$stage};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $PUBLIC_CONVERSION{$stage} 0 9112 9112
68 die "Conversion <$name> references compound pipeline stage <$stage>\n"
69 9112 ▶ if $PUBLIC_CONVERSION{$stage}{operation} eq 'pipeline';
Branch: 1 branch
BranchTrueFalseTotal
if $PUBLIC_CONVERSION{$stage}{"operation"} eq "pipeline" 0 9112 9112
70 }
71 }
72  
73 6009 ▶sub is_public_conversion {
Subroutine is_public_conversion: called CC=4 SCAR=14.9
Pod undocumented
74 6009 my ($conversion) = @_;
75 6009 ▶ return 0 unless defined $conversion && !ref($conversion);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $conversion and not ref $conversion 0 6009 6009
Condition33%1/3
defined $conversion and not ref $conversion
!ll&&!rl&&r
006009
MC/DC0%0/2
defined $conversion and not ref $conversion
defined $conversion not ref $conversion
Truth table33%1/3
A and not(B)
A= defined $conversionB= not ref $conversion
ABresult
0X0
100
111
76 6009 ▶ return exists $PUBLIC_CONVERSION{$conversion} ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
exists $PUBLIC_CONVERSION{$conversion} ? : 6003 6 6009
77 }
78  
79 38 ▶sub public_conversions {
Subroutine public_conversions: called CC=1 SCAR=0.0
Pod undocumented
80 38 return [ sort keys %PUBLIC_CONVERSION ];
81 }
82  
83 4174 ▶sub conversion_spec {
Subroutine conversion_spec: called CC=2 SCAR=6.9
Pod undocumented
84 4174 my ($conversion) = @_;
85 4174 ▶ return unless is_public_conversion($conversion);
Branch: 1 branch
BranchTrueFalseTotal
unless is_public_conversion($conversion) 1 4173 4174
86  
87 4173 my $spec = dclone( $PUBLIC_CONVERSION{$conversion} );
88 4173 $spec->{name} = $conversion;
89 4173 return $spec;
90 }
91  
92 1663 ▶sub is_http_conversion {
Subroutine is_http_conversion: called CC=3 SCAR=11.7
Pod undocumented
93 1663 my ($conversion) = @_;
94 1663 ▶ return 0 unless is_public_conversion($conversion);
Branch: 1 branch
BranchTrueFalseTotal
unless is_public_conversion($conversion) 0 1663 1663
95 1663 ▶ return $PUBLIC_CONVERSION{$conversion}{http_enabled} ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$PUBLIC_CONVERSION{$conversion}{'http_enabled'} ? : 1663 0 1663
96 }
97  
98 1 ▶sub http_request_fields {
Subroutine http_request_fields: called CC=1 SCAR=0.0
Pod undocumented
99 1 return dclone( $registry->{http_request_fields} );
100 }
101  
102 106 ▶sub registry_metadata {
Subroutine registry_metadata: called CC=6 SCAR=22.4
Pod undocumented
103 return dclone(
104 {
105 formats => $registry->{formats} || {},
106 input_definitions => $registry->{input_definitions} || {},
107 option_definitions => $registry->{option_definitions} || {},
108 resources => $registry->{resources} || {},
109 http_profiles => $registry->{http_profiles} || {},
110 }
111 106 ▶ );
Condition50%5/10
$registry->{'formats'} || {}
l!l
1060
$registry->{'input_definitions'} || {}
l!l
1060
$registry->{'option_definitions'} || {}
l!l
1060
$registry->{'resources'} || {}
l!l
1060
$registry->{'http_profiles'} || {}
l!l
1060
MC/DC0%0/1
$registry->{'formats'} || {}
$registry->{'formats'}
MC/DC0%0/1
$registry->{'input_definitions'} || {}
$registry->{'input_definitions'}
MC/DC0%0/1
$registry->{'option_definitions'} || {}
$registry->{'option_definitions'}
MC/DC0%0/1
$registry->{'resources'} || {}
$registry->{'resources'}
MC/DC0%0/1
$registry->{'http_profiles'} || {}
$registry->{'http_profiles'}
Truth table50%1/2
A
A= $registry->{'formats'}
Aresult
11
00
Truth table50%1/2
A
A= $registry->{'input_definitions'}
Aresult
11
00
Truth table50%1/2
A
A= $registry->{'option_definitions'}
Aresult
11
00
Truth table50%1/2
A
A= $registry->{'resources'}
Aresult
11
00
Truth table50%1/2
A
A= $registry->{'http_profiles'}
Aresult
11
00
112 }
113  
114 136 1;
« lib/Convert/Pheno/BFF/Biosample.pm ↑ Summary lib/Convert/Pheno/CDISC/ODM/V1.pm »