From e18540eef69c5f861e30336e78855cbf5ffe66da Mon Sep 17 00:00:00 2001 From: Mickey Nasriachi Date: Sat, 3 May 2025 16:28:10 +0000 Subject: [PATCH 1/5] Ingest: read_00whois - supprort alternative file (for testing) --- lib/MetaCPAN/Ingest.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/MetaCPAN/Ingest.pm b/lib/MetaCPAN/Ingest.pm index 07cc036..d9df9d5 100644 --- a/lib/MetaCPAN/Ingest.pm +++ b/lib/MetaCPAN/Ingest.pm @@ -294,9 +294,9 @@ sub extract_section ( $pod, $section ) { return $out; } -sub read_00whois () { +sub read_00whois ( $file = undef ) { my $cpan = cpan_dir(); - my $authors_file = sprintf( "%s/%s", $cpan, 'authors/00whois.xml' ); + my $authors_file = $file || sprintf( "%s/%s", $cpan, 'authors/00whois.xml' ); my $data = XMLin( $authors_file, From 2a14e35e2f42562a370fd3fbd93b1ace2bce0f5a Mon Sep 17 00:00:00 2001 From: Mickey Nasriachi Date: Sat, 3 May 2025 16:28:37 +0000 Subject: [PATCH 2/5] Ingest: read_02packages_fh - supprort alternative file (for testing) --- lib/MetaCPAN/Ingest.pm | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/MetaCPAN/Ingest.pm b/lib/MetaCPAN/Ingest.pm index d9df9d5..8a11eb4 100644 --- a/lib/MetaCPAN/Ingest.pm +++ b/lib/MetaCPAN/Ingest.pm @@ -330,10 +330,18 @@ sub read_00whois ( $file = undef ) { } # TODO: replace usage with read_02packages -sub read_02packages_fh ( $log_meta = 0 ) { - my $cpan = cpan_dir(); - my $fh = $cpan->child(qw< modules 02packages.details.txt.gz >) - ->openr(':gzip'); +sub read_02packages_fh ( %args ) { + my $log_meta = $args{log_meta} // 0; + my $file = $args{file}; + + my $fh; + if ( $file ) { + $fh = path($file)->openr(':gzip'); + } else { + my $cpan = cpan_dir(); + $fh = $cpan->child(qw< modules 02packages.details.txt.gz >) + ->openr(':gzip'); + } # read first 9 lines (meta info) my $meta = "Meta info:\n"; From b0d11d1262117f7e2beea2fc3720b712c4798091 Mon Sep 17 00:00:00 2001 From: Mickey Nasriachi Date: Sat, 3 May 2025 16:33:42 +0000 Subject: [PATCH 3/5] Ingest: read_02packages - supprort alternative file (for testing) --- bin/package.pl | 2 +- lib/MetaCPAN/Ingest.pm | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/bin/package.pl b/bin/package.pl index 276f140..d0a60b1 100644 --- a/bin/package.pl +++ b/bin/package.pl @@ -27,7 +27,7 @@ # read the rest of the file line-by-line (too big to slurp) -my $fh_packages = read_02packages_fh(1); +my $fh_packages = read_02packages_fh( log_meta => 1 ); while ( my $line = <$fh_packages> ) { next unless $line; chomp($line); diff --git a/lib/MetaCPAN/Ingest.pm b/lib/MetaCPAN/Ingest.pm index 8a11eb4..93418b6 100644 --- a/lib/MetaCPAN/Ingest.pm +++ b/lib/MetaCPAN/Ingest.pm @@ -355,10 +355,16 @@ sub read_02packages_fh ( %args ) { return $fh; } -sub read_02packages () { - my $cpan = cpan_dir(); - return Parse::CPAN::Packages::Fast->new( - $cpan->child(qw< modules 02packages.details.txt.gz >)->stringify ); +sub read_02packages ( $file = undef ) { + my $content; + if ( $file ) { + $content = path($file)->stringify; + } else { + my $cpan = cpan_dir(); + $content = $cpan->child(qw< modules 02packages.details.txt.gz >)->stringify; + } + + return Parse::CPAN::Packages::Fast->new($content); } # TODO: replace usage with unified read_06perms From 37b9e90b4c9767ff8a31466231ded778de0bc0a0 Mon Sep 17 00:00:00 2001 From: Mickey Nasriachi Date: Sat, 3 May 2025 16:35:51 +0000 Subject: [PATCH 4/5] Ingest: read_06perms_fh - supprort alternative file (for testing) --- lib/MetaCPAN/Ingest.pm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/MetaCPAN/Ingest.pm b/lib/MetaCPAN/Ingest.pm index 93418b6..ec7af3e 100644 --- a/lib/MetaCPAN/Ingest.pm +++ b/lib/MetaCPAN/Ingest.pm @@ -368,7 +368,9 @@ sub read_02packages ( $file = undef ) { } # TODO: replace usage with unified read_06perms -sub read_06perms_fh () { +sub read_06perms_fh ( $file = undef ) { + return path($file)->openr if $file; + my $cpan = cpan_dir(); return $cpan->child(qw< modules 06perms.txt >)->openr; } From b71602479b2ecf92fff639bb924e156cfbaa8539 Mon Sep 17 00:00:00 2001 From: Mickey Nasriachi Date: Sat, 3 May 2025 16:38:44 +0000 Subject: [PATCH 5/5] Ingest: read_06perms_iter - supprort alternative file (for testing) --- lib/MetaCPAN/Ingest.pm | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/MetaCPAN/Ingest.pm b/lib/MetaCPAN/Ingest.pm index ec7af3e..ce7d869 100644 --- a/lib/MetaCPAN/Ingest.pm +++ b/lib/MetaCPAN/Ingest.pm @@ -375,10 +375,16 @@ sub read_06perms_fh ( $file = undef ) { return $cpan->child(qw< modules 06perms.txt >)->openr; } -sub read_06perms_iter () { - my $cpan = cpan_dir(); - my $file_path = $cpan->child(qw< modules 06perms.txt >)->absolute; - my $pp = PAUSE::Permissions->new( path => $file_path ); +sub read_06perms_iter ( $file = undef ) { + my $file_path; + if ( $file ) { + $file_path = path($file)->absolute; + } else { + my $cpan = cpan_dir(); + $file_path = $cpan->child(qw< modules 06perms.txt >)->absolute; + } + + my $pp = PAUSE::Permissions->new( path => $file_path ); return $pp->module_iterator; }