Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #624 from metacpan/oalders/06perms-tiny
Adds indexing for 06perms.txt
- Loading branch information
Showing
18 changed files
with
338 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,24 @@ | ||
# carton/local::lib | ||
/local/ | ||
|
||
.DS_Store | ||
*.sw* | ||
*.kpf | ||
# coverage | ||
# generated by Makefile.PL (for instance when doing `cpanm --installdeps .`) | ||
# tidyall | ||
*.komodoproject | ||
*.kpf | ||
*.sqlite* | ||
/var | ||
/t/var/tmp/ | ||
/t/var/darkpan/ | ||
/t/var/log/ | ||
/etc/metacpan_local.pl | ||
metacpan_server_local.conf | ||
|
||
# generated by Makefile.PL (for instance when doing `cpanm --installdeps .`) | ||
*.sw* | ||
.DS_Store | ||
.tidyall.d | ||
/MYMETA.* | ||
/Makefile | ||
/Makefile.old | ||
/MYMETA.* | ||
/pm_to_blib | ||
/blib | ||
|
||
# tidyall | ||
.tidyall.d | ||
perltidy.LOG | ||
|
||
# coverage | ||
/etc/metacpan_local.pl | ||
/local/ | ||
/pm_to_blib | ||
/t/var/darkpan/ | ||
/t/var/log/ | ||
/t/var/tmp/ | ||
/var | ||
cover_db/ | ||
metacpan_server_local.conf | ||
perltidy.LOG |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package MetaCPAN::Document::Permission; | ||
|
||
use MetaCPAN::Moose; | ||
|
||
use ElasticSearchX::Model::Document; | ||
use MetaCPAN::Types qw( ArrayRef Str ); | ||
|
||
has module_name => ( | ||
is => 'ro', | ||
isa => Str, | ||
required => 1, | ||
); | ||
|
||
has owner => ( | ||
is => 'ro', | ||
isa => Str, | ||
); | ||
|
||
has co_maintainers => ( | ||
is => 'ro', | ||
isa => ArrayRef, | ||
); | ||
|
||
__PACKAGE__->meta->make_immutable; | ||
1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package MetaCPAN::Script::Mapping::CPAN::Permission; | ||
|
||
use strict; | ||
use warnings; | ||
|
||
sub mapping { | ||
'{ | ||
"dynamic" : false, | ||
"properties" : { | ||
"module_name" : { | ||
"ignore_above" : 2048, | ||
"index" : "not_analyzed", | ||
"type" : "string" | ||
}, | ||
"owner" : { | ||
"ignore_above" : 2048, | ||
"index" : "not_analyzed", | ||
"type" : "string" | ||
}, | ||
"co_maintainers" : { | ||
"ignore_above" : 2048, | ||
"index" : "not_analyzed", | ||
"type" : "string" | ||
} | ||
} | ||
}'; | ||
} | ||
|
||
1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
package MetaCPAN::Script::Permission; | ||
|
||
use Moose; | ||
|
||
use Log::Contextual qw( :log ); | ||
use MetaCPAN::Document::Permission (); | ||
use PAUSE::Permissions (); | ||
|
||
with 'MooseX::Getopt', 'MetaCPAN::Role::Script'; | ||
|
||
=head1 SYNOPSIS | ||
Loads 06perms info into db. Does not require the presence of a local | ||
CPAN/minicpan. | ||
=cut | ||
|
||
sub run { | ||
my $self = shift; | ||
$self->index_permissions; | ||
$self->index->refresh; | ||
} | ||
|
||
sub index_permissions { | ||
my $self = shift; | ||
|
||
my $file_path | ||
= $self->cpan->subdir('modules')->file('06perms.txt')->absolute; | ||
my $pp = PAUSE::Permissions->new( path => $file_path ); | ||
|
||
my $bulk_helper = $self->es->bulk_helper( | ||
index => $self->index->name, | ||
type => 'permission', | ||
); | ||
|
||
my $iterator = $pp->module_iterator; | ||
while ( my $perms = $iterator->next_module ) { | ||
|
||
# This method does a "return sort @foo", so it can't be called in the | ||
# ternary since it always returns false in that context. | ||
# https://github.com/neilb/PAUSE-Permissions/pull/16 | ||
|
||
my @co_maints = $perms->co_maintainers; | ||
my $doc = { | ||
@co_maints | ||
? ( co_maintainers => \@co_maints ) | ||
: (), | ||
module_name => $perms->name, | ||
owner => $perms->owner, | ||
}; | ||
|
||
$bulk_helper->update( | ||
{ | ||
id => $perms->name, | ||
doc => $doc, | ||
doc_as_upsert => 1, | ||
} | ||
); | ||
} | ||
|
||
$bulk_helper->flush; | ||
log_info {'finished indexing 06perms'}; | ||
} | ||
|
||
__PACKAGE__->meta->make_immutable; | ||
1; | ||
|
||
=pod | ||
=head1 SYNOPSIS | ||
Parse out CPAN author permissions. | ||
my $perms = MetaCPAN::Script::Permission->new; | ||
my $result = $perms->index_permissions; | ||
=head2 index_authors | ||
Adds/updates all ownership and maintenance permissions in the CPAN index to | ||
Elasticsearch. | ||
=cut |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package MetaCPAN::Server::Controller::Permission; | ||
|
||
use Moose; | ||
use namespace::autoclean; | ||
|
||
BEGIN { extends 'MetaCPAN::Server::Controller' } | ||
|
||
with 'MetaCPAN::Server::Role::JSONP'; | ||
|
||
__PACKAGE__->meta->make_immutable; | ||
1; |
Oops, something went wrong.