+ - API of 'provides' changed to require a 'version' argument to future
+ proof the function against CPAN Meta Spec changes
+
1.0.8 2012-02-07 22:30:00
- Adds 'provides' method to generate a CPAN META provides data structure
correctly; use of package_versions_from_directory is discouraged (DAGOLDEN)
die "provides() takes only one of 'dir' or 'files'\n"
if $args{dir} && $args{files};
+ die "provides() requires a 'version' argument"
+ unless defined $args{version};
+
+ die "provides() does not support version '$args{version}' metadata"
+ unless grep { $args{version} eq $_ } qw/1.4 2/;
+
$args{prefix} = 'lib' unless defined $args{prefix};
my $p;
my $version = $info->version;
# CPAN META 'provides' field for .pm files in a directory
- my $provides = Module::Metadata->provides(dir => 'lib');
+ my $provides = Module::Metadata->provides(
+ dir => 'lib', version => 2
+ );
=head1 DESCRIPTION
=over
+=item version B<(required)>
+
+Specifies which version of the L<CPAN::Meta::Spec> should be used as
+the format of the C<provides> output. Currently only '1.4' and '2'
+are supported (and their format is identical). This may change in
+the future as the definition of C<provides> changes.
+
+The C<version> option is required. If it is omitted or if
+an unsupported version is given, then C<provides> will throw an error.
+
=item dir
Directory to search recursively for F<.pm> files. May not be specified with
or diag explain $got_pvfd;
{
- my $got_provides = Module::Metadata->provides(dir => 'lib');
+ my $got_provides = Module::Metadata->provides(dir => 'lib', version => 2);
my $exp_provides = {
'Simple' => {
'file' => 'lib/Simple.pm',
}
{
- my $got_provides = Module::Metadata->provides(dir => 'lib', prefix => 'other');
+ my $got_provides = Module::Metadata->provides(dir => 'lib', prefix => 'other', version => 1.4);
my $exp_provides = {
'Simple' => {
'file' => 'other/Simple.pm',