Debian Codegraph @

upstream/mageia-cauldron/man3pm/CPAN::Meta::Converter.3pm

raw
1 .\" -*- mode: troff; coding: utf-8 -*-
2 .\" Automatically generated by Pod::Man v6.0.2 (Pod::Simple 3.45)
3 .\"
4 .\" Standard preamble:
5 .\" ========================================================================
6 .de Sp \" Vertical space (when we can't use .PP)
7 .if t .sp .5v
8 .if n .sp
9 ..
10 .de Vb \" Begin verbatim text
11 .ft CW
12 .nf
13 .ne \\$1
14 ..
15 .de Ve \" End verbatim text
16 .ft R
17 .fi
18 ..
19 .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>.
20 .ie n \{\
21 . ds C` ""
22 . ds C' ""
23 'br\}
24 .el\{\
25 . ds C`
26 . ds C'
27 'br\}
28 .\"
29 .\" Escape single quotes in literal strings from groff's Unicode transform.
30 .ie \n(.g .ds Aq \(aq
31 .el .ds Aq '
32 .\"
33 .\" If the F register is >0, we'll generate index entries on stderr for
34 .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
35 .\" entries marked with X<> in POD. Of course, you'll have to process the
36 .\" output yourself in some meaningful fashion.
37 .\"
38 .\" Avoid warning from groff about undefined register 'F'.
39 .de IX
40 ..
41 .nr rF 0
42 .if \n(.g .if rF .nr rF 1
43 .if (\n(rF:(\n(.g==0)) \{\
44 . if \nF \{\
45 . de IX
46 . tm Index:\\$1\t\\n%\t"\\$2"
47 ..
48 . if !\nF==2 \{\
49 . nr % 0
50 . nr F 2
51 . \}
52 . \}
53 .\}
54 .rr rF
55 .\"
56 .\" Required to disable full justification in groff 1.23.0.
57 .if n .ds AD l
58 .\" ========================================================================
59 .\"
60 .IX Title "CPAN::Meta::Converter 3pm"
61 .TH CPAN::Meta::Converter 3pm 2023-12-22 "perl v5.42.0" "Perl Programmers Reference Guide"
62 .\" For nroff, turn off justification. Always turn off hyphenation; it makes
63 .\" way too many mistakes in technical documents.
64 .if n .ad l
65 .nh
66 .SH NAME
67 CPAN::Meta::Converter \- Convert CPAN distribution metadata structures
68 .SH VERSION
69 .IX Header "VERSION"
70 version 2.150010
71 .SH SYNOPSIS
72 .IX Header "SYNOPSIS"
73 .Vb 1
74 \& my $struct = decode_json_file(\*(AqMETA.json\*(Aq);
75 \&
76 \& my $cmc = CPAN::Meta::Converter\->new( $struct );
77 \&
78 \& my $new_struct = $cmc\->convert( version => "2" );
79 .Ve
80 .SH DESCRIPTION
81 .IX Header "DESCRIPTION"
82 This module converts CPAN Meta structures from one form to another. The
83 primary use is to convert older structures to the most modern version of
84 the specification, but other transformations may be implemented in the
85 future as needed. (E.g. stripping all custom fields or stripping all
86 optional fields.)
87 .SH METHODS
88 .IX Header "METHODS"
89 .SS new
90 .IX Subsection "new"
91 .Vb 1
92 \& my $cmc = CPAN::Meta::Converter\->new( $struct );
93 .Ve
94 .PP
95 The constructor should be passed a valid metadata structure but invalid
96 structures are accepted. If no meta\-spec version is provided, version 1.0 will
97 be assumed.
98 .PP
99 Optionally, you can provide a \f(CW\*(C`default_version\*(C'\fR argument after \f(CW$struct\fR:
100 .PP
101 .Vb 1
102 \& my $cmc = CPAN::Meta::Converter\->new( $struct, default_version => "1.4" );
103 .Ve
104 .PP
105 This is only needed when converting a metadata fragment that does not include a
106 \&\f(CW\*(C`meta\-spec\*(C'\fR field.
107 .SS convert
108 .IX Subsection "convert"
109 .Vb 1
110 \& my $new_struct = $cmc\->convert( version => "2" );
111 .Ve
112 .PP
113 Returns a new hash reference with the metadata converted to a different form.
114 \&\f(CW\*(C`convert\*(C'\fR will die if any conversion/standardization still results in an
115 invalid structure.
116 .PP
117 Valid parameters include:
118 .IP \(bu 4
119 \&\f(CW\*(C`version\*(C'\fR \-\- Indicates the desired specification version (e.g. "1.0", "1.1" ... "1.4", "2").
120 Defaults to the latest version of the CPAN Meta Spec.
121 .PP
122 Conversion proceeds through each version in turn. For example, a version 1.2
123 structure might be converted to 1.3 then 1.4 then finally to version 2. The
124 conversion process attempts to clean\-up simple errors and standardize data.
125 For example, if \f(CW\*(C`author\*(C'\fR is given as a scalar, it will converted to an array
126 reference containing the item. (Converting a structure to its own version will
127 also clean\-up and standardize.)
128 .PP
129 When data are cleaned and standardized, missing or invalid fields will be
130 replaced with sensible defaults when possible. This may be lossy or imprecise.
131 For example, some badly structured META.yml files on CPAN have prerequisite
132 modules listed as both keys and values:
133 .PP
134 .Vb 1
135 \& requires => { \*(AqFoo::Bar\*(Aq => \*(AqBam::Baz\*(Aq }
136 .Ve
137 .PP
138 These would be split and each converted to a prerequisite with a minimum
139 version of zero.
140 .PP
141 When some mandatory fields are missing or invalid, the conversion will attempt
142 to provide a sensible default or will fill them with a value of \*(Aqunknown\*(Aq. For
143 example a missing or unrecognized \f(CW\*(C`license\*(C'\fR field will result in a \f(CW\*(C`license\*(C'\fR
144 field of \*(Aqunknown\*(Aq. Fields that may get an \*(Aqunknown\*(Aq include:
145 .IP \(bu 4
146 abstract
147 .IP \(bu 4
148 author
149 .IP \(bu 4
150 license
151 .SS upgrade_fragment
152 .IX Subsection "upgrade_fragment"
153 .Vb 1
154 \& my $new_struct = $cmc\->upgrade_fragment;
155 .Ve
156 .PP
157 Returns a new hash reference with the metadata converted to the latest version
158 of the CPAN Meta Spec. No validation is done on the result \-\- you must
159 validate after merging fragments into a complete metadata document.
160 .PP
161 Available since version 2.141170.
162 .SH BUGS
163 .IX Header "BUGS"
164 Please report any bugs or feature using the CPAN Request Tracker.
165 Bugs can be submitted through the web interface at
166 <http://rt.cpan.org/Dist/Display.html?Queue=CPAN\-Meta>
167 .PP
168 When submitting a bug or request, please include a test\-file or a patch to an
169 existing test\-file that illustrates the bug or desired feature.
170 .SH AUTHORS
171 .IX Header "AUTHORS"
172 .IP \(bu 4
173 David Golden <[email protected]>
174 .IP \(bu 4
175 Ricardo Signes <[email protected]>
176 .IP \(bu 4
177 Adam Kennedy <[email protected]>
178 .SH "COPYRIGHT AND LICENSE"
179 .IX Header "COPYRIGHT AND LICENSE"
180 This software is copyright (c) 2010 by David Golden, Ricardo Signes, Adam Kennedy and Contributors.
181 .PP
182 This is free software; you can redistribute it and/or modify it under
183 the same terms as the Perl 5 programming language system itself.