| 1 | package HTML::Lint::Pluggable; | ||||||||||||||||||||||||||||
| 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 | |||||||||||||||||||||||||||||
| 5 | 2 | our $VERSION = '0.08'; | |||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 2 | ▶ | use parent qw/ HTML::Lint /; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 2 | ▶ | use Carp qw/croak/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 2 | ▶ | use Module::Load (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 2 | ▶ | use Package::Stash; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | sub new { | ||||||||||||||||||||||||||||
| 14 | 10 | ▶ | my $class = shift; | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 10 | my $subclass; | |||||||||||||||||||||||||||
| 17 | 10 | ▶ | do { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 18 | 10 | $subclass = sprintf '%s::__ANON__::%x%x%x', $class, $$, 0+{}, int(rand(65535)); | |||||||||||||||||||||||||||
| 19 | } while $subclass->isa($class); | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 10 | push @{ Package::Stash->new($subclass)->get_or_add_symbol('@ISA') } => $class; | |||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 10 | return $subclass->SUPER::new(@_); | |||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | sub load_plugins { | ||||||||||||||||||||||||||||
| 27 | 4 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
load_plugins: called CC=4 SCAR=14.0
Pod
documented
| |||||||||||||||||||||||||||||
| 28 | 4 | ▶ | while (@_) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 29 | 5 | my $plugin = shift; | |||||||||||||||||||||||||||
| 30 | 5 | ▶ | my $conf = @_ > 0 && ref($_[0]) eq 'HASH' ? +shift : undef; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
@_ > 0 and ref $_[0] eq "HASH"
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"
| |||||||||||||||||||||||||||||
| 31 | 5 | $self->load_plugin($plugin, $conf); | |||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | sub load_plugin { | ||||||||||||||||||||||||||||
| 36 | 5 | ▶ | my ($self, $plugin, $conf) = @_; | ||||||||||||||||||||||||||
|
Subroutine
load_plugin: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||
| 37 | 5 | ▶ | $plugin = "HTML::Lint::Pluggable::${plugin}" unless $plugin =~ s/^\+//; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 38 | 5 | Module::Load::load($plugin); | |||||||||||||||||||||||||||
| 39 | 5 | $plugin->init($self, $conf); | |||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | sub override { | ||||||||||||||||||||||||||||
| 43 | 5 | ▶ | my ($self, $method, $code) = @_; | ||||||||||||||||||||||||||
|
Subroutine
override: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 44 | 5 | ▶ | my $class = ref($self) or croak('this method can called by instance only.'); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | 5 | my $override_code = $code->($class->can($method)); | |||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | { | ||||||||||||||||||||||||||||
| 49 | 2 | ▶ | no strict 'refs'; ## no critic | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 50 | 2 | ▶ | no warnings 'redefine'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 51 | 5 | *{"${class}::${method}"} = $override_code; | |||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | 2 | 1; | |||||||||||||||||||||||||||
| 56 | __END__ | ||||||||||||||||||||||||||||