line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
use 5.010; |
3
|
53
|
|
|
53
|
|
677093
|
use Moo; |
|
53
|
|
|
|
|
275
|
|
4
|
53
|
|
|
53
|
|
2639
|
use strict; |
|
53
|
|
|
|
|
50782
|
|
|
53
|
|
|
|
|
317
|
|
5
|
53
|
|
|
53
|
|
20512
|
use warnings; |
|
53
|
|
|
|
|
105
|
|
|
53
|
|
|
|
|
849
|
|
6
|
53
|
|
|
53
|
|
211
|
use Path::Class; |
|
53
|
|
|
|
|
93
|
|
|
53
|
|
|
|
|
1134
|
|
7
|
53
|
|
|
53
|
|
1760
|
use Locale::TextDomain qw(App-Sqitch); |
|
53
|
|
|
|
|
113773
|
|
|
53
|
|
|
|
|
2611
|
|
8
|
53
|
|
|
53
|
|
1839
|
use App::Sqitch::X qw(hurl); |
|
53
|
|
|
|
|
50905
|
|
|
53
|
|
|
|
|
285
|
|
9
|
53
|
|
|
53
|
|
81474
|
use Config::GitLike 1.15; |
|
53
|
|
|
|
|
115
|
|
|
53
|
|
|
|
|
263
|
|
10
|
53
|
|
|
53
|
|
40814
|
use utf8; |
|
53
|
|
|
|
|
1321071
|
|
|
53
|
|
|
|
|
1600
|
|
11
|
53
|
|
|
53
|
|
383
|
|
|
53
|
|
|
|
|
104
|
|
|
53
|
|
|
|
|
317
|
|
12
|
|
|
|
|
|
|
extends 'Config::GitLike'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our $VERSION = 'v1.3.1'; # VERSION |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
has '+confname' => ( default => 'sqitch.conf' ); |
17
|
|
|
|
|
|
|
has '+encoding' => ( default => 'UTF-8' ); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# Set by ./Build; see Module::Build::Sqitch for details. |
20
|
|
|
|
|
|
|
my $SYSTEM_DIR = q{/usr/local/etc/sqitch}; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
my $hd = $^O eq 'MSWin32' && "$]" < '5.016' ? $ENV{HOME} || $ENV{USERPROFILE} : (glob('~'))[0]; |
23
|
|
|
|
|
|
|
hurl config => __("Could not determine home directory") if not $hd; |
24
|
5
|
50
|
33
|
5
|
1
|
1265
|
return dir $hd, '.sqitch'; |
|
|
|
0
|
|
|
|
|
25
|
5
|
50
|
|
|
|
31
|
} |
26
|
5
|
|
|
|
|
49
|
|
27
|
|
|
|
|
|
|
dir $SYSTEM_DIR || do { |
28
|
|
|
|
|
|
|
require Config; |
29
|
|
|
|
|
|
|
$Config::Config{prefix}, 'etc', 'sqitch'; |
30
|
7
|
|
33
|
7
|
1
|
965
|
}; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
my $self = shift; |
34
|
|
|
|
|
|
|
return file $ENV{SQITCH_SYSTEM_CONFIG} |
35
|
|
|
|
|
|
|
|| $self->system_dir->file( $self->confname ); |
36
|
|
|
|
|
|
|
} |
37
|
7
|
|
|
7
|
1
|
710
|
|
38
|
|
|
|
|
|
|
|
39
|
7
|
|
66
|
|
|
102
|
my $self = shift; |
40
|
|
|
|
|
|
|
return file $ENV{SQITCH_USER_CONFIG} |
41
|
|
|
|
|
|
|
|| $self->user_dir->file( $self->confname ); |
42
|
73
|
|
|
73
|
1
|
680180
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
return file $ENV{SQITCH_CONFIG} if $ENV{SQITCH_CONFIG}; |
45
|
5
|
|
|
5
|
1
|
15398
|
return file shift->confname; |
46
|
|
|
|
|
|
|
} |
47
|
5
|
|
66
|
|
|
105
|
|
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# Section keys always have the top section lowercase, and subsections are |
50
|
|
|
|
|
|
|
# left as-is. |
51
|
16
|
100
|
|
16
|
1
|
1389
|
my $key = shift // return ''; |
52
|
14
|
|
|
|
|
298
|
my ($sec, $sub, $name) = Config::GitLike::_split_key($key); |
53
|
|
|
|
|
|
|
return lc $key unless $sec; |
54
|
|
|
|
|
|
|
return lc($sec) . '.' . join '.', grep { defined } $sub, $name; |
55
|
14
|
|
|
14
|
1
|
2237
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
my ( $self, %p ) = @_; |
58
|
|
|
|
|
|
|
$self->load unless $self->is_loaded; |
59
|
|
|
|
|
|
|
my $section = _skey $p{section}; |
60
|
723
|
|
50
|
723
|
|
2027
|
my $data = $self->data; |
61
|
723
|
|
|
|
|
1709
|
return { |
62
|
723
|
100
|
|
|
|
37152
|
map { |
63
|
629
|
|
|
|
|
1559
|
( split /[.]/ => $self->initial_key("$section.$_") )[-1], |
|
1258
|
|
|
|
|
2774
|
|
64
|
|
|
|
|
|
|
$data->{"$section.$_"} |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
grep { s{^\Q$section.\E([^.]+)$}{$1} } keys %{$data} |
67
|
723
|
|
|
723
|
1
|
207254
|
}; |
68
|
723
|
100
|
|
|
|
2186
|
} |
69
|
723
|
|
|
|
|
28927
|
|
70
|
723
|
|
|
|
|
11559
|
my $key = shift->original_key(shift); |
71
|
|
|
|
|
|
|
return ref $key ? $key->[0] : $key; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
463
|
|
|
|
|
1537
|
my $self = shift; |
75
|
|
|
|
|
|
|
$self->load unless $self->is_loaded; |
76
|
723
|
|
|
|
|
3697
|
return $self->{_initialized}; |
|
4936
|
|
|
|
|
29820
|
|
|
723
|
|
|
|
|
2350
|
|
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
my $self = shift; |
80
|
|
|
|
|
|
|
local $self->{__loading_dirs} = 1; |
81
|
463
|
|
|
463
|
1
|
1223
|
$self->SUPER::load_dirs(@_); |
82
|
463
|
100
|
|
|
|
43954
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
my $self = shift; |
85
|
|
|
|
|
|
|
$self->{_initialized} ||= $self->{__loading_dirs}; |
86
|
6
|
|
|
6
|
1
|
7653
|
$self->SUPER::load_file(@_); |
87
|
6
|
100
|
|
|
|
45
|
} |
88
|
6
|
|
|
|
|
12727
|
|
89
|
|
|
|
|
|
|
1; |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 Name |
92
|
3
|
|
|
3
|
1
|
13496
|
|
93
|
3
|
|
|
|
|
51
|
App::Sqitch::Config - Sqitch configuration management |
94
|
3
|
|
|
|
|
68
|
|
95
|
|
|
|
|
|
|
=head1 Synopsis |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
my $config = App::Sqitch::Config->new; |
98
|
240
|
|
|
240
|
1
|
1044105
|
say scalar $config->dump; |
99
|
240
|
|
66
|
|
|
4211
|
|
100
|
240
|
|
|
|
|
1864
|
=head1 Description |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
This class provides the interface to Sqitch configuration. It inherits from |
103
|
|
|
|
|
|
|
L<Config::GitLike>, and therefore provides the complete interface of that |
104
|
|
|
|
|
|
|
module. |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head1 Interface |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head2 Instance Methods |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head3 C<confname> |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Returns the configuration file base name, which is F<sqitch.conf>. |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head3 C<system_dir> |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
Returns the path to the system configuration directory, which is |
117
|
|
|
|
|
|
|
F<$(prefix)/etc/sqitch/templates>. Call C<sqitch --etc-path> to find out |
118
|
|
|
|
|
|
|
where, exactly (e.g., C<$(sqitch --etc-path)/sqitch.plan>). |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head3 C<user_dir> |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
Returns the path to the user configuration directory, which is F<~/.sqitch/>. |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head3 C<system_file> |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
Returns the path to the system configuration file. The value returned will be |
127
|
|
|
|
|
|
|
the contents of the C<$SQITCH_SYSTEM_CONFIG> environment variable, if it's |
128
|
|
|
|
|
|
|
defined, or else F<$(prefix)/etc/sqitch/templates>. Call C<sqitch --etc-path> |
129
|
|
|
|
|
|
|
to find out where, exactly (e.g., C<$(sqitch --etc-path)/sqitch.plan>). |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head3 C<global_file> |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
An alias for C<system_file()> for use by the parent class. |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=head3 C<user_file> |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
Returns the path to the user configuration file. The value returned will be |
138
|
|
|
|
|
|
|
the contents of the C<$SQITCH_USER_CONFIG> environment variable, if it's |
139
|
|
|
|
|
|
|
defined, or else C<~/.sqitch/sqitch.conf>. |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head3 C<local_file> |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
Returns the path to the local configuration file, which is just |
144
|
|
|
|
|
|
|
F<./sqitch.conf>, unless C<$SQITCH_CONFIG> is set, in which case its value |
145
|
|
|
|
|
|
|
will be returned. |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=head3 C<dir_file> |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
An alias for C<local_file()> for use by the parent class. |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=head3 C<initialized> |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
say 'Project not initialized' unless $config->initialized; |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
Returns true if the project configuration file was found, and false if it was |
156
|
|
|
|
|
|
|
not. Useful for detecting when a command has been run from a directory with no |
157
|
|
|
|
|
|
|
Sqitch configuration. |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=head3 C<get_section> |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
my $core = $config->get_section(section => 'core'); |
162
|
|
|
|
|
|
|
my $pg = $config->get_section(section => 'engine.pg'); |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
Returns a hash reference containing only the keys within the specified |
165
|
|
|
|
|
|
|
section or subsection. |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=head3 C<add_comment> |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
Adds a comment to the configuration file. |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=head3 C<initial_key> |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
my $key = $config->initial_key($data_key); |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
Given the lowercase key from the loaded data, this method returns it in its |
176
|
|
|
|
|
|
|
original case. This is like C<original_key>, only in the case where there are |
177
|
|
|
|
|
|
|
multiple keys (for multivalue keys), only the first key is returned. |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=head1 See Also |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=over |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=item * L<Config::GitLike> |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=item * L<App::Sqitch::Command::config> |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
=item * L<sqitch-config> |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=back |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
=head1 Author |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
David E. Wheeler <david@justatheory.com> |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
=head1 License |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
Copyright (c) 2012-2022 iovation Inc., David E. Wheeler |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy |
200
|
|
|
|
|
|
|
of this software and associated documentation files (the "Software"), to deal |
201
|
|
|
|
|
|
|
in the Software without restriction, including without limitation the rights |
202
|
|
|
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
203
|
|
|
|
|
|
|
copies of the Software, and to permit persons to whom the Software is |
204
|
|
|
|
|
|
|
furnished to do so, subject to the following conditions: |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in all |
207
|
|
|
|
|
|
|
copies or substantial portions of the Software. |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
210
|
|
|
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
211
|
|
|
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
212
|
|
|
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
213
|
|
|
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
214
|
|
|
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
215
|
|
|
|
|
|
|
SOFTWARE. |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
=cut |