Archive-Peek-0.35/0000755000175000017500000000000011640150327012277 5ustar acmeacmeArchive-Peek-0.35/CHANGES0000644000175000017500000000065611640150301013271 0ustar acmeacmeRevision history for Perl module Archive::Peek: 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.35/lib/0000755000175000017500000000000011640150327013045 5ustar acmeacmeArchive-Peek-0.35/lib/Archive/0000755000175000017500000000000011640150327014426 5ustar acmeacmeArchive-Peek-0.35/lib/Archive/Peek/0000755000175000017500000000000011640150327015312 5ustar acmeacmeArchive-Peek-0.35/lib/Archive/Peek/Zip.pm0000644000175000017500000000165411055455023016421 0ustar acmeacmepackage Archive::Peek::Zip; use Moose; 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.35/lib/Archive/Peek/Tar.pm0000644000175000017500000000107511640144201016373 0ustar acmeacmepackage Archive::Peek::Tar; use Moose; 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.35/lib/Archive/Peek.pm0000644000175000017500000000320411640150307015645 0ustar acmeacmepackage Archive::Peek; use Moose; use Archive::Peek::Tar; use Archive::Peek::Zip; use MooseX::Types::Path::Class qw( File ); our $VERSION = '0.35'; 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.35/t/0000755000175000017500000000000011640150327012542 5ustar acmeacmeArchive-Peek-0.35/t/archive.tar.bz20000644000175000017500000000050511055443247015375 0ustar acmeacmeBZh91AY&SY5@@>"@g D0x0@h4@  !55=$xjR2z=S|wk߾m4LrĄ""6KV4s&$Ʋu{ɏ݊DԒy%O skjVR "Test::Pod 1.14 required for testing POD: $@" if $@; all_pod_files_ok(); Archive-Peek-0.35/t/simple.t0000644000175000017500000000135511640144132014221 0ustar acmeacme#!perl use strict; use warnings; use Test::More; 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; 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.35/MANIFEST0000644000175000017500000000041511640144551013432 0ustar acmeacmeCHANGES lib/Archive/Peek.pm lib/Archive/Peek/Tar.pm lib/Archive/Peek/Zip.pm Makefile.PL MANIFEST This list of files README t/archive.tar.bz2 t/archive.tgz t/archive.zip t/pod.t t/simple.t META.yml Module meta-data (added by MakeMaker) Archive-Peek-0.35/Makefile.PL0000644000175000017500000000105611062000442014241 0ustar acmeacme#!perl use strict; use warnings; use ExtUtils::MakeMaker; 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', 'Moose' => '0', 'MooseX::Types::Path::Class' => '0', 'Test::More' => '0', } ); Archive-Peek-0.35/META.yml0000644000175000017500000000125411640150327013552 0ustar acmeacme--- #YAML:1.0 name: Archive-Peek version: 0.35 abstract: Peek into archives without extracting them author: - Leon Brocard license: perl distribution_type: module configure_requires: ExtUtils::MakeMaker: 0 build_requires: ExtUtils::MakeMaker: 0 requires: Archive::Tar: 0 Archive::Zip: 0 Moose: 0 MooseX::Types::Path::Class: 0 Test::More: 0 no_index: directory: - t - inc generated_by: ExtUtils::MakeMaker version 6.56 meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 Archive-Peek-0.35/README0000644000175000017500000000177411640145766013203 0ustar acmeacmeNAME 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.