| 1 |
.\" -*- mode: troff; coding: utf-8 -*- |
| 2 |
.\" Automatically generated by Pod::Man 5.0102 (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 |
.\" |
| 57 |
.IX Title "CPAN::Meta::Converter 3perl" |
| 58 |
.TH CPAN::Meta::Converter 3perl 2025-11-16 "perl v5.40.1" "Perl Programmers Reference Guide" |
| 59 |
.\" For nroff, turn off justification. Always turn off hyphenation; it makes |
| 60 |
.\" way too many mistakes in technical documents. |
| 61 |
.if n .ad l |
| 62 |
.nh |
| 63 |
.SH NAME |
| 64 |
CPAN::Meta::Converter \- Convert CPAN distribution metadata structures |
| 65 |
.SH VERSION |
| 66 |
.IX Header "VERSION" |
| 67 |
version 2.150010 |
| 68 |
.SH SYNOPSIS |
| 69 |
.IX Header "SYNOPSIS" |
| 70 |
.Vb 1 |
| 71 |
\& my $struct = decode_json_file(\*(AqMETA.json\*(Aq); |
| 72 |
\& |
| 73 |
\& my $cmc = CPAN::Meta::Converter\->new( $struct ); |
| 74 |
\& |
| 75 |
\& my $new_struct = $cmc\->convert( version => "2" ); |
| 76 |
.Ve |
| 77 |
.SH DESCRIPTION |
| 78 |
.IX Header "DESCRIPTION" |
| 79 |
This module converts CPAN Meta structures from one form to another. The |
| 80 |
primary use is to convert older structures to the most modern version of |
| 81 |
the specification, but other transformations may be implemented in the |
| 82 |
future as needed. (E.g. stripping all custom fields or stripping all |
| 83 |
optional fields.) |
| 84 |
.SH METHODS |
| 85 |
.IX Header "METHODS" |
| 86 |
.SS new |
| 87 |
.IX Subsection "new" |
| 88 |
.Vb 1 |
| 89 |
\& my $cmc = CPAN::Meta::Converter\->new( $struct ); |
| 90 |
.Ve |
| 91 |
.PP |
| 92 |
The constructor should be passed a valid metadata structure but invalid |
| 93 |
structures are accepted. If no meta-spec version is provided, version 1.0 will |
| 94 |
be assumed. |
| 95 |
.PP |
| 96 |
Optionally, you can provide a \f(CW\*(C`default_version\*(C'\fR argument after \f(CW$struct\fR: |
| 97 |
.PP |
| 98 |
.Vb 1 |
| 99 |
\& my $cmc = CPAN::Meta::Converter\->new( $struct, default_version => "1.4" ); |
| 100 |
.Ve |
| 101 |
.PP |
| 102 |
This is only needed when converting a metadata fragment that does not include a |
| 103 |
\&\f(CW\*(C`meta\-spec\*(C'\fR field. |
| 104 |
.SS convert |
| 105 |
.IX Subsection "convert" |
| 106 |
.Vb 1 |
| 107 |
\& my $new_struct = $cmc\->convert( version => "2" ); |
| 108 |
.Ve |
| 109 |
.PP |
| 110 |
Returns a new hash reference with the metadata converted to a different form. |
| 111 |
\&\f(CW\*(C`convert\*(C'\fR will die if any conversion/standardization still results in an |
| 112 |
invalid structure. |
| 113 |
.PP |
| 114 |
Valid parameters include: |
| 115 |
.IP \(bu 4 |
| 116 |
\&\f(CW\*(C`version\*(C'\fR \-\- Indicates the desired specification version (e.g. "1.0", "1.1" ... "1.4", "2"). |
| 117 |
Defaults to the latest version of the CPAN Meta Spec. |
| 118 |
.PP |
| 119 |
Conversion proceeds through each version in turn. For example, a version 1.2 |
| 120 |
structure might be converted to 1.3 then 1.4 then finally to version 2. The |
| 121 |
conversion process attempts to clean-up simple errors and standardize data. |
| 122 |
For example, if \f(CW\*(C`author\*(C'\fR is given as a scalar, it will converted to an array |
| 123 |
reference containing the item. (Converting a structure to its own version will |
| 124 |
also clean-up and standardize.) |
| 125 |
.PP |
| 126 |
When data are cleaned and standardized, missing or invalid fields will be |
| 127 |
replaced with sensible defaults when possible. This may be lossy or imprecise. |
| 128 |
For example, some badly structured META.yml files on CPAN have prerequisite |
| 129 |
modules listed as both keys and values: |
| 130 |
.PP |
| 131 |
.Vb 1 |
| 132 |
\& requires => { \*(AqFoo::Bar\*(Aq => \*(AqBam::Baz\*(Aq } |
| 133 |
.Ve |
| 134 |
.PP |
| 135 |
These would be split and each converted to a prerequisite with a minimum |
| 136 |
version of zero. |
| 137 |
.PP |
| 138 |
When some mandatory fields are missing or invalid, the conversion will attempt |
| 139 |
to provide a sensible default or will fill them with a value of 'unknown'. For |
| 140 |
example a missing or unrecognized \f(CW\*(C`license\*(C'\fR field will result in a \f(CW\*(C`license\*(C'\fR |
| 141 |
field of 'unknown'. Fields that may get an 'unknown' include: |
| 142 |
.IP \(bu 4 |
| 143 |
abstract |
| 144 |
.IP \(bu 4 |
| 145 |
author |
| 146 |
.IP \(bu 4 |
| 147 |
license |
| 148 |
.SS upgrade_fragment |
| 149 |
.IX Subsection "upgrade_fragment" |
| 150 |
.Vb 1 |
| 151 |
\& my $new_struct = $cmc\->upgrade_fragment; |
| 152 |
.Ve |
| 153 |
.PP |
| 154 |
Returns a new hash reference with the metadata converted to the latest version |
| 155 |
of the CPAN Meta Spec. No validation is done on the result \-\- you must |
| 156 |
validate after merging fragments into a complete metadata document. |
| 157 |
.PP |
| 158 |
Available since version 2.141170. |
| 159 |
.SH BUGS |
| 160 |
.IX Header "BUGS" |
| 161 |
Please report any bugs or feature using the CPAN Request Tracker. |
| 162 |
Bugs can be submitted through the web interface at |
| 163 |
<http://rt.cpan.org/Dist/Display.html?Queue=CPAN\-Meta> |
| 164 |
.PP |
| 165 |
When submitting a bug or request, please include a test-file or a patch to an |
| 166 |
existing test-file that illustrates the bug or desired feature. |
| 167 |
.SH AUTHORS |
| 168 |
.IX Header "AUTHORS" |
| 169 |
.IP \(bu 4 |
| 170 |
David Golden <[email protected]> |
| 171 |
.IP \(bu 4 |
| 172 |
Ricardo Signes <[email protected]> |
| 173 |
.IP \(bu 4 |
| 174 |
Adam Kennedy <[email protected]> |
| 175 |
.SH "COPYRIGHT AND LICENSE" |
| 176 |
.IX Header "COPYRIGHT AND LICENSE" |
| 177 |
This software is copyright (c) 2010 by David Golden, Ricardo Signes, Adam Kennedy and Contributors. |
| 178 |
.PP |
| 179 |
This is free software; you can redistribute it and/or modify it under |
| 180 |
the same terms as the Perl 5 programming language system itself. |