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
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# ABSTRACT: role to read or write configuration files |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
use strict; |
14
|
59
|
|
|
59
|
|
27208
|
use warnings; |
|
59
|
|
|
|
|
164
|
|
|
59
|
|
|
|
|
1600
|
|
15
|
59
|
|
|
59
|
|
287
|
use Carp; |
|
59
|
|
|
|
|
122
|
|
|
59
|
|
|
|
|
1369
|
|
16
|
59
|
|
|
59
|
|
276
|
use 5.10.0; |
|
59
|
|
|
|
|
117
|
|
|
59
|
|
|
|
|
3077
|
|
17
|
59
|
|
|
59
|
|
730
|
|
|
59
|
|
|
|
|
233
|
|
18
|
|
|
|
|
|
|
use Mouse::Util; |
19
|
59
|
|
|
59
|
|
395
|
use Log::Log4perl qw(get_logger :levels); |
|
59
|
|
|
|
|
131
|
|
|
59
|
|
|
|
|
402
|
|
20
|
59
|
|
|
59
|
|
5051
|
use Path::Tiny; |
|
59
|
|
|
|
|
145
|
|
|
59
|
|
|
|
|
407
|
|
21
|
59
|
|
|
59
|
|
7005
|
|
|
59
|
|
|
|
|
158
|
|
|
59
|
|
|
|
|
2923
|
|
22
|
|
|
|
|
|
|
use Mouse::Role; |
23
|
59
|
|
|
59
|
|
393
|
|
|
59
|
|
|
|
|
159
|
|
|
59
|
|
|
|
|
389
|
|
24
|
|
|
|
|
|
|
use Config::Model::TypeConstraints; |
25
|
59
|
|
|
59
|
|
16741
|
|
|
59
|
|
|
|
|
151
|
|
|
59
|
|
|
|
|
14400
|
|
26
|
|
|
|
|
|
|
my $logger = get_logger("FileHandler"); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# used only for tests |
29
|
|
|
|
|
|
|
Config::Model::TypeConstraints::_set_test_home(shift) ; |
30
|
|
|
|
|
|
|
return; |
31
|
14
|
|
|
14
|
|
9227
|
} |
32
|
14
|
|
|
|
|
32
|
|
33
|
|
|
|
|
|
|
# Configuration directory where to read and write files. This value |
34
|
|
|
|
|
|
|
# does not override the configuration directory specified in the model |
35
|
|
|
|
|
|
|
# data passed to read and write functions. |
36
|
|
|
|
|
|
|
has config_dir => ( is => 'ro', isa => 'Config::Model::TypeContraints::Path', required => 0 ); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
my ($self, %args) = @_; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
my $dir = $args{os_config_dir}{$^O} || $args{config_dir} || $self->config_dir || ''; |
41
|
367
|
|
|
367
|
0
|
1479
|
if ( $dir =~ /^~/ ) { |
42
|
|
|
|
|
|
|
# because of tests, we can't rely on Path::Tiny's tilde processing |
43
|
367
|
|
100
|
|
|
3226
|
# TODO: should this be my_config ? May be once this is done: |
44
|
367
|
100
|
|
|
|
1201
|
# https://github.com/perl5-utils/File-HomeDir/pull/5/files |
45
|
|
|
|
|
|
|
# beware of compat and migration issues |
46
|
|
|
|
|
|
|
my $home = &Config::Model::TypeConstraints::_get_test_home || File::HomeDir->my_home; |
47
|
|
|
|
|
|
|
$dir =~ s/^~/$home/; |
48
|
|
|
|
|
|
|
} |
49
|
4
|
|
33
|
|
|
20
|
|
50
|
4
|
|
|
|
|
21
|
return $args{root} ? $args{root}->child($dir) |
51
|
|
|
|
|
|
|
: $dir ? path($dir) |
52
|
|
|
|
|
|
|
: path ('.'); |
53
|
367
|
100
|
|
|
|
2585
|
} |
|
|
100
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
1; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=pod |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=encoding UTF-8 |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 NAME |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
Config::Model::Role::FileHandler - role to read or write configuration files |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 VERSION |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
version 2.152 |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 SYNOPSIS |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 DESCRIPTION |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Role used to handle configuration files on the behalf of a backend. |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 METHODS |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 AUTHOR |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
Dominique Dumont |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
This software is Copyright (c) 2005-2022 by Dominique Dumont. |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
This is free software, licensed under: |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
The GNU Lesser General Public License, Version 2.1, February 1999 |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=cut |