line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
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.153; # TRIAL |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# ABSTRACT: role to read or write configuration files |
13
|
|
|
|
|
|
|
|
14
|
59
|
|
|
59
|
|
30800
|
use strict; |
|
59
|
|
|
|
|
198
|
|
|
59
|
|
|
|
|
1904
|
|
15
|
59
|
|
|
59
|
|
365
|
use warnings; |
|
59
|
|
|
|
|
249
|
|
|
59
|
|
|
|
|
1499
|
|
16
|
59
|
|
|
59
|
|
368
|
use Carp; |
|
59
|
|
|
|
|
205
|
|
|
59
|
|
|
|
|
3243
|
|
17
|
59
|
|
|
59
|
|
783
|
use 5.10.0; |
|
59
|
|
|
|
|
293
|
|
18
|
|
|
|
|
|
|
|
19
|
59
|
|
|
59
|
|
586
|
use Mouse::Util; |
|
59
|
|
|
|
|
210
|
|
|
59
|
|
|
|
|
509
|
|
20
|
59
|
|
|
59
|
|
5623
|
use Log::Log4perl qw(get_logger :levels); |
|
59
|
|
|
|
|
200
|
|
|
59
|
|
|
|
|
438
|
|
21
|
59
|
|
|
59
|
|
8668
|
use Path::Tiny; |
|
59
|
|
|
|
|
195
|
|
|
59
|
|
|
|
|
3374
|
|
22
|
|
|
|
|
|
|
|
23
|
59
|
|
|
59
|
|
447
|
use Mouse::Role; |
|
59
|
|
|
|
|
222
|
|
|
59
|
|
|
|
|
448
|
|
24
|
|
|
|
|
|
|
|
25
|
59
|
|
|
59
|
|
20065
|
use Config::Model::TypeConstraints; |
|
59
|
|
|
|
|
157
|
|
|
59
|
|
|
|
|
17441
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
my $logger = get_logger("FileHandler"); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# used only for tests |
30
|
|
|
|
|
|
|
sub _set_test_home { |
31
|
14
|
|
|
14
|
|
9784
|
Config::Model::TypeConstraints::_set_test_home(shift) ; |
32
|
14
|
|
|
|
|
38
|
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
|
|
|
|
|
|
|
has config_dir => ( is => 'ro', isa => 'Config::Model::TypeContraints::Path', required => 0 ); |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub get_tuned_config_dir { |
41
|
367
|
|
|
367
|
0
|
1668
|
my ($self, %args) = @_; |
42
|
|
|
|
|
|
|
|
43
|
367
|
|
100
|
|
|
3221
|
my $dir = $args{os_config_dir}{$^O} || $args{config_dir} || $self->config_dir || ''; |
44
|
367
|
100
|
|
|
|
1746
|
if ( $dir =~ /^~/ ) { |
45
|
|
|
|
|
|
|
# because of tests, we can't rely on Path::Tiny's tilde processing |
46
|
|
|
|
|
|
|
# TODO: should this be my_config ? May be once this is done: |
47
|
|
|
|
|
|
|
# https://github.com/perl5-utils/File-HomeDir/pull/5/files |
48
|
|
|
|
|
|
|
# beware of compat and migration issues |
49
|
4
|
|
33
|
|
|
25
|
my $home = &Config::Model::TypeConstraints::_get_test_home || File::HomeDir->my_home; |
50
|
4
|
|
|
|
|
20
|
$dir =~ s/^~/$home/; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
367
|
100
|
|
|
|
3000
|
return $args{root} ? $args{root}->child($dir) |
|
|
100
|
|
|
|
|
|
54
|
|
|
|
|
|
|
: $dir ? path($dir) |
55
|
|
|
|
|
|
|
: path ('.'); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
1; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
__END__ |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=pod |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=encoding UTF-8 |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 NAME |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
Config::Model::Role::FileHandler - role to read or write configuration files |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 VERSION |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
version 2.153 |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 SYNOPSIS |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 DESCRIPTION |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Role used to handle configuration files on the behalf of a backend. |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 METHODS |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 AUTHOR |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
Dominique Dumont |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
This software is Copyright (c) 2005-2022 by Dominique Dumont. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
This is free software, licensed under: |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
The GNU Lesser General Public License, Version 2.1, February 1999 |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=cut |