2 package Module::Depends;
3 use YAML qw( LoadFile );
5 use base qw( Class::Accessor::Chained );
6 __PACKAGE__->mk_accessors(qw( dist_dir debug libs requires build_requires error ));
11 Module::Depends - identify the dependencies of a distribution
17 my $deps = Module::Depends->new->dist_dir( '.' )->find_modules;
18 print "Our dependencies:\n", Dump $deps->requires;
22 Module::Depends extracts module dependencies from an unpacked
25 Module::Depends only evaluates the META.yml shipped with a
26 distribution. This won't be effective until all distributions ship
27 META.yml files, so we suggest you take your life in your hands and
28 look at Module::Depends::Intrusive.
41 return $self->SUPER::new({
51 Path where the distribution has been extracted to.
55 scan the C<dist_dir> to populate C<libs>, C<requires>, and C<build_requires>
63 unless (chdir $self->dist_dir) {
64 $self->error( "couldn't chdir to " . $self->dist_dir . ": $!" );
67 eval { $self->_find_modules };
77 my $file = 'META.yml';
79 my $meta = LoadFile( $file );
80 $self->requires( $meta->{requires} );
81 $self->build_requires( $meta->{build_requires} );
84 $self->error( "No META.yml found in ". $self->dist_dir );
95 an array reference of lib lines
99 A reference to a hash enumerating the prerequisite modules for this
102 =head2 build_requires
104 A reference to a hash enumerating the modules needed to build the
109 A reason, if any, for failing to get dependencies.
113 Richard Clamp, based on code extracted from the Fotango build system
114 originally by James Duncan and Arthur Bergman.
118 Copyright 2004, 2007, 2008 Fotango. All Rights Reserved.
120 This module is free software; you can redistribute it and/or modify it
121 under the same terms as Perl itself.
125 L<Module::Depends::Intrusive>