Pluggable.pm

filter: Statementstmt 100% 48 / 48 Branchbran 60.0% 6 / 10 Conditioncond 66.6% 2 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 12 / 12 Podpod 75.0% 3 / 4 totaltotal 89.8% 71 / 79 CC 7 SCAR 7.0
CC
7
Cov
92%
load_plugins
4.1
load_plugin
2.0
new
2.0
CRAP 2.0
« Pluggable/HTML5.pm ↑ Summary Pluggable/Microdata.pm »
1 package HTML::Lint::Pluggable;
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  
5 3 our $VERSION = '0.10';
6  
7 3 ▶use parent qw/ HTML::Lint /;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 3 ▶use Carp qw/croak/;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 3 ▶use Module::Load ();
Subroutine BEGIN: called CC=1 SCAR=0.0
11 3 ▶use Package::Stash;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 14 ▶sub new {
Subroutine new: called CC=2 SCAR=7.0
Pod documented
14 14 my $class = shift;
15  
16 14 my $subclass;
17 14 ▶ do {
Branch: 1 branch
BranchTrueFalseTotal
$subclass->isa($class) and do { do { $subclass = sprintf("%s::__ANON__::%x%x%x", $class, $$, 0 + {}, int rand 65535) } } 0 14 14
18 14 $subclass = sprintf '%s::__ANON__::%x%x%x', $class, $$, 0+{}, int(rand(65535));
19 } while $subclass->isa($class);
20  
21 14 push @{ Package::Stash->new($subclass)->get_or_add_symbol('@ISA') } => $class;
22  
23 14 return $subclass->SUPER::new(@_);
24 }
25  
26 7 ▶sub load_plugins {
Subroutine load_plugins: called CC=4 SCAR=14.0
Pod documented
27 7 my $self = shift;
28 7 ▶ while (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 10 7 17
29 10 my $plugin = shift;
30 10 ▶ my $conf = @_ > 0 && ref($_[0]) eq 'HASH' ? +shift : undef;
Branch: 1 branch
BranchTrueFalseTotal
@_ > 0 && ref $_[0] eq 'HASH' ? : 0 10 10
Condition66%2/3
@_ > 0 and ref $_[0] eq "HASH"
!ll&&!rl&&r
730
MC/DC0%0/2
@_ > 0 and ref $_[0] eq "HASH"
@_ > 0 ref $_[0] eq "HASH"
Truth table66%2/3
A and B
A= @_ > 0B= ref $_[0] eq "HASH"
ABresult
0X0
100
111
31 10 $self->load_plugin($plugin, $conf);
32 }
33 }
34  
35 10 ▶sub load_plugin {
Subroutine load_plugin: called CC=2 SCAR=7.0
Pod documented
36 10 my ($self, $plugin, $conf) = @_;
37 10 ▶ $plugin = "HTML::Lint::Pluggable::${plugin}" unless $plugin =~ s/^\+//;
Branch: 1 branch
BranchTrueFalseTotal
unless $plugin =~ s/^\+// 10 0 10
38 10 Module::Load::load($plugin);
39 10 $plugin->init($self, $conf);
40 }
41  
42 10 ▶sub override {
Subroutine override: called CC=2 SCAR=6.9
Pod undocumented
43 10 my ($self, $method, $code) = @_;
44 10 ▶ my $class = ref($self) or croak('this method can called by instance only.');
Branch: 1 branch
BranchTrueFalseTotal
my $class = ref $self or croak("this method can called by instance only.") 10 0 10
45  
46 10 my $override_code = $code->($class->can($method));
47  
48 {
49 3 ▶ no strict 'refs'; ## no critic
Subroutine BEGIN: called CC=1 SCAR=0.0
50 3 ▶ no warnings 'redefine';
Subroutine BEGIN: called CC=1 SCAR=0.0
51 10 *{"${class}::${method}"} = $override_code;
52 }
53 }
54  
55 3 1;
56 __END__
« Pluggable/HTML5.pm ↑ Summary Pluggable/Microdata.pm »