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

filter: Statementstmt 78.3% 29 / 37 Branchbran n/a Conditioncond 50.0% 2 / 4 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 78.5% 11 / 14 Podpod 0.0% 0 / 4 totaltotal 68.8% 42 / 61 CC 3 SCAR 6.0
CC
3
Cov
76%
register_tools
4.4
__ANON__
2.0
__ANON__
2.0
CRAP 1.8
« blib/lib/SignalWire/Skills/Builtin/ApiNinjasTrivia.pm ↑ Summary blib/lib/SignalWire/Skills/Builtin/Datetime.pm »
1 package SignalWire::Skills::Builtin::GoogleMaps;
2 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 extends 'SignalWire::Skills::SkillBase';
6  
7 3 ▶use SignalWire::Skills::SkillRegistry;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 3 SignalWire::Skills::SkillRegistry->register_skill('google_maps', __PACKAGE__);
9  
10 4 ▶has '+skill_name' => (default => sub { 'google_maps' });
Subroutine __ANON__: called CC=1 SCAR=0.0
11 4 ▶has '+skill_description' => (default => sub { 'Validate addresses and compute driving routes using Google Maps' });
Subroutine __ANON__: called CC=1 SCAR=0.0
12 4 ▶has '+supports_multiple_instances' => (default => sub { 0 });
Subroutine __ANON__: called CC=1 SCAR=0.0
13  
14 3 ▶sub setup { 1 }
Subroutine setup: called CC=1 SCAR=0.0
Pod undocumented
15  
16 2 ▶sub register_tools {
Subroutine register_tools: called CC=3 SCAR=14.7
Pod undocumented
17 2 my ($self) = @_;
18 2 ▶ my $lookup_name = $self->params->{lookup_tool_name} // 'lookup_address';
Condition50%1/2
$self->params->{"lookup_tool_name"} // "lookup_address"
l!l
02
MC/DC0%0/1
$self->params->{"lookup_tool_name"} // "lookup_address"
$self->params->{"lookup_tool_name"}
Truth table50%1/2
A
A= $self->params->{"lookup_tool_name"}
Aresult
11
00
19 2 ▶ my $route_name = $self->params->{route_tool_name} // 'compute_route';
Condition50%1/2
$self->params->{"route_tool_name"} // "compute_route"
l!l
02
MC/DC0%0/1
$self->params->{"route_tool_name"} // "compute_route"
$self->params->{"route_tool_name"}
Truth table50%1/2
A
A= $self->params->{"route_tool_name"}
Aresult
11
00
20  
21 $self->define_tool(
22 name => $lookup_name,
23 description => 'Look up and validate an address using Google Maps Geocoding',
24 parameters => {
25 type => 'object',
26 properties => {
27 address => { type => 'string', description => 'Address to look up' },
28 bias_lat => { type => 'number', description => 'Latitude bias' },
29 bias_lng => { type => 'number', description => 'Longitude bias' },
30 },
31 required => ['address'],
32 },
33 0 ▶ handler => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
34 0 my ($args, $raw) = @_;
35 0 require SignalWire::SWAIG::FunctionResult;
36 0 return SignalWire::SWAIG::FunctionResult->new(
37 response => "Address lookup for: $args->{address}"
38 );
39 },
40 2 );
41  
42 $self->define_tool(
43 name => $route_name,
44 description => 'Compute a driving route between two points',
45 parameters => {
46 type => 'object',
47 properties => {
48 origin_lat => { type => 'number', description => 'Origin latitude' },
49 origin_lng => { type => 'number', description => 'Origin longitude' },
50 dest_lat => { type => 'number', description => 'Destination latitude' },
51 dest_lng => { type => 'number', description => 'Destination longitude' },
52 },
53 required => ['origin_lat', 'origin_lng', 'dest_lat', 'dest_lng'],
54 },
55 0 ▶ handler => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
56 0 my ($args, $raw) = @_;
57 0 require SignalWire::SWAIG::FunctionResult;
58 0 return SignalWire::SWAIG::FunctionResult->new(
59 response => "Route computed from ($args->{origin_lat},$args->{origin_lng}) to ($args->{dest_lat},$args->{dest_lng})"
60 );
61 },
62 2 );
63 }
64  
65 2 ▶sub get_hints {
Subroutine get_hints: called CC=1 SCAR=0.0
Pod undocumented
66 2 return ['address', 'location', 'route', 'directions', 'miles', 'distance'];
67 }
68  
69 1 ▶sub _get_prompt_sections {
Subroutine _get_prompt_sections: called CC=1 SCAR=0.0
70 return [{
71 1 title => 'Google Maps',
72 body => '',
73 bullets => [
74 'Use lookup_address to validate and geocode addresses',
75 'Use compute_route to get driving directions between two points',
76 ],
77 }];
78 }
79  
80 0 ▶sub get_parameter_schema {
Subroutine get_parameter_schema: not called CC=1 SCAR=6.9
Pod undocumented
81 return {
82 0 %{ SignalWire::Skills::SkillBase->get_parameter_schema },
83 api_key => { type => 'string', required => 1, hidden => 1 },
84 lookup_tool_name => { type => 'string', default => 'lookup_address' },
85 route_tool_name => { type => 'string', default => 'compute_route' },
86 };
87 }
88  
89 3 1;
« blib/lib/SignalWire/Skills/Builtin/ApiNinjasTrivia.pm ↑ Summary blib/lib/SignalWire/Skills/Builtin/Datetime.pm »