| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Test::CPAN::Meta::YAML; |
|
2
|
|
|
|
|
|
|
|
|
3
|
8
|
|
|
8
|
|
100819
|
use warnings; |
|
|
8
|
|
|
|
|
17
|
|
|
|
8
|
|
|
|
|
287
|
|
|
4
|
8
|
|
|
8
|
|
33
|
use strict; |
|
|
8
|
|
|
|
|
10
|
|
|
|
8
|
|
|
|
|
265
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
8
|
|
|
8
|
|
33
|
use vars qw($VERSION); |
|
|
8
|
|
|
|
|
16
|
|
|
|
8
|
|
|
|
|
595
|
|
|
7
|
|
|
|
|
|
|
$VERSION = '0.24'; |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
#---------------------------------------------------------------------------- |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 NAME |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
Test::CPAN::Meta::YAML - Validate a F 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 F 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 F 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 C is actually two |
|
47
|
|
|
|
|
|
|
tests under the hood. |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
This module was written to ensure that a F 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
|
|
|
|
|
|
|
=cut |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
#---------------------------------------------------------------------------- |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
############################################################################# |
|
63
|
|
|
|
|
|
|
#Library Modules # |
|
64
|
|
|
|
|
|
|
############################################################################# |
|
65
|
|
|
|
|
|
|
|
|
66
|
8
|
|
|
8
|
|
607
|
use Test::Builder; |
|
|
8
|
|
|
|
|
8243
|
|
|
|
8
|
|
|
|
|
250
|
|
|
67
|
8
|
|
|
8
|
|
4087
|
use Test::YAML::Valid -Syck; |
|
|
8
|
|
|
|
|
8362
|
|
|
|
8
|
|
|
|
|
55
|
|
|
68
|
8
|
|
|
8
|
|
24578
|
use Test::CPAN::Meta::YAML::Version; |
|
|
8
|
|
|
|
|
35
|
|
|
|
8
|
|
|
|
|
662
|
|
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
#---------------------------------------------------------------------------- |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
my $Test = Test::Builder->new(); |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub import { |
|
75
|
8
|
|
|
8
|
|
111
|
my $self = shift; |
|
76
|
8
|
|
|
|
|
20
|
my $caller = caller; |
|
77
|
8
|
|
|
8
|
|
74
|
no strict 'refs'; |
|
|
8
|
|
|
|
|
8
|
|
|
|
8
|
|
|
|
|
2418
|
|
|
78
|
8
|
|
|
|
|
15
|
*{$caller.'::meta_yaml_ok'} = \&meta_yaml_ok; |
|
|
8
|
|
|
|
|
47
|
|
|
79
|
8
|
|
|
|
|
15
|
*{$caller.'::meta_spec_ok'} = \&meta_spec_ok; |
|
|
8
|
|
|
|
|
29
|
|
|
80
|
|
|
|
|
|
|
|
|
81
|
8
|
|
|
|
|
42
|
$Test->exported_to($caller); |
|
82
|
8
|
|
|
|
|
93
|
$Test->plan(@_); |
|
83
|
|
|
|
|
|
|
} |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
############################################################################# |
|
86
|
|
|
|
|
|
|
#Interface Functions # |
|
87
|
|
|
|
|
|
|
############################################################################# |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 FUNCTIONS |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=over |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=item * meta_yaml_ok([$msg]) |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
Basic F wrapper around C. |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=cut |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub meta_yaml_ok { |
|
100
|
1
|
|
|
1
|
1
|
27
|
$Test->plan( tests => 2 ); |
|
101
|
1
|
|
|
|
|
625
|
return meta_spec_ok(undef,undef,@_); |
|
102
|
|
|
|
|
|
|
} |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=item * meta_spec_ok($file, $version [,$msg]) |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Validates the named file against the given specification version. Both C<$file> |
|
107
|
|
|
|
|
|
|
and C<$version> can be undefined. |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=back |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=cut |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
sub meta_spec_ok { |
|
114
|
10
|
|
|
10
|
1
|
3802
|
my ($file, $vers, $msg) = @_; |
|
115
|
10
|
|
100
|
|
|
33
|
$file ||= 'META.yml'; |
|
116
|
|
|
|
|
|
|
|
|
117
|
10
|
100
|
|
|
|
25
|
unless($msg) { |
|
118
|
8
|
|
|
|
|
14
|
$msg = "$file meets the designated specification"; |
|
119
|
8
|
100
|
|
|
|
48
|
$msg .= " ($vers)" if($vers); |
|
120
|
|
|
|
|
|
|
} |
|
121
|
|
|
|
|
|
|
|
|
122
|
10
|
50
|
|
|
|
32
|
if(my $yaml = yaml_file_ok($file)) { |
|
123
|
10
|
|
|
|
|
5377
|
my %hash; |
|
124
|
10
|
100
|
|
|
|
32
|
$hash{spec} = $vers if($vers); |
|
125
|
10
|
|
|
|
|
17
|
$hash{data} = $yaml; |
|
126
|
|
|
|
|
|
|
|
|
127
|
10
|
|
|
|
|
73
|
my $spec = Test::CPAN::Meta::YAML::Version->new(%hash); |
|
128
|
10
|
100
|
|
|
|
30
|
if(my $result = $spec->parse()) { |
|
129
|
2
|
|
|
|
|
5
|
$Test->ok(0,$msg); |
|
130
|
2
|
|
|
|
|
692
|
$Test->diag(" ERR: $_") for($spec->errors); |
|
131
|
|
|
|
|
|
|
} else { |
|
132
|
8
|
|
|
|
|
77
|
$Test->ok(1,$msg); |
|
133
|
|
|
|
|
|
|
} |
|
134
|
|
|
|
|
|
|
|
|
135
|
10
|
|
|
|
|
2436
|
return $yaml; |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
} else { |
|
138
|
0
|
|
|
|
|
|
print STDERR "\n#Failed\n"; |
|
139
|
|
|
|
|
|
|
} |
|
140
|
|
|
|
|
|
|
} |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
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 ); |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
__END__ |