| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package DBIx::Class::DeploymentHandler::CLI::ConfigReader; |
|
2
|
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
120366
|
use strict; |
|
|
2
|
|
|
|
|
12
|
|
|
|
2
|
|
|
|
|
64
|
|
|
4
|
2
|
|
|
2
|
|
16
|
use warnings; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
64
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
606
|
use Moo; |
|
|
2
|
|
|
|
|
11605
|
|
|
|
2
|
|
|
|
|
15
|
|
|
7
|
2
|
|
|
2
|
|
7130
|
use Config::Any; |
|
|
2
|
|
|
|
|
23717
|
|
|
|
2
|
|
|
|
|
78
|
|
|
8
|
2
|
|
|
2
|
|
2487
|
use File::HomeDir; |
|
|
2
|
|
|
|
|
10311
|
|
|
|
2
|
|
|
|
|
110
|
|
|
9
|
2
|
|
|
2
|
|
582
|
use Types::Standard qw/ArrayRef HashRef Maybe/; |
|
|
2
|
|
|
|
|
76928
|
|
|
|
2
|
|
|
|
|
29
|
|
|
10
|
2
|
|
|
2
|
|
4671
|
use Types::Common::String qw/NonEmptyStr/; |
|
|
2
|
|
|
|
|
73117
|
|
|
|
2
|
|
|
|
|
21
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
2
|
|
|
2
|
|
1774
|
use namespace::clean; |
|
|
2
|
|
|
|
|
10653
|
|
|
|
2
|
|
|
|
|
19
|
|
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 NAME |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
DBIx::Class::DeploymentHandler::CLI::ConfigReader - Config reader class for Deployment Handler CLI. |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 Description |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
Searches the configuration file in the following locations: |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=over 4 |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=item C<$ENV{DBIX_CONFIG_DIR}> |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=item current directory |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=item home directory |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=item C</etc> directory |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=back |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
The config accessor will return undefined if a configuration file is absent in all these locations. |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head1 Attributes |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head2 config |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
Configuration values as a hash reference. Generated by builder. |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head2 config_name |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
Name for the configuration file without the suffix. Defaults to C<dh-cli>. |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head2 config_files |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
List of configuration files. |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head2 config_paths |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
List of configuration paths. |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=cut |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
has config => ( |
|
57
|
|
|
|
|
|
|
is => 'ro', |
|
58
|
|
|
|
|
|
|
isa => Maybe[HashRef], |
|
59
|
|
|
|
|
|
|
lazy => 1, |
|
60
|
|
|
|
|
|
|
builder => '_build_config', |
|
61
|
|
|
|
|
|
|
); |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
has config_name => ( |
|
64
|
|
|
|
|
|
|
is => 'ro', |
|
65
|
|
|
|
|
|
|
isa => NonEmptyStr, |
|
66
|
|
|
|
|
|
|
default => 'dh-cli', |
|
67
|
|
|
|
|
|
|
); |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
has config_files => ( |
|
70
|
|
|
|
|
|
|
is => 'ro', |
|
71
|
|
|
|
|
|
|
isa => ArrayRef, |
|
72
|
|
|
|
|
|
|
default => sub { [] }, |
|
73
|
|
|
|
|
|
|
); |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
has config_paths => ( |
|
76
|
|
|
|
|
|
|
is => 'ro', |
|
77
|
|
|
|
|
|
|
isa => ArrayRef, |
|
78
|
|
|
|
|
|
|
lazy => 1, |
|
79
|
|
|
|
|
|
|
builder => '_builder_config_paths', |
|
80
|
|
|
|
|
|
|
); |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub _build_config { |
|
83
|
3
|
|
|
3
|
|
1242
|
my ($self) = @_; |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
# If we have ->config_files, we'll use those and load_files |
|
86
|
|
|
|
|
|
|
# instead of the default load_stems. |
|
87
|
3
|
|
|
|
|
20
|
my %cf_opts = ( use_ext => 1 ); |
|
88
|
3
|
100
|
|
|
|
7
|
my $configs = @{$self->config_files} |
|
|
3
|
|
|
|
|
53
|
|
|
89
|
|
|
|
|
|
|
? Config::Any->load_files({ files => $self->config_files, %cf_opts }) |
|
90
|
|
|
|
|
|
|
: Config::Any->load_stems({ stems => $self->config_paths, %cf_opts }); |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
# return configuration from first existing configuration file |
|
93
|
3
|
|
|
|
|
92667
|
for my $cf (@$configs) { |
|
94
|
2
|
|
|
|
|
10
|
for my $filename ( keys %$cf ) { |
|
95
|
2
|
|
|
|
|
60
|
return $cf->{$filename}; |
|
96
|
|
|
|
|
|
|
} |
|
97
|
|
|
|
|
|
|
} |
|
98
|
|
|
|
|
|
|
|
|
99
|
1
|
|
|
|
|
29
|
return undef; |
|
100
|
|
|
|
|
|
|
} |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub _builder_config_paths { |
|
103
|
5
|
|
|
5
|
|
322
|
my ($self) = @_; |
|
104
|
5
|
|
|
|
|
18
|
my $config_name = $self->config_name; |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
return [ |
|
107
|
5
|
|
|
|
|
46
|
$self->get_env_vars, |
|
108
|
|
|
|
|
|
|
".$config_name", |
|
109
|
|
|
|
|
|
|
File::HomeDir->my_home . '/.' . $config_name, |
|
110
|
|
|
|
|
|
|
"/etc/$config_name", |
|
111
|
|
|
|
|
|
|
]; |
|
112
|
|
|
|
|
|
|
} |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head1 Methods |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head2 get_env_vars |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
Returns stem for environment variable C<DBIX_CONFIG_DIR>. |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=cut |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
sub get_env_vars { |
|
123
|
5
|
|
|
5
|
1
|
14
|
my ($self) = @_; |
|
124
|
|
|
|
|
|
|
|
|
125
|
5
|
100
|
|
|
|
35
|
return $ENV{DBIX_CONFIG_DIR} . "/" . $self->config_name if exists $ENV{DBIX_CONFIG_DIR}; |
|
126
|
2
|
|
|
|
|
11
|
return (); |
|
127
|
|
|
|
|
|
|
} |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
1; |