line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
2
|
|
|
2
|
|
1574
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
52
|
|
2
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
83
|
|
3
|
|
|
|
|
|
|
package App::AppSpec::Schema::Validator; |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.005'; # VERSION |
6
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
859
|
use App::Spec; |
|
2
|
|
|
|
|
51656
|
|
|
2
|
|
|
|
|
68
|
|
8
|
2
|
|
|
2
|
|
872
|
use App::Spec::Schema qw/ $SCHEMA /; |
|
2
|
|
|
|
|
1122
|
|
|
2
|
|
|
|
|
239
|
|
9
|
2
|
|
|
2
|
|
13
|
use YAML::PP; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
59
|
|
10
|
2
|
|
|
2
|
|
10
|
use Moo; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
9
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub validate_spec_file { |
13
|
1
|
|
|
1
|
0
|
498
|
my ($self, $file) = @_; |
14
|
1
|
|
|
|
|
13
|
my $yp = YAML::PP->new( boolean => 'JSON::PP', schema => [qw/ JSON /] ); |
15
|
1
|
|
|
|
|
15083
|
my $spec = $yp->load_file($file); |
16
|
1
|
|
|
|
|
45986
|
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
|
|
|
|
|
765
|
|
22
|
|
|
|
|
|
|
or die "JSON::Validator is needed for validating a spec file"; |
23
|
1
|
|
|
|
|
213514
|
my $json_validator = JSON::Validator->new; |
24
|
1
|
|
|
|
|
26
|
$json_validator->schema($SCHEMA); |
25
|
1
|
|
|
|
|
10639
|
my @errors = $json_validator->validate($spec); |
26
|
1
|
|
|
|
|
12961
|
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; |