File Coverage

blib/lib/ExtUtils/Helpers.pm
Criterion Covered Total %
statement 34 34 100.0
branch n/a
condition 5 12 41.6
subroutine 9 9 100.0
pod 2 2 100.0
total 50 57 87.7


line stmt bran cond sub pod time code
1             package ExtUtils::Helpers;
2             $ExtUtils::Helpers::VERSION = '0.028';
3 4     4   520162 use strict;
  4         9  
  4         209  
4 4     4   22 use warnings FATAL => 'all';
  4         7  
  4         343  
5 4     4   41 use Exporter 5.57 'import';
  4         130  
  4         158  
6              
7 4     4   20 use Config;
  4         12  
  4         268  
8 4     4   25 use File::Basename qw/basename/;
  4         18  
  4         465  
9 4     4   1601 use File::Spec::Functions qw/splitpath canonpath abs2rel splitdir/;
  4         3783  
  4         837  
10              
11             our @EXPORT_OK = qw/make_executable split_like_shell man1_pagename man3_pagename detildefy/;
12              
13             BEGIN {
14 4     4   24 my %impl_for = ( MSWin32 => 'Windows', VMS => 'VMS');
15 4   50     49 my $package = 'ExtUtils::Helpers::' . ($impl_for{$^O} || 'Unix');
16 4   50     55 my $impl = $impl_for{$^O} || 'Unix';
17 4         2409 require "ExtUtils/Helpers/$impl.pm";
18 4         1436 "ExtUtils::Helpers::$impl"->import();
19             }
20              
21             sub man1_pagename {
22 1     1 1 223520 my ($filename, $ext) = @_;
23 1   33     94 $ext ||= $Config{man1ext};
24 1         58 return basename($filename).".$ext";
25             }
26              
27             my %separator = (
28             MSWin32 => '.',
29             VMS => '__',
30             os2 => '.',
31             cygwin => '.',
32             );
33             my $separator = $separator{$^O} || '::';
34              
35             sub man3_pagename {
36 3     3 1 7 my ($filename, $base, $ext) = @_;
37 3   50     13 $base ||= 'lib';
38 3   33     74 $ext ||= $Config{man3ext};
39 3         10 my ($vols, $dirs, $file) = splitpath(canonpath(abs2rel($filename, $base)));
40 3         380 $file = basename($file, qw/.pm .pod/);
41 3         8 my @dirs = grep { length } splitdir($dirs);
  5         13  
42 3         31 return join $separator, @dirs, "$file.$ext";
43             }
44              
45             1;
46              
47             # ABSTRACT: Various portability utilities for module builders
48              
49             __END__