| 1 | package Serge::Interface::PluginHost; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | sub load_plugin { | ||||||||||||||||||||||||||||
| 6 | 35 | ▶ | my ($self, $class, $data) = @_; | ||||||||||||||||||||||||||
|
Subroutine
load_plugin: called CC=6 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 35 | ▶ | print "Loading plugin: $class\n" if $self->{debug}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 35 | my $p; | |||||||||||||||||||||||||||
| 11 | 35 | ▶ | eval('use '.$class.'; $p = '.$class.'->new($self);'); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 35 | ▶ | die "Can't create instance for plugin '$class': $@" if $@; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 13 | 35 | ▶ | print "Created plugin instance: '".$p->name."'\n" if $self->{debug}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 35 | ▶ | $p->{debug} = 1 if $self->{debug}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 35 | $p->init($data); | |||||||||||||||||||||||||||
| 18 | 35 | eval { | |||||||||||||||||||||||||||
| 19 | 35 | $p->validate_data; | |||||||||||||||||||||||||||
| 20 | }; | ||||||||||||||||||||||||||||
| 21 | 35 | ▶ | die "Data validation failed for plugin '$class': $@" if $@; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 34 | return $p; | |||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | sub load_plugin_from_node { | ||||||||||||||||||||||||||||
| 27 | 35 | ▶ | my ($self, $class_prefix, $node) = @_; | ||||||||||||||||||||||||||
|
Subroutine
load_plugin_from_node: called CC=5 SCAR=17.2
Pod
undocumented
| |||||||||||||||||||||||||||||
| 28 | 35 | ▶ | die "'plugin' parameter missing" unless exists $node->{plugin}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | # if plugin name has '::', treat it as a full class name and don't expand it; | ||||||||||||||||||||||||||||
| 31 | # otherwise, prepend the provided class prefix to form a full class name | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 35 | my $class = $node->{plugin}; | |||||||||||||||||||||||||||
| 34 | 35 | ▶ | $class = $class_prefix.'::'.$class if ($class_prefix ne '' && $class !~ m/::/); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$class_prefix ne "" and not $class =~ /::/
MC/DC0%0/2
$class_prefix ne "" and not $class =~ /::/
$class_prefix ne ""
not $class =~ /::/
Truth table33%1/3
A and not(B)
A= $class_prefix ne ""B= not $class =~ /::/
| |||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 35 | ▶ | return $self->load_plugin($class, $node->{data} || {}); | ||||||||||||||||||||||||||
|
Condition100%2/2
$node->{'data'} || {}
MC/DC100%1/1
$node->{'data'} || {}
$node->{'data'}
Truth table100%2/2
A
A= $node->{'data'}
| |||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 2 | 1; | |||||||||||||||||||||||||||