package Alien::Build::Plugin::Decode::DirListing;
use strict;
use warnings;
use 5.008004;
use Alien::Build::Plugin;
use File::Basename ();
# ABSTRACT: Plugin to extract links from a directory listing
our $VERSION = '2.84'; # VERSION
sub init
{
my($self, $meta) = @_;
$meta->add_requires('share' => 'File::Listing' => 0);
$meta->add_requires('share' => 'URI' => 0);
$meta->register_hook( decode => sub {
my(undef, $res) = @_;
die "do not know how to decode @{[ $res->{type} ]}"
unless $res->{type} eq 'dir_listing';
my $base = URI->new($res->{base});
return {
type => 'list',
list => [
map {
my($name) = @$_;
my $basename = $name;
$basename =~ s{/$}{};
my %h = (
filename => File::Basename::basename($basename),
url => URI->new_abs($name, $base)->as_string,
);
\%h;
} File::Listing::parse_dir($res->{content})
],
};
});
$self;
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
Alien::Build::Plugin::Decode::DirListing - Plugin to extract links from a directory listing
=head1 VERSION
version 2.84
=head1 SYNOPSIS
use alienfile;
plugin 'Decode::DirListing';
=head1 DESCRIPTION
Note: in most case you will want to use L