forked from miyagawa/cpanminus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathp5i
33 lines (26 loc) · 829 Bytes
/
p5i
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
name 'p5i';
description 'Support .p5i file';
author 'Tatsuhiko Miyagawa';
api_version 0.1;
hook locate_dist => sub {
my $args = shift;
if ($args->{module} =~ m!\.p5i$!) {
my $content;
if (-e $args->{module}) {
$content = do { open my $fh, "<$args->{module}"; join '', <$fh> };
} elsif ($args->{module} =~ /^(https?|ftp|file):/) {
$args->{app}->chat("Fetching remote p5i $args->{module}\n");
$content = $args->{app}->get($args->{module});
}
return unless $content;
my @lines = split /\r?\n/, $content;
my @dists;
for (@lines) {
s/#.*$//;
next unless /\S/;
next if /^Module::Plan::Lite/;
push @dists, $_;
}
return sub { \@dists };
}
};