File Coverage

_build/lib/MyModuleBuilder.pm
Criterion Covered Total %
statement 14 39 35.9
branch 0 10 0.0
condition 1 9 11.1
subroutine 5 10 50.0
pod 0 4 0.0
total 20 72 27.7


line stmt bran cond sub pod time code
1             package MyModuleBuilder;
2 1     1   930 use Module::Build;
  1         125343  
  1         142  
3             our @ISA = qw(Module::Build);
4              
5 1     1   41 use Perl::OSType qw(os_type);
  1         3  
  1         91  
6 1     1   7 use Cwd qw( cwd );
  1         2  
  1         718  
7              
8             #---------------------------------
9             # Build
10             #---------------------------------
11              
12             sub ACTION_build {
13 0     0 0 0 my ($s) = @_;
14 0         0 $s->_readme();
15 0         0 $s->SUPER::ACTION_build;
16             }
17              
18             # Only for the maintainer on "Build build".
19             sub _readme {
20 0     0   0 my ($s) = @_;
21 0 0       0 return if cwd() !~ m{ / git / perlmy / [^/]+ $ }x;
22              
23             my ($installed) =
24 0         0 grep { -x "$_/pod2markdown" }
25 0         0 split /:/, $ENV{PATH};
26 0 0       0 return if !$installed;
27              
28 0         0 print "Building README\n";
29 0         0 my $lib = $s->{properties}{dist_version_from};
30 0         0 system "pod2markdown $lib > README.md";
31             }
32              
33             #---------------------------------
34             # Install
35             #---------------------------------
36              
37             sub ACTION_install {
38 0     0 0 0 my ($s) = @_;
39 0         0 $s->_clear_cache;
40 0 0       0 $s->_check_for_source_command if os_type eq "Unix";
41 0         0 $s->SUPER::ACTION_install;
42             }
43             sub ACTION_clean {
44 0     0 0 0 my ($s) = @_;
45 0         0 $s->_clear_cache;
46 0         0 $s->SUPER::ACTION_clean;
47             }
48             sub ACTION_test {
49 1     1 0 95 my ($s) = @_;
50 1         5 $s->_clear_cache;
51 1         19 $s->SUPER::ACTION_test;
52             }
53              
54             sub _clear_cache {
55 1   33 1   58 my $home = $ENV{HOME} // $ENV{USERPROFILE} // $ENV{LOGDIR};
      0        
56 1         77 for ( glob qq("$home/.cache/my_pod*.cache") ) {
57 0           print "Removing: $_\n";
58 0 0         unlink or warn $!;
59             }
60             }
61             sub _check_for_source_command {
62 0     0     my $file = "bash_completion_pod";
63 0           my $path = qx(which $file);
64 0           chomp $path;
65 0 0 0       if ( not $ENV{MY_POD_CACHE} and $path ) {
66 0           print <
67              
68             Add this to your bashrc file (or compatible):
69              
70             [ "\$(which $file)" != "" ] && source $file
71              
72             Or this one (if $file is not in your PATH):
73              
74             [ -f "$path" ] && source $path
75              
76             ECHO
77             }
78             }
79            
80             1;