| 1 | package Pheno::Ranker::Config; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 8 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 8 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | 8 | ▶ | use Hash::Util qw(lock_hash); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 8 | ▶ | use Moo; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 8 | ▶ | use Types::Standard qw(ArrayRef Enum HashRef Int Str); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||
| 10 | 8 | ▶ | use Pheno::Ranker::IO; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | has file => ( | ||||||||||||||||||||||||||||||||||||||||||
| 13 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 14 | required => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 15 | 40 | ▶ | isa => sub { die "Config file '$_[0]' is not a valid file" unless -e $_[0] }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.6
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | 8 | ); | |||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | 8 | has raw => ( | |||||||||||||||||||||||||||||||||||||||||
| 19 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 20 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 21 | builder => '_build_raw', | ||||||||||||||||||||||||||||||||||||||||||
| 22 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||
| 24 | has sort_by => ( | ||||||||||||||||||||||||||||||||||||||||||
| 25 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 26 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 27 | 37 | ▶ | default => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | 37 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 29 | 37 | ▶ | return exists $self->raw->{sort_by} ? $self->raw->{sort_by} : 'hamming'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 30 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 31 | 8 | isa => Enum [qw(hamming jaccard)], | |||||||||||||||||||||||||||||||||||||||||
| 32 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||
| 34 | has similarity_metric_cohort => ( | ||||||||||||||||||||||||||||||||||||||||||
| 35 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 36 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 37 | 37 | ▶ | default => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 38 | 37 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 39 | return exists $self->raw->{similarity_metric_cohort} | ||||||||||||||||||||||||||||||||||||||||||
| 40 | ? $self->raw->{similarity_metric_cohort} | ||||||||||||||||||||||||||||||||||||||||||
| 41 | 37 | ▶ | : 'hamming'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 42 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 43 | 8 | isa => Enum [qw(hamming jaccard)], | |||||||||||||||||||||||||||||||||||||||||
| 44 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||
| 46 | has matrix_format => ( | ||||||||||||||||||||||||||||||||||||||||||
| 47 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 48 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 49 | 37 | ▶ | default => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 50 | 37 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 51 | return exists $self->raw->{matrix_format} | ||||||||||||||||||||||||||||||||||||||||||
| 52 | ? $self->raw->{matrix_format} | ||||||||||||||||||||||||||||||||||||||||||
| 53 | 37 | ▶ | : 'dense'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 54 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 55 | 8 | isa => Enum [qw(dense mtx)], | |||||||||||||||||||||||||||||||||||||||||
| 56 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||
| 58 | has max_out => ( | ||||||||||||||||||||||||||||||||||||||||||
| 59 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 60 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 61 | 37 | ▶ | default => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 62 | 37 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 63 | 37 | ▶ | return exists $self->raw->{max_out} ? $self->raw->{max_out} : 50; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 64 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 65 | 8 | isa => Int, | |||||||||||||||||||||||||||||||||||||||||
| 66 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||
| 68 | has max_number_vars => ( | ||||||||||||||||||||||||||||||||||||||||||
| 69 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 70 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 71 | 37 | ▶ | default => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 72 | 37 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 73 | return exists $self->raw->{max_number_vars} | ||||||||||||||||||||||||||||||||||||||||||
| 74 | ? $self->raw->{max_number_vars} | ||||||||||||||||||||||||||||||||||||||||||
| 75 | 37 | ▶ | : 10_000; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 76 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 77 | 8 | isa => Int, | |||||||||||||||||||||||||||||||||||||||||
| 78 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||
| 80 | has max_matrix_records_in_ram => ( | ||||||||||||||||||||||||||||||||||||||||||
| 81 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 82 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 83 | 37 | ▶ | default => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.2
| |||||||||||||||||||||||||||||||||||||||||||
| 84 | 37 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 85 | return exists $self->raw->{max_matrix_records_in_ram} | ||||||||||||||||||||||||||||||||||||||||||
| 86 | ? $self->raw->{max_matrix_records_in_ram} | ||||||||||||||||||||||||||||||||||||||||||
| 87 | 37 | ▶ | : 5_000; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 88 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 89 | 8 | isa => Int, | |||||||||||||||||||||||||||||||||||||||||
| 90 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||
| 92 | has allowed_terms => ( | ||||||||||||||||||||||||||||||||||||||||||
| 93 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 94 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 95 | 10 | ▶ | default => sub { shift->raw->{allowed_terms} }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 96 | 8 | isa => ArrayRef, | |||||||||||||||||||||||||||||||||||||||||
| 97 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||
| 99 | has primary_key => ( | ||||||||||||||||||||||||||||||||||||||||||
| 100 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 101 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 102 | 37 | ▶ | default => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 103 | 37 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 104 | 37 | ▶ | return exists $self->raw->{primary_key} ? $self->raw->{primary_key} : 'id'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 105 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 106 | 8 | ); | |||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||
| 108 | has exclude_variables_regex => ( | ||||||||||||||||||||||||||||||||||||||||||
| 109 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 110 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 111 | 37 | ▶ | default => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 112 | 37 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 113 | return exists $self->raw->{exclude_variables_regex} | ||||||||||||||||||||||||||||||||||||||||||
| 114 | ? $self->raw->{exclude_variables_regex} | ||||||||||||||||||||||||||||||||||||||||||
| 115 | 37 | ▶ | : undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 116 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 117 | 8 | ); | |||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||
| 119 | has exclude_variables_regex_qr => ( | ||||||||||||||||||||||||||||||||||||||||||
| 120 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 121 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 122 | 37 | ▶ | default => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 123 | 37 | my $regex = shift->exclude_variables_regex; | |||||||||||||||||||||||||||||||||||||||||
| 124 | 37 | ▶ | return defined $regex ? qr/$regex/ : undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 125 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 126 | 8 | ); | |||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||
| 128 | has array_terms => ( | ||||||||||||||||||||||||||||||||||||||||||
| 129 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 130 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 131 | 39 | ▶ | default => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 132 | 39 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 133 | 39 | ▶ | return $self->_config_value( 'indexed_terms', 'array_terms' ) // ['foo']; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->_config_value("indexed_terms", "array_terms") // ["foo"]
MC/DC100%1/1
$self->_config_value("indexed_terms", "array_terms") // ["foo"]
$self->_config_value("indexed_terms", "array_terms")
Truth table100%2/2
A
A= $self->_config_value("indexed_terms", "array_terms")
| |||||||||||||||||||||||||||||||||||||||||||
| 134 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 135 | 8 | isa => ArrayRef, | |||||||||||||||||||||||||||||||||||||||||
| 136 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||
| 138 | has array_regex => ( | ||||||||||||||||||||||||||||||||||||||||||
| 139 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 140 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 141 | 37 | ▶ | default => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 142 | 37 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 143 | 37 | ▶ | return defined $self->_config_value( 'index_regex', 'array_regex' ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 144 | ? $self->_config_value( 'index_regex', 'array_regex' ) | ||||||||||||||||||||||||||||||||||||||||||
| 145 | : '^([^:]+):(\d+)'; | ||||||||||||||||||||||||||||||||||||||||||
| 146 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 147 | 8 | ); | |||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||
| 149 | has array_regex_qr => ( | ||||||||||||||||||||||||||||||||||||||||||
| 150 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 151 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 152 | 37 | ▶ | default => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 153 | 37 | my $regex = shift->array_regex; | |||||||||||||||||||||||||||||||||||||||||
| 154 | 37 | return qr/$regex/; | |||||||||||||||||||||||||||||||||||||||||
| 155 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 156 | 8 | ); | |||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||
| 158 | has array_terms_regex_str => ( | ||||||||||||||||||||||||||||||||||||||||||
| 159 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 160 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 161 | 37 | ▶ | default => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 162 | 37 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 163 | 37 | return '^(' . join( '|', map { "\Q$_\E" } @{ $self->array_terms } ) . '):'; | |||||||||||||||||||||||||||||||||||||||||
| 164 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 165 | 8 | ); | |||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||
| 167 | has array_terms_regex_qr => ( | ||||||||||||||||||||||||||||||||||||||||||
| 168 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 169 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 170 | 37 | ▶ | default => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 171 | 37 | my $regex = shift->array_terms_regex_str; | |||||||||||||||||||||||||||||||||||||||||
| 172 | 37 | return qr/$regex/; | |||||||||||||||||||||||||||||||||||||||||
| 173 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 174 | 8 | ); | |||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||
| 176 | has format => ( | ||||||||||||||||||||||||||||||||||||||||||
| 177 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 178 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 179 | 38 | ▶ | default => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 180 | 38 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 181 | 38 | ▶ | return exists $self->raw->{format} ? $self->raw->{format} : undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 182 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 183 | 8 | ); | |||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||
| 185 | has seed => ( | ||||||||||||||||||||||||||||||||||||||||||
| 186 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 187 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 188 | 37 | ▶ | default => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||
| 189 | 37 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 190 | 37 | ▶ | my $seed = exists $self->raw->{seed} ? $self->raw->{seed} : undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 191 | 37 | ▶ | return defined $seed && Int->check($seed) ? $seed : 123456789; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $seed and &Int()->check($seed)
MC/DC50%1/2
defined $seed and &Int()->check($seed)
defined $seed
&Int()->check($seed)
Truth table66%2/3
A and B
A= defined $seedB= &Int()->check($seed)
| |||||||||||||||||||||||||||||||||||||||||||
| 192 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 193 | 8 | isa => Int, | |||||||||||||||||||||||||||||||||||||||||
| 194 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||
| 196 | has id_correspondence => ( | ||||||||||||||||||||||||||||||||||||||||||
| 197 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 198 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 199 | 39 | ▶ | default => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 200 | 39 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 201 | 39 | return $self->_config_value( 'identity_paths', 'id_correspondence' ); | |||||||||||||||||||||||||||||||||||||||||
| 202 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 203 | 8 | ); | |||||||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||||||||
| 205 | 150 | ▶ | sub _config_value { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_config_value: called CC=4 SCAR=14.6
| |||||||||||||||||||||||||||||||||||||||||||
| 206 | 150 | my ( $self, $primary, $legacy ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 207 | 150 | ▶ | return $self->raw->{$primary} if exists $self->raw->{$primary}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 208 | 6 | ▶ | return $self->raw->{$legacy} if defined $legacy && exists $self->raw->{$legacy}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $legacy and exists $self->raw->{$legacy}
MC/DC0%0/2
defined $legacy and exists $self->raw->{$legacy}
defined $legacy
exists $self->raw->{$legacy}
Truth table33%1/3
A and B
A= defined $legacyB= exists $self->raw->{$legacy}
| |||||||||||||||||||||||||||||||||||||||||||
| 209 | 6 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||
| 212 | 40 | ▶ | sub BUILD { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BUILD: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 213 | 40 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 214 | 40 | $self->raw; | |||||||||||||||||||||||||||||||||||||||||
| 215 | 39 | $self->_validate_id_correspondence; | |||||||||||||||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||
| 218 | 40 | ▶ | sub _build_raw { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_raw: called CC=4 SCAR=14.0
| |||||||||||||||||||||||||||||||||||||||||||
| 219 | 40 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 220 | 40 | my $config = read_yaml( $self->file ); | |||||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||||||
| 222 | 40 | ▶ | unless ( exists $config->{allowed_terms} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
exists $config->{"allowed_terms"} and &ArrayRef()->check($config->{"allowed_terms"}) and @{$config->{"allowed_terms"};}
exists $config->{"allowed_terms"} and &ArrayRef()->check($config->{"allowed_terms"})
MC/DC33%1/3
exists $config->{"allowed_terms"} and &ArrayRef()->check($config->{"allowed_terms"}) and @{$config->{"allowed_terms"};}
exists $config->{"allowed_terms"}
&ArrayRef()->check($config->{"allowed_terms"})
@{$config->{"allowed_terms"};}
Truth table50%2/4
A and B and C
A= exists $config->{"allowed_terms"}B= &ArrayRef()->check($config->{"allowed_terms"})C= @{$config->{"allowed_terms"};}
| |||||||||||||||||||||||||||||||||||||||||||
| 223 | && ArrayRef->check( $config->{allowed_terms} ) | ||||||||||||||||||||||||||||||||||||||||||
| 224 | 39 | && @{ $config->{allowed_terms} } ) | |||||||||||||||||||||||||||||||||||||||||
| 225 | { | ||||||||||||||||||||||||||||||||||||||||||
| 226 | 1 | die "No <allowed terms> provided or not an array ref at " . $self->file . "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||
| 229 | 39 | lock_hash(%$config); | |||||||||||||||||||||||||||||||||||||||||
| 230 | 39 | return $config; | |||||||||||||||||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||
| 233 | 39 | ▶ | sub _validate_id_correspondence { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_validate_id_correspondence: called CC=9 SCAR=22.1
| |||||||||||||||||||||||||||||||||||||||||||
| 234 | 39 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 235 | 39 | ▶ | return if $self->array_terms->[0] eq 'foo'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||
| 237 | 38 | ▶ | unless ( defined $self->id_correspondence ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 238 | 2 | ▶ | return if defined $self->format && $self->format eq 'JSON'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $self->format and $self->format eq "JSON"
MC/DC50%1/2
defined $self->format and $self->format eq "JSON"
defined $self->format
$self->format eq "JSON"
Truth table66%2/3
A and B
A= defined $self->formatB= $self->format eq "JSON"
| |||||||||||||||||||||||||||||||||||||||||||
| 239 | 1 | die "No <identity_paths> provided or not a hash ref at " . $self->file . "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||||||
| 242 | 36 | ▶ | die "No <identity_paths> provided or not a hash ref at " . $self->file . "\n" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 243 | unless HashRef->check( $self->id_correspondence ); | ||||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||
| 245 | 36 | ▶ | if ( exists $self->raw->{format} && Str->check( $self->raw->{format} ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
exists $self->raw->{"format"} and &Str()->check($self->raw->{"format"})
MC/DC50%1/2
exists $self->raw->{"format"} and &Str()->check($self->raw->{"format"})
exists $self->raw->{"format"}
&Str()->check($self->raw->{"format"})
Truth table66%2/3
A and B
A= exists $self->raw->{"format"}B= &Str()->check($self->raw->{"format"})
| |||||||||||||||||||||||||||||||||||||||||||
| 246 | die "<" . $self->raw->{format} . "> does not match any key from <identity_paths>\n" | ||||||||||||||||||||||||||||||||||||||||||
| 247 | 4 | ▶ | unless exists $self->id_correspondence->{ $self->raw->{format} }; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||
| 251 | 74 | ▶ | sub validate_terms { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
validate_terms: called CC=3 SCAR=11.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 252 | 74 | my ( $self, @terms ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||
| 254 | 74 | for my $term (@terms) { | |||||||||||||||||||||||||||||||||||||||||
| 255 | die | ||||||||||||||||||||||||||||||||||||||||||
| 256 | "Invalid term '$term' in <--include_terms> or <--exclude_terms>. Allowed values are: " | ||||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | . join( ', ', @{ $self->allowed_terms } ) . "\n" | |||||||||||||||||||||||||||||||||||||||||
| 258 | 11 | ▶ | unless grep { $_ eq $term } @{ $self->allowed_terms }; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||
| 261 | 74 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 262 | } | ||||||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||||
| 264 | 37 | ▶ | sub apply_to { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
apply_to: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 265 | 37 | my ( $self, $ranker ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||||||||||
| 267 | 37 | for my $attribute ( | |||||||||||||||||||||||||||||||||||||||||
| 268 | qw( | ||||||||||||||||||||||||||||||||||||||||||
| 269 | primary_key exclude_variables_regex exclude_variables_regex_qr | ||||||||||||||||||||||||||||||||||||||||||
| 270 | array_terms array_regex array_regex_qr array_terms_regex_str | ||||||||||||||||||||||||||||||||||||||||||
| 271 | array_terms_regex_qr format seed id_correspondence | ||||||||||||||||||||||||||||||||||||||||||
| 272 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 273 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 274 | { | ||||||||||||||||||||||||||||||||||||||||||
| 275 | 407 | $ranker->{$attribute} = $self->$attribute; | |||||||||||||||||||||||||||||||||||||||||
| 276 | } | ||||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||
| 278 | 37 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||||||||
| 281 | 8 | 1; | |||||||||||||||||||||||||||||||||||||||||