Permalink
Browse files

updated from david's master

  • Loading branch information...
2 parents 6075a4a + c0b30eb commit f10de0083b9354c2c014746c5e2cd371e1c088a2 @barbie committed Apr 21, 2010
Showing with 65 additions and 30 deletions.
  1. +12 −0 Changes
  2. +13 −7 lib/CPAN/Meta/Spec.pm
  3. +40 −23 lib/CPAN/Meta/Validator.pm
View
12 Changes
@@ -2,6 +2,18 @@ Revision history for CPAN-Meta
{{$NEXT}}
+2.101110 2010-04-21 11:06:52 EST5EDT
+
+ - clarified that .XXXXXX versions of the CPAN-Meta distribution will not
+ change the meaning of the CPAN::Meta::Spec, but may fix typos or
+ clarify prose
+
+ - fixed a typo regarding dotted-integer versions: keeping components
+ in the range 0-999 was corrected to a "should" instead of a "must"
+
+ - fixed validation bugs for certain types of nested data structures
+ (based on a patch provided by Barbie)
+
2.101091 2010-04-19 06:32:13 EST5EDT
- keep the old specs from getting indexed so as not to confuse people
View
@@ -13,7 +13,7 @@ package CPAN::Meta::Spec;
name => 'Module-Build',
abstract => 'Build and install Perl modules',
description => "Module::Build is a system for "
- . "building, testing, and installing Perl modules. "
+ . "building, testing, and installing Perl modules. "
. "It is meant to ... blah blah blah ...",
version => '0.36',
author => [
@@ -68,6 +68,11 @@ package CPAN::Meta::Spec;
This document describes version 2 of the CPAN distribution metadata
specification, also known as the "CPAN Meta Spec".
+Revisions of this specification for typo corrections and prose
+clarifications may be issued as CPAN::Meta::Spec 2.I<x>. These
+revisions will never change semantics or add or remove specified
+behavior.
+
Distribution metadata describe important properties of Perl
distributions. Distribution building tools like Module::Build,
Module::Install, ExtUtils::MakeMaker or Dist::Zilla should create a
@@ -357,8 +362,8 @@ The following keys are valid, but only C<version> is required.
=item version
-This subkey gives the I<Version> of the CPAN Meta Spec against which the
-document was generated.
+This subkey gives the integer I<Version> of the CPAN Meta Spec against
+which the document was generated.
=item url
@@ -442,7 +447,7 @@ structure refers.
Example:
description => "Module::Build is a system for "
- . "building, testing, and installing Perl modules. "
+ . "building, testing, and installing Perl modules. "
. "It is meant to ... blah blah blah ...",
(Spec 2) [optional] {String}
@@ -803,8 +808,9 @@ positive integers separated by full stop characters (i.e. "dots",
"periods" or "decimal points"). This are equivalent in format to Perl
"v-strings", with some additional restrictions on form. They must be
given in "normal" form, which has a leading "v" character and at least
-three integer components. All components after the first are restricted
-to the range 0 to 999. The final component B<may> be separated by an
+three integer components. To retain a one-to-one mapping with decimal
+versions, all components after the first B<should> be restricted to the
+range 0 to 999. The final component B<may> be separated by an
underscore character instead of a period.
version => 'v1.2.3' # OK
@@ -816,7 +822,7 @@ underscore character instead of a period.
version => 'v1.2' # Illegal
version => '1.2.3' # Illegal
version => 'v1.2_3_4' # Illegal
- version => 'v1.2009.10.31' # Illegal
+ version => 'v1.2009.10.31' # Not recommended
=back
View
@@ -62,11 +62,11 @@ my $prereq_map = {
'map' => {
':key' => {
name => \&relation,
- 'map' => { ':key' => { name => \&module, value => \&exversion } },
- }
- }
+ %$module_map1,
+ },
+ },
}
- }
+ },
};
my %definitions = (
@@ -94,7 +94,8 @@ my %definitions = (
'no_index' => $no_index_1_3,
'optional_features' => {
'map' => {
- ':key' => { name => \&identifier,
+ ':key' => {
+ name => \&identifier,
'map' => {
description => { value => \&string },
prereqs => $prereq_map,
@@ -104,29 +105,40 @@ my %definitions = (
},
'prereqs' => $prereq_map,
'provides' => {
- 'map' => { ':key' => { name => \&module,
- 'map' => { file => { mandatory => 1, value => \&file },
- version => { value => \&version } } } }
+ 'map' => {
+ ':key' => {
+ name => \&module,
+ 'map' => {
+ file => { mandatory => 1, value => \&file },
+ version => { value => \&version }
+ }
+ }
+ }
},
'resources' => {
- 'map' => { license => { lazylist => { value => \&url } },
+ 'map' => {
+ license => { lazylist => { value => \&url } },
homepage => { value => \&url },
- bugtracker => { 'map' => {
+ bugtracker => {
+ 'map' => {
web => { value => \&url },
mailto => { value => \&string},
- }},
- repository => { 'map' => {
+ }
+ },
+ repository => {
+ 'map' => {
web => { value => \&url },
url => { value => \&url },
type => { value => \&string },
- }},
+ }
+ },
':key' => { value => \&string, name => \&custom_2 },
}
},
# CUSTOM -- additional user defined key/value pairs
# note we can only validate the key name, as the structure is user defined
- ':key' => { name => \&custom_2 },
+ ':key' => { name => \&custom_2, value => \&anything },
},
'1.4' => {
@@ -184,7 +196,7 @@ my %definitions = (
# additional user defined key/value pairs
# note we can only validate the key name, as the structure is user defined
- ':key' => { name => \&string },
+ ':key' => { name => \&string, value => \&anything },
},
'1.3' => {
@@ -241,7 +253,7 @@ my %definitions = (
# additional user defined key/value pairs
# note we can only validate the key name, as the structure is user defined
- ':key' => { name => \&string },
+ ':key' => { name => \&string, value => \&anything },
},
# v1.2 is misleading, it seems to assume that a number of fields where created
@@ -302,7 +314,7 @@ my %definitions = (
# additional user defined key/value pairs
# note we can only validate the key name, as the structure is user defined
- ':key' => { name => \&string },
+ ':key' => { name => \&string, value => \&anything },
},
# note that the 1.1 spec only specifies 'version' as mandatory
@@ -325,7 +337,7 @@ my %definitions = (
# additional user defined key/value pairs
# note we can only validate the key name, as the structure is user defined
- ':key' => { name => \&string },
+ ':key' => { name => \&string, value => \&anything },
},
# note that the 1.0 spec doesn't specify optional or mandatory fields
@@ -346,7 +358,7 @@ my %definitions = (
# additional user defined key/value pairs
# note we can only validate the key name, as the structure is user defined
- ':key' => { name => \&string },
+ ':key' => { name => \&string, value => \&anything },
},
);
@@ -386,6 +398,9 @@ sub errors {
}
+my $spec_error = "Missing validation action in specification. "
+ . "Must be one of 'map', 'list', 'lazylist', or 'value'";
+
sub check_map {
my ($self,$spec,$data) = @_;
@@ -419,7 +434,7 @@ sub check_map {
} elsif($spec->{$key}{'lazylist'}) {
$self->check_lazylist($spec->{$key}{'lazylist'},$data->{$key});
} else {
- $self->_error( "Missing validation action in specification. Must be one of 'map', 'list', 'lazylist', or 'value' for '$key'." );
+ $self->_error( "$spec_error for '$key'" );
}
} elsif ($spec->{':key'}) {
@@ -432,8 +447,8 @@ sub check_map {
$self->check_list($spec->{':key'}{'list'},$data->{$key});
} elsif($spec->{':key'}{'lazylist'}) {
$self->check_lazylist($spec->{':key'}{'lazylist'},$data->{$key});
- } elsif(!$spec->{':key'}{name}) {
- $self->_error( "Missing validation action in specification. Must be one of 'map', 'list', 'lazylist', 'name' or 'value' for ':key'." );
+ } else {
+ $self->_error( "$spec_error for ':key'" );
}
} else {
@@ -481,7 +496,7 @@ sub check_list {
} elsif ($spec->{':key'}) {
$self->check_map($spec,$value);
} else {
- $self->_error( "Missing validation action in specification. Must be one of 'map', 'list', 'lazylist', 'value' or ':key' in the 'list' or 'lazylist' associated with '$self->{stack}[-2]'." );
+ $self->_error( "$spec_error associated with '$self->{stack}[-2]'" );
}
pop @{$self->{stack}};
}
@@ -562,6 +577,8 @@ sub urlspec {
return 0;
}
+sub anything { return 1 }
+
sub string {
my ($self,$key,$value) = @_;
if(defined $value) {

0 comments on commit f10de00

Please sign in to comment.