X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FText%2FTradition.pm;h=0bbc76b442c32f012edcff255872fe6d3220fd79;hb=f8331a4d9b70a88b2a2cfdfba09c43daeb6aa398;hp=7995d0552f5f3e994664067074471693a08c82fa;hpb=9ba651b9a7717e06b04d524277307df39bcfd8e8;p=scpubgit%2Fstemmatology.git diff --git a/lib/Text/Tradition.pm b/lib/Text/Tradition.pm index 7995d05..0bbc76b 100644 --- a/lib/Text/Tradition.pm +++ b/lib/Text/Tradition.pm @@ -7,7 +7,7 @@ use Text::Tradition::Stemma; use Text::Tradition::Witness; use vars qw( $VERSION ); -$VERSION = "0.1"; +$VERSION = "0.3"; has 'collation' => ( is => 'ro', @@ -34,11 +34,22 @@ has 'name' => ( default => 'Tradition', ); -has 'stemma' => ( - is => 'ro', - isa => 'Text::Tradition::Stemma', - writer => '_add_stemma', - predicate => 'has_stemma', +has 'language' => ( + is => 'rw', + isa => 'Str', + ); + +has 'stemmata' => ( + traits => ['Array'], + isa => 'ArrayRef[Text::Tradition::Stemma]', + handles => { + stemmata => 'elements', + _add_stemma => 'push', + stemma => 'get', + stemma_count => 'count', + clear_stemmata => 'clear', + }, + default => sub { [] }, ); # Create the witness before trying to add it @@ -301,10 +312,12 @@ my $t = Text::Tradition->new( 'file' => 't/data/simple.txt', ); +is( $t->stemma_count, 0, "No stemmas added yet" ); my $s; ok( $s = $t->add_stemma( dotfile => 't/data/simple.dot' ), "Added a simple stemma" ); is( ref( $s ), 'Text::Tradition::Stemma', "Got a stemma object returned" ); -is( $t->stemma, $s, "Stemma is the right one" ); +is( $t->stemma_count, 1, "Tradition claims to have a stemma" ); +is( $t->stemma(0), $s, "Tradition hands back the right stemma" ); =end testing