Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 t
Octocat-spinner-32 README.mkdn
Octocat-spinner-32 dist.ini
Octocat-spinner-32 tree.pl
Octocat-spinner-32 weaver.ini
README.mkdn

NAME

Version::Finder::MetaCPAN - Find the appropriate distributions to install to satisfy version requirements using MetaCPAN

VERSION

version 0.01

SYNOPSIS

use Version::Finder::MetaCPAN;
use CPAN::Meta::Requirements;

my $req = CPAN::Meta::Requirements->new;
$req->add_string_requirement('Moose', '== 2.0401');

my $vf = Version::Finder::MetaCPAN->new;
# Find all the requirements for the Requirements we've defined.
# The Chart::Clicker and 2.0 parts are just for information, the $req
# object is all that matters.
my $results = $vf->build_tree_deps('Chart::Clicker', '2.0', $req);

# Flatten and get the depth
my @items;
$results->traverse(sub {
    my ($_tree) = @_;
    my $info = $_tree->getNodeValue->info;
    push(@items, { depth => $_tree->getDepth, info => $info });
});

# Sort to find the deepest deps.
my @sorted = reverse sort { $a->{depth} <=> $b->{depth} } @items;

# Print out the tarballs we need
foreach my $item (@sorted) {
    print $item->{info}->{download_url}."\n";
}

DESCRIPTION

Warning: Version::Finder::MetaCPAN is experimental. It might be broken, return incorrect results or change drastically. Help is welcome!

Version::Finder::MetaCPAN uses the ElasticSearch index that backs MetaCPAN to find the specific releases of distributions that satisfy the requirements defined in a CPAN::Meta::Requirements object.

Calling find creates a search with a series of filters that returns the most recent release of a distribution that satisfies the requirements. It understands all of the restrictions defined by CPAN::Meta::Requirements.

OVERVIEW

Version::Finder::MetaCPAN is able to answer this question: Given a couple of modules and their requirements, what do I need to fetch from CPAN to get it all working?

my $reqs = CPAN::Meta::Requirements->new;
$reqs->add_minimum('Moose' => '2.0');
$reqs->add_maximum('Graphics::Primitive' => '0.60'); # Maybe 1.0 is incompatible
$reqs->exact_version('Try::Tiny' => '0.11'); # I insist!


my $vf = Version::Finder::MetaCPAN->new;
my $results = $vf->find($results);

foreach my $dep (@{ $results }) {
    print $dep->{download_url}."\n";
}

METHODS

find ($requirements)

Given a CPAN::Meta::Requirements object, returns an arrayref of hashrefs that point to the specific releases of each specified distribution.

find_distribution_for_module ('Some::Module')

Find the name of the distribution that provides the module with the specified name.

build_tree_deps ($dist, $ver, $reqs)

Given a dist name, version and CPAN::Meta::Requirements object this method inspects the dependencies recursively and returns a Tree::Simple object representing the recursively resolved dependencies of all modules.

AUTHOR

Cory G Watson gphat@cpan.org

COPYRIGHT AND LICENSE

This software is copyright (c) 2012 by Infinity Interactive, Inc.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

Something went wrong with that request. Please try again.