File Coverage

blib/lib/Eliza/Chatbot/Option.pm
Criterion Covered Total %
statement 16 20 80.0
branch 1 2 50.0
condition n/a
subroutine 5 6 83.3
pod 2 2 100.0
total 24 30 80.0


line stmt bran cond sub pod time code
1             package Eliza::Chatbot::Option;
2              
3 10     10   67638 use Moo;
  10         11422  
  10         61  
4 10     10   4910 use MooX::LazierAttributes;
  10         18175  
  10         61  
5 10     10   6765 use Eliza::Chatbot::ScriptParser;
  10         41  
  10         2544  
6              
7             attributes (
8             [qw/script_file debug_text transform_text botprompt userprompt/] => [ rw, '', {lzy}],
9             [qw/prompts_on memory_on likelihood_of_using_memory/] => [ rw, 1, {lzy}],
10             name => [ rw, 'Eliza', {lzy}],
11             debug => [rw, 0, {lzy}],
12             max_memory_size => [rw, 5, {lzy}],
13             memory => [rw, [ ], {lzy}],
14             data => [ro, nan, {lzy, bld}]
15             );
16              
17             sub _build_data {
18 23     23   25749 my $self = shift;
19 23         406 my $parser = Eliza::Chatbot::ScriptParser->new(script_file => $self->script_file);
20 23         12116 $parser->parse_script_data;
21 23         586 return $parser;
22             }
23              
24             sub myrand {
25 11     11 1 143 my ($self, $max) = @_;
26 11 50       43 my $n = defined $max ? $max : 1;
27 11         179 return rand($n);
28             }
29              
30             sub welcome_message {
31 0     0 1   my $self = shift;
32 0           my $initial = $self->data->initial;
33 0           return $initial->[ $self->myrand( scalar @{$initial} ) ];
  0            
34             }
35              
36             1;
37              
38             __END__