File Coverage

blib/lib/Perl/LibExtractor.pm
Criterion Covered Total %
statement 12 220 5.4
branch 0 78 0.0
condition 0 42 0.0
subroutine 4 27 14.8
pod 13 15 86.6
total 29 382 7.5


line stmt bran cond sub pod time code
1             =head1 NAME
2              
3             Perl::LibExtractor - determine perl library subsets for building distributions
4              
5             =head1 SYNOPSIS
6              
7             use Perl::LibExtractor;
8              
9             =head1 DESCRIPTION
10              
11             The purpose of this module is to determine subsets of your perl library,
12             that is, a set of files needed to satisfy certain dependencies (e.g. of a
13             program).
14              
15             The goal is to extract a part of your perl installation including
16             dependencies. A typical use case for this module would be to find out
17             which files are needed to be build a L distribution, to link into
18             an L binary, or to pack with L, to create
19             stand-alone distributions tailormade to run your app.
20              
21             =head1 METHODS
22              
23             To use this module, first call the C-constructor and then as many
24             other methods as you want, to generate a set of files. Then query the set
25             of files and do whatever you want with them.
26              
27             The command-line utility F can be a convenient
28             alternative to using this module directly, and offers a few extra options,
29             such as to copy out the files into a new directory, strip them and/or
30             manipulate them in other ways.
31              
32             =cut
33              
34             package Perl::LibExtractor;
35              
36             our $VERSION = '1.1';
37              
38 1     1   789 use Config;
  1         2  
  1         48  
39 1     1   6 use File::Spec ();
  1         2  
  1         16  
40 1     1   24912 use File::Temp ();
  1         31386  
  1         27  
41              
42 1     1   1005 use common::sense;
  1         9  
  1         5  
43              
44             sub I_SRC () { 0 }
45             sub I_DEP () { 1 }
46              
47             sub croak($) {
48 0     0 0   require Carp;
49 0           Carp::croak "(Perl::LibExtractor) $_[0]";
50             }
51              
52             my $canonpath = File::Spec->can ("canonpath");
53             my $case_tolerant = File::Spec->case_tolerant;
54              
55             sub canonpath($) {
56 0     0 0   local $_ = $canonpath->(File::Spec::, $_[0]);
57 0           s%\\%/%g;
58             # $_ = lc if $case_tolerant; # we assume perl file name case is always the same
59 0           $_
60             }
61              
62             =head2 CREATION
63              
64             =over 4
65              
66             =item $extractor = new Perl::LibExtractor [key => value...]
67              
68             Creates a new extractor object. Each extractor object stores some
69             configuration options and a subset of files that can be queried at any
70             time,.
71              
72             Binary executables (such as the perl interpreter) are stored inside
73             F, perl scripts are stored under F