File Coverage

blib/lib/ExtUtils/Helpers.pm
Criterion Covered Total %
statement 40 40 100.0
branch 2 4 50.0
condition 3 6 50.0
subroutine 11 11 100.0
pod 3 3 100.0
total 59 64 92.1


line stmt bran cond sub pod time code
1             package ExtUtils::Helpers;
2             $ExtUtils::Helpers::VERSION = '0.026';
3 4     4   53239 use strict;
  4         4  
  4         95  
4 4     4   11 use warnings FATAL => 'all';
  4         3  
  4         125  
5 4     4   11 use Exporter 5.57 'import';
  4         67  
  4         109  
6              
7 4     4   12 use Config;
  4         4  
  4         114  
8 4     4   12 use File::Basename qw/basename/;
  4         2  
  4         253  
9 4     4   1374 use File::Spec::Functions qw/splitpath canonpath abs2rel splitdir/;
  4         1572  
  4         274  
10 4     4   1672 use Text::ParseWords 3.24 ();
  4         3868  
  4         298  
11              
12             our @EXPORT_OK = qw/make_executable split_like_shell man1_pagename man3_pagename detildefy/;
13              
14             BEGIN {
15 4     4   13 my %impl_for = ( MSWin32 => 'Windows', VMS => 'VMS');
16 4   50     31 my $package = 'ExtUtils::Helpers::' . ($impl_for{$^O} || 'Unix');
17 4   50     16 my $impl = $impl_for{$^O} || 'Unix';
18 4         1334 require "ExtUtils/Helpers/$impl.pm";
19 4         1000 "ExtUtils::Helpers::$impl"->import();
20             }
21              
22             sub split_like_shell {
23 5     5 1 3867 my ($string) = @_;
24              
25 5 50       13 return if not defined $string;
26 5         27 $string =~ s/^\s+|\s+$//g;
27 5 50       10 return if not length $string;
28              
29 5         12 return Text::ParseWords::shellwords($string);
30             }
31              
32             sub man1_pagename {
33 1     1 1 11 my $filename = shift;
34 1         105 return basename($filename).".$Config{man1ext}";
35             }
36              
37             my %separator = (
38             MSWin32 => '.',
39             VMS => '__',
40             os2 => '.',
41             cygwin => '.',
42             );
43             my $separator = $separator{$^O} || '::';
44              
45             sub man3_pagename {
46 3     3 1 5 my ($filename, $base) = @_;
47 3   50     13 $base ||= 'lib';
48 3         8 my ($vols, $dirs, $file) = splitpath(canonpath(abs2rel($filename, $base)));
49 3         305 $file = basename($file, qw/.pm .pod/);
50 3         7 my @dirs = grep { length } splitdir($dirs);
  5         11  
51 3         83 return join $separator, @dirs, "$file.$Config{man3ext}";
52             }
53              
54             1;
55              
56             # ABSTRACT: Various portability utilities for module builders
57              
58             __END__