Skip to content

Commit

Permalink
Make Todo controller lookup authors, not full URLs
Browse files Browse the repository at this point in the history
Required guessing author when it's not specified, and gave us an
excuse to store a Problem when an author's not set.

This also fixes a bug with _builder being cleared if something's
stored there too early: we don't need to declare it anywhere in
particular, autoviv does the work for us.
  • Loading branch information
Tadeusz “tadzik” Sośnierz committed May 14, 2017
1 parent 1e55111 commit 02ab412
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/ModulesPerl6/Controller/Todo.pm
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ sub index {
sub author {
my $self = shift;
my $author = $self->stash('author');
my $dists = $self->dists->find({ url => { -like => "%$author%" } });
my $dists = $self->dists->find({ author_id => { -like => "%$author%" } });

$self->respond_to(
html => { dists => $dists, template => 'todo/index' },
Expand Down
4 changes: 4 additions & 0 deletions lib/ModulesPerl6/DbBuilder/Dist/PostProcessor/METAChecker.pm
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ sub process {
push @problems, problem("dist has no MANIFEST file", 3);
}

if ($dist->{_builder}{no_author_set}) {
push @problems, problem("dist has no author(s) specified", 3);
}

length $dist->{ $_ } or push @problems, problem("required `$_` field is missing", 5)
for qw/perl name version description provides/;

Expand Down
10 changes: 7 additions & 3 deletions lib/ModulesPerl6/DbBuilder/Dist/Source.pm
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,6 @@ sub _fill_missing {

%{ $old_dist_data || {} },
%$dist,

_builder => {}, # key used only during build process to store data
);

return $dist;
Expand Down Expand Up @@ -177,8 +175,14 @@ sub _save_logo {

sub _get_author {
my ( $self, $dist ) = @_;
my $author = $dist->{author} // $dist->{authors} // 'N/A';
my $author = $dist->{author} // $dist->{authors};
$author = $author->[0] if ref $author eq 'ARRAY';
unless ($author) {
# assume the github user/org name as the author,
# but note the lack of proper authorship as a problem
($author) = $dist->{url} =~ m{github\.com/([^/]+)/};
$dist->{_builder}{no_author_set} = 1;
}

return $author;
}
Expand Down

0 comments on commit 02ab412

Please sign in to comment.