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.120921
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       It takes an optional hashref of options. 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, \%options);
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, \%options);
94
95       Serializes the object as JSON and writes it to the given file.  The
96       only valid option is "version", which defaults to '2'. On Perl 5.8.1 or
97       later, the file is saved with UTF-8 encoding.
98
99       For "version" 2 (or higher), the filename should end in '.json'.
100       JSON::PP is the default JSON backend. Using another JSON backend
101       requires JSON 2.5 or later and you must set the $ENV{PERL_JSON_BACKEND}
102       to a supported alternate backend like JSON::XS.
103
104       For "version" less than 2, the filename should end in '.yml'.
105       CPAN::Meta::Converter is used to generate an older metadata structure,
106       which is serialized to YAML.  CPAN::Meta::YAML is the default YAML
107       backend.  You may set the $ENV{PERL_YAML_BACKEND} to a supported
108       alternative backend, though this is not recommended due to subtle
109       incompatibilities between YAML parsers on CPAN.
110
111   meta_spec_version
112       This method returns the version part of the "meta_spec" entry in the
113       distmeta structure.  It is equivalent to:
114
115         $meta->meta_spec->{version};
116
117   effective_prereqs
118         my $prereqs = $meta->effective_prereqs;
119
120         my $prereqs = $meta->effective_prereqs( \@feature_identifiers );
121
122       This method returns a CPAN::Meta::Prereqs object describing all the
123       prereqs for the distribution.  If an arrayref of feature identifiers is
124       given, the prereqs for the identified features are merged together with
125       the distribution's core prereqs before the CPAN::Meta::Prereqs object
126       is returned.
127
128   should_index_file
129         ... if $meta->should_index_file( $filename );
130
131       This method returns true if the given file should be indexed.  It
132       decides this by checking the "file" and "directory" keys in the
133       "no_index" property of the distmeta structure.
134
135       $filename should be given in unix format.
136
137   should_index_package
138         ... if $meta->should_index_package( $package );
139
140       This method returns true if the given package should be indexed.  It
141       decides this by checking the "package" and "namespace" keys in the
142       "no_index" property of the distmeta structure.
143
144   features
145         my @feature_objects = $meta->features;
146
147       This method returns a list of CPAN::Meta::Feature objects, one for each
148       optional feature described by the distribution's metadata.
149
150   feature
151         my $feature_object = $meta->feature( $identifier );
152
153       This method returns a CPAN::Meta::Feature object for the optional
154       feature with the given identifier.  If no feature with that identifier
155       exists, an exception will be raised.
156
157   as_struct
158         my $copy = $meta->as_struct( \%options );
159
160       This method returns a deep copy of the object's metadata as an
161       unblessed has reference.  It takes an optional hashref of options.  If
162       the hashref contains a "version" argument, the copied metadata will be
163       converted to the version of the specification and returned.  For
164       example:
165
166         my $old_spec = $meta->as_struct( {version => "1.4"} );
167
168   as_string
169         my $string = $meta->as_string( \%options );
170
171       This method returns a serialized copy of the object's metadata as a
172       character string.  (The strings are not UTF-8 encoded.)  It takes an
173       optional hashref of options.  If the hashref contains a "version"
174       argument, the copied metadata will be converted to the version of the
175       specification and returned.  For example:
176
177         my $string = $meta->as_struct( {version => "1.4"} );
178
179       For "version" greater than or equal to 2, the string will be serialized
180       as JSON.  For "version" less than 2, the string will be serialized as
181       YAML.  In both cases, the same rules are followed as in the "save()"
182       method for choosing a serialization backend.
183

STRING DATA

185       The following methods return a single value, which is the value for the
186       corresponding entry in the distmeta structure.  Values should be either
187       undef or strings.
188
189       ·   abstract
190
191       ·   description
192
193       ·   dynamic_config
194
195       ·   generated_by
196
197       ·   name
198
199       ·   release_status
200
201       ·   version
202

LIST DATA

204       These methods return lists of string values, which might be represented
205       in the distmeta structure as arrayrefs or scalars:
206
207       ·   authors
208
209       ·   keywords
210
211       ·   licenses
212
213       The "authors" and "licenses" methods may also be called as "author" and
214       "license", respectively, to match the field name in the distmeta
215       structure.
216

MAP DATA

218       These readers return hashrefs of arbitrary unblessed data structures,
219       each described more fully in the specification:
220
221       ·   meta_spec
222
223       ·   resources
224
225       ·   provides
226
227       ·   no_index
228
229       ·   prereqs
230
231       ·   optional_features
232

CUSTOM DATA

234       A list of custom keys are available from the "custom_keys" method and
235       particular keys may be retrieved with the "custom" method.
236
237         say $meta->custom($_) for $meta->custom_keys;
238
239       If a custom key refers to a data structure, a deep clone is returned.
240

BUGS

242       Please report any bugs or feature using the CPAN Request Tracker.  Bugs
243       can be submitted through the web interface at
244       <http://rt.cpan.org/Dist/Display.html?Queue=CPAN-Meta>
245
246       When submitting a bug or request, please include a test-file or a patch
247       to an existing test-file that illustrates the bug or desired feature.
248

SEE ALSO

250       ·   CPAN::Meta::Converter
251
252       ·   CPAN::Meta::Validator
253

SUPPORT

255   Bugs / Feature Requests
256       Please report any bugs or feature requests through the issue tracker at
257       <http://rt.cpan.org/Public/Dist/Display.html?Name=CPAN-Meta>.  You will
258       be notified automatically of any progress on your issue.
259
260   Source Code
261       This is open source software.  The code repository is available for
262       public review and contribution under the terms of the license.
263
264       <http://github.com/dagolden/cpan-meta>
265
266         git clone git://github.com/dagolden/cpan-meta.git
267

AUTHORS

269       ·   David Golden <dagolden@cpan.org>
270
271       ·   Ricardo Signes <rjbs@cpan.org>
272
274       This software is copyright (c) 2010 by David Golden and Ricardo Signes.
275
276       This is free software; you can redistribute it and/or modify it under
277       the same terms as the Perl 5 programming language system itself.
278
279
280
281perl v5.16.3                      2012-04-01                     CPAN::Meta(3)
Impressum