X-Git-Url: http://git.equinoxoli.org/?p=migration-tools.git;a=blobdiff_plain;f=Equinox-Migration%2Flib%2FEquinox%2FMigration%2FSimpleTagList.pm;h=c596d06f4ca7d7e9274d8eef941da749bab73f36;hp=301094b96b609dac61e34ff919e2c45761cb0846;hb=f3f1703187556e900e3b1b5e0f00ef8cce14da52;hpb=2c1a0eff7bc0ae19b91f43fce329298fbe1826f5 diff --git a/Equinox-Migration/lib/Equinox/Migration/SimpleTagList.pm b/Equinox-Migration/lib/Equinox/Migration/SimpleTagList.pm index 301094b..c596d06 100644 --- a/Equinox-Migration/lib/Equinox/Migration/SimpleTagList.pm +++ b/Equinox-Migration/lib/Equinox/Migration/SimpleTagList.pm @@ -40,8 +40,8 @@ or =head2 new -Takes one argument, optional argument, C. If this is speficied, -the tag list will be populated as per that file on instantiation. +Takes one optional argument, C. If this is speficied, the tag +list will be populated as per that file on instantiation. Returns a E::M::STL object. @@ -109,23 +109,28 @@ sub generate { open TAGFILE, '<', $self->{conf}{file}; while () { + next if m/^#/; + next if m/^\s*\n$/; + $self->{conf}{lastwasrange} = 0; $self->{conf}{range}{high} = 0; $self->{conf}{range}{low} = 0; - $self->{conf}{except} = 0; my @chunks = split /\s+/; while (my $chunk = shift @chunks) { + last if ($chunk =~ /^#/); # single values if ($chunk =~ /^\d{1,3}$/) { $self->add_tag($chunk); + $self->{conf}{except} = 0; next; } # ranges if ($chunk =~ /^\d{1,3}\.\.\d{1,3}$/) { $self->add_range($chunk); + $self->{conf}{except} = 0; next; } @@ -133,8 +138,6 @@ sub generate { if ($chunk eq 'except') { die "Keyword 'except' can only follow a range (line $.)\n" unless $self->{conf}{lastwasrange}; - die "Keyword 'except' may only occur once per line (line $.)\n" - if $self->{conf}{except}; $self->{conf}{except} = 1; next; } @@ -158,7 +161,7 @@ sub add_range { if ($low > $high); if ($self->{conf}{except}) { die "Exception ranges must be within last addition range ($low..$high)\n" - if ($low < $self->{range}{low} or $high > $self->{range}{high}); + if ($low < $self->{conf}{range}{low} or $high > $self->{conf}{range}{high}); } for my $tag ($low..$high) { $self->add_tag($tag) @@ -179,17 +182,19 @@ sub add_tag { my ($self, $tag) = @_; $tag =~ s/^0+//; + die "Values must be numeric\n" if ($tag =~ /[^\d\-]/); + die "Values must be valid tags (0-999)\n" unless ($tag >= 0 and $tag <= 999); if ($self->{conf}{except}) { - $self->remove_tag($tag) + $self->remove_tag($tag); } else { die "Tag '$tag' specified twice\n" if $self->{tags}{$tag}; $self->{tags}{$tag} = 1; + $self->{conf}{lastwasrange} = 0; } - $self->{conf}{lastwasrange} = 0; } =head2 remove_tag @@ -209,14 +214,6 @@ sub remove_tag { Shawn Boyette, C<< >> -=head1 TODO - -=over - -=item * Remove single-except rule? - -=back - =head1 BUGS Please report any bugs or feature requests to the above email address. @@ -225,12 +222,12 @@ Please report any bugs or feature requests to the above email address. You can find documentation for this module with the perldoc command. - perldoc Equinox::Migration::TrashTags + perldoc Equinox::Migration::SimpleTagList =head1 COPYRIGHT & LICENSE -Copyright 2009 Shawn Boyette, all rights reserved. +Copyright 2009 Equinox, all rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.