NAME
Langertha::Holmgang::Role::AnswerWorld - The plugin role of a world with its own tools
VERSION
version 0.001
SYNOPSIS
package My::Sim::Library;
use Moose;
use namespace::autoclean;
with 'Langertha::Holmgang::Role::AnswerWorld';
sub device_type { 'library' }
sub tools { return { search_books => [], lend_book => [qw( book reader )] } }
sub tool {
my ( $self, $world, $name, $args, $ctx ) = @_;
if ( $name eq 'lend_book' ) {
my $b = $world->{books}{ $args->{book} } or return ( 'Error: no book '.$args->{book}.'.', 0 );
$b->{lent_to} = $args->{reader};
return ( 'ok', 1 );
}
return ( join( "\n", sort keys %{ $world->{books} || {} } ), 1 );
}
__PACKAGE__->meta->make_immutable;
# suite.yaml
tools:
- { name: lend_book, simulator: library, description: …, parameters: { … required: [ book, reader ] } }
DESCRIPTION
An answer world is a simulated world without a command line: instead of run_command it brings its own general tools (search, read, add …), the same for every case of a suite. A suite tool names the world as its simulator; the tool's name picks what the world does. The world's state is the entry of the case's state whose type is the world's "device_type" (the first by key, when several have it).
The arguments, the result list ($output, $ok, optional $sim_gap) and the rules (only the state, three answers, keys documented in the POD) are the same as for a device simulator — see Langertha::Holmgang::Role::Simulator. An answer world may also implement prepare as described there.
device_type
sub device_type { 'kueche' }
Required. The type of the world's entry in the state, and the name a suite tool gives as simulator.
tools
my $tools = $world->tools; # { tool_name => [ required parameter names ] }
Required. The tools this world answers, each with the parameters it cannot do without. The loader refuses a suite tool naming this world whose name is not a key here, or whose parameters.required lacks one of these names.
tool
my ( $output, $ok, $gap ) = $world->tool( $state, $name, \%args, $ctx );
Required. Answers one call of the tool $name with the model's %args on the world's state $state (which it may change, like $dev of a device simulator).
SUPPORT
Issues
Please report bugs and feature requests at https://github.com/Getty/langertha-holmgang/issues.
IRC
Join #langertha on irc.perl.org or message Getty directly.
CONTRIBUTING
Contributions are welcome! Please fork the repository and submit a pull request.
AUTHOR
Torsten Raudssus <torsten@raudssus.de>
COPYRIGHT AND LICENSE
This software is copyright (c) 2026 by Torsten Raudssus <torsten@raudssus.de> https://raudssus.de/.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.