| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package MooX::File::ConfigDir; |
|
2
|
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
32387
|
use strict; |
|
|
3
|
|
|
|
|
8
|
|
|
|
3
|
|
|
|
|
79
|
|
|
4
|
3
|
|
|
3
|
|
16
|
use warnings; |
|
|
3
|
|
|
|
|
6
|
|
|
|
3
|
|
|
|
|
126
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = "0.006"; |
|
7
|
|
|
|
|
|
|
|
|
8
|
3
|
|
|
3
|
|
15
|
use Carp qw/croak/; |
|
|
3
|
|
|
|
|
8
|
|
|
|
3
|
|
|
|
|
177
|
|
|
9
|
3
|
|
|
3
|
|
19
|
use Scalar::Util qw(blessed); |
|
|
3
|
|
|
|
|
13
|
|
|
|
3
|
|
|
|
|
180
|
|
|
10
|
3
|
|
|
3
|
|
1299
|
use File::ConfigDir (); |
|
|
3
|
|
|
|
|
53908
|
|
|
|
3
|
|
|
|
|
95
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
3
|
|
|
3
|
|
465
|
use Moo::Role; |
|
|
3
|
|
|
|
|
13531
|
|
|
|
3
|
|
|
|
|
27
|
|
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
has 'config_identifier' => ( |
|
15
|
|
|
|
|
|
|
is => 'lazy', |
|
16
|
|
|
|
|
|
|
); |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
1
|
|
|
sub _build_config_identifier { } |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub _fetch_file_config_dir |
|
21
|
|
|
|
|
|
|
{ |
|
22
|
35
|
|
|
35
|
|
114
|
my ($self, $attr, $params) = @_; |
|
23
|
35
|
100
|
66
|
|
|
442
|
croak "either \$self or \$params must be valid" unless blessed $self or "HASH" eq ref $params; |
|
24
|
|
|
|
|
|
|
my $app_name = |
|
25
|
|
|
|
|
|
|
blessed($self) ? $self->config_identifier |
|
26
|
|
|
|
|
|
|
: defined $params->{config_identifier} ? $params->{config_identifier} |
|
27
|
34
|
0
|
|
|
|
1016
|
: $self->_build_config_identifier($params); |
|
|
|
50
|
|
|
|
|
|
|
28
|
34
|
100
|
|
|
|
437
|
my @app_names = $app_name ? ($app_name) : (); |
|
29
|
34
|
|
|
|
|
235
|
my $sub = File::ConfigDir->can($attr); |
|
30
|
34
|
|
|
|
|
92
|
my @dirs = &{$sub}(@app_names); |
|
|
34
|
|
|
|
|
149
|
|
|
31
|
34
|
|
|
|
|
3429
|
return \@dirs; |
|
32
|
|
|
|
|
|
|
} |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
has singleapp_cfg_dir => ( |
|
35
|
|
|
|
|
|
|
is => 'ro', |
|
36
|
|
|
|
|
|
|
lazy => 1, |
|
37
|
|
|
|
|
|
|
clearer => 1, |
|
38
|
3
|
|
|
3
|
|
2185
|
builder => sub { [File::ConfigDir::singleapp_cfg_dir] }, |
|
39
|
|
|
|
|
|
|
); |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
my @file_config_dir_attrs = ( |
|
42
|
|
|
|
|
|
|
qw(system_cfg_dir xdg_config_dirs desktop_cfg_dir), |
|
43
|
|
|
|
|
|
|
qw(core_cfg_dir site_cfg_dir vendor_cfg_dir vendorapp_cfg_dir), |
|
44
|
|
|
|
|
|
|
qw(local_cfg_dir locallib_cfg_dir here_cfg_dir user_cfg_dir), |
|
45
|
|
|
|
|
|
|
qw(xdg_config_home config_dirs) |
|
46
|
|
|
|
|
|
|
); |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
foreach my $attr (@file_config_dir_attrs) |
|
49
|
|
|
|
|
|
|
{ |
|
50
|
|
|
|
|
|
|
has $attr => ( |
|
51
|
|
|
|
|
|
|
is => 'ro', |
|
52
|
|
|
|
|
|
|
lazy => 1, |
|
53
|
|
|
|
|
|
|
clearer => 1, |
|
54
|
35
|
|
|
35
|
|
74177
|
builder => sub { my $self = shift; $self->_fetch_file_config_dir($attr, @_) }, |
|
|
35
|
|
|
35
|
|
152
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
55
|
|
|
|
|
|
|
); |
|
56
|
|
|
|
|
|
|
} |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head1 NAME |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
MooX::File::ConfigDir - Moo eXtension for File::ConfigDir |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
my App; |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
use Moo; |
|
67
|
|
|
|
|
|
|
with MooX::File::ConfigDir; |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
1; |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
package main; |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
my $app = App->new(); |
|
74
|
|
|
|
|
|
|
$app->config_identifier('MyProject'); |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
my @cfgdirs = @{ $app->config_dirs }; |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
# install support |
|
79
|
|
|
|
|
|
|
my $site_cfg_dir = $app->site_cfg_dir->[0]; |
|
80
|
|
|
|
|
|
|
my $vendor_cfg_dir = $app->site_cfg_dir->[0]; |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
This module is a helper for easily find configuration file locations. |
|
86
|
|
|
|
|
|
|
Whether to use this information for find a suitable place for installing |
|
87
|
|
|
|
|
|
|
them or looking around for finding any piece of settings, heavily depends |
|
88
|
|
|
|
|
|
|
on the requirements. |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head2 config_identifier |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
Allows to deal with a global unique identifier passed to the functions of |
|
95
|
|
|
|
|
|
|
L. Using it encapsulates configuration files from the |
|
96
|
|
|
|
|
|
|
other ones (eg. C vs. C). |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
C can be initialized by specifying it as parameter |
|
99
|
|
|
|
|
|
|
during object construction or via inheriting default builder |
|
100
|
|
|
|
|
|
|
(C<_build_config_identifier>). |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head2 system_cfg_dir |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
Provides the configuration directory where configuration files of the |
|
105
|
|
|
|
|
|
|
operating system resides. For details see L. |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head2 desktop_cfg_dir |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
Provides the configuration directory where configuration files of the |
|
110
|
|
|
|
|
|
|
desktop applications resides. For details see L. |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head2 xdg_config_dirs |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
Alias for desktop_cfg_dir to support |
|
115
|
|
|
|
|
|
|
L |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head2 core_cfg_dir |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
Provides the configuration directory of the Perl5 core location. |
|
120
|
|
|
|
|
|
|
For details see L. |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head2 site_cfg_dir |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
Provides the configuration directory of the Perl5 sitelib location. |
|
125
|
|
|
|
|
|
|
For details see L. |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head2 vendor_cfg_dir |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
Provides the configuration directory of the Perl5 vendorlib location. |
|
130
|
|
|
|
|
|
|
For details see L. |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head2 singleapp_cfg_dir |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
Provides the configuration directory of C<$0> if it's installed as |
|
135
|
|
|
|
|
|
|
a separate package - either a program bundle (TSM, Oracle DB) or |
|
136
|
|
|
|
|
|
|
an independent package combination (eg. via L |
|
137
|
|
|
|
|
|
|
For details see L. |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=head2 vendorapp_cfg_dir |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
Provides the configuration directory of C<$0> if it's installed as |
|
142
|
|
|
|
|
|
|
a separate package via a vendor installation as e.g. L |
|
143
|
|
|
|
|
|
|
or L. |
|
144
|
|
|
|
|
|
|
For details see L. |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=head2 local_cfg_dir |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
Returns the configuration directory for distribution independent, 3rd |
|
149
|
|
|
|
|
|
|
party applications. For details see L. |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=head2 locallib_cfg_dir |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
Provides the configuration directory of the Perl5 L environment |
|
154
|
|
|
|
|
|
|
location. For details see L. |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=head2 here_cfg_dir |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
Provides the path for the C directory below the current working directory. |
|
159
|
|
|
|
|
|
|
For details see L. |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=head2 user_cfg_dir |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
Provides the users home folder using L. |
|
164
|
|
|
|
|
|
|
For details see L. |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=head2 xdg_config_home |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
Returns the user configuration directory for desktop applications. |
|
169
|
|
|
|
|
|
|
For details see L. |
|
170
|
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=head2 config_dirs |
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
Tries to get all available configuration directories as described above. |
|
174
|
|
|
|
|
|
|
Returns those who exists and are readable. |
|
175
|
|
|
|
|
|
|
For details see L. |
|
176
|
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=head1 AUTHOR |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
Jens Rehsack, C<< >> |
|
180
|
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=head1 BUGS |
|
182
|
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
Please report any bugs or feature requests to |
|
184
|
|
|
|
|
|
|
C, or through the web interface at |
|
185
|
|
|
|
|
|
|
L. |
|
186
|
|
|
|
|
|
|
I will be notified, and then you'll automatically be notified of progress |
|
187
|
|
|
|
|
|
|
on your bug as I make changes. |
|
188
|
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=head1 SUPPORT |
|
190
|
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
|
192
|
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
perldoc MooX::File::ConfigDir |
|
194
|
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
You can also look for information at: |
|
196
|
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=over 4 |
|
198
|
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
|
200
|
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
L |
|
202
|
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
|
204
|
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
L |
|
206
|
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
=item * CPAN Ratings |
|
208
|
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
L |
|
210
|
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
=item * Search CPAN |
|
212
|
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
L |
|
214
|
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
=back |
|
216
|
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
|
218
|
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
Copyright 2013-2017 Jens Rehsack. |
|
220
|
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
|
222
|
|
|
|
|
|
|
under the terms of either: the GNU General Public License as published |
|
223
|
|
|
|
|
|
|
by the Free Software Foundation; or the Artistic License. |
|
224
|
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
See http://dev.perl.org/licenses/ for more information. |
|
226
|
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
=cut |
|
228
|
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
1; |