Pluggable.pm

filter: Statementstmt 53.7% 29 / 54 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 53.3% 8 / 15 Podpod 71.4% 5 / 7 totaltotal 50.0% 42 / 84 SCAR 32.2
CC
10
Cov
47%
watchfunction
30.0
afterinit
12.0
__ANON__
12.0
CRAP 25.1
« Pluggable/Plugin/BreakOnTestNumber.pm ↑ Summary Pluggable/Plugin/TypeAhead.pm »
1 package DB::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 2 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use Brickyard::Accessor new => 1, rw => [qw(brickyard)];
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use Brickyard 1.111750;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 our $VERSION = '1.112001';
8  
9 sub run_with_config {
10 0 ▶ my $file = $_[1];
Subroutine run_with_config: not called CC=1 SCAR=6.9
Pod documented
11 0 __PACKAGE__->new->init_from_config($file)->run;
12 }
13  
14 sub plugins_with {
15 0 ▶ my ($self, $role) = @_;
Subroutine plugins_with: not called CC=1 SCAR=6.9
Pod documented
16 0 $self->brickyard->plugins_with($role);
17 }
18  
19 sub init_from_config {
20 1 ▶ my $self = shift;
Subroutine init_from_config: called CC=1 SCAR=0.0
Pod documented
21 1 $self->brickyard(Brickyard->new(base_package => 'DB::Pluggable'));
22 1 $self->brickyard->init_from_config(@_);
23 1 $self;
24 }
25  
26 sub enable_watchfunction {
27 0 ▶ my $self = shift;
Subroutine enable_watchfunction: not called CC=1 SCAR=0.6
Pod documented
28 2 ▶ no warnings 'once';
Subroutine BEGIN: called CC=1 SCAR=0.0
29 0 $DB::trace |= 4; # Enable watchfunction
30 }
31  
32 sub run {
33 0 ▶ my $self = shift;
Subroutine run: not called CC=2 SCAR=17.9
Pod documented
34 0 $DB::Pluggable::HANDLER = $self;
35 0 $_->initialize for $self->plugins_with(-Initializer);
36 }
37 2 1;
38  
39 # switch package so as to get the desired stack trace
40 package # hide from PAUSE indexer
41 DB;
42  
43 sub watchfunction {
44 0 ▶ return unless defined $DB::Pluggable::HANDLER;
Subroutine watchfunction: not called CC=5 SCAR=34.0
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
unless defined $DB::Pluggable::HANDLER 0 0 0
45 0 my $depth = 1;
46 0 while (1) {
47 0 my ($package, $file, $line, $sub) = caller $depth;
48 0 ▶ last unless defined $package;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $package 0 0 0
49 0 ▶ return if $sub =~ /::DESTROY$/;
Branch: 1 branch
BranchTrueFalseTotal
if $sub =~ /::DESTROY$/ 0 0 0
50 0 $depth++;
51 }
52 0 $_->watchfunction for $DB::Pluggable::HANDLER->plugins_with(-WatchFunction);
53 }
54  
55 sub afterinit {
56 0 ▶ return unless defined $DB::Pluggable::HANDLER;
Subroutine afterinit: not called CC=3 SCAR=24.8
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
unless defined $DB::Pluggable::HANDLER 0 0 0
57 0 $_->afterinit for $DB::Pluggable::HANDLER->plugins_with(-AfterInit);
58 }
59 2 ▶no warnings 'redefine';
Subroutine BEGIN: called CC=1 SCAR=0.0
60 2 my $DB_eval = \&DB::eval;
61 *eval = sub {
62 0 ▶ my @result;
Subroutine __ANON__: not called CC=3 SCAR=24.8
63 0 for my $plugin ($DB::Pluggable::HANDLER->plugins_with(-Eval)) {
64 0 push @result => $plugin->eval;
65 }
66 0 &$DB_eval; # XXX Why doesn't this work if called from the plugin?
67 0 $_->() for grep { ref eq 'CODE' } @result;
68 2 };
69 2 1;
70  
71 =pod
72  
73 =for test_synopsis 1;
74 __END__
« Pluggable/Plugin/BreakOnTestNumber.pm ↑ Summary Pluggable/Plugin/TypeAhead.pm »