blib/lib/Config/Model/Role/FileHandler.pm

filter: Statementstmt 100% 37 / 37 Branchbran 100% 6 / 6 Conditioncond 72.7% 8 / 11 MC/DCmcdc 40.0% 2 / 5 Subroutinesub 100% 11 / 11 Podpod 0.0% 0 / 1 totaltotal 90.1% 64 / 71 CC 8 SCAR 14.3
CC
8
Cov
94%
get_tuned_config_dir
8.1
BEGIN
1.0
BEGIN
1.0
CRAP 4.2
« blib/lib/Config/Model/ListId.pm ↑ Summary blib/lib/Config/Model/Backend/ShellVar.pm »
1 #
2 # This file is part of Config-Model
3 #
4 # This software is Copyright (c) 2005-2022 by Dominique Dumont.
5 #
6 # This is free software, licensed under:
7 #
8 # The GNU Lesser General Public License, Version 2.1, February 1999
9 #
10 package Config::Model::Role::FileHandler 2.169;
11  
12 # ABSTRACT: role to read or write configuration files
13  
14 59 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 59 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 59 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 59 ▶use 5.10.0;
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 59 ▶use Mouse::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 59 ▶use Log::Log4perl qw(get_logger :levels);
Subroutine BEGIN: called CC=1 SCAR=0.0
21 59 ▶use Path::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 59 ▶use Mouse::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
24  
25 59 ▶use Config::Model::TypeConstraints;
Subroutine BEGIN: called CC=1 SCAR=0.0
26  
27 59 my $logger = get_logger("FileHandler");
28  
29 # used only for tests
30 13 ▶sub _set_test_home {
Subroutine _set_test_home: called CC=1 SCAR=0.0
31 13 Config::Model::TypeConstraints::_set_test_home(shift) ;
32 13 return;
33 }
34  
35 # Configuration directory where to read and write files. This value
36 # does not override the configuration directory specified in the model
37 # data passed to read and write functions.
38 59 has config_dir => ( is => 'ro', isa => 'Config::Model::TypeContraints::Path', required => 0 );
39  
40 405 ▶sub get_tuned_config_dir {
Subroutine get_tuned_config_dir: called CC=8 SCAR=21.0
Pod undocumented
41 405 my ($self, %args) = @_;
42  
43 405 ▶ my $dir = $args{os_config_dir}{$^O} || $args{config_dir} || $self->config_dir || '';
Condition87%7/8
$args{'os_config_dir'}{$^O} || $args{'config_dir'} || $self->config_dir || ''
l!l
38916
$args{"os_config_dir"}{$^O} or $args{"config_dir"} or $self->config_dir
l!l&&r!l&&!r
3791016
$args{"os_config_dir"}{$^O} or $args{"config_dir"}
l!l&&r!l&&!r
037926
MC/DC66%2/3
$args{'os_config_dir'}{$^O} || $args{'config_dir'} || $self->config_dir || ''
$args{"os_config_dir"}{$^O} $args{"config_dir"} $self->config_dir
Truth table75%3/4
A or B or C
A= $args{"os_config_dir"}{$^O}B= $args{"config_dir"}C= $self->config_dir
ABCresult
1XX1
01X1
0011
0000
44 405 ▶ if ( $dir =~ /^~/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dir =~ /^~/) 4 401 405
45 # because of tests, we can't rely on Path::Tiny's tilde processing
46 4 ▶ my $home = &Config::Model::TypeConstraints::_get_test_home || File::HomeDir->my_home;
Condition33%1/3
&Config::Model::TypeConstraints::_get_test_home || 'File::HomeDir'->my_home
l!l&&r!l&&!r
400
MC/DC0%0/2
&Config::Model::TypeConstraints::_get_test_home || 'File::HomeDir'->my_home
&Config::Model::TypeConstraints::_get_test_home 'File::HomeDir'->my_home
Truth table33%1/3
A || B
A= &Config::Model::TypeConstraints::_get_test_homeB= 'File::HomeDir'->my_home
ABresult
1X1
011
000
47 4 $dir =~ s/^~/$home/;
48 }
49  
50 405 ▶ return $args{root} ? $args{root}->child($dir)
Branch: 2 branches
BranchTrueFalseTotal
$args{'root'} ? : 205 200 405
$dir ? : 184 16 200
51 : $dir ? path($dir)
52 : path ('.');
53 }
54  
55 59 1;
56  
57 __END__
« blib/lib/Config/Model/ListId.pm ↑ Summary blib/lib/Config/Model/Backend/ShellVar.pm »