line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
2
|
|
|
2
|
|
1708
|
use strict; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
66
|
|
2
|
2
|
|
|
2
|
|
17
|
use warnings; |
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
108
|
|
3
|
|
|
|
|
|
|
package App::AppSpec::Schema::Validator; |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.006'; # VERSION |
6
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
943
|
use App::Spec; |
|
2
|
|
|
|
|
59705
|
|
|
2
|
|
|
|
|
99
|
|
8
|
2
|
|
|
2
|
|
1021
|
use App::Spec::Schema qw/ $SCHEMA /; |
|
2
|
|
|
|
|
1361
|
|
|
2
|
|
|
|
|
283
|
|
9
|
2
|
|
|
2
|
|
16
|
use YAML::PP; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
75
|
|
10
|
2
|
|
|
2
|
|
13
|
use Moo; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
11
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub validate_spec_file { |
13
|
1
|
|
|
1
|
0
|
498
|
my ($self, $file) = @_; |
14
|
1
|
|
|
|
|
8
|
my $yp = YAML::PP->new( boolean => 'JSON::PP', schema => [qw/ JSON /] ); |
15
|
1
|
|
|
|
|
16023
|
my $spec = $yp->load_file($file); |
16
|
1
|
|
|
|
|
50221
|
return $self->validate_spec($spec); |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub validate_spec { |
20
|
1
|
|
|
1
|
0
|
4
|
my ($self, $spec) = @_; |
21
|
1
|
50
|
|
|
|
2
|
eval { require JSON::Validator } |
|
1
|
|
|
|
|
777
|
|
22
|
|
|
|
|
|
|
or die "JSON::Validator is needed for validating a spec file"; |
23
|
1
|
|
|
|
|
239374
|
my $json_validator = JSON::Validator->new; |
24
|
1
|
|
|
|
|
26
|
$json_validator->schema($SCHEMA); |
25
|
1
|
|
|
|
|
12176
|
my @errors = $json_validator->validate($spec); |
26
|
1
|
|
|
|
|
7932
|
return @errors; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub format_errors { |
30
|
0
|
|
|
0
|
0
|
|
my ($self, $errors) = @_; |
31
|
0
|
|
|
|
|
|
my $output = ''; |
32
|
0
|
|
|
|
|
|
for my $error (@$errors) { |
33
|
0
|
|
|
|
|
|
$output .= "Path: " . $error->path . "\n"; |
34
|
0
|
|
|
|
|
|
$output .= " Message: " . $error->message . "\n"; |
35
|
|
|
|
|
|
|
} |
36
|
0
|
|
|
|
|
|
return $output; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
1; |