File Coverage

blib/lib/Exporter/Auto.pm
Criterion Covered Total %
statement 38 38 100.0
branch 8 8 100.0
condition n/a
subroutine 10 10 100.0
pod n/a
total 56 56 100.0


line stmt bran cond sub pod time code
1             package Exporter::Auto;
2 2     2   46810 use strict;
  2         6  
  2         78  
3 2     2   11 use warnings;
  2         4  
  2         52  
4 2     2   53 use 5.008005;
  2         11  
  2         147  
5             our $VERSION = '0.04';
6              
7 2     2   1703 use Sub::Identify qw(stash_name);
  2         2227  
  2         133  
8 2     2   1855 use B::Hooks::EndOfScope;
  2         29022  
  2         16  
9 2     2   186 use Exporter;
  2         7  
  2         99  
10              
11             sub import {
12 2     2   22 my $klass = caller(0);
13              
14 2     2   11 no strict 'refs';
  2         4  
  2         485  
15 2         5 unshift @{"${klass}::ISA"}, 'Exporter';
  2         28  
16              
17             on_scope_end {
18 2     2   2374 my %hash = %{"${klass}::"};
  2         552  
19 2         39 while (my ($k, $v) = each %hash) {
20 244 100       696 next if $k =~ /^(?:BEGIN|CHECK|END|INIT|UNITCHECK)$/;
21 242 100       769 next if $k =~ /^_/;
22 1 100   1   836 next unless *{"${klass}::${k}"}{CODE};
  1         1211  
  1         11  
  131         127  
  131         630  
23 29 100       159 next if $klass ne stash_name($klass->can($k));
24 1         11 push @{"${klass}::EXPORT"}, $k;
  1         12  
25             }
26 2         16 };
27             }
28              
29             1;
30             __END__