Archive-Peek-0.37/0000755000175000017500000000000014143630107012363 5ustar zakizakiArchive-Peek-0.37/lib/0000755000175000017500000000000014143630107013131 5ustar zakizakiArchive-Peek-0.37/lib/Archive/0000755000175000017500000000000014143630107014512 5ustar zakizakiArchive-Peek-0.37/lib/Archive/Peek/0000755000175000017500000000000014143630107015376 5ustar zakizakiArchive-Peek-0.37/lib/Archive/Peek/Tar.pm0000644000175000017500000000112114143620412016453 0ustar zakizakipackage Archive::Peek::Tar; use Moo; use Carp qw(confess); use Archive::Tar; extends 'Archive::Peek'; sub tar { my $self = shift; my $filename = $self->filename; my $tar = Archive::Tar->new( $filename->stringify ) || confess("Error reading $filename"); return $tar; } sub files { my $self = shift; my $tar = $self->tar; my @files = sort map { $_->full_path } grep { $_->is_file } $tar->get_files(); return @files; } sub file { my ( $self, $filename ) = @_; my $tar = $self->tar; return $tar->get_content($filename); } 1; Archive-Peek-0.37/lib/Archive/Peek/Zip.pm0000644000175000017500000000170014143620412016472 0ustar zakizakipackage Archive::Peek::Zip; use Moo; use Carp qw(confess); use Archive::Zip qw(AZ_OK); use Archive::Zip::MemberRead; extends 'Archive::Peek'; sub zip { my $self = shift; my $filename = $self->filename; my $zip = Archive::Zip->new(); unless ( $zip->read( $filename->stringify ) == AZ_OK ) { confess("Error reading $filename"); } return $zip; } sub files { my $self = shift; my $zip = $self->zip; my @members = $zip->members(); my @files = sort map { $_->fileName } grep { !$_->isDirectory } @members; return @files; } sub file { my ( $self, $filename ) = @_; my $zip = $self->zip; my $fh = Archive::Zip::MemberRead->new( $zip, $filename ); my $file = ''; while (1) { my $read = $fh->read( my $buffer, 1024 ); die "FATAL ERROR reading my secrets !\n" if ( !defined($read) ); last if ( !$read ); $file .= $buffer; } return $file; } 1; Archive-Peek-0.37/lib/Archive/Peek.pm0000644000175000017500000000321714143627577015760 0ustar zakizakipackage Archive::Peek; use Moo; use Carp qw(confess); use Archive::Peek::Tar; use Archive::Peek::Zip; use Types::Path::Tiny qw( File ); our $VERSION = '0.37'; has 'filename' => ( is => 'ro', isa => File, required => 1, coerce => 1, ); sub BUILD { my $self = shift; my $filename = $self->filename; my $basename = $filename->basename; if ( $basename =~ /\.zip$/i ) { bless $self, 'Archive::Peek::Zip'; } elsif ( $basename =~ /(\.tar|\.tar\.gz|\.tgz|\.bz2|\.bzip2)$/i ) { bless $self, 'Archive::Peek::Tar'; } else { confess("Failed to open $filename"); } } 1; __END__ =head1 NAME Archive::Peek - Peek into archives without extracting them =head1 SYNOPSIS use Archive::Peek; my $peek = Archive::Peek->new( filename => 'archive.tgz' ); my @files = $peek->files(); my $contents = $peek->file('README.txt') =head1 DESCRIPTION This module lets you peek into archives without extracting them. It currently supports tar files and zip files. To support Bzip2- compressed files, you should install IO::Uncompress::Bunzip2. =head1 METHODS =head2 new The constructor takes the filename of the archive to peek into: my $peek = Archive::Peek->new( filename => 'archive.tgz' ); =head2 files Returns the files in the archive: my @files = $peek->files(); =head2 file Returns the contents of a file in the archive: my $contents = $peek->file('README.txt') =head1 AUTHOR Leon Brocard =head1 COPYRIGHT Copyright (C) 2008, Leon Brocard. =head1 LICENSE This module is free software; you can redistribute it or modify it under the same terms as Perl itself. Archive-Peek-0.37/README0000644000175000017500000000177414047434345013265 0ustar zakizakiNAME Archive::Peek - Peek into archives without extracting them SYNOPSIS use Archive::Peek; my $peek = Archive::Peek->new( filename => 'archive.tgz' ); my @files = $peek->files(); my $contents = $peek->file('README.txt') DESCRIPTION This module lets you peek into archives without extracting them. It currently supports tar files and zip files. To support Bzip2- compressed files, you should install IO::Uncompress::Bunzip2. METHODS new The constructor takes the filename of the archive to peek into: my $peek = Archive::Peek->new( filename => 'archive.tgz' ); files Returns the files in the archive: my @files = $peek->files(); file Returns the contents of a file in the archive: my $contents = $peek->file('README.txt') AUTHOR Leon Brocard COPYRIGHT Copyright (C) 2008, Leon Brocard. LICENSE This module is free software; you can redistribute it or modify it under the same terms as Perl itself. Archive-Peek-0.37/Makefile.PL0000644000175000017500000000236114143625166014350 0ustar zakizaki#!perl use strict; use warnings; use ExtUtils::MakeMaker; my $github_slug = 'acme/archive-peek'; WriteMakefile( NAME => 'Archive::Peek', VERSION_FROM => 'lib/Archive/Peek.pm', AUTHOR => 'Leon Brocard ', ABSTRACT => 'Peek into archives without extracting them', LICENSE => 'perl', PREREQ_PM => { 'Archive::Tar' => '0', 'Archive::Zip' => '0', 'Moo' => '0', 'Types::Path::Tiny' => '0', 'Carp' => '0', }, TEST_REQUIRES => { 'Test::More' => '0', 'File::Temp' => '0', }, META_MERGE => { "meta-spec" => { version => 2 }, resources => { bugtracker => { web => "https://github.com/$github_slug/issues" }, repository => { url => "git://github.com/$github_slug.git", type => 'git', web => "https://github.com/$github_slug", }, }, prereqs => { develop => { requires => { 'Test::Pod' => '1.14', }, }, }, }, ); Archive-Peek-0.37/MANIFEST0000644000175000017500000000056414143630107013521 0ustar zakizakiCHANGES lib/Archive/Peek.pm lib/Archive/Peek/Tar.pm lib/Archive/Peek/Zip.pm Makefile.PL MANIFEST This list of files MANIFEST.SKIP README t/archive.tar.bz2 t/archive.tgz t/archive.zip t/pod.t t/simple.t META.yml Module YAML meta-data (added by MakeMaker) META.json Module JSON meta-data (added by MakeMaker) Archive-Peek-0.37/META.json0000644000175000017500000000305414143630107014006 0ustar zakizaki{ "abstract" : "Peek into archives without extracting them", "author" : [ "Leon Brocard " ], "dynamic_config" : 1, "generated_by" : "ExtUtils::MakeMaker version 7.62, CPAN::Meta::Converter version 2.150010", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : 2 }, "name" : "Archive-Peek", "no_index" : { "directory" : [ "t", "inc" ] }, "prereqs" : { "build" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "configure" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "develop" : { "requires" : { "Test::Pod" : "1.14" } }, "runtime" : { "requires" : { "Archive::Tar" : "0", "Archive::Zip" : "0", "Carp" : "0", "Moo" : "0", "Types::Path::Tiny" : "0" } }, "test" : { "requires" : { "File::Temp" : "0", "Test::More" : "0" } } }, "release_status" : "stable", "resources" : { "bugtracker" : { "web" : "https://github.com/acme/archive-peek/issues" }, "repository" : { "type" : "git", "url" : "git://github.com/acme/archive-peek.git", "web" : "https://github.com/acme/archive-peek" } }, "version" : "0.37", "x_serialization_backend" : "JSON::PP version 4.06" } Archive-Peek-0.37/META.yml0000644000175000017500000000143414143630107013636 0ustar zakizaki--- abstract: 'Peek into archives without extracting them' author: - 'Leon Brocard ' build_requires: ExtUtils::MakeMaker: '0' File::Temp: '0' Test::More: '0' configure_requires: ExtUtils::MakeMaker: '0' dynamic_config: 1 generated_by: 'ExtUtils::MakeMaker version 7.62, CPAN::Meta::Converter version 2.150010' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: Archive-Peek no_index: directory: - t - inc requires: Archive::Tar: '0' Archive::Zip: '0' Carp: '0' Moo: '0' Types::Path::Tiny: '0' resources: bugtracker: https://github.com/acme/archive-peek/issues repository: git://github.com/acme/archive-peek.git version: '0.37' x_serialization_backend: 'CPAN::Meta::YAML version 0.018' Archive-Peek-0.37/MANIFEST.SKIP0000644000175000017500000000013714143614071014264 0ustar zakizakiArchive-Peek-* Makefile$ Makefile\.old MYMETA\.(json|yml) ^\.git ^\.github/ \.swp$ ^\.vscode Archive-Peek-0.37/CHANGES0000644000175000017500000000143314143627642013371 0ustar zakizakiRevision history for Perl module Archive::Peek: 0.37 Fri Nov 12 22:23:12 EST 2021 - update repository metadata (Zakariyya Mughal) 0.36 Fri Nov 12 21:40:27 EST 2021 - add repository metadata (thanks David Steinbrunner) - port from Moose to Moo and Type::Tiny (Zakariyya Mughal) - make prereqs more specific with respect to phase (Zakariyya Mughal) - add negative test (Zakariyya Mughal) 0.35 Mon Sep 26 20:21:30 BST 2011 - add support for .tar.bz2 (as suggested by Fabrizio Regalli) 0.34 10 Sep 2008 17:38:14 GMT - put human-readable license in the documentation - add an abstract to the Makefile.PL 0.33 Thu Aug 28 15:30:42 BST 2008 - remove MooseX::LogDispatch, it was causing problems 0.32 Thu Aug 28 09:01:31 BST 2008 - initial release Archive-Peek-0.37/t/0000755000175000017500000000000014143630107012626 5ustar zakizakiArchive-Peek-0.37/t/pod.t0000644000175000017500000000022014047434345013600 0ustar zakizaki#!perl -T use Test::More; eval "use Test::Pod 1.14"; plan skip_all => "Test::Pod 1.14 required for testing POD: $@" if $@; all_pod_files_ok(); Archive-Peek-0.37/t/simple.t0000644000175000017500000000205114143620412014300 0ustar zakizaki#!perl use strict; use warnings; use Test::More; use File::Temp qw(tempfile); use_ok 'Archive::Peek'; my @filenames = ( 'archive/README', 'archive/a/A', 'archive/a/b/B', 'archive/c/C' ); test_archive('t/archive.zip'); test_archive('t/archive.tgz') if Archive::Tar->has_zlib_support; test_archive('t/archive.tar.bz2') if Archive::Tar->has_bzip2_support; subtest "Test opening empty file" => sub { my ($empty_fh, $empty_path) = tempfile( SUFFIX => '.zip' ); my $empty_peek = Archive::Peek->new( filename => $empty_path ); eval { $empty_peek->files; 1 } and fail 'No exception on empty file'; pass "Exception on empty file: $@" if $@; }; done_testing(); sub test_archive { my $filename = shift; my $peek = Archive::Peek->new( filename => $filename ); isa_ok( $peek, 'Archive::Peek', "Can read $filename" ); is_deeply( [ $peek->files ], \@filenames, "Can read files inside $filename" ); is( $peek->file('archive/README'), 'This is in the root directory. It is a file. ', "Can read archive/README inside $filename" ); } Archive-Peek-0.37/t/archive.tgz0000644000175000017500000000052614047434345015011 0ustar zakizakiFHJ0Sd=1i~: nȴ)h i|{2%2D9p/s{͛"a#R~bupΔR\6n Nk?G)1Ջ黵g9_E?蟂M^`-K'%h-pMOMmiͲ"@g D0x0@h4@  !55=$xjR2z=S|wk߾m4LrĄ""6KV4s&$Ʋu{ɏ݊DԒy%O skjVR