Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
controller/release: correct categories logic
code originally migrated from template. attempt to cut a corner
was buggy.
this makes it a bit more accurate, but this code still need
some love.
  • Loading branch information
mickeyn committed Aug 31, 2016
1 parent 8517528 commit 09e2895
Showing 1 changed file with 35 additions and 27 deletions.
62 changes: 35 additions & 27 deletions lib/MetaCPAN/Web/Controller/Release.pm
Expand Up @@ -176,35 +176,42 @@ sub _files_to_categories {
};

for my $f ( @{$files} ) {
if ( length $f->{module} ) {
push @{ $ret->{modules} }, $f if $f->{documentation};
my %info = (
status => $f->{status},
path => $f->{path},
release => $release->{name},
author => $release->{author},
);
for my $m (
is_arrayref( $f->{module} )
? @{ $f->{module} }
: $f->{module}
)
{
$info{package} = $m->{name};
if ( $f->{documentation} ) {
if ( $m->{name} ne $f->{documentation}
and $m->{indexed}
and $m->{authorized} )
{
push @{ $ret->{provides} },
+{ %info, authorized => 1 };
}
}
else {
push @{ $ret->{provides} }, \%info;
}
my %info = (
status => $f->{status},
path => $f->{path},
release => $release->{name},
author => $release->{author},
);

my @modules
= is_arrayref( $f->{module} )
? @{ $f->{module} }
: $f->{module};

if ( $f->{documentation} and @modules ) {
push @{ $ret->{modules} }, $f;
for my $m (@modules) {
push @{ $ret->{provides} },
map +{
%info,
package => $_->{name},
authorized => $_->{authorized}
},
grep {
$_->{name} ne $f->{documentation}
and $_->{indexed}
and $_->{authorized}
} @modules;
}
}
elsif (@modules) {
push @{ $ret->{provides} },
map +{
%info,
package => $_->{name},
authorized => $_->{authorized}
}, @modules;
}
elsif ( $f->{documentation} ) {
push @{ $ret->{documentation} }, $f;
}
Expand All @@ -219,3 +226,4 @@ sub _files_to_categories {
__PACKAGE__->meta->make_immutable;

1;

0 comments on commit 09e2895

Please sign in to comment.