Skip to content

Commit

Permalink
Fix relations and release status.
Browse files Browse the repository at this point in the history
No need to support old CPAN stuff.

Also, document undocumented validator methods.
  • Loading branch information
theory committed May 25, 2011
1 parent 45593e5 commit c16110c
Showing 1 changed file with 32 additions and 13 deletions.
45 changes: 32 additions & 13 deletions lib/PGXN/Meta/Validator.pm
Expand Up @@ -344,6 +344,10 @@ sub check_listormap {
=over =over
=item * anything($self,$key,$value)
Any value is valid, so this function always returns true.
=item * header($self,$key,$value) =item * header($self,$key,$value)
Validates that the header is valid. Validates that the header is valid.
Expand All @@ -354,6 +358,10 @@ Note: No longer used as we now read the data structure, not the file.
Validates that a given value is in an acceptable URL format Validates that a given value is in an acceptable URL format
=item * email($self,$key,$value)
Validates that a given value is in an acceptable EMAIL format
=item * urlspec($self,$key,$value) =item * urlspec($self,$key,$value)
Validates that the URL to a META specification is a known one. Validates that the URL to a META specification is a known one.
Expand All @@ -368,11 +376,30 @@ defined.
Validates that a string exists for the given key. Validates that a string exists for the given key.
=item * lc_string($self,$key,$value)
Validates that a string exists for the given key and contains only lowercase
characters.
=item * file($self,$key,$value) =item * file($self,$key,$value)
Validate that a file is passed for the given key. This may be made more Validate that a file is passed for the given key. This may be made more
thorough in the future. For now it acts like \&string. thorough in the future. For now it acts like \&string.
=item * phase($self,$key,$value)
Validate that a prereq phase is one of "configure", "build", "test",
"runtime", or "develop".
=item * relation($self,$key,$value)
Validate that a prereq relation is one of "requires", "recommends", or
"suggests".
=item * release_status($self,$key,$value)
Validate that release status is one of "stable", "testing", or "unstable".
=item * exversion($self,$key,$value) =item * exversion($self,$key,$value)
Validates a list of versions, e.g. '<= 5, >=2, ==3, !=4, >1, <6, 0'. Validates a list of versions, e.g. '<= 5, >=2, ==3, !=4, >1, <6, 0'.
Expand Down Expand Up @@ -430,19 +457,11 @@ sub header {


sub release_status { sub release_status {
my ($self,$key,$value) = @_; my ($self,$key,$value) = @_;
if(defined $value) { if (defined $value) {
my $version = $self->{data}{version} || ''; return 1 if $value =~ /\A(?:(?:un)?stable|testing)\z/;
if ( $version =~ /_/ ) {
return 1 if ( $value =~ /\A(?:testing|unstable)\z/ );
$self->_error( "'$value' for '$key' is invalid for version '$version'" );
}
else {
return 1 if ( $value =~ /\A(?:stable|testing|unstable)\z/ );
$self->_error( "'$value' for '$key' is invalid" ); $self->_error( "'$value' for '$key' is invalid" );
} } else {
} $self->_error( "'$key' is not defined" );
else {
$self->_error( "'$key' is not defined" );
} }
return 0; return 0;
} }
Expand Down Expand Up @@ -687,7 +706,7 @@ sub phase {
return 0; return 0;
} }


my @valid_relations = qw/ requires recommends suggests conflicts /; my @valid_relations = qw/ requires recommends suggests /;
sub relation { sub relation {
my ($self,$key) = @_; my ($self,$key) = @_;
if(defined $key) { if(defined $key) {
Expand Down

0 comments on commit c16110c

Please sign in to comment.