blib/lib/FreePAN/IndexPages.pm

filter: Statementstmt 88.8% 16 / 18 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod n/a totaltotal 91.6% 22 / 24 CC 1 SCAR 0.5
CC
1
Cov
89%
BEGIN
1.3
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
↑ Summary
1 package FreePAN::IndexPages;
2 1 ▶use FreePAN::Plugin -Base;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use mixin 'FreePAN::Installer';
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use IO::All;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 0 ▶use SVK;
Subroutine BEGIN: called CC=1 SCAR=2.6
6 use SVK::XD;
7 our $VERSION = '0.02';
8  
9 const class_id => 'indexpages';
10 const config_file => 'config/indexpages.yaml';
11  
12 # module, repository, mirror
13  
14 sub register {
15 my $reg = shift;
16 $reg->add(command => 'create_module_index',
17 description => 'Create Module index page');
18 $reg->add(command => 'create_repository_index',
19 description => 'Create Repository index page');
20 }
21  
22 sub handle_create_repository_index {
23 my @repos = map { $_->filename } io($self->hub->config->repos_base)->all_dirs;
24 my $output = $self->hub->template->process('repositories.html',repos => \@repos);
25 $output > io->catfile($self->hub->config->document_root,"repositories.html")->assert;
26 }
27  
28 sub handle_create_module_index {
29 die("You don't have repos_base directory\n")
30 unless -d $self->hub->config->repos_base;
31 my %repos = sub {
32 map {
33 $_->filename , $_->name
34 } io($self->hub->config->repos_base)->all_dirs;
35 }->();
36 my $output;
37 my $xd = SVK::XD->new(depotmap => \%repos);
38 my $svk = SVK->new(xd => $xd, output => \$output);
39 my %author_of;
40 for my $author (keys %repos) {
41 $svk->ls("/$author/");
42 $author_of{$_} = $author for map {s{/$}{};$_} grep !/^\s*$/,split/\n+/,$output;
43 }
44 $output = $self->hub->template->process('modules.html',
45 modules => \%author_of,
46 hub => $self->hub);
47 $output > io->catfile($self->hub->config->document_root,"modules.html")->assert
48 }
49  
50 __DATA__
↑ Summary