Debian Codegraph @

README

raw
1 NAME
2 Module::Extract - Base class for working with Perl distributions
3
4 SYNOPSIS
5 Creating a Module::Extract subclass.
6
7 package My::Readme;
8
9 # Shows the README file for a module
10
11 use strict;
12 use base 'Module::Extract';
13
14 sub show {
15 my $self = shift;
16 my $readme = $self->file_path('README');
17 if ( -f $readme ) {
18 system( "cat $readme" );
19 } else {
20 print "Dist does not have a README file";
21 }
22 }
23
24 1;
25
26 A script that uses the module to show the readme file for a distribution
27 filename provided by the user.
28
29 #!/usr/bin/perl
30
31 use My::Readme;
32
33 My::Readme->new( dist_file => $ARGV[0] )->show;
34
35 exit(0);
36
37 DESCRIPTION
38 Module::Extract is a convenience base class for creating module that
39 work with Perl distributions.
40
41 Its purpose is to take care of the mechanisms of locating and extracting
42 a Perl distribution so that your module can do something specific to the
43 distribution.
44
45 This module was originally created to provide an abstraction for the
46 extraction logic for both Module::Inspector and Module::P4P and to allow
47 additional features to be added in the future without having to modify
48 both of them, because the general problem of "locate, download, and
49 expand a distribution" is one that is almost ideal for adding additional
50 features down the line.
51
52 new
53 my $from_file = My::Class->new(
54 dist_file => 'tarball.tar.gz',
55 );
56
57 my $from_dir = My::Class->new(
58 dist_dir => 'some/dir',
59 );
60
61 The "new" constructor takes a "dist_file" and/or a "dist_dir" param,
62 locates and (if needed) expands the distribution tarball.
63
64 It takes either a "dist_file" param, which should be the local path to
65 the tarball, or a "dist_dir" which should be the path to a directory
66 which contains an already-expanded distribution (such as from a
67 repository checkout).
68
69 Return a new Module::Extract-subclass object, or dies on error.
70
71 dist_file
72 The "dist_file" accessor returns the (absolute) path to the distribution
73 tarball. If the inspector was created with "dist_dir" rather than
74 "dist_file", this will return "undef".
75
76 dist_type
77 The "dist_type" method returns the archive type of the distribution
78 tarball. This will be either 'tar.gz', 'tgz', or 'zip'. Other file types
79 are not supported at this time.
80
81 If the inspector was created with "dist_dir" rather than "dist_file",
82 this will return "undef".
83
84 dist_dir
85 The "dist_dir" method returns the (absolute) distribution root
86 directory.
87
88 If the inspector was created with "dist_file" rather than "dist_file",
89 this method will return the temporary directory created to hold the
90 unwrapped tarball.
91
92 file_path
93 my $local_path = $inspector->file_path('lib/Foo.pm');
94
95 To simplify implementations, most tools that work with distributions
96 identify files in unix-style relative paths.
97
98 The "file_path" method takes a unix-style relative path and returns a
99 localised absolute path to the file on disk (either in the actual
100 distribution directory, or the temp directory holding the expanded
101 tarball.
102
103 dir_path
104 my $local_path = $inspector->file_path('lib');
105
106 The "dir_path" method is the matching pair of the "file_path" method.
107
108 As for that method, it takes a unix-style relative directory name, and
109 returns a localised absolute path to the directory.
110
111 SUPPORT
112 This module is stored in an Open Repository at the following address.
113
114 <http://svn.phase-n.com/svn/cpan/trunk/Module-Extract>
115
116 Write access to the repository is made available automatically to any
117 published CPAN author, and to most other volunteers on request.
118
119 If you are able to submit your bug report in the form of new (failing)
120 unit tests, or can apply your fix directly instead of submitting a
121 patch, you are strongly encouraged to do so as the author currently
122 maintains over 100 modules and it can take some time to deal with
123 non-Critcal bug reports or patches.
124
125 This will guarentee that your issue will be addressed in the next
126 release of the module.
127
128 If you cannot provide a direct test or fix, or don't have time to do so,
129 then regular bug reports are still accepted and appreciated via the CPAN
130 bug tracker.
131
132 <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Module-Extract>
133
134 For other issues, for commercial enhancement or support, or to have your
135 write access enabled for the repository, contact the author at the email
136 address above.
137
138 AUTHORS
139 Adam Kennedy <[email protected]>
140
141 SEE ALSO
142 Module::Inspector, Module::P4P
143
144 COPYRIGHT
145 Copyright 2006 Adam Kennedy.
146
147 This program is free software; you can redistribute it and/or modify it
148 under the same terms as Perl itself.
149
150 The full text of the license can be found in the LICENSE file included
151 with this module.
152