lib/Serge/Plugin/Base.pm

filter: Statementstmt 98.1% 52 / 53 Branchbran 50.0% 3 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 94.4% 17 / 18 Podpod 0.0% 0 / 6 totaltotal 86.7% 72 / 83 SCAR 13.9
CC
4
Cov
93%
validate_data
3.2
new
2.0
name
2.0
CRAP 4.0
« bin/tools/lib/cli.pm ↑ Summary lib/Serge/Engine/Plugin/parse_dtd.pm »
1 package Serge::Plugin::Base;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 2 ▶use Config::Neat::Inheritable 1.204;
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use Config::Neat::Schema 1.204;
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use Config::Neat::Util 1.204 qw(to_ixhash_recursive);
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use File::Spec::Functions qw(rel2abs);
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use File::Basename qw(dirname);
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 sub name {
12 0 ▶ return 'Base plugin';
Subroutine name: not called CC=1 SCAR=6.9
Pod undocumented
13 }
14  
15 sub new {
16 35 ▶ my ($class, $parent) = @_;
Subroutine new: called CC=2 SCAR=7.0
Pod undocumented
17  
18 35 ▶ die "parent not specified" unless $parent;
Branch: 1 branch
BranchTrueFalseTotal
unless $parent 0 35 35
19  
20 35 my $self = {
21 parent => $parent,
22 schema => Config::Neat::Schema->new({}),
23 };
24  
25 35 bless($self, $class);
26  
27 35 return $self;
28 }
29  
30 sub init {
31 35 ▶ my ($self, $data) = @_;
Subroutine init: called CC=1 SCAR=0.0
Pod undocumented
32  
33 35 $self->{data} = $data;
34 }
35  
36 sub set_schema {
37 32 ▶ my ($self, $schema_data) = @_;
Subroutine set_schema: called CC=1 SCAR=0.0
Pod undocumented
38  
39 32 $self->{schema}->set($schema_data);
40 }
41  
42 sub merge_schema {
43 32 ▶ my ($self, $merge_data) = @_;
Subroutine merge_schema: called CC=1 SCAR=0.0
Pod undocumented
44  
45 32 my $c = Config::Neat::Inheritable->new();
46  
47 32 $self->set_schema($c->merge_data($self->{schema}->{schema}, to_ixhash_recursive($merge_data), dirname(rel2abs($0))));
48 }
49  
50 sub validate_data {
51 35 ▶ my ($self) = @_;
Subroutine validate_data: called CC=3 SCAR=11.7
Pod undocumented
52  
53 35 ▶ print "Validating plugin data\n" if $self->{parent}->{debug};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"parent"}{"debug"} 0 35 35
54 35 ▶ $self->{schema}->validate($self->{data}) if exists $self->{data};
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->{"data"} 35 0 35
55 }
56  
57 2 1;
« bin/tools/lib/cli.pm ↑ Summary lib/Serge/Engine/Plugin/parse_dtd.pm »