Skip to content

Commit 5bee46b

Browse files
committed
tidy
1 parent a2bb17b commit 5bee46b

File tree

12 files changed

+69
-52
lines changed

12 files changed

+69
-52
lines changed

bin/author.pl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,14 @@
6161
# TODO: find a better way
6262
$mode eq 'test' and Log::Log4perl::init('log4perl_test.conf');
6363

64-
6564
# setup
66-
my $es = MetaCPAN::ES->new( index => "author", ( $mode ? ( mode => $mode ) : () ) );
65+
my $es = MetaCPAN::ES->new(
66+
index => "author",
67+
( $mode ? ( mode => $mode ) : () )
68+
);
6769

6870
log_info {'Reading 00whois'};
69-
my $authors_data = read_00whois( $whois_file );
71+
my $authors_data = read_00whois($whois_file);
7072

7173
if ($pauseid) {
7274
log_info {"Indexing 1 author"};

bin/backpan.pl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ ()
5555
(
5656
$undo
5757
or exists $cpan_file_map->{$author}{$archive}
58-
)
58+
)
5959
? 'cpan'
6060
: 'backpan',
6161
$release->{_id}

bin/first.pl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
$release
3939
? log_debug {
4040
"@{[ $release->name ]} by @{[ $release->author ]} was first"
41-
}
41+
}
4242
: log_warn {
4343
"no release found for distribution @{[$distribution->name]}"
4444
};

bin/latest.pl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ ( $bulk, $source, $status )
310310

311311
log_info {
312312
$status eq 'latest' ? 'Upgrading ' : 'Downgrading ',
313-
'release ', $release->{name}
313+
'release ', $release->{name}
314314
};
315315

316316
# Get all the files for the release.

bin/mapping.pl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@
2222

2323
if ( $cmd eq 'create' ) {
2424
$mapper->index_create($index);
25-
$mapper->index_add_mapping($index, $type);
25+
$mapper->index_add_mapping( $index, $type );
2626
}

bin/package.pl

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,15 @@
1919
"mode=s" => \$mode,
2020
"package_file=s" => \$package_file,
2121
);
22+
2223
# TODO: find a better way
2324
$mode eq 'test' and Log::Log4perl::init('log4perl_test.conf');
2425

2526
# setup
26-
my $es = MetaCPAN::ES->new( index => "package", ( $mode ? ( mode => $mode ) : () ) );
27+
my $es = MetaCPAN::ES->new(
28+
index => "package",
29+
( $mode ? ( mode => $mode ) : () )
30+
);
2731
my $bulk = $es->bulk();
2832

2933
my %seen;
@@ -33,7 +37,10 @@
3337

3438
# read the rest of the file line-by-line (too big to slurp)
3539

36-
my $fh_packages = read_02packages_fh( log_meta => 1, ( $package_file ? (file => $package_file) : () ) );
40+
my $fh_packages = read_02packages_fh(
41+
log_meta => 1,
42+
( $package_file ? ( file => $package_file ) : () )
43+
);
3744
while ( my $line = <$fh_packages> ) {
3845
next unless $line;
3946
chomp($line);

bin/permission.pl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,21 @@
1818
"mode=s" => \$mode,
1919

2020
);
21+
2122
# TODO: find a better way
2223
$mode eq 'test' and Log::Log4perl::init('log4perl_test.conf');
2324

2425
# setup
25-
my $es = MetaCPAN::ES->new( index => "permission", ( $mode ? ( mode => $mode ) : () ) );
26+
my $es = MetaCPAN::ES->new(
27+
index => "permission",
28+
( $mode ? ( mode => $mode ) : () )
29+
);
2630
my $bulk = $es->bulk();
2731

2832
my %seen;
2933
log_debug {"building permission data to add"};
3034

31-
my $iterator = read_06perms_iter( $perms_file );
35+
my $iterator = read_06perms_iter($perms_file);
3236
while ( my $perms = $iterator->next_module ) {
3337

3438
# This method does a "return sort @foo", so it can't be called in the

bin/release.pl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@
121121
$find = $find->mtime( ">" . ( time - $age * 3600 ) )
122122
if $age;
123123
push( @files,
124-
map { $_->{file} }
124+
map { $_->{file} }
125125
sort { $a->{mtime} <=> $b->{mtime} }
126126
map { +{ file => $_, mtime => File::stat::stat($_)->mtime } }
127127
$find->in($_) );

bin/tickets.pl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ ($tsv)
105105
source => _rt_dist_url( $row->{dist} ),
106106
active => $row->{active} + 0,
107107
closed => $row->{inactive} + 0,
108-
map { $_ => $row->{$_} + 0 }
108+
map { $_ => $row->{$_} + 0 }
109109
grep { not /^(dist|active|inactive)$/ }
110110
keys %$row,
111111
};

lib/MetaCPAN/ES.pm

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ sub new ( $class, %args ) {
1515
my $index = $args{index} // "cpan";
1616

1717
my $config = config;
18-
my $config_node =
19-
$node ? $node :
20-
$mode eq 'local' ? $config->{es_node} :
21-
$mode eq 'test' ? $config->{es_test_node} :
22-
$mode eq 'prod' ? $config->{es_production_node} :
23-
undef;
18+
my $config_node
19+
= $node ? $node
20+
: $mode eq 'local' ? $config->{es_node}
21+
: $mode eq 'test' ? $config->{es_test_node}
22+
: $mode eq 'prod' ? $config->{es_production_node}
23+
: undef;
2424
$config_node or die "Cannot create an ES instance without a node\n";
2525

2626
return bless {

lib/MetaCPAN/Mapper.pm

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,22 @@ use warnings;
55
use v5.36;
66

77
use Cpanel::JSON::XS qw< decode_json >;
8-
use Path::Tiny qw< path >;
8+
use Path::Tiny qw< path >;
99
use MetaCPAN::Logger qw< :log :dlog >;
1010
use Search::Elasticsearch;
1111
use MetaCPAN::Ingest qw< config home >;
1212

1313
sub new ( $class, %args ) {
14-
my $mode = $args{mode} // "local";
15-
my $node = $args{node};
14+
my $mode = $args{mode} // "local";
15+
my $node = $args{node};
1616

1717
my $config = config;
18-
my $config_node =
19-
$node ? $node :
20-
$mode eq 'local' ? $config->{es_node} :
21-
$mode eq 'test' ? $config->{es_test_node} :
22-
$mode eq 'prod' ? $config->{es_production_node} :
23-
undef;
18+
my $config_node
19+
= $node ? $node
20+
: $mode eq 'local' ? $config->{es_node}
21+
: $mode eq 'test' ? $config->{es_test_node}
22+
: $mode eq 'prod' ? $config->{es_production_node}
23+
: undef;
2424
$config_node or die "Cannot create an ES instance without a node\n";
2525

2626
return bless {
@@ -31,35 +31,35 @@ sub new ( $class, %args ) {
3131
}, $class;
3232
}
3333

34-
sub index_exists ($self, $index) {
34+
sub index_exists ( $self, $index ) {
3535
$self->{es}->indices->exists( index => $index );
3636
}
3737

38-
sub index_create ($self, $index) {
38+
sub index_create ( $self, $index ) {
3939
$self->{es}->indices->create( index => $index );
4040
}
4141

42-
sub index_delete ($self, $index, $skip_exists) {
42+
sub index_delete ( $self, $index, $skip_exists ) {
4343
return if $skip_exists and !$self->index_exists($index);
4444
$self->{es}->indices->delete( index => $index );
4545
}
4646

47-
sub index_put_mapping ($self, $index, $mapping) {
47+
sub index_put_mapping ( $self, $index, $mapping ) {
4848
$self->{es}->indices->put_mapping(
4949
index => $index,
5050
type => $index,
5151
body => $mapping,
5252
);
5353
}
5454

55-
sub index_add_mapping ($self, $index, $skip_exists) {
55+
sub index_add_mapping ( $self, $index, $skip_exists ) {
5656
return if $skip_exists and !$self->index_exists($index);
5757

58-
my $home = home();
59-
my $map_file = $home->child('conf/es/' . $index . '/mapping.json');
60-
my $mapping = decode_json $map_file->slurp();
58+
my $home = home();
59+
my $map_file = $home->child( 'conf/es/' . $index . '/mapping.json' );
60+
my $mapping = decode_json $map_file->slurp();
6161

62-
$self->index_put_mapping($index, $mapping);
62+
$self->index_put_mapping( $index, $mapping );
6363
}
6464

6565
1;

t/00_setup.t

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use MetaCPAN::ES;
88
use MetaCPAN::Mapper;
99
use MetaCPAN::Ingest qw< home >;
1010

11-
my $es = MetaCPAN::ES->new( mode => 'test' );
11+
my $es = MetaCPAN::ES->new( mode => 'test' );
1212
my $mapper = MetaCPAN::Mapper->new( mode => 'test' );
1313

1414
my $home = home();
@@ -31,7 +31,8 @@ my @files = qw<
3131

3232
subtest 'Check Files' => sub {
3333
ok( $authors->child('00whois.xml'), "Found 00whois.xml" );
34-
ok( $modules->child('02packages.details.txt.gz'), "Found 02packages.details.txt.gz" );
34+
ok( $modules->child('02packages.details.txt.gz'),
35+
"Found 02packages.details.txt.gz" );
3536
ok( $modules->child('06perms.txt'), "Found 06perms.txt" );
3637
};
3738

@@ -40,7 +41,8 @@ my @packages = qw<
4041
>;
4142

4243
subtest 'Check Packages' => sub {
43-
ok( $authors->child('id/O/OA/OALDERS/HTML-Parser-3.83.tar.gz'), "Found HTML-Parser-3.83.tar.gz" );
44+
ok( $authors->child('id/O/OA/OALDERS/HTML-Parser-3.83.tar.gz'),
45+
"Found HTML-Parser-3.83.tar.gz" );
4446
};
4547

4648
# === Mapping
@@ -59,13 +61,13 @@ my @indices = qw<
5961
release
6062
>;
6163

62-
for my $i ( @indices ) {
63-
$mapper->index_delete($i, 'skip_exists');
64+
for my $i (@indices) {
65+
$mapper->index_delete( $i, 'skip_exists' );
6466
$mapper->index_create($i);
6567
}
6668

6769
subtest 'Check Mappings' => sub {
68-
for my $i ( @indices ) {
70+
for my $i (@indices) {
6971
ok( $mapper->index_exists($i), "Index '$i' exists" );
7072
}
7173
};
@@ -74,35 +76,38 @@ subtest 'Check Mappings' => sub {
7476

7577
# run the author indexing script in test mode
7678
my $author_script = $bin->child('author.pl');
77-
my $whois_file = $authors->child('00whois.xml');
79+
my $whois_file = $authors->child('00whois.xml');
7880
`perl $author_script -whois_file $whois_file --mode test`;
7981

8082
subtest 'Author Indexing' => sub {
8183
my $es_author = MetaCPAN::ES->new( index => 'author', mode => 'test' );
82-
ok( $es_author->exists( index => 'author', id => 'OALDERS' ), "Found author OALDERS" );
84+
ok( $es_author->exists( index => 'author', id => 'OALDERS' ),
85+
"Found author OALDERS" );
8386
};
8487

8588
# run the package indexing script in test mode
8689
my $package_script = $bin->child('package.pl');
87-
my $package_file = $modules->child('02packages.details.txt.gz');
90+
my $package_file = $modules->child('02packages.details.txt.gz');
8891
`perl $package_script -package_file $package_file --mode test`;
8992

9093
subtest 'Package Indexing' => sub {
9194
my $es_package = MetaCPAN::ES->new( index => 'package', mode => 'test' );
92-
ok( $es_package->exists( index => 'package', id => 'LWP' ), "Found package LWP" );
95+
ok( $es_package->exists( index => 'package', id => 'LWP' ),
96+
"Found package LWP" );
9397
};
9498

9599
# run the permission indexing script in test mode
96100
my $perms_script = $bin->child('permission.pl');
97-
my $perms_file = $modules->child('06perms.txt');
101+
my $perms_file = $modules->child('06perms.txt');
98102
`perl $perms_script -perms_file $perms_file --mode test`;
99103

100104
subtest 'Permissions Indexing' => sub {
101-
my $es_permission = MetaCPAN::ES->new( index => 'permission', mode => 'test' );
102-
ok( $es_permission->exists( index => 'permission', id => 'LWP' ), "Found permissions for LWP" );
105+
my $es_permission
106+
= MetaCPAN::ES->new( index => 'permission', mode => 'test' );
107+
ok( $es_permission->exists( index => 'permission', id => 'LWP' ),
108+
"Found permissions for LWP" );
103109
};
104110

105-
106111
# check test data directory
107112
# - check all distros for test are there
108113
# - check all other data sources are there to test all indices
@@ -113,5 +118,4 @@ subtest 'Permissions Indexing' => sub {
113118
# $server->set_first;
114119
# $server->prepare_user_test_data;
115120

116-
117121
done_testing;

0 commit comments

Comments
 (0)