Workflow/Config/YAML.pm

filter: Statementstmt 92.5% 50 / 54 Branchbran 66.6% 8 / 12 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 10 / 10 Podpod 100% 1 / 1 totaltotal 85.3% 70 / 82 CC 9 SCAR 13.9
CC
9
Cov
86%
parse
7.8
_translate_yaml
3.0
BEGIN
1.0
CRAP 4.0
« Workflow/Persister/DBI.pm ↑ Summary Workflow/Config/Perl.pm »
1 package Workflow::Config::YAML;
2  
3 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use v5.14.0;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use parent qw( Workflow::Config );
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use Log::Any qw( $log );
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use Workflow::Exception qw( configuration_error );
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use Syntax::Keyword::Try;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 2 $Workflow::Config::YAML::VERSION = '2.12';
13  
14 2 my $YAML_REQUIRED = 0;
15  
16 1 ▶sub parse {
Subroutine parse: called CC=7 SCAR=20.6
Pod documented
17 1 my ( $self, $type, @items ) = @_;
18  
19 1 $self->_check_config_type($type);
20 1 my @config_items = Workflow::Config::_expand_refs(@items);
21 1 ▶ return () unless ( scalar @config_items );
Branch: 1 branch
BranchTrueFalseTotal
unless scalar @config_items 0 1 1
22  
23 1 my @config = ();
24 1 foreach my $item (@config_items) {
25 4 ▶ my $file_name = ( ref $item ) ? '[scalar ref]' : $item;
Branch: 1 branch
BranchTrueFalseTotal
ref $item ? : 0 4 4
26 4 $log->info("Will parse '$type' YAML config file '$file_name'");
27 4 my $this_config = do {
28 try {
29 4 $self->_translate_yaml( $type, $item );
30 }
31 4 catch ($error) {
32 0 croak $log->error("Processing $file_name: ", $error);
33 }
34 };
35 4 $log->info("Parsed YAML '$file_name' ok");
36 4 my $key = $self->get_config_type_tag($type);
37 4 ▶ if ( exists $this_config->{'type'} ) {
Branch: 2 branches
BranchTrueFalseTotal
if (exists $this_config->{'type'}) { } 1 3 4
elsif ($type eq 'persister' and ref $this_config->{'persister'} eq 'ARRAY') { } 0 3 3
38 1 push @config, $this_config;
39 }
40 ▶ elsif ( $type eq 'persister'
Condition33%1/3
$type eq "persister" and ref $this_config->{"persister"} eq "ARRAY"
!ll&&!rl&&r
300
MC/DC0%0/2
$type eq "persister" and ref $this_config->{"persister"} eq "ARRAY"
$type eq "persister" ref $this_config->{"persister"} eq "ARRAY"
Truth table33%1/3
A and B
A= $type eq "persister"B= ref $this_config->{"persister"} eq "ARRAY"
ABresult
0X0
100
111
41 and ref $this_config->{'persister'} eq 'ARRAY' ) {
42 0 push @config, @{ $this_config->{'persister'} };
43 }
44 else {
45 3 push @config, $this_config;
46 }
47 }
48 1 return @config;
49 }
50  
51 4 ▶sub _translate_yaml {
Subroutine _translate_yaml: called CC=3 SCAR=11.1
52 4 my ( $self, $type, $item ) = @_;
53  
54 4 ▶ unless ( $YAML_REQUIRED ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($YAML_REQUIRED) 1 3 4
55 1 require YAML;
56 1 YAML->import( qw( Load LoadFile ) );
57 1 $YAML_REQUIRED++;
58 }
59  
60 4 ▶ if ( ref $item ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $item) { } 0 4 4
61 0 return Load( $$item );
62 }
63 else {
64 4 return LoadFile( $item );
65 }
66 }
67  
68 2 1;
69  
70  
71 __END__
« Workflow/Persister/DBI.pm ↑ Summary Workflow/Config/Perl.pm »