blib/lib/Dist/Metadata/Archive.pm

filter: Statementstmt 97.1% 34 / 35 Branchbran 87.5% 7 / 8 Conditioncond 100% 3 / 3 MC/DCmcdc 100% 2 / 2 Subroutinesub 90.9% 10 / 11 Podpod 100% 7 / 7 totaltotal 95.4% 63 / 66 CC 6 SCAR 7.8
CC
6
Cov
96%
new
4.0
archive
3.0
read_archive
2.0
CRAP 2.2
« blib/lib/Dist/Metadata/Dist.pm ↑ Summary blib/lib/Dist/Metadata/Struct.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 8 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 8 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 package Dist::Metadata::Archive;
14 8 our $AUTHORITY = 'cpan:RWSTAUNER';
15 # ABSTRACT: Base class for Dist::Metadata archive files
16 8 $Dist::Metadata::Archive::VERSION = '0.927';
17 8 ▶use Carp (); # core
Subroutine BEGIN: called CC=1 SCAR=0.0
18 8 ▶use parent 'Dist::Metadata::Dist';
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 8 push(@Dist::Metadata::CARP_NOT, __PACKAGE__);
21  
22  
23 30 ▶sub new {
Subroutine new: called CC=4 SCAR=13.9
Pod documented
24 30 my $class = shift;
25 30 my $self = $class->SUPER::new(@_);
26  
27 27 ▶ if( $class eq __PACKAGE__ ){
Branch: 1 branch
BranchTrueFalseTotal
if ($class eq __PACKAGE__) 21 6 27
28 my $subclass = 'Dist::Metadata::' .
29 21 ▶ ( $self->{file} =~ /\.zip$/ ? 'Zip' : 'Tar' );
Branch: 1 branch
BranchTrueFalseTotal
$self->{'file'} =~ /\.zip$/ ? : 10 11 21
30  
31 21 ▶ eval "require $subclass"
Branch: 1 branch
BranchTrueFalseTotal
eval "require $subclass" or Carp::croak($@) 21 0 21
32 or Carp::croak $@;
33  
34 # rebless into format specific subclass
35 21 bless $self, $subclass;
36 }
37  
38 27 return $self;
39 }
40  
41 33 ▶sub required_attribute { 'file' }
Subroutine required_attribute: called CC=1 SCAR=0.0
Pod documented
42  
43  
44 73 ▶sub archive {
Subroutine archive: called CC=3 SCAR=11.0
Pod documented
45 73 my ($self) = @_;
46 73 ▶ return $self->{archive} ||= do {
Condition100%3/3
$self->{"archive"} ||= do { my $file = $self->file; Carp::croak("File '${file}' does not exist") unless -e $file; $self->read_archive($file) }
l!l&&r!l&&!r
49231
MC/DC100%2/2
$self->{"archive"} ||= do { my $file = $self->file; Carp::croak("File '${file}' does not exist") unless -e $file; $self->read_archive($file) }
$self->{"archive"} do { my $file = $self->file; Carp::croak("File '${file}' does not exist") unless -e $file; $self->read_archive($file) }
Truth table100%3/3
A ||= B
A= $self->{"archive"}B= do { my $file = $self->file; Carp::croak("File '${file}' does not exist") unless -e $file; $self->read_archive($file) }
ABresult
1X1
011
000
47 24 my $file = $self->file;
48  
49 24 ▶ Carp::croak "File '$file' does not exist"
Branch: 1 branch
BranchTrueFalseTotal
unless -e $file 3 21 24
50 unless -e $file;
51  
52 21 $self->read_archive($file); # return
53 };
54 }
55  
56  
57 21 ▶sub default_file_spec { 'Unix' }
Subroutine default_file_spec: called CC=1 SCAR=0.0
Pod documented
58  
59  
60 22 ▶sub determine_name_and_version {
Subroutine determine_name_and_version: called CC=1 SCAR=0.0
Pod documented
61 22 my ($self) = @_;
62 22 $self->set_name_and_version( $self->parse_name_and_version( $self->file ) );
63 22 return $self->SUPER::determine_name_and_version(@_);
64 }
65  
66  
67 48 ▶sub file {
Subroutine file: called CC=1 SCAR=0.0
Pod documented
68 48 return $_[0]->{file};
69 }
70  
71  
72 0 ▶sub read_archive {
Subroutine read_archive: not called CC=1 SCAR=6.9
Pod documented
73 0 Carp::croak q[Method 'read_archive' not defined];
74 }
75  
76 8 1;
77  
78 __END__
« blib/lib/Dist/Metadata/Dist.pm ↑ Summary blib/lib/Dist/Metadata/Struct.pm »