-
Notifications
You must be signed in to change notification settings - Fork 0
/
auto_generate.pl
88 lines (76 loc) · 2.28 KB
/
auto_generate.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
#!/usr/bin/perl
use strict;
use warnings;
use CPANDB;
use YAML::LoadURI;
use Data::Dumper;
# set feature dists
my @feature_dists = qw/
Padre-Plugin-Parrot
Padre-Plugin-Perl6
Padre-Plugin-PSI
Padre-Plugin-SpellCheck
Padre-Plugin-SVN
Padre-Plugin-SVK
Padre-Plugin-Git
Padre-Plugin-Catalyst
Padre-Plugin-Mojolicious
Padre-Plugin-REPL
/; # REPL, FAIL on Win32
my @requires_dists;
my $padre_dist = CPANDB::Distribution->select(
'where distribution=?',
'Padre'
);
# get all used_by Padre, http://cpants.perl.org/dist/used_by/Padre
my $padre_prereq = CPANDB::Requires->select(
'where module=?',
'Padre'
);
my %seen;
foreach my $prereq ( @$padre_prereq ) {
my $dist_name = $prereq->distribution;
if ( $dist_name =~ /^Padre-Plugin-/ or $dist_name =~ /^Acme-Padre-/ ) {
# no duplication
next if $seen{$dist_name};
$seen{$dist_name} = 1;
unless ( grep { $_ eq $dist_name } @feature_dists ) {
push @requires_dists, $dist_name;
}
}
}
my %meta_cache;
open(my $fh, '>', 'Makefile.txt');
print $fh "requires 'Padre' => '" . $padre_dist->[0]->version . "';\n";
foreach my $dist ( sort @requires_dists ) {
print $dist . "\n";
my $meta = LoadURI("http://cpansearch.perl.org/dist/$dist/META.yml");
$meta_cache{ $dist } = $meta;
my $module = $dist; $module =~ s/\-/\:\:/g;
print $fh "requires '$module' => '$meta->{version}';\n";
}
print $fh "\n";
foreach my $dist ( sort @feature_dists ) {
print $dist . "\n";
my $meta; # Padre-Plugin-Git don't have a META, BAD
if ( $dist eq 'Padre-Plugin-Git' ) {
$meta = {
abstract => 'Simple Git interface for Padre',
version => '0.01',
};
} else {
$meta = LoadURI("http://cpansearch.perl.org/dist/$dist/META.yml");
}
$meta_cache{ $dist } = $meta;
my $module = $dist; $module =~ s/\-/\:\:/g;
print $fh "feature '$meta->{abstract}',\n\t-default => 0,\n\t'$module' => '$meta->{version}';\n";
}
close($fh);
open(my $fh2, '>', 'Plugins.txt');
foreach my $dist ( sort (@requires_dists, @feature_dists) ) {
my $meta = $meta_cache{ $dist };
my $module = $dist; $module =~ s/\-/\:\:/g;
print $fh2 "=head2 L<$module>\n\n$meta->{abstract}\n\nSee L<$module>\n\n";
}
close($fh2);
1;