line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::CPAN::Meta::YAML; |
2
|
|
|
|
|
|
|
|
3
|
8
|
|
|
8
|
|
93625
|
use warnings; |
|
8
|
|
|
|
|
14
|
|
|
8
|
|
|
|
|
262
|
|
4
|
8
|
|
|
8
|
|
28
|
use strict; |
|
8
|
|
|
|
|
11
|
|
|
8
|
|
|
|
|
211
|
|
5
|
|
|
|
|
|
|
|
6
|
8
|
|
|
8
|
|
27
|
use vars qw($VERSION); |
|
8
|
|
|
|
|
13
|
|
|
8
|
|
|
|
|
490
|
|
7
|
|
|
|
|
|
|
$VERSION = '0.23'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
#---------------------------------------------------------------------------- |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 NAME |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
Test::CPAN::Meta::YAML - Validate a META.yml file within a CPAN distribution. |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 SYNOPSIS |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
There are two forms this module can be used. |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
The first is a standalone test of your distribution's META.yml file: |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
use Test::More; |
22
|
|
|
|
|
|
|
eval "use Test::CPAN::Meta::YAML"; |
23
|
|
|
|
|
|
|
plan skip_all => "Test::CPAN::Meta::YAML required for testing META.yml" if $@; |
24
|
|
|
|
|
|
|
meta_yaml_ok(); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
Note that you may provide an optional label/comment/message/etc to the |
27
|
|
|
|
|
|
|
function, or one will be created automatically. |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
The second form allows you to test other META.yml files, or specify a specific |
30
|
|
|
|
|
|
|
version you wish to test against: |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
use Test::More test => 6; |
33
|
|
|
|
|
|
|
use Test::CPAN::Meta::YAML; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
# specify a file and specification version |
36
|
|
|
|
|
|
|
meta_spec_ok('META.yml','1.3',$msg); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
# specify the specification version to validate the local META.yml |
39
|
|
|
|
|
|
|
meta_spec_ok(undef,'1.3',$msg); |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# specify a file, where the specification version is deduced |
42
|
|
|
|
|
|
|
# from the file itself |
43
|
|
|
|
|
|
|
meta_spec_ok('META.yml',undef,$msg); |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
Note that this form requires you to specify the number of tests you will be |
46
|
|
|
|
|
|
|
running in your test script. Also note that each 'meta_spec_ok' is actually 2 |
47
|
|
|
|
|
|
|
tests under the hood. |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head1 DESCRIPTION |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
This module was written to ensure that a META.yml file, provided with a |
52
|
|
|
|
|
|
|
standard distribution uploaded to CPAN, meets the specifications that slowly |
53
|
|
|
|
|
|
|
being introduced to module uploads, via the use of L, |
54
|
|
|
|
|
|
|
L and L. |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
See L for further details of the CPAN Meta Specification. |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head1 ABSTRACT |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
A test module to validate a META.yml file. |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=cut |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
#---------------------------------------------------------------------------- |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
############################################################################# |
67
|
|
|
|
|
|
|
#Library Modules # |
68
|
|
|
|
|
|
|
############################################################################# |
69
|
|
|
|
|
|
|
|
70
|
8
|
|
|
8
|
|
723
|
use Test::Builder; |
|
8
|
|
|
|
|
9850
|
|
|
8
|
|
|
|
|
186
|
|
71
|
8
|
|
|
8
|
|
3733
|
use Test::YAML::Valid -Syck; |
|
8
|
|
|
|
|
7692
|
|
|
8
|
|
|
|
|
54
|
|
72
|
8
|
|
|
8
|
|
21788
|
use Test::CPAN::Meta::YAML::Version; |
|
8
|
|
|
|
|
24
|
|
|
8
|
|
|
|
|
547
|
|
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
#---------------------------------------------------------------------------- |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
my $Test = Test::Builder->new(); |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub import { |
79
|
8
|
|
|
8
|
|
98
|
my $self = shift; |
80
|
8
|
|
|
|
|
17
|
my $caller = caller; |
81
|
8
|
|
|
8
|
|
48
|
no strict 'refs'; |
|
8
|
|
|
|
|
8
|
|
|
8
|
|
|
|
|
2035
|
|
82
|
8
|
|
|
|
|
13
|
*{$caller.'::meta_yaml_ok'} = \&meta_yaml_ok; |
|
8
|
|
|
|
|
36
|
|
83
|
8
|
|
|
|
|
13
|
*{$caller.'::meta_spec_ok'} = \&meta_spec_ok; |
|
8
|
|
|
|
|
23
|
|
84
|
|
|
|
|
|
|
|
85
|
8
|
|
|
|
|
30
|
$Test->exported_to($caller); |
86
|
8
|
|
|
|
|
76
|
$Test->plan(@_); |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
############################################################################# |
90
|
|
|
|
|
|
|
#Interface Functions # |
91
|
|
|
|
|
|
|
############################################################################# |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head1 FUNCTIONS |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=over |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=item * meta_yaml_ok([$msg]) |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
Basic META.yml wrapper around meta_spec_ok. |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=cut |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
sub meta_yaml_ok { |
104
|
1
|
|
|
1
|
1
|
16
|
$Test->plan( tests => 2 ); |
105
|
1
|
|
|
|
|
408
|
return meta_spec_ok(undef,undef,@_); |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=item * meta_spec_ok($file, $version [,$msg]) |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
Validates the named file against the given specification version. Both $file |
111
|
|
|
|
|
|
|
and $version can be undefined. |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=back |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=cut |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
sub meta_spec_ok { |
118
|
10
|
|
|
10
|
1
|
3054
|
my ($file, $vers, $msg) = @_; |
119
|
10
|
|
100
|
|
|
33
|
$file ||= 'META.yml'; |
120
|
|
|
|
|
|
|
|
121
|
10
|
100
|
|
|
|
23
|
unless($msg) { |
122
|
8
|
|
|
|
|
13
|
$msg = "$file meets the designated specification"; |
123
|
8
|
100
|
|
|
|
70
|
$msg .= " ($vers)" if($vers); |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
|
126
|
10
|
50
|
|
|
|
32
|
if(my $yaml = yaml_file_ok($file)) { |
127
|
10
|
|
|
|
|
5594
|
my %hash; |
128
|
10
|
100
|
|
|
|
30
|
$hash{spec} = $vers if($vers); |
129
|
10
|
|
|
|
|
15
|
$hash{data} = $yaml; |
130
|
|
|
|
|
|
|
|
131
|
10
|
|
|
|
|
62
|
my $spec = Test::CPAN::Meta::YAML::Version->new(%hash); |
132
|
10
|
100
|
|
|
|
26
|
if(my $result = $spec->parse()) { |
133
|
2
|
|
|
|
|
6
|
$Test->ok(0,$msg); |
134
|
2
|
|
|
|
|
844
|
$Test->diag(" ERR: $_") for($spec->errors); |
135
|
|
|
|
|
|
|
} else { |
136
|
8
|
|
|
|
|
26
|
$Test->ok(1,$msg); |
137
|
|
|
|
|
|
|
} |
138
|
|
|
|
|
|
|
|
139
|
10
|
|
|
|
|
2195
|
return $yaml; |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
} else { |
142
|
0
|
|
|
|
|
|
print STDERR "\n#Failed\n"; |
143
|
|
|
|
|
|
|
} |
144
|
|
|
|
|
|
|
} |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
q( This release is sponsored by Made In Love: Hand made gifts for your loved ones, friends or even a treat for your own home - http://madeinlove.co.uk ); |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
__END__ |