1CPAN::Meta::Converter(3U)ser Contributed Perl DocumentatiCoPnAN::Meta::Converter(3)
2
3
4

NAME

6       CPAN::Meta::Converter - Convert CPAN distribution metadata structures
7

VERSION

9       version 2.150010
10

SYNOPSIS

12         my $struct = decode_json_file('META.json');
13
14         my $cmc = CPAN::Meta::Converter->new( $struct );
15
16         my $new_struct = $cmc->convert( version => "2" );
17

DESCRIPTION

19       This module converts CPAN Meta structures from one form to another.
20       The primary use is to convert older structures to the most modern
21       version of the specification, but other transformations may be
22       implemented in the future as needed.  (E.g. stripping all custom fields
23       or stripping all optional fields.)
24

METHODS

26   new
27         my $cmc = CPAN::Meta::Converter->new( $struct );
28
29       The constructor should be passed a valid metadata structure but invalid
30       structures are accepted.  If no meta-spec version is provided, version
31       1.0 will be assumed.
32
33       Optionally, you can provide a "default_version" argument after $struct:
34
35         my $cmc = CPAN::Meta::Converter->new( $struct, default_version => "1.4" );
36
37       This is only needed when converting a metadata fragment that does not
38       include a "meta-spec" field.
39
40   convert
41         my $new_struct = $cmc->convert( version => "2" );
42
43       Returns a new hash reference with the metadata converted to a different
44       form.  "convert" will die if any conversion/standardization still
45       results in an invalid structure.
46
47       Valid parameters include:
48
49       ·   "version" -- Indicates the desired specification version (e.g.
50           "1.0", "1.1" ... "1.4", "2").  Defaults to the latest version of
51           the CPAN Meta Spec.
52
53       Conversion proceeds through each version in turn.  For example, a
54       version 1.2 structure might be converted to 1.3 then 1.4 then finally
55       to version 2. The conversion process attempts to clean-up simple errors
56       and standardize data.  For example, if "author" is given as a scalar,
57       it will converted to an array reference containing the item.
58       (Converting a structure to its own version will also clean-up and
59       standardize.)
60
61       When data are cleaned and standardized, missing or invalid fields will
62       be replaced with sensible defaults when possible.  This may be lossy or
63       imprecise.  For example, some badly structured META.yml files on CPAN
64       have prerequisite modules listed as both keys and values:
65
66         requires => { 'Foo::Bar' => 'Bam::Baz' }
67
68       These would be split and each converted to a prerequisite with a
69       minimum version of zero.
70
71       When some mandatory fields are missing or invalid, the conversion will
72       attempt to provide a sensible default or will fill them with a value of
73       'unknown'.  For example a missing or unrecognized "license" field will
74       result in a "license" field of 'unknown'.  Fields that may get an
75       'unknown' include:
76
77       ·   abstract
78
79       ·   author
80
81       ·   license
82
83   upgrade_fragment
84         my $new_struct = $cmc->upgrade_fragment;
85
86       Returns a new hash reference with the metadata converted to the latest
87       version of the CPAN Meta Spec.  No validation is done on the result --
88       you must validate after merging fragments into a complete metadata
89       document.
90
91       Available since version 2.141170.
92

BUGS

94       Please report any bugs or feature using the CPAN Request Tracker.  Bugs
95       can be submitted through the web interface at
96       <http://rt.cpan.org/Dist/Display.html?Queue=CPAN-Meta>
97
98       When submitting a bug or request, please include a test-file or a patch
99       to an existing test-file that illustrates the bug or desired feature.
100

AUTHORS

102       ·   David Golden <dagolden@cpan.org>
103
104       ·   Ricardo Signes <rjbs@cpan.org>
105
106       ·   Adam Kennedy <adamk@cpan.org>
107
109       This software is copyright (c) 2010 by David Golden, Ricardo Signes,
110       Adam Kennedy and Contributors.
111
112       This is free software; you can redistribute it and/or modify it under
113       the same terms as the Perl 5 programming language system itself.
114
115
116
117perl v5.32.0                      2020-07-28          CPAN::Meta::Converter(3)
Impressum