=begin testing
use Text::Tradition;
+use TryCatch;
my $READINGS = 311;
my $PATHS = 361;
is( scalar $st->collation->relationships, 3, "Reparsed collation has new relationships" );
# Now add a stemma, write to GraphML, and look at the output.
-my $stemma = $tradition->add_stemma( 'dotfile' => 't/data/florilegium.dot' );
-is( ref( $stemma ), 'Text::Tradition::Stemma', "Parsed dotfile into stemma" );
-is( $tradition->stemmata, 1, "Tradition now has the stemma" );
-$graphml = $c->as_graphml;
-like( $graphml, qr/digraph/, "Digraph declaration exists in GraphML" );
+my $SKIP_STEMMA;
+try {
+ $tradition->enable_stemmata;
+} catch {
+ $SKIP_STEMMA = 1;
+}
+SKIP: {
+ skip "Analysis module not present", 3 if $SKIP_STEMMA;
+ my $stemma = $tradition->add_stemma( 'dotfile' => 't/data/florilegium.dot' );
+ is( ref( $stemma ), 'Text::Tradition::Stemma', "Parsed dotfile into stemma" );
+ is( $tradition->stemmata, 1, "Tradition now has the stemma" );
+ $graphml = $c->as_graphml;
+ like( $graphml, qr/digraph/, "Digraph declaration exists in GraphML" );
+}
# Now add a user, write to GraphML, and look at the output.
unlike( $graphml, qr/testuser/, "Test user name does not exist in GraphML yet" );
=cut
+## TODO MOVE this to Tradition.pm
sub as_graphml {
my( $self, $options ) = @_;
$self->calculate_ranks unless $self->_graphcalc_done;
}
# Extra custom keys for complex objects that should be saved in some form.
# The subroutine should return a string, or undef/empty.
- $graph_attributes{'stemmata'} = sub {
- my @stemstrs;
- map { push( @stemstrs, $_->editable( {linesep => ''} ) ) }
- $self->tradition->stemmata;
- join( "\n", @stemstrs );
- };
+ if( $tmeta->has_method('stemmata') ) {
+ $graph_attributes{'stemmata'} = sub {
+ my @stemstrs;
+ map { push( @stemstrs, $_->editable( {linesep => ''} ) ) }
+ $self->tradition->stemmata;
+ join( "\n", @stemstrs );
+ };
+ }
+
$graph_attributes{'user'} = sub {
$self->tradition->user ? $self->tradition->user->id : undef
};