« blib/lib/SignalWire/Agents/Skills/Builtin/Joke.pm
↑ Summary
blib/lib/SignalWire/Agents/Skills/Builtin/Datasphere.pm »
| 1 | package SignalWire::Agents::SWML::Document; | ||||||||||||
| 2 | 2 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 3 | 2 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 4 | 2 | ▶ | use Moo; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 5 | 2 | ▶ | use JSON (); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 6 | |||||||||||||
| 7 | has 'version' => ( | ||||||||||||
| 8 | is => 'ro', | ||||||||||||
| 9 | 10 | ▶ | default => sub { '1.0.0' }, | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 10 | 2 | ); | |||||||||||
| 11 | |||||||||||||
| 12 | has 'sections' => ( | ||||||||||||
| 13 | is => 'rw', | ||||||||||||
| 14 | 10 | ▶ | default => sub { {} }, | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 15 | 2 | ); | |||||||||||
| 16 | |||||||||||||
| 17 | 7 | ▶ | sub add_section { | ||||||||||
|
Subroutine
add_section: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||
| 18 | 7 | my ($self, $name) = @_; | |||||||||||
| 19 | 7 | ▶ | $self->sections->{$name} //= []; | ||||||||||
|
Condition50%1/2
$self->sections->{$name} //= []
MC/DC0%0/1
$self->sections->{$name} //= []
$self->sections->{$name}
Truth table50%1/2
A
A= $self->sections->{$name}
| |||||||||||||
| 20 | 7 | return $self; | |||||||||||
| 21 | } | ||||||||||||
| 22 | |||||||||||||
| 23 | 9 | ▶ | sub add_verb { | ||||||||||
|
Subroutine
add_verb: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||
| 24 | 9 | my ($self, $section_name, $verb_name, $verb_data) = @_; | |||||||||||
| 25 | 9 | ▶ | $self->sections->{$section_name} //= []; | ||||||||||
|
Condition50%1/2
$self->sections->{$section_name} //= []
MC/DC0%0/1
$self->sections->{$section_name} //= []
$self->sections->{$section_name}
Truth table50%1/2
A
A= $self->sections->{$section_name}
| |||||||||||||
| 26 | 9 | push @{ $self->sections->{$section_name} }, { $verb_name => $verb_data }; | |||||||||||
| 27 | 9 | return $self; | |||||||||||
| 28 | } | ||||||||||||
| 29 | |||||||||||||
| 30 | 2 | ▶ | sub add_raw_verb { | ||||||||||
|
Subroutine
add_raw_verb: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||
| 31 | 2 | my ($self, $section_name, $verb_hash) = @_; | |||||||||||
| 32 | 2 | ▶ | $self->sections->{$section_name} //= []; | ||||||||||
|
Condition50%1/2
$self->sections->{$section_name} //= []
MC/DC0%0/1
$self->sections->{$section_name} //= []
$self->sections->{$section_name}
Truth table50%1/2
A
A= $self->sections->{$section_name}
| |||||||||||||
| 33 | 2 | push @{ $self->sections->{$section_name} }, $verb_hash; | |||||||||||
| 34 | 2 | return $self; | |||||||||||
| 35 | } | ||||||||||||
| 36 | |||||||||||||
| 37 | 7 | ▶ | sub get_section { | ||||||||||
|
Subroutine
get_section: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||
| 38 | 7 | my ($self, $name) = @_; | |||||||||||
| 39 | 7 | return $self->sections->{$name}; | |||||||||||
| 40 | } | ||||||||||||
| 41 | |||||||||||||
| 42 | 4 | ▶ | sub has_section { | ||||||||||
|
Subroutine
has_section: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||
| 43 | 4 | my ($self, $name) = @_; | |||||||||||
| 44 | 4 | return exists $self->sections->{$name}; | |||||||||||
| 45 | } | ||||||||||||
| 46 | |||||||||||||
| 47 | 2 | ▶ | sub clear_section { | ||||||||||
|
Subroutine
clear_section: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||
| 48 | 2 | my ($self, $name) = @_; | |||||||||||
| 49 | 2 | $self->sections->{$name} = []; | |||||||||||
| 50 | 2 | return $self; | |||||||||||
| 51 | } | ||||||||||||
| 52 | |||||||||||||
| 53 | 5 | ▶ | sub to_hash { | ||||||||||
|
Subroutine
to_hash: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||
| 54 | 5 | my ($self) = @_; | |||||||||||
| 55 | return { | ||||||||||||
| 56 | 5 | version => $self->version, | |||||||||||
| 57 | sections => $self->sections, | ||||||||||||
| 58 | }; | ||||||||||||
| 59 | } | ||||||||||||
| 60 | |||||||||||||
| 61 | 2 | ▶ | sub to_json { | ||||||||||
|
Subroutine
to_json: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||
| 62 | 2 | my ($self) = @_; | |||||||||||
| 63 | 2 | return JSON::encode_json($self->to_hash); | |||||||||||
| 64 | } | ||||||||||||
| 65 | |||||||||||||
| 66 | 0 | ▶ | sub to_pretty_json { | ||||||||||
|
Subroutine
to_pretty_json: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||
| 67 | 0 | my ($self) = @_; | |||||||||||
| 68 | 0 | my $json = JSON->new->utf8->canonical->pretty; | |||||||||||
| 69 | 0 | return $json->encode($self->to_hash); | |||||||||||
| 70 | } | ||||||||||||
| 71 | |||||||||||||
| 72 | 2 | 1; | |||||||||||