Module::Packaged::Generator - build list of modules packaged by a linux distribution


Module-Packaged-Generator documentation Contained in the Module-Packaged-Generator distribution.

Index


Code Index:

NAME

Top

Module::Packaged::Generator - build list of modules packaged by a linux distribution

VERSION

Top

version 1.111040

DESCRIPTION

Top

This module alows to fetch modules available as native Linux (or BSD) distribution packages, and wraps them in a sqlite database. This allows people to do analysis, draw CPANTS metrics from it or whatever.

Of course, running the utility shipped in this dist will only create the database for the current distribution. But that's not our job to do crazy manipulation with this data, we just provide the data :-)

METHODS

Top

all_drivers

    my @drivers = Module::Packaged::Generator->all_drivers();

Return a list of all available drivers supporting a distribution. The list is a list of module names (strings) such as Module::Packaged::Generator::Mandriva.

find_driver

    my $driver = Module::Packaged::Generator->find_driver;

Return a driver that can be used on the current machine, or undef if no suitable driver was found.

create_db

    my $dbh = Module::Packaged::Generator->create_db($file);

Creates a sqlite database with the correct schema. Remove the previous $file if it exists. Return the handler on the opened database.

SEE ALSO

Top

You can find more information on this module at:

* Search CPAN

http://search.cpan.org/dist/Module-Packaged-Generator

* See open / report bugs

http://rt.cpan.org/NoAuth/Bugs.html?Dist=Module-Packaged-Generator

* Git repository

http://github.com/jquelin/module-packaged-generator

* AnnoCPAN: Annotated CPAN documentation

http://annocpan.org/dist/Module-Packaged-Generator

* CPAN Ratings

http://cpanratings.perl.org/d/Module-Packaged-Generator

AUTHOR

Top

Jerome Quelin

COPYRIGHT AND LICENSE

Top


Module-Packaged-Generator documentation Contained in the Module-Packaged-Generator distribution.

#
# This file is part of Module-Packaged-Generator
#
# This software is copyright (c) 2010 by Jerome Quelin.
#
# This is free software; you can redistribute it and/or modify it under
# the same terms as the Perl 5 programming language system itself.
#
use 5.008;
use strict;
use warnings;

package Module::Packaged::Generator;
BEGIN {
  $Module::Packaged::Generator::VERSION = '1.111040';
}
# ABSTRACT: build list of modules packaged by a linux distribution

use DBI;
use List::Util qw{ first };
use Module::Pluggable
    require     => 1,
    sub_name    => 'dists',
    search_path => __PACKAGE__.'::Distribution';


# -- public methods


sub all_drivers { return $_[0]->dists; }



sub find_driver {
    my $self = shift;
    return first { $_->match } $self->dists;
}



sub create_db {
    my ($self, $file) = @_;

    unlink($file) if -f $file;
    my $dbh = DBI->connect("dbi:SQLite:dbname=$file", '', '');
    $dbh->do("
                CREATE TABLE module (
                        module      TEXT NOT NULL,
                        version     TEXT,
                        dist        TEXT,
                        pkgname     TEXT NOT NULL
                );
        ");
    return $dbh;
}


1;



__END__