Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tag: 1.0010
Fetching contributors…

Cannot retrieve contributors at this time

47 lines (37 sloc) 1.353 kb
name 'minicpan';
description 'fallback to local minicpan when a dist is not found';
author 'Tatsuhiko Miyagawa';
api_version 0.1;
my $minicpan_rc = File::Spec->catfile($ENV{HOME}, ".minicpanrc");
my $minicpan_home = find_home($minicpan_rc) || File::Spec->catfile($ENV{HOME}, "minicpan");
hook search_module => 100, sub {
my $args = shift;
my $pkgs = File::Spec->catfile($minicpan_home, "modules", "02packages.details.txt.gz");
unless (-e $pkgs) {
$args->{app}->diag("! $pkgs not found. Configure $minicpan_rc correctly. mnicpan plugin is disabled.\n");
return;
}
push @{$args->{uris}}, sub {
require IO::Zlib;
my $fh = IO::Zlib->new($pkgs, 'rb') or return;
$args->{app}->chat("Scanning $pkgs to find $args->{module}...\n");
while (<$fh>) {
my($module, $ver, $dist) = split /\s+/, $_;
if ($module eq $args->{module}) {
$args->{app}->chat("Found $module on minicpan index: $dist\n");
return "file://" . File::Spec->catfile($minicpan_home, "authors", "id", $dist);
}
}
return;
};
return;
};
sub find_home {
my $rc = shift;
return unless -e $rc;
open my $fh, "<$rc" or return;
while (<$fh>) {
/^local:\s+(.*?)\s*$/ and return $1;
}
return;
}
Jump to Line
Something went wrong with that request. Please try again.