AnnoCPAN

 view release on metacpan or  search on metacpan

lib/AnnoCPAN/Dist.pm  view on Meta::CPAN


=item *

"Old-style" packages, where the modules are in the top directory, with
sub-namespaces in subdirectories.

=back

Files that appear to be PPM packages are ignored.

This class inherits from CPAN::DistnameInfo, and relies on it for parsing
the filename and figuring out things such as the version number.

The version numbers are derived from the package filename only, and are
expected to be floating-point numbers. The $VERSION values inside the module
code are considered irrelevant for the purpose of this project.

=head1 METHODS

=over

=cut

# default files to ignore
my @exclude = (
    qr(/inc/),      # used by Module::Install bundles
    qr(/t/),
    qr(/eg/),
    qr(/blib/),
    qr(/Makefile(.PL)?$),
    qr(/Build.PL$),
    qr(/MANIFEST$)i,
    qr(/README$)i,
    qr(/Changes$)i,
    qr(/ChangeLog$)i,
    qr(/LICENSE$)i,
    qr(/TODO$)i,
    qr(/AUTHORS?$)i,
);

# default files to include
my @include = (
    qr{.(pm|pod|pl)$}i,
    qr{/[^./]+$},       # files with no extension (typically scripts)
);

=item $class->new($fname, %options)

Create a new distribution object from a filename. Returns undef on failure.
Currently the only option is 'verbose'; if true, various diagnostic messages
are printed to STDOUT and STDERR when extracting the file.

=cut

sub new {
    my ($class, $fname, %options) = @_;
    
    return unless $fname =~ m{(authors/id/.*)};
    my $rel_pathname = $1;
    # let CPAN::DistnameInfo do the guessing
    my $self = $class->SUPER::new($fname);
    $self->{verbose}        = $options{verbose};
    $self->{rel_pathname}   = $rel_pathname;

    # XXX should make sure we like the filename...

    $self;
}

=item $obj->archive

Return the AnnoCPAN::Archive object for this distribution.

=cut

sub archive { 
    my ($self) = @_;
    $self->{archive} ||= AnnoCPAN::Archive->new($self->pathname);
}

=item $obj->mtime

Returns the modification time of the package (seconds since epoch).

=cut

sub mtime { shift->stat->mtime }

=item $obj->stat

Returns a L<File::stat> object for the distribution package.

=cut

sub stat {
    my ($self) = @_;
    $self->{stat} ||= File::stat::stat($self->pathname);
}

sub dbi_dist    { shift->{dbi_dist} }
sub dbi_distver { shift->{dbi_distver} }

=item $obj->files

Returns a list of all the filenames in the package.

=cut

sub files       { shift->archive->files }

=item $obj->read_file($fname)

Returns the contents of a file in the package.

=cut

sub read_file   { shift->archive->read_file(@_) }

=item $obj->verbose

Returns true if the verbose option was given when constructing the object.



( run in 1.507 second using v1.01-cache-2.11-cpan-5b529ec07f3 )