line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::Sky::Config::Validate; |
2
|
|
|
|
|
|
|
$App::Sky::Config::Validate::VERSION = '0.4.2'; |
3
|
1
|
|
|
1
|
|
75597
|
use strict; |
|
1
|
|
|
|
|
12
|
|
|
1
|
|
|
|
|
24
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
20
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
4
|
use Carp (); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
11
|
|
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
457
|
use Moo; |
|
1
|
|
|
|
|
8008
|
|
|
1
|
|
|
|
|
4
|
|
10
|
1
|
|
|
1
|
|
1735
|
use MooX 'late'; |
|
1
|
|
|
|
|
8411
|
|
|
1
|
|
|
|
|
5
|
|
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
123811
|
use Scalar::Util qw(reftype); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
49
|
|
13
|
1
|
|
|
1
|
|
591
|
use List::MoreUtils qw(notall); |
|
1
|
|
|
|
|
7938
|
|
|
1
|
|
|
|
|
10
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
has 'config' => ( isa => 'HashRef', is => 'ro', required => 1, ); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub _sorted_keys |
19
|
|
|
|
|
|
|
{ |
20
|
2
|
|
|
2
|
|
4
|
my $hash_ref = shift; |
21
|
|
|
|
|
|
|
|
22
|
2
|
|
|
|
|
9
|
my @ret = sort { $a cmp $b } keys(%$hash_ref); |
|
3
|
|
|
|
|
7
|
|
23
|
|
|
|
|
|
|
|
24
|
2
|
|
|
|
|
14
|
return @ret; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub _validate_section |
28
|
|
|
|
|
|
|
{ |
29
|
3
|
|
|
3
|
|
6
|
my ( $self, $site_name, $sect_name, $sect_conf ) = @_; |
30
|
|
|
|
|
|
|
|
31
|
3
|
|
|
|
|
5
|
foreach my $string_key (qw( basename_re target_dir)) |
32
|
|
|
|
|
|
|
{ |
33
|
6
|
|
|
|
|
8
|
my $v = $sect_conf->{$string_key}; |
34
|
|
|
|
|
|
|
|
35
|
6
|
50
|
33
|
|
|
27
|
if ( |
|
|
|
33
|
|
|
|
|
36
|
|
|
|
|
|
|
not( defined($v) |
37
|
|
|
|
|
|
|
&& ref($v) eq '' |
38
|
|
|
|
|
|
|
&& $v =~ /\S/ ) |
39
|
|
|
|
|
|
|
) |
40
|
|
|
|
|
|
|
{ |
41
|
0
|
|
|
|
|
0
|
die |
42
|
|
|
|
|
|
|
"Section '$sect_name' at site '$site_name' must contain a non-empty $string_key"; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
3
|
|
|
|
|
5
|
return; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub _validate_site |
50
|
|
|
|
|
|
|
{ |
51
|
1
|
|
|
1
|
|
3
|
my ( $self, $site_name, $site_conf ) = @_; |
52
|
|
|
|
|
|
|
|
53
|
1
|
|
|
|
|
2
|
my $base_upload_cmd = $site_conf->{base_upload_cmd}; |
54
|
1
|
50
|
|
|
|
8
|
if ( ref($base_upload_cmd) ne 'ARRAY' ) |
55
|
|
|
|
|
|
|
{ |
56
|
0
|
|
|
|
|
0
|
die "base_upload_cmd for site '$site_name' is not an array."; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
1
|
50
|
|
5
|
|
8
|
if ( notall { defined($_) && ref($_) eq '' } @$base_upload_cmd ) |
|
5
|
50
|
|
|
|
14
|
|
60
|
|
|
|
|
|
|
{ |
61
|
0
|
|
|
|
|
0
|
die "base_upload_cmd for site '$site_name' must contain only strings."; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
1
|
|
|
|
|
4
|
foreach my $kk (qw(dest_upload_prefix dest_upload_url_prefix)) |
65
|
|
|
|
|
|
|
{ |
66
|
2
|
|
|
|
|
5
|
my $s = $site_conf->{$kk}; |
67
|
2
|
50
|
33
|
|
|
16
|
if ( not( defined($s) && ( ref($s) eq '' ) && ( $s =~ m/\S/ ) ) ) |
|
|
|
33
|
|
|
|
|
68
|
|
|
|
|
|
|
{ |
69
|
0
|
|
|
|
|
0
|
die "$kk for site '$site_name' is not a string."; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
1
|
|
|
|
|
2
|
my $sections = $site_conf->{sections}; |
74
|
1
|
50
|
|
|
|
3
|
if ( ref($sections) ne 'HASH' ) |
75
|
|
|
|
|
|
|
{ |
76
|
0
|
|
|
|
|
0
|
die "Sections for site '$site_name' is not a hash."; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
1
|
|
|
|
|
2
|
foreach my $sect_name ( _sorted_keys($sections) ) |
80
|
|
|
|
|
|
|
{ |
81
|
|
|
|
|
|
|
$self->_validate_section( $site_name, $sect_name, |
82
|
3
|
|
|
|
|
7
|
$sections->{$sect_name} ); |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
1
|
|
|
|
|
3
|
return; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub is_valid |
89
|
|
|
|
|
|
|
{ |
90
|
1
|
|
|
1
|
1
|
2166
|
my ($self) = @_; |
91
|
|
|
|
|
|
|
|
92
|
1
|
|
|
|
|
6
|
my $config = $self->config(); |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
# Validate the configuration |
95
|
|
|
|
|
|
|
{ |
96
|
1
|
50
|
|
|
|
2
|
if ( !exists( $config->{default_site} ) ) |
|
1
|
|
|
|
|
3
|
|
97
|
|
|
|
|
|
|
{ |
98
|
0
|
|
|
|
|
0
|
die "A 'default_site' key must be present in the configuration."; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
1
|
|
|
|
|
2
|
my $sites = $config->{sites}; |
102
|
1
|
50
|
|
|
|
5
|
if ( ref($sites) ne 'HASH' ) |
103
|
|
|
|
|
|
|
{ |
104
|
0
|
|
|
|
|
0
|
die "sites key must be a hash."; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
1
|
|
|
|
|
4
|
foreach my $name ( _sorted_keys($sites) ) |
108
|
|
|
|
|
|
|
{ |
109
|
1
|
|
|
|
|
5
|
$self->_validate_site( $name, $sites->{$name} ); |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
|
113
|
1
|
|
|
|
|
2
|
return; |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
1; |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
__END__ |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=pod |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=encoding UTF-8 |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head1 NAME |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
App::Sky::Config::Validate - validate the configuration. |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head1 VERSION |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
version 0.4.2 |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head1 METHODS |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head2 $self->config() |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
The configuration to validate. |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=head2 $self->is_valid() |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
Determines if the configuration is valid. Throws an exception if not valid, |
141
|
|
|
|
|
|
|
and returns FALSE (in both list context and scalar context if it is valid.). |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=for :stopwords cpan testmatrix url bugtracker rt cpants kwalitee diff irc mailto metadata placeholders metacpan |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=head1 SUPPORT |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=head2 Websites |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
The following websites have more information about this module, and may be of help to you. As always, |
150
|
|
|
|
|
|
|
in addition to those websites please use your favorite search engine to discover more resources. |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=over 4 |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=item * |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
MetaCPAN |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
A modern, open-source CPAN search engine, useful to view POD in HTML format. |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
L<https://metacpan.org/release/App-Sky> |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=item * |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
RT: CPAN's Bug Tracker |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
The RT ( Request Tracker ) website is the default bug/issue tracking system for CPAN. |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
L<https://rt.cpan.org/Public/Dist/Display.html?Name=App-Sky> |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=item * |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
CPANTS |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
The CPANTS is a website that analyzes the Kwalitee ( code metrics ) of a distribution. |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
L<http://cpants.cpanauthors.org/dist/App-Sky> |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=item * |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
CPAN Testers |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
The CPAN Testers is a network of smoke testers who run automated tests on uploaded CPAN distributions. |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
L<http://www.cpantesters.org/distro/A/App-Sky> |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
=item * |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
CPAN Testers Matrix |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
The CPAN Testers Matrix is a website that provides a visual overview of the test results for a distribution on various Perls/platforms. |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
L<http://matrix.cpantesters.org/?dist=App-Sky> |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
=item * |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
CPAN Testers Dependencies |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
The CPAN Testers Dependencies is a website that shows a chart of the test results of all dependencies for a distribution. |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
L<http://deps.cpantesters.org/?module=App::Sky> |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
=back |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
=head2 Bugs / Feature Requests |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
Please report any bugs or feature requests by email to C<bug-app-sky at rt.cpan.org>, or through |
207
|
|
|
|
|
|
|
the web interface at L<https://rt.cpan.org/Public/Bug/Report.html?Queue=App-Sky>. You will be automatically notified of any |
208
|
|
|
|
|
|
|
progress on the request by the system. |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
=head2 Source Code |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
The code is open to the world, and available for you to hack on. Please feel free to browse it and play |
213
|
|
|
|
|
|
|
with it, or whatever. If you want to contribute patches, please send me a diff or prod me to pull |
214
|
|
|
|
|
|
|
from your repository :) |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
L<https://github.com/shlomif/Sky-uploader> |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
git clone git://github.com/shlomif/Sky-uploader.git |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
=head1 AUTHOR |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
Shlomi Fish <shlomif@cpan.org> |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
=head1 BUGS |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
Please report any bugs or feature requests on the bugtracker website |
227
|
|
|
|
|
|
|
L<https://github.com/shlomif/Sky-uploader/issues> |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
When submitting a bug or request, please include a test-file or a |
230
|
|
|
|
|
|
|
patch to an existing test-file that illustrates the bug or desired |
231
|
|
|
|
|
|
|
feature. |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
This software is Copyright (c) 2013 by Shlomi Fish. |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
This is free software, licensed under: |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
The MIT (X11) License |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
=cut |