File Coverage

lib/lib/byversion.pm
Criterion Covered Total %
statement 28 30 93.3
branch 2 4 50.0
condition n/a
subroutine 8 8 100.0
pod n/a
total 38 42 90.4


line stmt bran cond sub pod time code
1 4     4   44337 use 5.006;
  4         15  
2 4     4   26 use strict;
  4         7  
  4         128  
3 4     4   28 use warnings;
  4         5  
  4         293  
4              
5             package lib::byversion;
6              
7             our $VERSION = '0.002001';
8              
9             # ABSTRACT: add paths to @INC depending on which version of Perl is running.
10              
11             our $AUTHORITY = 'cpan:KENTNL'; # AUTHORITY
12              
13 4     4   2454 use lib ();
  4         2896  
  4         135  
14 4     4   2714 use version 0.77;
  4         7518  
  4         28  
15              
16             use String::Formatter stringf => {
17             -as => path_format =>,
18             codes => {
19             v => "$]",
20 4         18 V => do {
21 4         49 my $x = version->parse("$]")->normal;
22 4         21 $x =~ s{^v}{}sx;
23 4         36 $x;
24             },
25             },
26 4     4   2795 };
  4         58048  
27              
28             sub import {
29 2     2   21 my ( undef, @args ) = @_;
30 2 50       8 if ( @args != 1 ) {
31 0         0 die 'lib::byversion->import takes exactly one argument, instead, you specified ' . scalar @args;
32             }
33 2         11 my $path = path_format(@args);
34 2         297 return lib->import($path);
35             }
36              
37             ## no critic (ProhibitBuiltinHomonyms)
38             sub unimport {
39 1     1   137 my ( undef, @args ) = @_;
40 1 50       4 if ( @args != 1 ) {
41 0         0 die 'lib::byversion->unimport takes exactly one argument, instead, you specified ' . scalar @args;
42             }
43 1         3 my $path = path_format(@args);
44 1         66 return lib->unimport($path);
45             }
46              
47             1;
48              
49             __END__