Regather/Plugin/list.pm untested

filter: Statementstmt 0.0% 0 / 37 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 51 CC 2 SCAR 11.0
CC
2
Cov
0%
run
6.0
new
2.0
BEGIN
2.0
CRAP 3.0
1 # -*- mode: cperl; eval: (follow-mode) -*-
2 #
3  
4 package App::Regather::Plugin::list;
5  
6 =head1 NAME
7  
8 list - prints all available plugins with short descriptions
9  
10 =cut
11  
12 use strict;
13 use warnings;
14 use diagnostics;
15  
16 use Carp;
17 use Pod::Usage;
18  
19 =head1 METHODS
20  
21 =head2 new
22  
23 Creates new object .
24  
25 =cut
26  
27 sub new {
28 my $class = shift;
29 my @classpath = split(/::/, $class);
30 pop @classpath;
31 bless { classpath => \@classpath }, $class
32 }
33  
34 =head2 run
35  
36 Lists available commands on the stdout. For each command an attempt is
37 made to load it, to ensure the module is usable. If so, its description
38 is extracted from the NAME section of its pod.
39  
40 =cut
41  
42 sub run {
43 my $self = shift;
44 print "\nPlugins available:\n\n";
45 my %names = App::Regather::Plugin->names;
46 my ($s, @res);
47 while ( my ($k, $v) = each %names ) {
48  
49 open(my $fh, '>', \$s);
50 pod2usage(-input => $v,
51 -output => $fh,
52 -verbose => 99,
53 -sections => ['NAME'],
54 -exitstatus => 'NOEXIT');
55 close $fh;
56 my (undef,$descr) = split("\n", $s||'');
57 $descr = $k unless ($descr);
58 my ($l,$r) = split / - /, $descr;
59 push @res, sprintf("%-15s: %s, App::Regather::Plugin::$k(3)\n", $l, $r);
60 }
61  
62 print $_ foreach (sort @res);
63 print "\n";
64 }
65  
66 ######################################################################
67  
68 1;
69