DESCRIPTION

An entire ecosystem of \s-1CPAN\s0 modules exist around the files and formats relating to the \s-1CPAN\s0 itself. Parsers and object models for various different types of files have been created over the years by various people for various projects.

These modules have a variety of different styles, and work in various different ways.

So when it comes to analysing the structure of a Perl module (either inside a repository, in a tarball, or in unpacked form) it is certainly quite possible to do.

It's just that often it takes a high level of experience with the various modules in question, and the knowledge of how to combine the dozen of so modules in one cohesive program.

Personally, I have always found this laborious.

What I would prefer is a single \s-1API\s0 that is easy to use, implements the magic invisibly behind the scenes, and co-ordinates the use of the various modules for me as needed.

Module::Inspector provides such an \s-1API\s0, and provides a companion to the Class::Inspector \s-1API\s0 for accessing information on class after installation.

It provides a wrapper around the various modules used to read and examine the different parts of a Perl module distribution tarball, and can inspect a module unrolled on disk, in a repository checkout, or just look directly inside a tarball.

METHODS

new

  # Inspect a plain dist directory or cvs/svn checkout
  my $dir = Module::Inspector->new(
          dist_dir => $dirpath,
          );

  # Inspect a tarball
  my $file = Module::Inspector->new(
          dist_file => 'Foo-Bar-0.01.tar.gz',
          );

The \*(C`new\*(C' constructor creates a new module inspector. It takes a named param of either \*(C`dist_file\*(C', which should be the file path of the dist tarball, or \*(C`dist_dir\*(C', which is the root of the distribution directory (if it is already unrolled).

The distribution will be quickly pre-scanned to locate the various significant documents in the distribution (although only a few are initially supported).

Returns a new \*(C`Module::Inspector\*(C' object, or dies on exception.

version_control

my $vcs_type = $self->version_control;

For reasons that will hopefully be more apparant later, Module::Inspector detects any version control system in use within the \*(C`dist_dir\*(C' for the module.

Currently, support is limited to detection of \s-1CVS\s0 and Subversion.

Returns a the name of the version control system detected in use as a string (currently 'cvs' or 'svn'). If no version control is able to be detected returns the null string ''.

documents

The \*(C`documents\*(C' method returns a list of the names of all the documents detected by the \*(C`Module::Inspector\*(C'.

In scalar context, returns the number of identifyable documens found in the distribution.

document_type

# Returns 'PPI::Document::File' my $ppi_class = $inspector->document_type('lib/Foo.pm');

In Module::Inspector, all documents are represented as objects.

Thus, for each different type of document, there is going to be a different class that implements the document objects for that type.

The \*(C`document_type\*(C' method returns the type for a provided document as a class name.

Please note that at this time these document types are not necesarily stable, and over the first several releases I may need to change the class I'm using to represent a particular document type.

document

my $perl = $inspector->document('lib/Foo.pm');

The \*(C`document\*(C' method returns the document object for a named file, loading and caching it on the fly if needed.

The type of object will vary depending on the document.

For example, a Perl file will be returned as a PPI::Document, a \s-1MANIFEST\s0 file as a Module::Manifest, and so on.

Returns an object, or dies on error.

dist_name

# Returns Config-Tiny my $name = $inspector->dist_name;

The \*(C`dist_name\*(C' method returns the name of the distribution, as determined from the \s-1META\s0.yml file.

Returns the name as a string, or dies on error.

dist_version

The \*(C`dist_version\*(C' method returns the version of the distribution, as determined from the \s-1META\s0.yml file in the distribution.

Returns a version object, or dies on error.

dist_requires

my $depends = $inspector->dist_requires;

The \*(C`dist_requires\*(C' method checks for any run-time dependencies of the distribution and returns them as a Module::Math::Depends object.

See the docs for Module::Math::Depends for more information on its structure and \s-1API\s0.

If the distribution has no run-time dependencies, the object will still be returned, but will be empty.

Returns a single Module::Math::Depends object, or dies on error.

dist_build_requires

The \*(C`dist_build_requires\*(C' method returns the build-time-only dependencies of the distribution.

If there are no build-time dependencies, the object will still be returned, but will be empty.

Returns a Module::Math::Depends object, or dies on exception.

dist_depends

The \*(C`dist_depends\*(C' method returns as for the two methods above (\*(C`dist_requires\*(C' and \*(C`dist_build_requires\*(C') except that this method returns a merged dependency object, representing \s-1BOTH\s0 the install-time and run-time dependencies for the distribution.

If there are no build-time or run-time dependencies, the object will be returned, but will be empty.

Returns a Module::Math::Depends object, or dies on error.

TO DO

- Implement most of the functionality

SUPPORT

This module is stored in an Open Repository at the following address.

http://svn.ali.as/cpan/trunk/Module-Inspector <http://svn.ali.as/cpan/trunk/Module-Inspector>

Write access to the repository is made available automatically to any published \s-1CPAN\s0 author, and to most other volunteers on request.

If you are able to submit your bug report in the form of new (failing) unit tests, or can apply your fix directly instead of submitting a patch, you are strongly encouraged to do so as the author currently maintains over 100 modules and it can take some time to deal with non-Critcal bug reports or patches.

This will guarentee that your issue will be addressed in the next release of the module.

If you cannot provide a direct test or fix, or don't have time to do so, then regular bug reports are still accepted and appreciated via the \s-1CPAN\s0 bug tracker.

http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Module-Inspector <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Module-Inspector>

For other issues, for commercial enhancement or support, or to have your write access enabled for the repository, contact the author at the email address above.

AUTHOR

Adam Kennedy <[email protected]>

RELATED TO Module::Inspector…

Class::Inspector

COPYRIGHT

Copyright 2006 - 2008 Adam Kennedy.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

The full text of the license can be found in the \s-1LICENSE\s0 file included with this module.