CPAN::Mini::FromList - create a minimal CPAN mirror of modules you specify


CPAN-Mini-FromList documentation Contained in the CPAN-Mini-FromList distribution.

Index


Code Index:

NAME

Top

CPAN::Mini::FromList - create a minimal CPAN mirror of modules you specify

SYNOPSIS

Top

Unless you need to do something unusual, you probably should be looking at minicpan-fromlist.

    use CPAN::Mini::FromList;

    CPAN::Mini::FromList->update_mirror(%args);
    ...

METHODS

Top

update_mirror %args

Begins the process of creating a local CPAN mirror, but only downloads modules specified by the user. See the documentation in CPAN::Mini for more details on the arguments.

delete_02packages

Delete 02packages.details.txt.gz

generate_fake_02packages

Generate a fake 02packages.details.txt.gz containing only the packages listed.

AUTHOR

Top

Thomas Klausner, domm@cpan.org

based on CPAN::Mini::Phalanx100 by Steve Peters

BUGS

Top

Please report any bugs or feature requests to bug-cpan-mini-fromlist@rt.cpan.org, or through the web interface at http://rt.cpan.org. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SEE ALSO

Top

CPAN::Mini

ACKNOWLEDGEMENTS

Top

Thanks to...

Ricardo Signes - for writing CPAN::Mini, which does 99% of the work in this module

Steve Peters - for writing CPAN::Mini::Phalanx100, from which I copied most of this code

COPYRIGHT & LICENSE

Top


CPAN-Mini-FromList documentation Contained in the CPAN-Mini-FromList distribution.
package CPAN::Mini::FromList;

use warnings;
use strict;

use CPAN::Mini;
use Data::Dumper;
use File::Spec::Functions;
use base qw(CPAN::Mini);

our $VERSION = '0.02';

our %dists = ();

sub update_mirror {
    my $self = shift;
    my @args = @_;
    my %args=@args;
    
    foreach my $d (@{$args{list}}) {
        $dists{$d} = 1;        
    }

    CPAN::Mini->update_mirror(@args, 'module_filters', [\&_fromlist_filter]);
}

sub _fromlist_filter {
   my $module = shift;
   return 1 if ! $dists{$module};
   return 0;
}

sub delete_02packages {
    my ($class,$local)=@_;
    my $packages02=catfile($local,qw(modules 02packages.details.txt.gz));
    if (-e $packages02) {
        unlink ($packages02) || die "Cannot unlink $packages02: $!";
    }
}

sub generate_fake_02packages {
    my ($class,$local)=@_;
    eval {
        my $packages=catfile($local,qw(modules 02packages.details.txt));
        my @files=File::Find::Rule->file()->name('*.gz')->relative->in(
            catdir($local,qw(authors id)));    
        open(my $fh,'>',$packages) || die "Cannot write to $packages: $!";
        my $linecnt=@files;
        my $now=scalar localtime;
        print $fh <<"EOHEAD";
File:         02packages.details.txt
URL:          http://www.perl.com/CPAN/modules/02packages.details.txt
Description:  Fake 02packges generate by CPAN::Mini::FromList
Columns:      package name, version, path
Intended-For: Automated fetch routines, namespace documentation.
Written-By:   CPAN::Mini::FromList 
Line-Count:   $linecnt
Last-Updated: $now

EOHEAD
        foreach (@files) {
            print $fh "Fake                   undef    $_\n";
        }
        close $fh;
        $class->delete_02packages($local);
        system('gzip',$packages);
    };
    print $@ if $@;
}


q{  listening to:
        CPAN discussions at the Oslo QA Hackathon    
};

__END__