Branch Coverage

blib/lib/Config/Abstraction.pm
Criterion Covered Total %
branch 138 250 55.2


line true false branch
321 1 23 if (scalar @_ == 1) { }
330 1 5 if (not defined $params->{'config_dirs'} and $params->{'file'})
334 6 18 unless (defined $params->{'config_dirs'})
335 1 5 if ($params->{'config_file'} and 'File::Spec'->file_name_is_absolute($params->{'config_file'})) { }
339 5 0 if ($^O ne 'MSWin32') { }
344 5 0 if ($ENV{'HOME'}) { }
0 0 elsif ($ENV{'DOCUMENT_ROOT'}) { }
355 0 5 if (my $dir = $ENV{'CONFIG_DIR'}) { }
365 0 24 $params->{'defaults'} ? :
370 0 24 if (my $logger = $self->{'logger'})
371 0 0 unless (builtin::blessed($logger))
374 0 0 if ($params->{'level'} and $self->{'logger'}->can("level"))
381 1 23 if (my $schema = $params->{'schema'})
385 22 1 if (defined $self->{'config'} and scalar keys %{$$self{"config"};})
393 0 24 unless (UNIVERSAL::isa((&CORE::GLOBAL::caller())[0], __PACKAGE__))
400 7 17 if ($self->{'data'})
406 0 24 if ($logger)
411 0 24 if ($self->{'config_file'} and scalar @dirs > 1)
412 0 0 if ('File::Spec'->file_name_is_absolute($self->{'config_file'})) { }
421 0 54 unless defined $dir
422 25 29 if (length $dir and not -d $dir)
428 0 290 if ($logger)
431 258 32 unless -f $path
432 0 32 unless -r $path
434 0 32 if ($logger)
440 7 25 if ($file =~ /\.ya?ml$/) { }
5 20 elsif ($file =~ /\.json$/) { }
10 10 elsif ($file =~ /\.xml$/) { }
10 0 elsif ($file =~ /\.ini$/) { }
443 0 7 if $@
446 0 5 if $@
449 0 10 if ($self->_load_driver("XML::Simple", ["XMLin"]))
451 0 0 if ($@) { }
0 0 elsif ($rc) { }
452 0 0 if ($logger) { }
462 10 0 if (not defined $rc and $self->_load_driver("XML::PP"))
465 10 0 if (my $tree = $xml_pp->parse(\$data))
466 10 0 if ($data = $xml_pp->collapse_structure($tree))
468 10 0 if ($data->{'config'})
476 10 0 if (my $ini = 'Config::IniFiles'->new('-file', $path)) { }
482 0 0 if ($logger) { }
489 32 0 if ($data)
490 0 32 unless (ref $data)
491 0 0 if ($logger)
496 0 32 if (ref $data ne "HASH")
497 0 0 if ($logger)
502 0 32 if ($logger)
511 24 5 unless ($self->{'script_name'})
512 0 24 unless "File::Basename"->can("basename")
520 18 160 unless defined $config_file
523 4 25 if $config_file eq $script_name and length $dir == 0 || $dir eq 'File::Spec'->curdir
524 137 19 length $dir ? :
525 0 156 if ($logger)
528 13 143 if (-f $path and -r $path)
530 0 13 if ($logger)
534 7 6 if ($data =~ /^\s*<\?xml/ or $data =~ m[]) { }
0 6 elsif ($data =~ /\{.+:.\}/s) { }
535 0 7 if ($self->_load_driver('XML::Simple', ['XMLin'])) { }
7 0 elsif ($self->_load_driver('XML::PP')) { }
536 0 0 if ($data = XMLin($path, "ForceArray", 0, "KeyAttr", scalar []))
541 7 0 if (my $tree = $xml_pp->parse(\$data))
542 7 0 if ($data = $xml_pp->collapse_structure($tree))
544 7 0 if ($data->{'config'})
555 0 0 if ($is_json) { }
557 0 0 if ($@)
563 0 0 if ($data)
569 6 7 unless ($data)
571 5 1 if (eval { do { $data = LoadFile($path) } } and ref $data eq "HASH")
576 0 19 unless (defined $v)
583 0 19 if $v =~ /^".+"$/
584 4 15 if ($v =~ /,/)
588 8 0 if ($val =~ /(.+)=(.+)/) { }
596 5 0 if ($data)
600 1 5 if (not $data or ref $data ne "HASH")
602 0 1 if (my $ini = "Config::IniFiles"->new("-file", $path))
607 0 0 if ($data)
611 1 0 if (not $data or ref $data ne "HASH")
613 0 1 if ($self->_load_driver("XML::Simple", ["XMLin"]))
616 1 0 if (not $data or ref $data ne "HASH")
617 0 1 if ($self->_load_driver("Config::Abstract"))
624 0 0 if ($err) { }
0 0 elsif ($data) { }
628 0 0 if (scalar keys %{$data;} == 0)
635 1 0 if (not $data or ref $data ne "HASH")
638 1 0 if ($data = $ca->parse)
646 0 13 if ($logger)
647 0 0 if ($@) { }
654 2 11 if (scalar keys %merged) { }
11 0 elsif ($data and ref $data eq 'HASH') { }
0 0 elsif (not $@ and $logger) { }
655 2 0 if ($data)
675 513 14 unless $key =~ /^$self->{'env_prefix'}(.*)$/i
677 10 4 if ($path =~ /__/) { }
689 0 1 unless $arg =~ /=/
691 0 1 unless $key =~ /^\-\-$self->{'env_prefix'}(.*)$/
695 1 0 if (scalar @parts > 0)
697 0 1 if (scalar @parts > 1)
704 2 22 if ($self->{'flatten'}) { }
711 2 22 $self->{'flatten'} ? :
725 2 26 if ($self->{'flatten'})
730 0 41 unless ref $ref eq "HASH"
733 24 2 if (defined $ref and not $self->{'no_fixate'})
734 24 0 unless ($self->{'reuse_loaded'})
739 0 24 unless ($@)
743 0 24 if ($self->{'reuse_loaded'})
744 0 0 if (ref $ref eq 'HASH') { }
0 0 elsif (ref $ref eq 'ARRAY') { }
766 0 1 if ($self->{'flatten'})
771 0 2 unless ref $ref eq "HASH"
772 0 2 unless exists $ref->{$part}
791 11 0 $self->{'config'} && scalar keys %{$$self{'config'};} ? :
843 0 4 if scalar @_ == 0
847 2 2 unless defined $defaults
852 0 2 if ($config->{'global'})
853 0 0 if ($params->{'deep'}) { }
860 0 0 if ($section and $config->{$section})
863 1 1 if ($params->{'merge'})
874 12 73 if $self->{'loaded'}{$driver}
875 5 68 if $self->{'failed'}{$driver}
878 14 54 if ($@)
879 0 14 if (my $logger = $self->{'logger'})
927 24 8 if $key eq "DESTROY"
935 3 5 if ($self->{'flatten'})
936 0 3 if exists $data->{$key}
944 13 1 if (ref $val eq 'HASH' and exists $val->{$part}) { }