Skip to content
This repository
tag: 1.1005
Fetching contributors…

Cannot retrieve contributors at this time

file 30 lines (22 sloc) 0.936 kb
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
name 'cpanidx';
description 'query CPAN IDX rather than scraping search.cpan.org';
author 'Tatsuhiko Miyagawa';

api_version 0.1;

# This is a proof-of-concept plugin:
# DO NOT USE THIS PLUGIN - the server hardcoded here is not frequently updated

hook search_module => sub {
    my $args = shift;

    return unless $args->{module} =~ /^[A-Za-z0-9_:]+$/;

    push @{$args->{uris}}, sub {
        require YAML;
        $args->{app}->chat("Querying CPANIDX for $args->{module}\n");

        my $yaml = $args->{app}->get("http://cpanidx.bingosnet.co.uk/cpandb/yaml/mod/$args->{module}");
        my $meta = (YAML::Load($yaml))[0];

        if (my $d = $meta->[0]) {
            $args->{app}->chat("Got a response from CPANIDX => $d->{dist_file}\n");
            return $args->{app}->cpan_uri($d->{dist_file});
        }

        $args->{app}->chat("! Finding $args->{module} on cpanidx failed.\n");
        return;
    };
};
Something went wrong with that request. Please try again.