X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FText%2FTradition%2FWitness.pm;h=145eba4c92e5ba074d25df96dc7599e110307824;hb=6a222840d60d8ef64c47e5ce0c4f033db1f72e2b;hp=f5703658a839e976e6c56ee33f24600480c82da9;hpb=4ca00eca4d82f9c83acdf8e88683f1465e6a7486;p=scpubgit%2Fstemmatology.git diff --git a/lib/Text/Tradition/Witness.pm b/lib/Text/Tradition/Witness.pm index f570365..145eba4 100644 --- a/lib/Text/Tradition/Witness.pm +++ b/lib/Text/Tradition/Witness.pm @@ -32,25 +32,19 @@ has 'path' => ( predicate => 'has_path', ); -has 'post_correctione' => ( - is => 'rw', - isa => 'Str', - predicate => 'has_post_correctione', - ); - subtype 'Correction', as 'ArrayRef', where { @{$_} == 3 && - $_->[0]->isa( 'Int' ) && - $_->[1]->isa( 'Int' ) && - $_->[2]->isa( 'ArrayRef[Text::Tradition::Collation::Reading]' ); + find_type_constraint('Int')->check( $_->[0] ) && + find_type_constraint('Int')->check( $_->[1] ) && + find_type_constraint('ArrayRef[Text::Tradition::Collation::Reading]')->check( $_->[2] ); }, message { 'Correction must be a tuple of [offset, length, list]' }; -has 'corrections' => ( - is => 'ro', +has 'ante_corr' => ( + is => 'rw', isa => 'ArrayRef[Correction]', - default => sub { [] }, + predicate => 'has_ante_corr', ); @@ -85,20 +79,14 @@ around text => sub { $self->$orig( @_ ); }; -sub add_correction { - my( $self, $offset, $length, @replacement ) = @_; - # Rely on Moose for type checking of the arguments - push( @{$self->corrections}, [ $offset, $length, \@replacement ] ); -} - -sub corrected_path { +sub uncorrected_path { my $self = shift; my @new_path; push( @new_path, @{$self->path} ); my $drift = 0; - foreach my $correction ( @{$self->corrections} ) { - my( $offset, $length, $items ) = @$correction; + foreach my $change ( @{$self->ante_corr} ) { + my( $offset, $length, $items ) = @$change; my $realoffset = $offset + $drift; splice( @new_path, $realoffset, $length, @$items ); $drift += @$items - $length;