blib/lib/Dist/Metadata/Zip.pm

filter: Statementstmt 100% 31 / 31 Branchbran 50.0% 2 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 8 / 8 Podpod 100% 3 / 3 totaltotal 95.6% 44 / 46 CC 3 SCAR 3.4
CC
3
Cov
94%
file_content
2.0
read_archive
2.0
BEGIN
1.0
CRAP 1.4
« blib/lib/Dist/Metadata/Dir.pm ↑ Summary blib/lib/Dist/Metadata/Tar.pm »
1 # vim: set ts=2 sts=2 sw=2 expandtab smarttab:
2 #
3 # This file is part of Dist-Metadata
4 #
5 # This software is copyright (c) 2011 by Randy Stauner.
6 #
7 # This is free software; you can redistribute it and/or modify it under
8 # the same terms as the Perl 5 programming language system itself.
9 #
10 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 package Dist::Metadata::Zip;
14 5 our $AUTHORITY = 'cpan:RWSTAUNER';
15 # ABSTRACT: Enable Dist::Metadata for zip files
16 5 $Dist::Metadata::Zip::VERSION = '0.927';
17 5 ▶use Archive::Zip 1.30 ();
Subroutine BEGIN: called CC=1 SCAR=0.0
18 5 ▶use Carp (); # core
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 5 ▶use parent 'Dist::Metadata::Archive';
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 5 push(@Dist::Metadata::CARP_NOT, __PACKAGE__);
23  
24 22 ▶sub file_content {
Subroutine file_content: called CC=2 SCAR=7.0
Pod documented
25 22 my ($self, $file) = @_;
26 22 my ($content, $status) = $self->archive->contents( $self->full_path($file) );
27 22 ▶ Carp::croak "Failed to get content of '$file' from archive"
Branch: 1 branch
BranchTrueFalseTotal
if $status != 0 0 22 22
28 if $status != Archive::Zip::AZ_OK();
29 22 return $content;
30 }
31  
32 11 ▶sub find_files {
Subroutine find_files: called CC=1 SCAR=0.0
Pod documented
33 11 my ($self) = @_;
34 return
35 37 map { $_->fileName }
36 11 grep { !$_->isDirectory }
37 $self->archive->members;
38 }
39  
40 11 ▶sub read_archive {
Subroutine read_archive: called CC=2 SCAR=7.0
Pod documented
41 11 my ($self, $file) = @_;
42  
43 11 my $archive = Archive::Zip->new();
44 11 ▶ $archive->read($file) == Archive::Zip::AZ_OK()
Branch: 1 branch
BranchTrueFalseTotal
$archive->read($file) == 0 or Carp::croak("Failed to read zip file!") 11 0 11
45 or Carp::croak "Failed to read zip file!";
46  
47 11 return $archive;
48 }
49  
50 5 1;
51  
52 __END__
« blib/lib/Dist/Metadata/Dir.pm ↑ Summary blib/lib/Dist/Metadata/Tar.pm »