blib/lib/SignalWire/Skills/Builtin/PlayBackgroundFile.pm

filter: Statementstmt 100% 31 / 31 Branchbran 50.0% 1 / 2 Conditioncond 100% 4 / 4 MC/DCmcdc 100% 2 / 2 Subroutinesub 100% 10 / 10 Podpod 0.0% 0 / 3 totaltotal 92.3% 48 / 52 CC 5 SCAR 8.9
CC
5
Cov
97%
register_tools
5.0
BEGIN
1.0
BEGIN
1.0
CRAP 2.4
« blib/lib/SignalWire/Logging.pm ↑ Summary blib/lib/SignalWire/REST/Namespaces/PhoneNumbers.pm »
1 package SignalWire::Skills::Builtin::PlayBackgroundFile;
2 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 4 extends 'SignalWire::Skills::SkillBase';
6  
7 4 ▶use SignalWire::Skills::SkillRegistry;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 4 SignalWire::Skills::SkillRegistry->register_skill('play_background_file', __PACKAGE__);
9  
10 5 ▶has '+skill_name' => (default => sub { 'play_background_file' });
Subroutine __ANON__: called CC=1 SCAR=0.0
11 5 ▶has '+skill_description' => (default => sub { 'Control background file playback' });
Subroutine __ANON__: called CC=1 SCAR=0.0
12 5 ▶has '+supports_multiple_instances' => (default => sub { 1 });
Subroutine __ANON__: called CC=1 SCAR=0.0
13  
14 4 ▶sub setup { 1 }
Subroutine setup: called CC=1 SCAR=0.0
Pod undocumented
15  
16 3 ▶sub register_tools {
Subroutine register_tools: called CC=5 SCAR=16.1
Pod undocumented
17 3 my ($self) = @_;
18 3 ▶ my $tool_name = $self->params->{tool_name} // 'play_background_file';
Condition100%2/2
$self->params->{"tool_name"} // "play_background_file"
l!l
12
MC/DC100%1/1
$self->params->{"tool_name"} // "play_background_file"
$self->params->{"tool_name"}
Truth table100%2/2
A
A= $self->params->{"tool_name"}
Aresult
11
00
19 3 ▶ my $files = $self->params->{files} // [];
Condition100%2/2
$self->params->{"files"} // []
l!l
21
MC/DC100%1/1
$self->params->{"files"} // []
$self->params->{"files"}
Truth table100%2/2
A
A= $self->params->{"files"}
Aresult
11
00
20  
21 # Build action enum from file keys
22 3 my @actions = ('stop');
23 3 for my $f (@$files) {
24 2 ▶ push @actions, "start_$f->{key}" if $f->{key};
Branch: 1 branch
BranchTrueFalseTotal
if $f->{"key"} 2 0 2
25 }
26  
27 # DataMap-style registration with expressions
28 $self->agent->register_swaig_function({
29 3 function => $tool_name,
30 description => "Control background file playback for $tool_name",
31 parameters => {
32 type => 'object',
33 properties => {
34 action => {
35 type => 'string',
36 description => 'Playback action',
37 enum => \@actions,
38 },
39 },
40 required => ['action'],
41 },
42 data_map => {
43 expressions => [
44 {
45 string => '${args.action}',
46 pattern => 'stop',
47 output => {
48 response => 'Stopping background playback.',
49 action => [{ stop_background_file => {} }],
50 },
51 },
52 ],
53 },
54 });
55 }
56  
57 1 ▶sub get_parameter_schema {
Subroutine get_parameter_schema: called CC=1 SCAR=0.0
Pod undocumented
58 return {
59 1 %{ SignalWire::Skills::SkillBase->get_parameter_schema },
60 files => { type => 'array', required => 1, description => 'Array of file objects with key, description, url' },
61 tool_name => { type => 'string', default => 'play_background_file' },
62 };
63 }
64  
65 4 1;
« blib/lib/SignalWire/Logging.pm ↑ Summary blib/lib/SignalWire/REST/Namespaces/PhoneNumbers.pm »