@@ -294,9 +294,9 @@ sub extract_section ( $pod, $section ) {
294
294
return $out ;
295
295
}
296
296
297
- sub read_00whois () {
297
+ sub read_00whois ( $file = undef ) {
298
298
my $cpan = cpan_dir();
299
- my $authors_file = sprintf ( " %s /%s " , $cpan , ' authors/00whois.xml' );
299
+ my $authors_file = $file || sprintf ( " %s /%s " , $cpan , ' authors/00whois.xml' );
300
300
301
301
my $data = XMLin(
302
302
$authors_file ,
@@ -330,10 +330,18 @@ sub read_00whois () {
330
330
}
331
331
332
332
# TODO: replace usage with read_02packages
333
- sub read_02packages_fh ( $log_meta = 0 ) {
334
- my $cpan = cpan_dir();
335
- my $fh = $cpan -> child(qw< modules 02packages.details.txt.gz > )
336
- -> openr(' :gzip' );
333
+ sub read_02packages_fh ( %args ) {
334
+ my $log_meta = $args {log_meta } // 0;
335
+ my $file = $args {file };
336
+
337
+ my $fh ;
338
+ if ( $file ) {
339
+ $fh = path($file )-> openr(' :gzip' );
340
+ } else {
341
+ my $cpan = cpan_dir();
342
+ $fh = $cpan -> child(qw< modules 02packages.details.txt.gz > )
343
+ -> openr(' :gzip' );
344
+ }
337
345
338
346
# read first 9 lines (meta info)
339
347
my $meta = " Meta info:\n " ;
@@ -347,22 +355,36 @@ sub read_02packages_fh ( $log_meta = 0 ) {
347
355
return $fh ;
348
356
}
349
357
350
- sub read_02packages () {
351
- my $cpan = cpan_dir();
352
- return Parse::CPAN::Packages::Fast-> new(
353
- $cpan -> child(qw< modules 02packages.details.txt.gz > )-> stringify );
358
+ sub read_02packages ( $file = undef ) {
359
+ my $content ;
360
+ if ( $file ) {
361
+ $content = path($file )-> stringify;
362
+ } else {
363
+ my $cpan = cpan_dir();
364
+ $content = $cpan -> child(qw< modules 02packages.details.txt.gz > )-> stringify;
365
+ }
366
+
367
+ return Parse::CPAN::Packages::Fast-> new($content );
354
368
}
355
369
356
370
# TODO: replace usage with unified read_06perms
357
- sub read_06perms_fh () {
371
+ sub read_06perms_fh ( $file = undef ) {
372
+ return path($file )-> openr if $file ;
373
+
358
374
my $cpan = cpan_dir();
359
375
return $cpan -> child(qw< modules 06perms.txt > )-> openr;
360
376
}
361
377
362
- sub read_06perms_iter () {
363
- my $cpan = cpan_dir();
364
- my $file_path = $cpan -> child(qw< modules 06perms.txt > )-> absolute;
365
- my $pp = PAUSE::Permissions-> new( path => $file_path );
378
+ sub read_06perms_iter ( $file = undef ) {
379
+ my $file_path ;
380
+ if ( $file ) {
381
+ $file_path = path($file )-> absolute;
382
+ } else {
383
+ my $cpan = cpan_dir();
384
+ $file_path = $cpan -> child(qw< modules 06perms.txt > )-> absolute;
385
+ }
386
+
387
+ my $pp = PAUSE::Permissions-> new( path => $file_path );
366
388
return $pp -> module_iterator;
367
389
}
368
390
0 commit comments