Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
102 additions
and
1 deletion.
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
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,30 @@ | ||
package MetaCPAN::Document::Permissions; | ||
|
||
use strict; | ||
use warnings; | ||
|
||
use Moose; | ||
use ElasticSearchX::Model::Document; | ||
use MetaCPAN::Util; | ||
use MooseX::StrictConstructor; | ||
|
||
has name => ( | ||
is => 'ro', | ||
isa => 'Str', | ||
required => 1, | ||
); | ||
|
||
has owner => ( | ||
is => 'ro', | ||
isa => 'Str', | ||
required => 0, | ||
); | ||
|
||
has co_maintainers => ( | ||
is => 'ro', | ||
isa => 'ArrayRef', | ||
required => 0, | ||
); | ||
|
||
__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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -81,5 +81,5 @@ sub map_perlmongers { | |
|
||
} | ||
|
||
__PACKAGE__->meta->make_immutable; | ||
__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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package MetaCPAN::Script::Permissions; | ||
|
||
use strict; | ||
use warnings; | ||
|
||
use Moose; | ||
with 'MooseX::Getopt', 'MetaCPAN::Role::Common'; | ||
|
||
use Log::Contextual qw( :log ); | ||
use PAUSE::Permissions; | ||
|
||
#use MetaCPAN::Document::Permissions; | ||
|
||
=head1 SYNOPSIS | ||
Loads 06perms info into db. Does not require the presence of a local | ||
CPAN/minicpan. | ||
=cut | ||
|
||
has author_fh => ( | ||
is => 'rw', | ||
traits => ['NoGetopt'], | ||
lazy => 1, | ||
default => sub { shift->cpan . '/authors/00whois.xml' }, | ||
); | ||
|
||
sub run { | ||
my $self = shift; | ||
$self->index_permissions; | ||
$self->index->refresh; | ||
} | ||
|
||
sub index_permissions { | ||
my $self = shift; | ||
|
||
my $pp = PAUSE::Permissions->new; | ||
my $type = $self->index->type('permissions'); | ||
my $bulk = $self->model->bulk( size => 100 ); | ||
|
||
my $iterator = $pp->module_iterator(); | ||
while ( my $mp = $iterator->next_module ) { | ||
my $put = { name => $mp->name }; | ||
$put->{owner} = $mp->owner if $mp->owner; | ||
$put->{co_maintainers} = $mp->co_maintainers if $mp->co_maintainers; | ||
$bulk->put( $type->new_document($put) ); | ||
} | ||
|
||
$self->index->refresh; | ||
log_info {"done"}; | ||
} | ||
|
||
#__PACKAGE__->meta->make_immutable; | ||
1; | ||
|
||
=pod | ||
=head1 SYNOPSIS | ||
Parse out CPAN author permissions. | ||
my $perms = MetaCPAN::Script::Permissions->new; | ||
my $result = $perms->index_permissions; | ||
=head2 index_authors | ||
Adds/updates all ownership and maintenance permissions in the CPAN index to | ||
ElasticSearch. | ||
=cut |