make the rest of the tests work with the new Witness
[scpubgit/stemmatology.git] / lib / Text / Tradition.pm
index 5f8ad83..668383f 100644 (file)
@@ -1,6 +1,6 @@
 package Text::Tradition;
 
-use JSON qw / decode_json /;
+use JSON qw / from_json /;
 use Module::Load;
 use Moose;
 use Text::Tradition::Collation;
@@ -101,7 +101,14 @@ Text::Tradition - a software model for a set of collated texts
 
   my @text_wits = $t->witnesses();
   my $manuscript_a = $t->witness( 'A' );
-  my $new_ms = $t->add_witness( 'sigil' => 'B' );
+
+  $t = Text::Tradition->new();
+  $t->add_witness( 'sourcetype' => 'xmldesc', 
+    'file' => '/path/to/teitranscription.xml' );
+  $t->add_witness( 'sourcetype => 'plaintext', 'sigil' => 'Q',
+    'string' => 'The quick brown fox jumped over the lazy dogs' );
+  ## TODO
+  $t->collate_texts;
   
   my $text_path_svg = $t->collation->as_svg();
   ## See Text::Tradition::Collation for more on text collation itself
@@ -226,7 +233,7 @@ if( $wit_a ) {
 is( $s->witness('X'), undef, "There is no witness X" );
 ok( !exists $s->{'witnesses'}->{'X'}, "Witness key X not created" );
 
-my $wit_d = $s->add_witness( 'sigil' => 'D' );
+my $wit_d = $s->add_witness( 'sigil' => 'D', 'sourcetype' => 'collation' );
 is( ref( $wit_d ), 'Text::Tradition::Witness', "new witness created" );
 is( $wit_d->sigil, 'D', "witness has correct sigil" );
 is( scalar $s->witnesses, 4, "object now has four witnesses" );
@@ -294,8 +301,8 @@ each element therein.
 
 sub add_json_witnesses {
        my( $self, $jsonstr, $extraopts ) = @_;
-       my $witarray = decode_json( $jsonstr );
-       foreach my $witspec ( @$witarray ) {
+       my $witarray = from_json( $jsonstr );
+       foreach my $witspec ( @{$witarray->{witnesses}} ) {
                my $opts = $extraopts || {};
                $opts->{'sourcetype'} = 'json';
                $opts->{'object'} = $witspec;