File tree 3 files changed +109
-0
lines changed
3 files changed +109
-0
lines changed Original file line number Diff line number Diff line change
1
+ package MetaCPAN::Document::Permissions ;
2
+
3
+ use strict;
4
+ use warnings;
5
+
6
+ use Moose;
7
+ use ElasticSearchX::Model::Document;
8
+ use MetaCPAN::Util;
9
+ use MooseX::StrictConstructor;
10
+
11
+ has name => (
12
+ is => ' ro' ,
13
+ isa => ' Str' ,
14
+ required => 1,
15
+ );
16
+
17
+ has owner => (
18
+ is => ' ro' ,
19
+ isa => ' Str' ,
20
+ required => 0,
21
+ );
22
+
23
+ has co_maintainers => (
24
+ is => ' ro' ,
25
+ isa => ' ArrayRef' ,
26
+ required => 0,
27
+ );
28
+
29
+ __PACKAGE__ -> meta-> make_immutable;
30
+ 1;
Original file line number Diff line number Diff line change @@ -448,6 +448,21 @@ sub deploy_mapping {
448
448
1;
449
449
}
450
450
451
+ sub _prompt {
452
+ my ( $self , $msg ) = @_ ;
453
+
454
+ if (is_interactive) {
455
+ print colored( [' bold red' ], " *** Warning ***: $msg " ), " \n " ;
456
+ my $answer = prompt
457
+ ' Are you sure you want to do this (type "YES" to confirm) ? ' ;
458
+ if ( $answer ne ' YES' ) {
459
+ print " bye.\n " ;
460
+ exit 0;
461
+ }
462
+ print " alright then...\n " ;
463
+ }
464
+ }
465
+
451
466
__PACKAGE__ -> meta-> make_immutable;
452
467
1;
453
468
Original file line number Diff line number Diff line change
1
+ package MetaCPAN::Script::Permissions ;
2
+
3
+ use strict;
4
+ use warnings;
5
+
6
+ use Moose;
7
+ with ' MooseX::Getopt' , ' MetaCPAN::Role::Common' ;
8
+
9
+ use Log::Contextual qw( :log ) ;
10
+ use PAUSE::Permissions;
11
+
12
+ # use MetaCPAN::Document::Permissions;
13
+
14
+ =head1 SYNOPSIS
15
+
16
+ Loads 06perms info into db. Does not require the presence of a local
17
+ CPAN/minicpan.
18
+
19
+ =cut
20
+
21
+ sub run {
22
+ my $self = shift ;
23
+ $self -> index_permissions;
24
+ $self -> index -> refresh;
25
+ }
26
+
27
+ sub index_permissions {
28
+ my $self = shift ;
29
+
30
+ my $file_path = $self -> cpan . ' /modules/06perms.txt' ;
31
+ my $pp = PAUSE::Permissions-> new( path => $file_path );
32
+ my $type = $self -> index -> type(' permissions' );
33
+ my $bulk = $self -> model-> bulk( size => 100 );
34
+
35
+ my $iterator = $pp -> module_iterator();
36
+ while ( my $mp = $iterator -> next_module ) {
37
+ my $put = { name => $mp -> name };
38
+ $put -> {owner } = $mp -> owner if $mp -> owner;
39
+ $put -> {co_maintainers } = $mp -> co_maintainers if $mp -> co_maintainers;
40
+ $bulk -> put( $type -> new_document($put ) );
41
+ }
42
+
43
+ $self -> index -> refresh;
44
+ log_info {' done' };
45
+ }
46
+
47
+ # __PACKAGE__->meta->make_immutable;
48
+ 1;
49
+
50
+ =pod
51
+
52
+ =head1 SYNOPSIS
53
+
54
+ Parse out CPAN author permissions.
55
+
56
+ my $perms = MetaCPAN::Script::Permissions->new;
57
+ my $result = $perms->index_permissions;
58
+
59
+ =head2 index_authors
60
+
61
+ Adds/updates all ownership and maintenance permissions in the CPAN index to
62
+ ElasticSearch.
63
+
64
+ =cut
You can’t perform that action at this time.
0 commit comments