/
generatefile.pl
95 lines (73 loc) · 2.44 KB
/
generatefile.pl
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/usr/bin/perl
use strict; use warnings;
# run this like: perl examples/generatefile.pl > lib/Task/POE/All.pm
# we use CPANPLUS to search!
use CPANPLUS::Backend;
use CPANPLUS::Configure;
# silence CPANPLUS!
{
no warnings 'redefine';
sub Log::Message::Handlers::cp_msg { return };
sub Log::Message::Handlers::cp_error { return };
}
# Okay, get all the distributions that are POE :)
# init the backend ( and set some options )
my $conf = CPANPLUS::Configure->new;
$conf->set_conf( 'verbose' => 0 );
$conf->set_conf( 'no_update' => 1 );
# ARGH, CPANIDX doesn't work well with this kind of search...
if ( $conf->get_conf( 'source_engine' ) =~ /CPANIDX/ ) {
warn "Disabling CPANIDX for CPANPLUS";
$conf->set_conf( 'source_engine' => 'CPANPLUS::Internals::Source::Memory' );
}
# search for matching modules/packages
my $cb = CPANPLUS::Backend->new( $conf );
my @mods = $cb->search( 'type' => 'module', 'allow' => [ qr/^POEx?::/ ] );
# collate the data
my %seen;
foreach my $m ( sort @mods ) {
if ( exists $seen{ $m->package_name } ) {
# is the module name == package name?
my $pkg = $m->package_name; $pkg =~ s/-/::/g;
if ( $m->name eq $pkg ) {
$seen{ $m->package_name } = $m;
}
} else {
$seen{ $m->package_name } = $m;
}
}
# invert the sense of the hash to prepare for prereq
%seen = map { $_->module => $_->version } values %seen;
# Now, dump it!
my $string = <<'EOF';
package Task::POE::All;
# ABSTRACT: All of POE on CPAN
1;
=pod
=head1 SYNOPSIS
# apoc@box:~$ cpanp install Task::POE::All
=head1 DESCRIPTION
This task contains all distributions under the L<POE> namespace.
EOF
$string .= pkgroup( 'Servers', qr/^POE::Component::Server::/ );
$string .= pkgroup( 'Clients', qr/^POE::Component::Client::/ );
$string .= pkgroup( 'Generic Components', qr/^POE::Component::/ );
$string .= pkgroup( 'Data Parsers and Wheels', qr/^POE::(?:Filter|Wheel)::/ );
$string .= pkgroup( 'Event Loops', qr/^POE::Loop::/ );
$string .= pkgroup( 'Session Types', qr/^POE::Session::/ );
$string .= pkgroup( 'Debugging and Developing POE', qr/^POE::(?:API|Devel|Test|XS)::/ );
$string .= pkgroup( 'POE Extensions', qr/^POEx::/ );
$string .= pkgroup( 'Uncategorized', qr/.+/ );
$string .= "\n=cut\n";
# Write it out!
print $string;
exit;
sub pkgroup {
my( $header, $re ) = @_;
my $str = "\n=pkgroup $header\n\n";
foreach my $s ( grep { $_ =~ $re } sort keys %seen ) {
$str .= "=pkg $s $seen{$s}\n\n";
delete $seen{$s}; # so our final catch-all will work!
}
return $str;
}