CPAN-Index-API

 view release on metacpan or  search on metacpan

lib/CPAN/Index/API/File/ModList.pm  view on Meta::CPAN

package CPAN::Index::API::File::ModList;

our $VERSION = '0.008';

use strict;
use warnings;
use URI;
use Carp        qw(carp croak);
use Path::Class qw(file);
use namespace::autoclean;
use Moose;

with qw(
    CPAN::Index::API::Role::Writable
    CPAN::Index::API::Role::Readable
    CPAN::Index::API::Role::Clonable
    CPAN::Index::API::Role::HavingFilename
    CPAN::Index::API::Role::HavingGeneratedBy
);

has description => (
    is       => 'ro',
    isa      => 'Str',
    required => 1,
    default  => 'Package names found in directory $CPAN/authors/id/',
);

has modules => (
    is      => 'bare',
    isa     => 'ArrayRef',
    default => sub { [] },
    traits  => ['Array'],
    handles => {
        module_count => 'count',
        modules      => 'elements',
    },
);

# lots of code from Parse::CPAN::Modlist here
sub parse {
    my ( $self, $content ) = @_;

    ### get rid of the comments and the code ###
    ### need a smarter parser, some people have this in their dslip info:
    # [
    # 'Statistics::LTU',
    # 'R',
    # 'd',
    # 'p',
    # 'O',
    # '?',
    # 'Implements Linear Threshold Units',
    # ...skipping...
    # "\x{c4}dd \x{fc}ml\x{e4}\x{fc}ts t\x{f6} \x{eb}v\x{eb}r\x{ff}th\x{ef}ng!",
    # 'BENNIE',
    # '11'
    # ],
    ### also, older versions say:
    ### $cols = [....]
    ### and newer versions say:
    ### $CPANPLUS::Modulelist::cols = [...]
    $content =~ s/.+}\s+(\$(?:CPAN::Modulelist::)?cols)/$1/s;

    ### split '$cols' and '$data' into 2 variables ###
    my ($ds_one, $ds_two) = split ';', $content, 2;

    ### eval them into existance ###
    my ($columns, $data, @modules, %args );

    $columns = eval $ds_one;



( run in 0.868 second using v1.01-cache-2.11-cpan-39bf76dae61 )