| Module-Depends documentation | Contained in the Module-Depends distribution. |
Module::Depends - identify the dependencies of a distribution
use YAML; use Module::Depends; my $deps = Module::Depends->new->dist_dir( '.' )->find_modules; print "Our dependencies:\n", Dump $deps->requires;
Module::Depends extracts module dependencies from an unpacked distribution tree.
Module::Depends only evaluates the META.yml shipped with a distribution. This won't be effective until all distributions ship META.yml files, so we suggest you take your life in your hands and look at Module::Depends::Intrusive.
simple constructor
Path where the distribution has been extracted to.
scan the dist_dir to populate libs, requires, and build_requires
an array reference of lib lines
A reference to a hash enumerating the prerequisite modules for this distribution.
A reference to a hash enumerating the modules needed to build the distribution.
A reason, if any, for failing to get dependencies.
Richard Clamp, based on code extracted from the Fotango build system originally by James Duncan and Arthur Bergman.
Copyright 2010, Richard Clamp. Copyright 2004-2008, Fotango.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
| Module-Depends documentation | Contained in the Module-Depends distribution. |
use strict; package Module::Depends; use Parse::CPAN::Meta; use Cwd qw( getcwd ); use base qw( Class::Accessor::Chained ); __PACKAGE__->mk_accessors(qw( dist_dir debug libs requires build_requires error )); our $VERSION = '0.15';
sub new { my $self = shift; return $self->SUPER::new({ libs => [], requires => {}, build_requires => {}, error => '', }); }
sub find_modules { my $self = shift; my $here = getcwd; unless (chdir $self->dist_dir) { $self->error( "couldn't chdir to " . $self->dist_dir . ": $!" ); return $self; } eval { $self->_find_modules }; chdir $here; die $@ if $@; return $self; } sub _find_modules { my $self = shift; my ($file) = grep { -e $_ } qw( MYMETA.yml META.yml ); if ($file) { my $meta = ( Parse::CPAN::Meta::LoadFile( $file ) )[0]; $self->requires( $meta->{requires} ); $self->build_requires( $meta->{build_requires} ); } else { $self->error( "No META.yml found in ". $self->dist_dir ); } return $self; } 1; __END__