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
|
|
27264
|
use warnings; |
|
59
|
|
|
|
|
187
|
|
|
59
|
|
|
|
|
1629
|
|
15
|
59
|
|
|
59
|
|
324
|
use Carp; |
|
59
|
|
|
|
|
115
|
|
|
59
|
|
|
|
|
1399
|
|
16
|
59
|
|
|
59
|
|
259
|
use 5.10.0; |
|
59
|
|
|
|
|
126
|
|
|
59
|
|
|
|
|
2893
|
|
17
|
59
|
|
|
59
|
|
714
|
|
|
59
|
|
|
|
|
224
|
|
18
|
|
|
|
|
|
|
use Mouse::Util; |
19
|
59
|
|
|
59
|
|
363
|
use Log::Log4perl qw(get_logger :levels); |
|
59
|
|
|
|
|
133
|
|
|
59
|
|
|
|
|
419
|
|
20
|
59
|
|
|
59
|
|
4940
|
use Path::Tiny; |
|
59
|
|
|
|
|
143
|
|
|
59
|
|
|
|
|
416
|
|
21
|
59
|
|
|
59
|
|
7050
|
|
|
59
|
|
|
|
|
148
|
|
|
59
|
|
|
|
|
2770
|
|
22
|
|
|
|
|
|
|
use Mouse::Role; |
23
|
59
|
|
|
59
|
|
377
|
|
|
59
|
|
|
|
|
160
|
|
|
59
|
|
|
|
|
444
|
|
24
|
|
|
|
|
|
|
use Config::Model::TypeConstraints; |
25
|
59
|
|
|
59
|
|
16256
|
|
|
59
|
|
|
|
|
141
|
|
|
59
|
|
|
|
|
14250
|
|
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
|
|
9168
|
} |
32
|
14
|
|
|
|
|
31
|
|
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
|
1361
|
if ( $dir =~ /^~/ ) { |
42
|
|
|
|
|
|
|
# because of tests, we can't rely on Path::Tiny's tilde processing |
43
|
367
|
|
100
|
|
|
2851
|
# TODO: should this be my_config ? May be once this is done: |
44
|
367
|
100
|
|
|
|
1079
|
# 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
|
|
|
21
|
|
50
|
4
|
|
|
|
|
20
|
return $args{root} ? $args{root}->child($dir) |
51
|
|
|
|
|
|
|
: $dir ? path($dir) |
52
|
|
|
|
|
|
|
: path ('.'); |
53
|
367
|
100
|
|
|
|
2309
|
} |
|
|
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.151 |
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 |