| 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
| |||||||||||||||||||||
| 28 | my $subclass = 'Dist::Metadata::' . | ||||||||||||||||||||
| 29 | 21 | ▶ | ( $self->{file} =~ /\.zip$/ ? 'Zip' : 'Tar' ); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 30 | |||||||||||||||||||||
| 31 | 21 | ▶ | eval "require $subclass" | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 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)
}
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)
}
| |||||||||||||||||||||
| 47 | 24 | my $file = $self->file; | |||||||||||||||||||
| 48 | |||||||||||||||||||||
| 49 | 24 | ▶ | Carp::croak "File '$file' does not exist" | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 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__ | ||||||||||||||||||||