File Coverage

blib/lib/App/VirtPerl/Setup.pm
Criterion Covered Total %
statement 11 20 55.0
branch 1 6 16.6
condition 1 6 16.6
subroutine 5 6 83.3
pod n/a
total 18 38 47.3


line stmt bran cond sub pod time code
1             package App::VirtPerl::Setup;
2             $App::VirtPerl::Setup::VERSION = '0.1';
3 1     1   2304 use strict;
  1         1  
  1         27  
4 1     1   3 use Config;
  1         1  
  1         27  
5 1     1   356 use lib ();
  1         404  
  1         20  
6              
7              
8             my @original_inc;
9 1     1   666 BEGIN { @original_inc = @INC };
10              
11             sub import {
12 1 50 33 1   23 return unless $ENV{PERL_VIRTPERL_ROOT} && $ENV{PERL_VIRTPERL_CURRENT_ENV};
13            
14 0           my $current = "$ENV{PERL_VIRTPERL_ROOT}/$ENV{PERL_VIRTPERL_CURRENT_ENV}/lib/perl5";
15            
16 0 0         if ($current !~ m:^([\w/.-]+)$:) { # XXX got to figure this out 100% before release.
17 0           return;
18             }
19            
20 0           $current = $1;
21            
22 0 0         if (-e $current) {
23 0   0       @INC = grep {
24 0           !m/^$Config{sitelibexp}/o
25             && !m/^$Config{vendorlibexp}/o
26             && !m/^$Config{updateslib}/o
27             && !m/^$Config{extraslib}/o
28             } @INC;
29            
30 0           lib->import($current);
31             }
32             }
33              
34             sub unimport {
35 0     0     @INC = @original_inc;
36             }
37              
38             1;
39             __END__