File Coverage

lib/Rex/Exporter.pm
Criterion Covered Total %
statement 31 31 100.0
branch 4 6 66.6
condition 4 6 66.6
subroutine 5 5 100.0
pod n/a
total 44 48 91.6


line stmt bran cond sub pod time code
1             #
2             # (c) Jan Gehring
3             #
4              
5             package Rex::Exporter;
6              
7 102     102   1414 use v5.12.5;
  102         399  
8 102     102   504 use warnings;
  102         177  
  102         4736  
9 102     102   1029 use Symbol;
  102         1032  
  102         7676  
10              
11             our $VERSION = '1.14.2.3'; # TRIAL VERSION
12              
13 102     102   691 use Data::Dumper;
  102         184  
  102         31724  
14              
15             our @EXPORT;
16              
17             sub import {
18 3260     3260   55545 my ( $mod_to_register, %option ) = @_;
19 3260         13182 my ( $mod_to_register_in, $file, $line ) = caller;
20              
21 3260 50 66     15229 if ( exists $option{register_in} && $option{register_in} ) {
22 1034         1812 $mod_to_register_in = $option{register_in};
23             }
24              
25 3260         7143 my $no_import = "";
26 3260 50 66     7026 if ( exists $option{"-no"} && $option{"-no"} ) {
27 12         42 $no_import = "," . join( ",", @{ $option{"-no"} } ) . ",";
  12         63  
28             }
29              
30 3260         11492 my $ref_to_export = qualify_to_ref( 'EXPORT', $mod_to_register );
31 3260         78652 my $ref_to_export_array = *{$ref_to_export}{ARRAY};
  3260         6983  
32              
33 3260         4830 for my $reg_func ( @{$ref_to_export_array} ) {
  3260         9238  
34 63646 100       549821 if ( $no_import =~ m/,$reg_func,/ ) {
35 12         74 next;
36             }
37              
38 63634         150249 my $ref_to_reg_func_in_source_mod =
39             qualify_to_ref( $reg_func, $mod_to_register );
40 63634         1097787 my $ref_to_reg_func_in_target_mod =
41             qualify_to_ref( $reg_func, $mod_to_register_in );
42              
43 63634         1071038 *{$ref_to_reg_func_in_target_mod} = *{$ref_to_reg_func_in_source_mod};
  63634         3325350  
  63634         80549  
44             }
45             }
46              
47             1;