File Coverage

blib/lib/lib/noop.pm
Criterion Covered Total %
statement 14 14 100.0
branch 1 2 50.0
condition n/a
subroutine 4 4 100.0
pod n/a
total 19 20 95.0


line stmt bran cond sub pod time code
1             package lib::noop;
2              
3             our $DATE = '2016-12-27'; # DATE
4             our $VERSION = '0.002'; # VERSION
5              
6 1     1   581 use strict;
  1         2  
  1         28  
7 1     1   3 use warnings;
  1         1  
  1         212  
8              
9             our @mods;
10             our $noop_code = "1;\n";
11              
12             our $hook = sub {
13             my ($self, $file) = @_;
14              
15             my $mod = $file; $mod =~ s/\.pm\z//; $mod =~ s!/!::!g;
16              
17             # decline if not in list of module to noop
18             return undef unless grep { $_ eq $mod } @mods;
19              
20             return \$noop_code;
21             };
22              
23             sub import {
24 1     1   7 my $class = shift;
25              
26 1         2 @mods = @_;
27              
28 1         2 @INC = ($hook, grep { $_ ne "$hook" } @INC);
  11         16  
29             }
30              
31             sub unimport {
32 1 50   1   364 return unless $hook;
33 1         2 @mods = ();
34 1         2 @INC = grep { "$_" ne "$hook" } @INC;
  12         25  
35             }
36              
37             1;
38             # ABSTRACT: no-op loading some modules
39              
40             __END__