@@ -294,9 +294,9 @@ sub extract_section ( $pod, $section ) {
294294 return $out ;
295295}
296296
297- sub read_00whois () {
297+ sub read_00whois ( $file = undef ) {
298298 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' );
300300
301301 my $data = XMLin(
302302 $authors_file ,
@@ -330,10 +330,18 @@ sub read_00whois () {
330330}
331331
332332# 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+ }
337345
338346 # read first 9 lines (meta info)
339347 my $meta = " Meta info:\n " ;
@@ -347,22 +355,36 @@ sub read_02packages_fh ( $log_meta = 0 ) {
347355 return $fh ;
348356}
349357
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 );
354368}
355369
356370# 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+
358374 my $cpan = cpan_dir();
359375 return $cpan -> child(qw< modules 06perms.txt > )-> openr;
360376}
361377
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 );
366388 return $pp -> module_iterator;
367389}
368390
0 commit comments