Debian Codegraph @

README

raw
1 NAME
2 Module::Inspector - An integrated API for inspecting Perl distributions
3
4 DESCRIPTION
5 An entire ecosystem of CPAN modules exist around the files and formats
6 relating to the CPAN itself. Parsers and object models for various
7 different types of files have been created over the years by various
8 people for various projects.
9
10 These modules have a variety of different styles, and work in various
11 different ways.
12
13 So when it comes to analysing the structure of a Perl module (either
14 inside a repository, in a tarball, or in unpacked form) it is certainly
15 quite possible to do.
16
17 It's just that often it takes a high level of experience with the
18 various modules in question, and the knowledge of how to combine the
19 dozen of so modules in one cohesive program.
20
21 Personally, I have always found this laborious.
22
23 What I would prefer is a single API that is easy to use, implements the
24 magic invisibly behind the scenes, and co-ordinates the use of the
25 various modules for me as needed.
26
27 Module::Inspector provides such an API, and provides a companion to the
28 Class::Inspector API for accessing information on class after
29 installation.
30
31 It provides a wrapper around the various modules used to read and
32 examine the different parts of a Perl module distribution tarball, and
33 can inspect a module unrolled on disk, in a repository checkout, or just
34 look directly inside a tarball.
35
36 METHODS
37 new
38 # Inspect a plain dist directory or cvs/svn checkout
39 my $dir = Module::Inspector->new(
40 dist_dir => $dirpath,
41 );
42
43 # Inspect a tarball
44 my $file = Module::Inspector->new(
45 dist_file => 'Foo-Bar-0.01.tar.gz',
46 );
47
48 The "new" constructor creates a new module inspector. It takes a named
49 param of either "dist_file", which should be the file path of the dist
50 tarball, or "dist_dir", which is the root of the distribution directory
51 (if it is already unrolled).
52
53 The distribution will be quickly pre-scanned to locate the various
54 significant documents in the distribution (although only a few are
55 initially supported).
56
57 Returns a new "Module::Inspector" object, or dies on exception.
58
59 version_control
60 my $vcs_type = $self->version_control;
61
62 For reasons that will hopefully be more apparant later,
63 Module::Inspector detects any version control system in use within the
64 "dist_dir" for the module.
65
66 Currently, support is limited to detection of CVS and Subversion.
67
68 Returns a the name of the version control system detected in use as a
69 string (currently 'cvs' or 'svn'). If no version control is able to be
70 detected returns the null string ''.
71
72 documents
73 The "documents" method returns a list of the names of all the documents
74 detected by the "Module::Inspector".
75
76 In scalar context, returns the number of identifyable documens found in
77 the distribution.
78
79 document_type
80 # Returns 'PPI::Document::File'
81 my $ppi_class = $inspector->document_type('lib/Foo.pm');
82
83 In Module::Inspector, all documents are represented as objects.
84
85 Thus, for each different type of document, there is going to be a
86 different class that implements the document objects for that type.
87
88 The "document_type" method returns the type for a provided document as a
89 class name.
90
91 Please note that at this time these document types are not necesarily
92 stable, and over the first several releases I may need to change the
93 class I'm using to represent a particular document type.
94
95 document
96 my $perl = $inspector->document('lib/Foo.pm');
97
98 The "document" method returns the document object for a named file,
99 loading and caching it on the fly if needed.
100
101 The type of object will vary depending on the document.
102
103 For example, a Perl file will be returned as a PPI::Document, a MANIFEST
104 file as a Module::Manifest, and so on.
105
106 Returns an object, or dies on error.
107
108 dist_name
109 # Returns Config-Tiny
110 my $name = $inspector->dist_name;
111
112 The "dist_name" method returns the name of the distribution, as
113 determined from the META.yml file.
114
115 Returns the name as a string, or dies on error.
116
117 dist_version
118 The "dist_version" method returns the version of the distribution, as
119 determined from the META.yml file in the distribution.
120
121 Returns a version object, or dies on error.
122
123 dist_requires
124 my $depends = $inspector->dist_requires;
125
126 The "dist_requires" method checks for any run-time dependencies of the
127 distribution and returns them as a Module::Math::Depends object.
128
129 See the docs for Module::Math::Depends for more information on its
130 structure and API.
131
132 If the distribution has no run-time dependencies, the object will still
133 be returned, but will be empty.
134
135 Returns a single Module::Math::Depends object, or dies on error.
136
137 dist_build_requires
138 The "dist_build_requires" method returns the build-time-only
139 dependencies of the distribution.
140
141 If there are no build-time dependencies, the object will still be
142 returned, but will be empty.
143
144 Returns a Module::Math::Depends object, or dies on exception.
145
146 dist_depends
147 The "dist_depends" method returns as for the two methods above
148 ("dist_requires" and "dist_build_requires") except that this method
149 returns a merged dependency object, representing BOTH the install-time
150 and run-time dependencies for the distribution.
151
152 If there are no build-time or run-time dependencies, the object will be
153 returned, but will be empty.
154
155 Returns a Module::Math::Depends object, or dies on error.
156
157 TO DO
158 - Implement most of the functionality
159
160 SUPPORT
161 This module is stored in an Open Repository at the following address.
162
163 <http://svn.ali.as/cpan/trunk/Module-Inspector>
164
165 Write access to the repository is made available automatically to any
166 published CPAN author, and to most other volunteers on request.
167
168 If you are able to submit your bug report in the form of new (failing)
169 unit tests, or can apply your fix directly instead of submitting a
170 patch, you are strongly encouraged to do so as the author currently
171 maintains over 100 modules and it can take some time to deal with
172 non-Critcal bug reports or patches.
173
174 This will guarentee that your issue will be addressed in the next
175 release of the module.
176
177 If you cannot provide a direct test or fix, or don't have time to do so,
178 then regular bug reports are still accepted and appreciated via the CPAN
179 bug tracker.
180
181 <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Module-Inspector>
182
183 For other issues, for commercial enhancement or support, or to have your
184 write access enabled for the repository, contact the author at the email
185 address above.
186
187 AUTHOR
188 Adam Kennedy <[email protected]>
189
190 SEE ALSO
191 Class::Inspector
192
193 COPYRIGHT
194 Copyright 2006 - 2008 Adam Kennedy.
195
196 This program is free software; you can redistribute it and/or modify it
197 under the same terms as Perl itself.
198
199 The full text of the license can be found in the LICENSE file included
200 with this module.
201