blib/lib/Namespace/Pollute.pm

filter: Statementstmt 100% 25 / 25 Branchbran 58.3% 7 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 2 / 2 Podpod n/a totaltotal 87.1% 34 / 39 CC 9 SCAR 21.4
CC
9
Cov
86%
import
9.4
BEGIN
1.0
CRAP 8.5
↑ Summary
1 package Namespace::Pollute;
2 {
3 1 $Namespace::Pollute::VERSION = '0.002';
4 }
5 # ABSTRACT: Loads and imports the default exported symbols of a list of modules
6  
7 1 ▶use Exporter;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 @ISA = qw(Exporter);
9  
10 1 ▶sub import {
Subroutine import: called CC=9 SCAR=22.4
11  
12 1 shift; #-- The first one is our own class name
13  
14 1 ▶ if ( $_[0] eq '-verbose' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_[0] eq "-verbose") 1 0 1
15 1 $VERBOSE = 1;
16 1 shift;
17 }
18  
19 1 foreach my $module (@_) {
20 2 eval "require $module";
21  
22 2 ▶ if ( eval { $module->isa('Exporter') } ) {
Branch: 2 branches
BranchTrueFalseTotal
if (eval { do { $module->isa('Exporter') } }) { } 1 1 2
elsif (eval { do { $module->can('import') } }) { } 1 0 1
23 1 ▶ print "ISA Exporter: $module\n" if $VERBOSE;
Branch: 1 branch
BranchTrueFalseTotal
if $VERBOSE 1 0 1
24  
25 1 @EXPORT = @{"${module}::EXPORT"};
26  
27 1 $module->import(@EXPORT);
28  
29 1 foreach my $symbol (@EXPORT) {
30 3 ▶ print "\tExporting: $module::$symbol\n" if $VERBOSE;
Branch: 1 branch
BranchTrueFalseTotal
if $VERBOSE 3 0 3
31 3 Namespace::Pollute->export_to_level( 1,, ($symbol) );
32 }
33  
34 } elsif (
35 eval {
36 1 $module->can('import');
37 }
38 )
39 {
40 1 ▶ print "Calling $module->import\n" if $VERBOSE;
Branch: 1 branch
BranchTrueFalseTotal
if $VERBOSE 1 0 1
41  
42 #-- Things that have an import sub:
43 1 $module->import;
44 }
45 }
46  
47 }
48  
49 1 1;
50  
51 __END__
↑ Summary