is( ref( $ptwit ), 'Text::Tradition::Witness', 'Created a witness' );
if( $ptwit ) {
is( $ptwit->sigil, 'A', "Witness has correct sigil" );
+ $c->make_witness_path( $ptwit );
is( $c->path_text( $ptwit->sigil ), $str, "Witness has correct text" );
}
=cut
+# Enable plugin(s) if available
+eval { with 'Text::Tradition::WitLanguage'; };
+
subtype 'SourceType',
as 'Str',
where { $_ =~ /^(xmldesc|plaintext|json|collation)$/ },
no Moose::Util::TypeConstraints;
has 'tradition' => (
- 'is' => 'ro',
- 'isa' => 'Text::Tradition',
- 'required' => 1,
- weak_ref => 1
+ is => 'ro',
+ isa => 'Text::Tradition',
+ required => 1,
+ weak_ref => 1
);
# Sigil. Required identifier for a witness, but may be found inside
predicate => 'has_layertext',
);
+has 'is_collated' => (
+ is => 'rw',
+ isa => 'Bool'
+ );
+
# Path. This is an array of Reading nodes that can be saved during
# initialization, but should be cleared before saving in a DB.
has 'path' => (
$self->$init_sub();
# Remove our XML / source objects; we no longer need them.
$self->clear_object if $self->has_object;
- $self->tradition->collation->make_witness_path( $self );
+ # $self->tradition->collation->make_witness_path( $self );
+ }
+ if( $self->sourcetype eq 'collation' ) {
+ $self->is_collated( 1 );
}
return $self;
}
sub _init_from_plaintext {
my( $self ) = @_;
+ unless( $self->has_sigil ) {
+ throw( "No sigil defined for the plaintext witness" );
+ }
my $str;
if( $self->has_file ) {
my $ok = open( INPUT, $self->file );
'name' => $self->identifier,
};
if( $self->is_layered ) {
- my @lwlist = map { { 't' => $_ || '' } } @{$self->uncorrected};
+ my @lwlist = map { { 't' => $_ || '' } } @{$self->layertext};
$obj->{'layertokens'} = \@lwlist;
}
return $obj;