File Coverage

blib/lib/B/CompilerPhase/Hook.pm
Criterion Covered Total %
statement 27 27 100.0
branch 2 2 100.0
condition n/a
subroutine 6 6 100.0
pod n/a
total 35 35 100.0


line stmt bran cond sub pod time code
1             package B::CompilerPhase::Hook;
2             # ABSTRACT: Programatically install BEGIN/CHECK/INIT/UNITCHECK/END blocks
3              
4 5     5   66421 use strict;
  5         8  
  5         117  
5 5     5   15 use warnings;
  5         7  
  5         166  
6              
7             our $VERSION;
8             our $AUTHORITY;
9              
10 5     5   15 use XSLoader;
  5         8  
  5         386  
11             BEGIN {
12 5     5   6 $VERSION = '0.04';
13 5         7 $AUTHORITY = 'cpan:STEVAN';
14 5         1889 XSLoader::load( __PACKAGE__, $VERSION );
15              
16             # now set up the DWIM methods ...
17 5         22 *enqueue_BEGIN = \&append_BEGIN;
18 5         7 *enqueue_CHECK = \&prepend_CHECK;
19 5         6 *enqueue_INIT = \&append_INIT;
20 5         5 *enqueue_UNITCHECK = \&prepend_UNITCHECK;
21 5         238 *enqueue_END = \&prepend_END;
22             }
23              
24             sub import {
25 6     6   4033 shift;
26 6 100       27 if ( @_ ) {
27 4         7 my $to = caller;
28 4         6 my $from = __PACKAGE__;
29 4         30 foreach ( @_ ) {
30 5     5   22 no strict 'refs';
  5         4  
  5         295  
31 10         34 *{ $to . '::' . $_ } = $from->can( $_ );
  10         128  
32             }
33             }
34             }
35              
36             1;
37              
38             __END__