/usr/share/perl5/Module/Depends.pm is in libmodule-depends-perl 0.16-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | use strict;
package Module::Depends;
use CPAN::Meta;
use Cwd qw( getcwd );
use base qw( Class::Accessor::Chained );
__PACKAGE__->mk_accessors(qw( dist_dir debug libs requires configure_requires build_requires test_requires error ));
our $VERSION = '0.16';
=head1 NAME
Module::Depends - identify the dependencies of a distribution
=head1 SYNOPSIS
use Module::Depends;
my $deps = Module::Depends->new->dist_dir( '.' )->find_modules;
print "Our dependencies:\n", Dump $deps->requires;
=head1 DESCRIPTION
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.
=head1 METHODS
=head2 new
simple constructor
=cut
sub new {
my $self = shift;
return $self->SUPER::new({
libs => [],
requires => {},
build_requires => {},
test_requires => {},
configure_requires => {},
error => '',
});
}
=head2 dist_dir
Path where the distribution has been extracted to.
=head2 find_modules
scan the C<dist_dir> to populate C<libs>, C<requires>, C<configure_requires>, C<test_requires>, and C<build_requires>
=cut
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.json MYMETA.yml META.json META.yml );
if ($file) {
my $meta = CPAN::Meta->load_file( $file );
my $prereqs = $meta->effective_prereqs();
$self->requires( $prereqs->requirements_for( 'runtime', 'requires' )->as_string_hash() );
$self->build_requires( $prereqs->requirements_for( 'build', 'requires' )->as_string_hash() );
$self->configure_requires( $prereqs->requirements_for( 'configure', 'requires' )->as_string_hash() );
$self->test_requires( $prereqs->requirements_for( 'test', 'requires' )->as_string_hash() );
}
else {
$self->error( "No {MY,}META.{json,yml} found in ". $self->dist_dir );
}
return $self;
}
1;
__END__
=head2 libs
an array reference of lib lines
=head2 requires
A reference to a hash enumerating the prerequisite modules for this
distribution.
=head2 configure_requires
A reference to a hash enumerating the prerequisite modules to configure this
distribution.
=head2 build_requires
A reference to a hash enumerating the modules needed to build the
distribution.
=head2 error
A reason, if any, for failing to get dependencies.
=head1 AUTHOR
Richard Clamp, based on code extracted from the Fotango build system
originally by James Duncan and Arthur Bergman.
=head1 COPYRIGHT
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.
=head1 SEE ALSO
L<Module::Depends::Intrusive>
=cut
|