blib/lib/Langertha/Holmgang/Simulators.pm

filter: Statementstmt 54.1% 104 / 192 Branchbran 39.4% 41 / 104 Conditioncond 29.6% 38 / 128 MC/DCmcdc 16.1% 11 / 68 Subroutinesub 59.5% 25 / 42 Podpod 91.6% 22 / 24 totaltotal 43.1% 241 / 558 CC 107 SCAR 26.0
CC
107
Cov
43%
simulator
34.7
simulator
34.7
register
21.5
CRAP 13.5
« blib/lib/Langertha/Holmgang/Sim/Sehen.pm ↑ Summary blib/lib/Langertha/Holmgang/Loader.pm »
1 package Langertha::Holmgang::Simulators;
2 # ABSTRACT: Registry of simulators by device type, and dispatch of calls to them
3  
4 89 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 89 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 89 ▶use Carp qw( croak );
Subroutine BEGIN: called CC=1 SCAR=0.0
7 89 ▶use Module::Runtime qw( module_notional_filename use_module );
Subroutine BEGIN: called CC=1 SCAR=0.0
8 89 ▶use Moose::Util qw( find_meta );
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 89 our $VERSION = '0.001';
11  
12  
13 89 my %BUILTIN = (
14 linux => 'Langertha::Holmgang::Sim::Linux',
15 routeros => 'Langertha::Holmgang::Sim::RouterOS',
16 ios => 'Langertha::Holmgang::Sim::IOS',
17 kueche => 'Langertha::Holmgang::Sim::Kueche',
18 sehen => 'Langertha::Holmgang::Sim::Sehen',
19 schichtfehler => 'Langertha::Holmgang::Sim::Schichtfehler',
20 uebersetzung => 'Langertha::Holmgang::Sim::Uebersetzung',
21 denken => 'Langertha::Holmgang::Sim::Denken',
22 roost => 'Langertha::Holmgang::Sim::Roost',
23 );
24  
25 has _classes => (
26 is => 'ro',
27 init_arg => undef,
28 384 ▶ default => sub { +{ %BUILTIN } },
Subroutine __ANON__: called CC=1 SCAR=0.0
29 89 );
30  
31 has _instances => (
32 is => 'ro',
33 init_arg => undef,
34 384 ▶ default => sub { {} },
Subroutine __ANON__: called CC=1 SCAR=0.0
35 89 );
36  
37 has register_classes => (
38 is => 'ro',
39 382 ▶ default => sub { [] },
Subroutine __ANON__: called CC=1 SCAR=0.0
40 89 );
41  
42  
43 384 ▶sub BUILD {
Subroutine BUILD: called CC=2 SCAR=9.2
Pod undocumented
44 0 ▶ my ( $self ) = @_;
Subroutine BUILD: not called CC=2 SCAR=9.2
Pod undocumented
45 0 $self->register($_) for @{ $self->register_classes };
46 }
47  
48 8 ▶sub register {
Subroutine register: called CC=7 SCAR=30.7
Pod documented
49 0 ▶ my ( $self, $class ) = @_;
Subroutine register: not called CC=7 SCAR=30.7
Pod documented
50 0 ▶ croak __PACKAGE__.'->register needs a class name' unless defined $class && length $class && !ref $class;
Branch: 2 branches
BranchTrueFalseTotal
unless defined $class and length $class and not ref $class 0 8 8
unless defined $class and length $class and not ref $class 0 0 0
Condition16%2/12
defined $class and length $class and not ref $class
!ll&&!rl&&r
008
defined $class and length $class
!ll&&!rl&&r
008
defined $class and length $class and not ref $class
!ll&&!rl&&r
000
defined $class and length $class
!ll&&!rl&&r
000
MC/DC0%0/3
defined $class and length $class and not ref $class
defined $class length $class not ref $class
MC/DC0%0/3
defined $class and length $class and not ref $class
defined $class length $class not ref $class
Truth table25%1/4
A and B and not(C)
A= defined $classB= length $classC= not ref $class
ABCresult
0XX0
10X0
1100
1111
Truth table0%0/4
A and B and not(C)
A= defined $classB= length $classC= not ref $class
ABCresult
0XX0
10X0
1100
1111
51 0 $self->_load($class);
52 0 ▶ croak __PACKAGE__.'->register: '.$class.' composes neither Langertha::Holmgang::Role::Simulator nor Langertha::Holmgang::Role::AnswerWorld'
Branch: 2 branches
BranchTrueFalseTotal
unless $self->_is_simulator($class) 1 6 7
unless $self->_is_simulator($class) 0 0 0
53 unless $self->_is_simulator($class);
54 0 my $type = $class->device_type;
55 0 ▶ croak __PACKAGE__.'->register: '.$class.' has no device_type' unless defined $type && length $type;
Branch: 2 branches
BranchTrueFalseTotal
unless defined $type and length $type 0 6 6
unless defined $type and length $type 0 0 0
Condition16%1/6
defined $type and length $type
!ll&&!rl&&r
006
defined $type and length $type
!ll&&!rl&&r
000
MC/DC0%0/2
defined $type and length $type
defined $type length $type
MC/DC0%0/2
defined $type and length $type
defined $type length $type
Truth table33%1/3
A and B
A= defined $typeB= length $type
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= defined $typeB= length $type
ABresult
0X0
100
111
56 0 $self->_classes->{$type} = $class;
57 0 delete $self->_instances->{$type};
58 0 return $self;
59 }
60  
61  
62 # a class defined in a file already loaded (or inline, in a test) needs no require
63 740 ▶sub _load {
Subroutine _load: called CC=2 SCAR=9.2
64 0 ▶ my ( $self, $class ) = @_;
Subroutine _load: not called CC=2 SCAR=9.2
65 0 ▶ return if find_meta($class);
Branch: 2 branches
BranchTrueFalseTotal
if find_meta($class) 403 337 740
if find_meta($class) 0 0 0
66 0 use_module($class);
67 0 return;
68 }
69  
70 739 ▶sub _is_simulator {
Subroutine _is_simulator: called CC=3 SCAR=15.3
71 0 ▶ my ( $self, $class ) = @_;
Subroutine _is_simulator: not called CC=3 SCAR=15.3
72 0 ▶ return $class->can('does')
Condition41%5/12
$class->can('does') && ($class->does('Langertha::Holmgang::Role::Simulator') || $class->does('Langertha::Holmgang::Role::AnswerWorld'))
!ll&&!rl&&r
01738
$class->does("Langertha::Holmgang::Role::Simulator") or $class->does("Langertha::Holmgang::Role::AnswerWorld")
l!l&&r!l&&!r
2904481
$class->can('does') && ($class->does('Langertha::Holmgang::Role::Simulator') || $class->does('Langertha::Holmgang::Role::AnswerWorld'))
!ll&&!rl&&r
000
$class->does("Langertha::Holmgang::Role::Simulator") or $class->does("Langertha::Holmgang::Role::AnswerWorld")
l!l&&r!l&&!r
000
MC/DC66%2/3
$class->can('does') && ($class->does('Langertha::Holmgang::Role::Simulator') || $class->does('Langertha::Holmgang::Role::AnswerWorld'))
$class->can('does') $class->does("Langertha::Holmgang::Role::Simulator") $class->does("Langertha::Holmgang::Role::AnswerWorld")
MC/DC0%0/3
$class->can('does') && ($class->does('Langertha::Holmgang::Role::Simulator') || $class->does('Langertha::Holmgang::Role::AnswerWorld'))
$class->can('does') $class->does("Langertha::Holmgang::Role::Simulator") $class->does("Langertha::Holmgang::Role::AnswerWorld")
Truth table75%3/4
A && B or C
A= $class->can('does')B= $class->does("Langertha::Holmgang::Role::Simulator")C= $class->does("Langertha::Holmgang::Role::AnswerWorld")
ABCresult
0XX0
1000
11X1
1011
Truth table0%0/4
A && B or C
A= $class->can('does')B= $class->does("Langertha::Holmgang::Role::Simulator")C= $class->does("Langertha::Holmgang::Role::AnswerWorld")
ABCresult
0XX0
1000
11X1
1011
73 && ( $class->does('Langertha::Holmgang::Role::Simulator') || $class->does('Langertha::Holmgang::Role::AnswerWorld') );
74 }
75  
76 394 ▶sub types {
Subroutine types: called CC=1 SCAR=1.2
Pod documented
77 0 ▶ my ( $self ) = @_;
Subroutine types: not called CC=1 SCAR=1.2
Pod documented
78 0 return sort grep { $self->simulator($_) } keys %{ $self->_classes };
79 }
80  
81  
82 6805 ▶sub simulator {
Subroutine simulator: called CC=9 SCAR=35.5
Pod documented
83 0 ▶ my ( $self, $type ) = @_;
Subroutine simulator: not called CC=9 SCAR=35.5
Pod documented
84 0 ▶ return unless defined $type && !ref $type;
Branch: 2 branches
BranchTrueFalseTotal
unless defined $type and not ref $type 0 6805 6805
unless defined $type and not ref $type 0 0 0
Condition16%1/6
defined $type and not ref $type
!ll&&!rl&&r
006805
defined $type and not ref $type
!ll&&!rl&&r
000
MC/DC0%0/2
defined $type and not ref $type
defined $type not ref $type
MC/DC0%0/2
defined $type and not ref $type
defined $type not ref $type
Truth table33%1/3
A and not(B)
A= defined $typeB= not ref $type
ABresult
0X0
100
111
Truth table0%0/3
A and not(B)
A= defined $typeB= not ref $type
ABresult
0X0
100
111
85 0 my $inst = $self->_instances;
86 0 ▶ return $inst->{$type} if exists $inst->{$type};
Branch: 2 branches
BranchTrueFalseTotal
if exists $inst->{$type} 6068 737 6805
if exists $inst->{$type} 0 0 0
87 0 ▶ my $class = $self->_classes->{$type} or return;
Branch: 2 branches
BranchTrueFalseTotal
my $class = $self->_classes->{$type} or return 732 5 737
my $class = $self->_classes->{$type} or return 0 0 0
88 0 my $ok = eval { $self->_load($class); 1 };
89 0 ▶ unless ( $ok ) {
Branch: 2 branches
BranchTrueFalseTotal
unless ($ok) 0 732 732
unless ($ok) 0 0 0
90 0 my $err = $@;
91 0 my $file = module_notional_filename($class);
92 0 ▶ return $inst->{$type} = undef if $err =~ /\ACan't locate \Q$file\E in \@INC/;
Branch: 2 branches
BranchTrueFalseTotal
if $err =~ /\ACan't locate \Q$file\E in \@INC/ 0 0 0
if $err =~ /\ACan't locate \Q$file\E in \@INC/ 0 0 0
93 0 croak __PACKAGE__.': simulator '.$class.' for type '.$type.' does not load: '.$err;
94 }
95 0 ▶ croak __PACKAGE__.': '.$class.' (type '.$type.') composes no simulator role' unless $self->_is_simulator($class);
Branch: 2 branches
BranchTrueFalseTotal
unless $self->_is_simulator($class) 0 732 732
unless $self->_is_simulator($class) 0 0 0
96 0 ▶ croak __PACKAGE__.': '.$class.' says device_type '.$class->device_type.', registered as '.$type
Branch: 2 branches
BranchTrueFalseTotal
unless $class->device_type eq $type 0 732 732
unless $class->device_type eq $type 0 0 0
97 unless $class->device_type eq $type;
98 0 return $inst->{$type} = $class->new;
99 }
100  
101  
102 378 ▶sub is_answer_world {
Subroutine is_answer_world: called CC=3 SCAR=14.2
Pod documented
103 0 ▶ my ( $self, $type ) = @_;
Subroutine is_answer_world: not called CC=3 SCAR=14.2
Pod documented
104 0 ▶ my $sim = $self->simulator($type) or return 0;
Branch: 2 branches
BranchTrueFalseTotal
my $sim = $self->simulator($type) or return 0 377 1 378
my $sim = $self->simulator($type) or return 0 0 0 0
105 0 ▶ return $sim->does('Langertha::Holmgang::Role::AnswerWorld') ? 1 : 0;
Branch: 2 branches
BranchTrueFalseTotal
$sim->does('Langertha::Holmgang::Role::AnswerWorld') ? : 372 5 377
$sim->does('Langertha::Holmgang::Role::AnswerWorld') ? : 0 0 0
106 }
107  
108  
109 2366 ▶sub _device {
Subroutine _device: called CC=5 SCAR=25.5
110 0 ▶ my ( $self, $state, $host ) = @_;
Subroutine _device: not called CC=5 SCAR=25.5
111 0 ▶ return unless defined $host && !ref $host && ref $state eq 'HASH' && ref $state->{$host} eq 'HASH';
Branch: 2 branches
BranchTrueFalseTotal
unless defined $host and not ref $host and ref $state eq "HASH" and ref $state->{$host} eq "HASH" 5 2361 2366
unless defined $host and not ref $host and ref $state eq "HASH" and ref $state->{$host} eq "HASH" 0 0 0
Condition22%4/18
defined $host and not ref $host and ref $state eq "HASH" and ref $state->{$host} eq "HASH"
!ll&&!rl&&r
052361
defined $host and not ref $host and ref $state eq "HASH"
!ll&&!rl&&r
002366
defined $host and not ref $host
!ll&&!rl&&r
002366
defined $host and not ref $host and ref $state eq "HASH" and ref $state->{$host} eq "HASH"
!ll&&!rl&&r
000
defined $host and not ref $host and ref $state eq "HASH"
!ll&&!rl&&r
000
defined $host and not ref $host
!ll&&!rl&&r
000
MC/DC25%1/4
defined $host and not ref $host and ref $state eq "HASH" and ref $state->{$host} eq "HASH"
defined $host not ref $host ref $state eq "HASH" ref $state->{$host} eq "HASH"
MC/DC0%0/4
defined $host and not ref $host and ref $state eq "HASH" and ref $state->{$host} eq "HASH"
defined $host not ref $host ref $state eq "HASH" ref $state->{$host} eq "HASH"
Truth table40%2/5
A and not(B) and C and D
A= defined $hostB= not ref $hostC= ref $state eq "HASH"D= ref $state->{$host} eq "HASH"
ABCDresult
0XXX0
10XX0
110X0
11100
11111
Truth table0%0/5
A and not(B) and C and D
A= defined $hostB= not ref $hostC= ref $state eq "HASH"D= ref $state->{$host} eq "HASH"
ABCDresult
0XXX0
10XX0
110X0
11100
11111
112 0 return $state->{$host};
113 }
114  
115 5 ▶sub _unresolved {
Subroutine _unresolved: called CC=2 SCAR=10.9
116 0 ▶ my ( $self, $host ) = @_;
Subroutine _unresolved: not called CC=2 SCAR=10.9
117 0 ▶ return ( 'ssh: Could not resolve hostname '.( $host // '' ).': Name or service not known', 0 );
Condition25%1/4
$host // ""
l!l
50
$host // ""
l!l
00
MC/DC0%0/1
$host // ""
$host
MC/DC0%0/1
$host // ""
$host
Truth table50%1/2
A
A= $host
Aresult
11
00
Truth table0%0/2
A
A= $host
Aresult
11
00
118 }
119  
120 407 ▶sub prepare {
Subroutine prepare: called CC=7 SCAR=26.5
Pod documented
121 0 ▶ my ( $self, $state ) = @_;
Subroutine prepare: not called CC=7 SCAR=26.5
Pod documented
122 0 ▶ for my $k ( sort keys %{ $state || {} } ) {
Condition25%1/4
$state || {}
l!l
4070
$state || {}
l!l
00
MC/DC0%0/1
$state || {}
$state
MC/DC0%0/1
$state || {}
$state
Truth table50%1/2
A
A= $state
Aresult
11
00
Truth table0%0/2
A
A= $state
Aresult
11
00
123 0 my $dev = $state->{$k};
124 0 ▶ next unless ref $dev eq 'HASH' && defined $dev->{type};
Branch: 2 branches
BranchTrueFalseTotal
unless ref $dev eq "HASH" and defined $dev->{"type"} 358 100 458
unless ref $dev eq "HASH" and defined $dev->{"type"} 0 0 0
Condition50%3/6
ref $dev eq "HASH" and defined $dev->{"type"}
!ll&&!rl&&r
111247100
ref $dev eq "HASH" and defined $dev->{"type"}
!ll&&!rl&&r
000
MC/DC100%2/2
ref $dev eq "HASH" and defined $dev->{"type"}
ref $dev eq "HASH" defined $dev->{"type"}
MC/DC0%0/2
ref $dev eq "HASH" and defined $dev->{"type"}
ref $dev eq "HASH" defined $dev->{"type"}
Truth table100%3/3
A and B
A= ref $dev eq "HASH"B= defined $dev->{"type"}
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= ref $dev eq "HASH"B= defined $dev->{"type"}
ABresult
0X0
100
111
125 0 ▶ my $sim = $self->simulator( $dev->{type} ) or next;
Branch: 2 branches
BranchTrueFalseTotal
my $sim = $self->simulator($dev->{"type"}) or next 99 1 100
my $sim = $self->simulator($dev->{"type"}) or next 0 0 0
126 0 ▶ $sim->prepare( $dev, { host => $k, state => $state } ) if $sim->can('prepare');
Branch: 2 branches
BranchTrueFalseTotal
if $sim->can("prepare") 67 32 99
if $sim->can("prepare") 0 0 0
127 }
128 0 return;
129 }
130  
131  
132 2212 ▶sub run_command {
Subroutine run_command: called CC=5 SCAR=21.8
Pod documented
133 0 ▶ my ( $self, $state, $host, $command ) = @_;
Subroutine run_command: not called CC=5 SCAR=21.8
Pod documented
134 0 ▶ my $dev = $self->_device( $state, $host ) or return $self->_unresolved($host);
Branch: 2 branches
BranchTrueFalseTotal
my $dev = $self->_device($state, $host) or return $self->_unresolved($host) 2207 5 2212
my $dev = $self->_device($state, $host) or return $self->_unresolved($host) 0 0 0
135 0 my $sim = $self->simulator( $dev->{type} );
136 0 ▶ return ( 'ssh: connect to host '.$host.' port 22: Connection refused', 0 )
Branch: 2 branches
BranchTrueFalseTotal
unless $sim and $sim->can("run_command") 2 2205 2207
unless $sim and $sim->can("run_command") 0 0 0
Condition50%3/6
$sim and $sim->can("run_command")
!ll&&!rl&&r
112205
$sim and $sim->can("run_command")
!ll&&!rl&&r
000
MC/DC100%2/2
$sim and $sim->can("run_command")
$sim $sim->can("run_command")
MC/DC0%0/2
$sim and $sim->can("run_command")
$sim $sim->can("run_command")
Truth table100%3/3
A and B
A= $simB= $sim->can("run_command")
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= $simB= $sim->can("run_command")
ABresult
0X0
100
111
137 unless $sim && $sim->can('run_command');
138 0 ▶ return $sim->run_command( $dev, $command // '', { host => $host, state => $state } );
Condition25%1/4
$command // ""
l!l
22050
$command // ""
l!l
00
MC/DC0%0/1
$command // ""
$command
MC/DC0%0/1
$command // ""
$command
Truth table50%1/2
A
A= $command
Aresult
11
00
Truth table0%0/2
A
A= $command
Aresult
11
00
139 }
140  
141  
142 154 ▶sub write_file {
Subroutine write_file: called CC=6 SCAR=26.9
Pod documented
143 0 ▶ my ( $self, $state, $host, $path, $content ) = @_;
Subroutine write_file: not called CC=6 SCAR=26.9
Pod documented
144 0 ▶ my $dev = $self->_device( $state, $host ) or return $self->_unresolved($host);
Branch: 2 branches
BranchTrueFalseTotal
my $dev = $self->_device($state, $host) or return $self->_unresolved($host) 154 0 154
my $dev = $self->_device($state, $host) or return $self->_unresolved($host) 0 0 0
145 0 my $sim = $self->simulator( $dev->{type} );
146 0 ▶ return ( 'scp: '.$host.': Datei schreiben auf diesem Gerät nicht möglich (nur Konsole über run_command)', 0 )
Branch: 2 branches
BranchTrueFalseTotal
unless $sim and $sim->can("write_file") 3 151 154
unless $sim and $sim->can("write_file") 0 0 0
Condition33%2/6
$sim and $sim->can("write_file")
!ll&&!rl&&r
03151
$sim and $sim->can("write_file")
!ll&&!rl&&r
000
MC/DC50%1/2
$sim and $sim->can("write_file")
$sim $sim->can("write_file")
MC/DC0%0/2
$sim and $sim->can("write_file")
$sim $sim->can("write_file")
Truth table66%2/3
A and B
A= $simB= $sim->can("write_file")
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= $simB= $sim->can("write_file")
ABresult
0X0
100
111
147 unless $sim && $sim->can('write_file');
148 0 ▶ return $sim->write_file( $dev, $path // '', $content // '', { host => $host, state => $state } );
Condition25%2/8
$path // ""
l!l
1510
$content // ""
l!l
1510
$path // ""
l!l
00
$content // ""
l!l
00
MC/DC0%0/1
$path // ""
$path
MC/DC0%0/1
$content // ""
$content
MC/DC0%0/1
$path // ""
$path
MC/DC0%0/1
$content // ""
$content
Truth table50%1/2
A
A= $path
Aresult
11
00
Truth table50%1/2
A
A= $content
Aresult
11
00
Truth table0%0/2
A
A= $path
Aresult
11
00
Truth table0%0/2
A
A= $content
Aresult
11
00
149 }
150  
151  
152 58 ▶sub world_tools {
Subroutine world_tools: called CC=2 SCAR=9.2
Pod documented
153 0 ▶ my ( $self, $type ) = @_;
Subroutine world_tools: not called CC=2 SCAR=9.2
Pod documented
154 0 ▶ return unless $self->is_answer_world($type);
Branch: 2 branches
BranchTrueFalseTotal
unless $self->is_answer_world($type) 6 52 58
unless $self->is_answer_world($type) 0 0 0
155 0 return $self->simulator($type)->tools;
156 }
157  
158  
159 316 ▶sub tool_call {
Subroutine tool_call: called CC=7 SCAR=29.4
Pod documented
160 0 ▶ my ( $self, $state, $type, $name, $args ) = @_;
Subroutine tool_call: not called CC=7 SCAR=29.4
Pod documented
161 0 ▶ my ($key) = grep { ref $state->{$_} eq 'HASH' && ( $state->{$_}{type} // '' ) eq $type } sort keys %{ $state || {} };
Condition28%4/14
ref $state->{$_} eq 'HASH' && ($state->{$_}{'type'} // '') eq $type
!ll&&!rl&&r
08314
$state->{$_}{"type"} // ""
l!l
3220
$state || {}
l!l
3160
ref $state->{$_} eq 'HASH' && ($state->{$_}{'type'} // '') eq $type
!ll&&!rl&&r
000
$state->{$_}{"type"} // ""
l!l
00
$state || {}
l!l
00
MC/DC0%0/2
ref $state->{$_} eq 'HASH' && ($state->{$_}{'type'} // '') eq $type
ref $state->{$_} eq 'HASH' $state->{$_}{"type"}
MC/DC0%0/1
$state || {}
$state
MC/DC0%0/2
ref $state->{$_} eq 'HASH' && ($state->{$_}{'type'} // '') eq $type
ref $state->{$_} eq 'HASH' $state->{$_}{"type"}
MC/DC0%0/1
$state || {}
$state
Truth table33%1/3
A && B
A= ref $state->{$_} eq 'HASH'B= $state->{$_}{"type"}
ABresult
0X0
100
111
Truth table50%1/2
A
A= $state
Aresult
11
00
Truth table0%0/3
A && B
A= ref $state->{$_} eq 'HASH'B= $state->{$_}{"type"}
ABresult
0X0
100
111
Truth table0%0/2
A
A= $state
Aresult
11
00
162 0 ▶ return ( 'Fehler: diese Umgebung hat keine '.$type.'.', 0 ) unless defined $key;
Branch: 2 branches
BranchTrueFalseTotal
unless defined $key 2 314 316
unless defined $key 0 0 0
163 0 ▶ return ( 'Fehler: unbekannte Welt '.$type.'.', 0 ) unless $self->is_answer_world($type);
Branch: 2 branches
BranchTrueFalseTotal
unless $self->is_answer_world($type) 0 314 314
unless $self->is_answer_world($type) 0 0 0
164 0 ▶ return $self->simulator($type)->tool( $state->{$key}, $name, $args || {}, { host => $key, state => $state } );
Condition25%1/4
$args || {}
l!l
3140
$args || {}
l!l
00
MC/DC0%0/1
$args || {}
$args
MC/DC0%0/1
$args || {}
$args
Truth table50%1/2
A
A= $args
Aresult
11
00
Truth table0%0/2
A
A= $args
Aresult
11
00
165 }
166  
167  
168 34 ▶sub _for_rule {
Subroutine _for_rule: called CC=5 SCAR=21.7
169 0 ▶ my ( $self, $dev, $method, $kind ) = @_;
Subroutine _for_rule: not called CC=5 SCAR=21.7
170 0 ▶ croak __PACKAGE__.': a '.$kind.' rule needs a device' unless ref $dev eq 'HASH';
Branch: 2 branches
BranchTrueFalseTotal
unless ref $dev eq "HASH" 0 34 34
unless ref $dev eq "HASH" 0 0 0
171 0 ▶ my $type = $dev->{type} // '';
Condition50%2/4
$dev->{"type"} // ""
l!l
331
$dev->{"type"} // ""
l!l
00
MC/DC100%1/1
$dev->{"type"} // ""
$dev->{"type"}
MC/DC0%0/1
$dev->{"type"} // ""
$dev->{"type"}
Truth table100%2/2
A
A= $dev->{"type"}
Aresult
11
00
Truth table0%0/2
A
A= $dev->{"type"}
Aresult
11
00
172 0 my $sim = $self->simulator($type);
173 0 ▶ croak __PACKAGE__.': device type '.$type.' cannot answer a '.$kind.' rule (no '.$method.')'
Branch: 2 branches
BranchTrueFalseTotal
unless $sim and $sim->can($method) 3 31 34
unless $sim and $sim->can($method) 0 0 0
Condition50%3/6
$sim and $sim->can($method)
!ll&&!rl&&r
1231
$sim and $sim->can($method)
!ll&&!rl&&r
000
MC/DC100%2/2
$sim and $sim->can($method)
$sim $sim->can($method)
MC/DC0%0/2
$sim and $sim->can($method)
$sim $sim->can($method)
Truth table100%3/3
A and B
A= $simB= $sim->can($method)
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= $simB= $sim->can($method)
ABresult
0X0
100
111
174 unless $sim && $sim->can($method);
175 0 return $sim;
176 }
177  
178 25 ▶sub packet_verdict {
Subroutine packet_verdict: called CC=2 SCAR=10.9
Pod documented
179 0 ▶ my ( $self, $dev, $packet, $boot ) = @_;
Subroutine packet_verdict: not called CC=2 SCAR=10.9
Pod documented
180 0 ▶ return $self->_for_rule( $dev, 'packet_verdict', 'packet' )->packet_verdict( $dev, $packet || {}, $boot );
Condition25%1/4
$packet || {}
l!l
240
$packet || {}
l!l
00
MC/DC0%0/1
$packet || {}
$packet
MC/DC0%0/1
$packet || {}
$packet
Truth table50%1/2
A
A= $packet
Aresult
11
00
Truth table0%0/2
A
A= $packet
Aresult
11
00
181 }
182  
183  
184 9 ▶sub login_check {
Subroutine login_check: called CC=2 SCAR=10.9
Pod documented
185 0 ▶ my ( $self, $dev, $attempt, $host ) = @_;
Subroutine login_check: not called CC=2 SCAR=10.9
Pod documented
186 0 ▶ return $self->_for_rule( $dev, 'login_check', 'login' )->login_check( $dev, $attempt || {}, $host );
Condition25%1/4
$attempt || {}
l!l
70
$attempt || {}
l!l
00
MC/DC0%0/1
$attempt || {}
$attempt
MC/DC0%0/1
$attempt || {}
$attempt
Truth table50%1/2
A
A= $attempt
Aresult
11
00
Truth table0%0/2
A
A= $attempt
Aresult
11
00
187 }
188  
189  
190 89 __PACKAGE__->meta->make_immutable;
191  
192 __END__
« blib/lib/Langertha/Holmgang/Sim/Sehen.pm ↑ Summary blib/lib/Langertha/Holmgang/Loader.pm »