Why not adopt me?
NAME
Gentoo::Util::VirtualDepend - Hard-coded replacements for perl-core/ dependencies and dependencies with odd names in Gentoo
VERSION
version 0.001000
SYNOPSIS
use Gentoo::Util::VirtualDepend;
my $v = Gentoo::Util::VirtualDepend->new();
# somewhere in complex dependency resolution
my $cpan_module = spooky_function();
my $gentoo_dependency;
if ( $v->has_module_override( $cpan_module ) ) {
$gentoo_dependency = $v->get_module_override( $cpan_module );
} else {
# do it the hard way.
}
If you're trying to be defensive and you're going to map the modules to distributions the hard way ( trust me, the code is really ugly ), then you may instead want
if ( $v->has_dist_override( $cpan_dist ) ) {
$gentoo_dependency = $v->get_dist_override( $cpan_dist );
} else {
# fallback to using dev-perl/Foo-Bar
}
Which basically serves as a distribution name translator.
WHY YOU WANT TO DO THAT
Well ...
{ requires => { Foo => 1.0 }}
Foo is in Bar
Foo 1.0 could have been shipped in in Bar-1.0, Bar-0.5, or Bar-2.0 for all you know.
That's the unfortunate reality of CPAN
dependencies.
So if you naively map
Foo-1.0 → >=dev-lang/Bar-1.0
You might get breakage if Foo 1.0
didn't ship till Bar-2.0
, and the user has Bar-1.0
→ Shower of sparks.
DESCRIPTION
This module serves as a low level glue layer for the handful of manual mappings that are needed in Gentoo due to things not strictly tracking upstream.
CPANPLUS::Dist::Gentoo
has similar logic to this, but not as simple ( or for that matter, usable without CPANPLUS
)
This module is not intended to be used entirely on its own, but as a short-circuit before calling complicated MetaCPAN
code.
METHODS
has_module_override
$v->has_module_override( $module )
Returns true if there is a known mapping for $module
in Gentoo
that is unusual and may require translation.
Will return true for anything that is either a virtual
or has an unusual name translation separating it from CPAN
.
get_module_override
$v->get_module_override( $module )
Returns a Gentoo
dependency atom corresponding to $module
if there is a known mapping for $module
.
For instance,
$v->get_module_override('ExtUtils::MakeMaker')
Emits:
virtual/perl-ExtUtilsMakeMaker
If ExtUtils::MakeMaker
is one day de-cored (Hah!, dreams are free) then has_module_override
will return false, and that instructs you to go back to assuming it is in dev-perl/
has_dist_override
$v->has_dist_override( $distname )
Similar to has_module_override
but closer to the dependency spec.
Will return true for anything that is either a virtual
or has an unusual name translation separating it from CPAN
.
get_dist_override
$v->get_dist_override( $distname )
Similar to get_module_override
but closer to the dependency spec.
For instance:
$v->get_dist_override('PathTools')
Emits:
virtual/perl-File-Spec
Because Gentoo
is quirky like that.
AUTHOR
Kent Fredric <kentnl@cpan.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2014 by Kent Fredric <kentfredric@gmail.com>.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.