Skip to content
This repository has been archived by the owner on Nov 19, 2021. It is now read-only.

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
jbarrett committed Mar 24, 2015
2 parents 0768038 + 006344d commit 75fdfe7
Show file tree
Hide file tree
Showing 22 changed files with 64 additions and 498 deletions.
125 changes: 0 additions & 125 deletions lib/DDGC/DB/Result/DuckPAN/Goodie.pm

This file was deleted.

62 changes: 0 additions & 62 deletions lib/DDGC/DB/Result/DuckPAN/Module.pm

This file was deleted.

11 changes: 0 additions & 11 deletions lib/DDGC/DB/Result/DuckPAN/Release.pm
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ use namespace::autoclean;

table 'duckpan_release';

sub u { [ 'Duckpan', 'release', $_[0]->name, $_[0]->version ] }

column id => {
data_type => 'bigint',
is_auto_increment => 1,
Expand Down Expand Up @@ -66,16 +64,7 @@ belongs_to 'user', 'DDGC::DB::Result::User', 'users_id', {
on_update => 'cascade',
};

has_many 'duckpan_modules', 'DDGC::DB::Result::DuckPAN::Module', 'duckpan_release_id', {
cascade_delete => 1,
};

unique_constraint [qw/ name version /];

sub primary_module {
my $self = shift;
$self->duckpan_modules->search({name => $self->name})->first;
}

no Moose;
__PACKAGE__->meta->make_immutable;
66 changes: 0 additions & 66 deletions lib/DDGC/DuckPAN.pm
Original file line number Diff line number Diff line change
Expand Up @@ -102,72 +102,6 @@ sub add_user_distribution {
$self->log("ERROR",'Could not generate documentation for',$dist_data->name,$dist_data->version,$@);
return "Failed to parse your POD. Perhaps you should test it first?";
}
eval {
$self->ddgc->db->txn_do(sub {
my $latest_dir = dir($self->ddgc->config->duckpandir,'latest',$dist_data->name);
$latest_dir->mkpath unless -d $latest_dir;
{
local $CWD = $latest_dir;
my $next = Archive::Tar->iter($distribution_filename, 1);
while (my $f = $next->()) {
my @path_parts = split('/',$f->full_path);
shift @path_parts;
$f->extract(join('/',@path_parts));
}
}
my %modules;
if (-d $latest_dir->subdir('lib')) {
my $lib = $latest_dir->subdir('lib');
my ( @pods, @pms );
$lib->traverse(sub {
my $b = $_[0]->basename;
if ($b =~ qr!\.pm$!) {
push @pms, $_[0];
} elsif ($b =~ qr!\.pod$!) {
push @pods, $_[0];
}
return $_[1]->();
});
for my $file (@pods) {
my @parts = $file->relative($lib)->components;
my $filename = pop @parts;
$filename =~ s!\.pod$!!;
my $module = join('::',@parts,$filename);
$modules{$module} = {} unless defined $modules{$module};
$modules{$module}->{filename_pod} = $file->relative($latest_dir)->stringify;
}
for my $file (@pms) {
my @parts = $file->relative($lib)->components;
shift @parts if $parts[0] eq '.';
my $filename = pop @parts;
$filename =~ s!\.pm$!!;
my $module = join('::',@parts,$filename);
$modules{$module} = {} unless defined $modules{$module};
$modules{$module}->{filename} = $file->relative($latest_dir)->stringify;
}
}
my %meta;
if (-f $latest_dir->file('duckpan.json')) {
%meta = %{decode_json(scalar $latest_dir->file('duckpan.json')->slurp)};
}
$release->duckpan_meta(\%meta);
for my $module (keys %modules) {
$self->ddgc->db->resultset('DuckPAN::Module')->update_or_create({
name => $module,
duckpan_release_id => $release->id,
defined $meta{$module} ? ( duckpan_meta => $meta{$module} ) : (),
%{$modules{$module}},
},{
key => 'duckpan_module_name',
});
}
});
};
if ($@) {
$release->duckpan_meta({ error => $@ });
$self->log(ERROR => $dist_data->name, $dist_data->version, $@);
return 'Error! '.$@;
}
return $release // "This... this is not possible.";
}

Expand Down
57 changes: 0 additions & 57 deletions lib/DDGC/Web/Controller/Duckpan.pm
Original file line number Diff line number Diff line change
Expand Up @@ -16,63 +16,6 @@ sub base :Chained('/base') :PathPart('duckpan') :CaptureArgs(0) {
my ( $self, $c ) = @_;
$c->stash->{title} = 'DuckPAN';
$c->stash->{duckpan} = $c->d->duckpan;
$c->add_bc('DuckPAN', $c->chained_uri('Duckpan','index'));
}

sub index :Chained('base') :PathPart('') :Args(0) {
my ( $self, $c ) = @_;
$c->bc_index;
$c->stash->{duckpan_releases} = $c->d->rs('DuckPAN::Release')->search_rs({
'me.current' => 1,
},{
prefetch => [qw( duckpan_modules )],
order_by => [{ -desc => 'me.created' },{ -asc => 'duckpan_modules.name' }],
});
}

sub release_base :Chained('base') :PathPart('release') :CaptureArgs(1) {
my ( $self, $c, $release_name ) = @_;
$c->stash->{release_name} = $release_name;
$c->add_bc($release_name, $c->chained_uri('Duckpan','release_index',$release_name));
}

sub release_index :Chained('release_base') :PathPart('') :Args(0) {
my ( $self, $c ) = @_;
my $latest = $c->d->rs('DuckPAN::Release')->search_rs({
'me.name' => $c->stash->{release_name},
current => 1,
},{
order_by => { -asc => 'duckpan_modules.name' },
prefetch => [qw( duckpan_modules )],
})->first;
if ($latest) {
$c->response->redirect($c->chained_uri('Duckpan','release',$c->stash->{release_name},$latest->version));
} else {
$c->response->redirect($c->chained_uri('Duckpan','index',{ release_not_found => 1 }));
}
return $c->detach;
}

sub release_all :Chained('release_base') :PathPart('all') :Args(0) {
my ( $self, $c ) = @_;
$c->add_bc('All versions');
$c->stash->{duckpan_releases} = $c->d->rs('DuckPAN::Release')->search_rs({
'me.name' => $c->stash->{release_name},
},{
prefetch => [qw( duckpan_modules )],
order_by => [{ -desc => 'me.created' },{ -asc => 'duckpan_modules.name' }],
});
}

sub release :Chained('release_base') :PathPart('v') :Args(1) {
my ( $self, $c, $version ) = @_;
$c->add_bc($version);
$c->stash->{duckpan_release} = $c->d->rs('DuckPAN::Release')->search_rs({
'me.name' => $c->stash->{release_name},
'me.version' => $version,
},{
prefetch => [qw( duckpan_modules )],
})->first;
}

sub logged_in :Chained('base') :PathPart('') :CaptureArgs(0) {
Expand Down
Loading

0 comments on commit 75fdfe7

Please sign in to comment.