1CPAN::Meta(3)         User Contributed Perl Documentation        CPAN::Meta(3)
2
3
4

NAME

6       CPAN::Meta - the distribution metadata for a CPAN dist
7

VERSION

9       version 2.102400
10

SYNOPSIS

12         my $meta = CPAN::Meta->load_file('META.json');
13
14         printf "testing requirements for %s version %s\n",
15           $meta->name,
16           $meta->version;
17
18         my $prereqs = $meta->requirements_for('configure');
19
20         for my $module ($prereqs->required_modules) {
21           my $version = get_local_version($module);
22
23           die "missing required module $module" unless defined $version;
24           die "version for $module not in range"
25             unless $prereqs->accepts_module($module, $version);
26         }
27

DESCRIPTION

29       Software distributions released to the CPAN include a META.json or, for
30       older distributions, META.yml, which describes the distribution, its
31       contents, and the requirements for building and installing the
32       distribution.  The data structure stored in the META.json file is
33       described in CPAN::Meta::Spec.
34
35       CPAN::Meta provides a simple class to represent this distribution
36       metadata (or distmeta), along with some helpful methods for
37       interrogating that data.
38
39       The documentation below is only for the methods of the CPAN::Meta
40       object.  For information on the meaning of individual fields, consult
41       the spec.
42

METHODS

44   new
45         my $meta = CPAN::Meta->new($distmeta_struct, \%options);
46
47       Returns a valid CPAN::Meta object or dies if the supplied metadata hash
48       reference fails to validate.  Older-format metadata will be up-
49       converted to version 2 if they validate against the original stated
50       specification.
51
52       Valid options include:
53
54       ·   lazy_validation -- if true, new will attempt to convert the given
55           metadata to version 2 before attempting to validate it.  This means
56           than any fixable errors will be handled by CPAN::Meta::Converter
57           before validation.  (Note that this might result in invalid
58           optional data being silently dropped.)  The default is false.
59
60   create
61         my $meta = CPAN::Meta->create($distmeta_struct);
62
63       This is same as "new()", except that "generated_by" and "meta-spec"
64       fields will be generated if not provided.  This means the metadata
65       structure is assumed to otherwise follow the latest CPAN::Meta::Spec.
66
67   load_file
68         my $meta = CPAN::Meta->load_file($distmeta_file, \%options);
69
70       Given a pathname to a file containing metadata, this deserializes the
71       file according to its file suffix and constructs a new "CPAN::Meta"
72       object, just like "new()".  It will die if the deserialized version
73       fails to validate against its stated specification version.
74
75       It takes the same options as "new()" but "lazy_validation" defaults to
76       true.
77
78   load_yaml_string
79         my $meta = CPAN::Meta->load_yaml_string($yaml, \%options);
80
81       This method returns a new CPAN::Meta object using the first document in
82       the given YAML string.  In other respects it is identical to
83       "load_file()".
84
85   load_json_string
86         my $meta = CPAN::Meta->load_json_string($json, \%options);
87
88       This method returns a new CPAN::Meta object using the structure
89       represented by the given JSON string.  In other respects it is
90       identical to "load_file()".
91
92   save
93         $meta->save($distmeta_file);
94
95       Serializes the object as JSON and writes it to the given file.  The
96       filename should end in '.json'.
97
98   meta_spec_version
99       This method returns the version part of the "meta_spec" entry in the
100       distmeta structure.  It is equivalent to:
101
102         $meta->meta_spec->{version};
103
104   effective_prereqs
105         my $prereqs = $meta->effective_prereqs;
106
107         my $prereqs = $meta->effective_prereqs( \@feature_identifiers );
108
109       This method returns a CPAN::Meta::Prereqs object describing all the
110       prereqs for the distribution.  If an arrayref of feature identifiers is
111       given, the prereqs for the identified features are merged together with
112       the distribution's core prereqs before the CPAN::Meta::Prereqs object
113       is returned.
114
115   should_index_file
116         ... if $meta->should_index_file( $filename );
117
118       This method returns true if the given file should be indexed.  It
119       decides this by checking the "file" and "directory" keys in the
120       "no_index" property of the distmeta structure.
121
122       $filename should be given in unix format.
123
124   should_index_package
125         ... if $meta->should_index_package( $package );
126
127       This method returns true if the given package should be indexed.  It
128       decides this by checking the "package" and "namespace" keys in the
129       "no_index" property of the distmeta structure.
130
131   features
132         my @feature_objects = $meta->features;
133
134       This method returns a list of CPAN::Meta::Feature objects, one for each
135       optional feature described by the distribution's metadata.
136
137   feature
138         my $feature_object = $meta->feature( $identifier );
139
140       This method returns a CPAN::Meta::Feature object for the optional
141       feature with the given identifier.  If no feature with that identifier
142       exists, an exception will be raised.
143
144   as_struct
145         my $copy = $meta->as_struct;
146
147       This method returns a deep copy of the object's metadata as an
148       unblessed has reference.  This is useful for raw analysis or for
149       passing to a converter object.  For example:
150
151         my $cmc = CPAN::Meta::Converter->new( $meta->as_struct );
152         my $meta_1_4 = $cmc->convert( version => "1.4" );
153

STRING DATA

155       The following methods return a single value, which is the value for the
156       corresponding entry in the distmeta structure.  Values should be either
157       undef or strings.
158
159       ·   abstract
160
161       ·   description
162
163       ·   dynamic_config
164
165       ·   generated_by
166
167       ·   name
168
169       ·   release_status
170
171       ·   version
172

LIST DATA

174       These methods return lists of string values, which might be represented
175       in the distmeta structure as arrayrefs or scalars:
176
177       ·   authors
178
179       ·   keywords
180
181       ·   licenses
182
183       The "authors" and "licenses" methods may also be called as "author" and
184       "license", respectively, to match the field name in the distmeta
185       structure.
186

MAP DATA

188       These readers return hashrefs of arbitrary unblessed data structures,
189       each described more fully in the specification:
190
191       ·   meta_spec
192
193       ·   resources
194
195       ·   provides
196
197       ·   no_index
198
199       ·   prereqs
200
201       ·   optional_features
202

CUSTOM DATA

204       A list of custom keys are available from the "custom_keys" method and
205       particular keys may be retrieved with the "custom" method.
206
207         say $meta->custom($_) for $meta->custom_keys;
208
209       If a custom key refers to a data structure, a deep clone is returned.
210

BUGS

212       Please report any bugs or feature using the CPAN Request Tracker.  Bugs
213       can be submitted through the web interface at
214       http://rt.cpan.org/Dist/Display.html?Queue=CPAN-Meta
215       <http://rt.cpan.org/Dist/Display.html?Queue=CPAN-Meta>
216
217       When submitting a bug or request, please include a test-file or a patch
218       to an existing test-file that illustrates the bug or desired feature.
219

SEE ALSO

221       ·   CPAN::Meta::Converter
222
223       ·   CPAN::Meta::Validator
224

AUTHORS

226       ·   David Golden <dagolden@cpan.org>
227
228       ·   Ricardo Signes <rjbs@cpan.org>
229
231       This software is copyright (c) 2010 by David Golden and Ricardo Signes.
232
233       This is free software; you can redistribute it and/or modify it under
234       the same terms as the Perl 5 programming language system itself.
235
236
237
238perl v5.12.1                      2010-08-28                     CPAN::Meta(3)
Impressum