X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FModule%2FMetadata.pm;h=05f4cc11917e6e3f489a9f4bf93f8fd5be0ee9f2;hb=refs%2Fheads%2Ftopic%2Ffix_provides_files;hp=d11c8c0995a7342659699ed5b427e245925e3042;hpb=62849b9aac1248b26061ba3dfc9fc07162a4b9c6;p=p5sagit%2FModule-Metadata.git diff --git a/lib/Module/Metadata.pm b/lib/Module/Metadata.pm index d11c8c0..05f4cc1 100644 --- a/lib/Module/Metadata.pm +++ b/lib/Module/Metadata.pm @@ -198,6 +198,9 @@ sub new_from_module { croak "provides() takes only one of 'dir' or 'files'\n" if $args{dir} && $args{files}; + croak "provides() takes only one of 'files' or 'prefix'\n" + if $args{files} && $args{prefix}; + croak "provides() requires a 'version' argument" unless defined $args{version}; @@ -213,11 +216,11 @@ sub new_from_module { else { croak "provides() requires 'files' to be an array reference\n" unless ref $args{files} eq 'ARRAY'; - $p = $class->package_versions_from_directory($args{files}); + $p = $class->package_versions_from_directory('', $args{files}); } # Now, fix up files with prefix - if ( length $args{prefix} ) { # check in case disabled with q{} + if ( not $args{files} and length $args{prefix} ) { # check in case disabled with q{} $args{prefix} =~ s{/$}{}; for my $v ( values %$p ) { $v->{file} = "$args{prefix}/$v->{file}"; @@ -908,15 +911,16 @@ C. =item files -Array reference of files to examine. May not be specified with C. +Array reference of files to examine. May not be combined with C or +C. =item prefix String to prepend to the C field of the resulting output. This defaults to F, which is the common case for most CPAN distributions with their F<.pm> files in F. This option ensures the META information has the -correct relative path even when the C or C arguments are -absolute or have relative paths from a location other than the distribution +correct relative path even when the C argument is +absolute or has relative paths from a location other than the distribution root. =back