/usr/share/perl5/Module/Math/Depends.pm is in libmodule-math-depends-perl 0.02-2.
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 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 | package Module::Math::Depends;
=pod
=head1 NAME
Module::Math::Depends - Convenience object for manipulating module dependencies
=head1 DESCRIPTION
This is a small convenience module created originally as part of
L<Module::Inspector> but released separately, in the hope that people
might find it useful in other contexts.
=head1 METHODS
=cut
use 5.005;
use strict;
use Carp ();
use version ();
use Params::Util qw{_CLASS _HASH _INSTANCE};
use vars qw{$VERSION};
BEGIN {
$VERSION = '0.02';
}
#####################################################################
# Constructors
=head2 new
my $deps = Module::Math::Depends->new;
Creates a new, empty, dependency set.
=cut
sub new {
bless {}, $_[0];
}
=head2 from_hash
my $deps = Module::Math::Depends->from_hash( \%modules );
Creates a new dependency set from a raw hashref of modules names
and versions.
=cut
sub from_hash {
my $self = shift()->new;
my $hash = _HASH(shift)
or Carp::croak("Did not provide a HASH reference");
# Add the deps
foreach my $module ( keys %$hash ) {
$self->add_module( $module => $hash->{$module} );
}
$self;
}
#####################################################################
# Main Methods
=head2 add_module
$deps->add_module( 'My::Module' => '1.23' );
Adds a single module dependency to the set.
Returns true, or dies on error.
=cut
sub add_module {
my $self = shift;
my $name = _CLASS(shift)
or Carp::croak("Invalid module name provided");
my $version = defined($_[0])
? ref($_[0])
? _INSTANCE(shift, 'version')
: version->new(shift)
: version->new(0);
unless ( defined $version ) {
Carp::croak("Invalid version provided");
}
if ( $self->{$name} ) {
if ( $version > $self->{$name} ) {
$self->{$name} = $version;
}
} else {
$self->{$name} = $version;
}
return 1;
}
=head2 merge
$my_deps->merge( $your_deps );
The C<merge> method takes another dependency set and merges it into the
current one, taking the highest version where both sets contain a module.
Returns true or dies on error.
=cut
sub merge {
my $self = shift;
my $from = _INSTANCE(shift, 'Module::Math::Depends')
or Carp::croak("Did not provide a Module::Math::Depends object");
foreach my $name ( sort keys %$from ) {
if ( $self->{$name} ) {
if ( $from->{$name} > $self->{$name} ) {
$self->{$name} = $from->{$name};
}
} else {
$self->{$name} = $from->{$name};
}
}
return 1;
}
=pod
=head2 as_string
print $depends->as_string;
Converts the dependency set to a simple printable string.
=cut
sub as_string {
my $self = shift;
join '', map { "$_: $self->{$_}\n" } sort keys %$self;
}
1;
=pod
=head1 SUPPORT
This module is stored in an Open Repository at the following address.
L<http://svn.ali.as/cpan/trunk/Module-Math-Depends>
Write access to the repository is made available automatically to any
published CPAN 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 B<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 CPAN
bug tracker.
L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Module-Math-Depends>
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.
=head1 AUTHORS
Adam Kennedy E<lt>adamk@cpan.orgE<gt>
=head1 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
LICENSE file included with this module.
=cut
|