Create.pm

filter: Statementstmt 100% 36 / 36 Branchbran 50.0% 2 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 9 / 9 Podpod 83.3% 5 / 6 totaltotal 94.5% 52 / 55 CC 4 SCAR 7.0
CC
4
Cov
95%
proxy_methods
4.0
BEGIN
1.0
BEGIN
1.0
CRAP 2.0
↑ Summary Create/Tar.pm »
1 package Archive::Any::Create;
2  
3 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 our $VERSION = '0.03';
5  
6 3 ▶use Exception::Class 'Archive::Any::Create::Error';
Subroutine BEGIN: called CC=1 SCAR=0.0
7 3 ▶use UNIVERSAL::require;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 3 our %Type2Class = (
10 'tar' => [ 'Archive::Any::Create::Tar' ],
11 'tar.gz' => [ 'Archive::Any::Create::Tar', { comp => 1 } ],
12 'zip' => [ 'Archive::Any::Create::Zip' ],
13 );
14  
15 3 my $re = '(' . join('|', map quotemeta, keys %Type2Class) . ')$';
16  
17 2 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
18 2 my $class = shift;
19 2 bless [ ], $class;
20 }
21  
22 2 ▶sub container {
Subroutine container: called CC=1 SCAR=0.0
Pod documented
23 2 my $self = shift;
24 2 push @$self, [ 'container', @_ ];
25 }
26  
27 4 ▶sub add_file {
Subroutine add_file: called CC=1 SCAR=0.0
Pod documented
28 4 my $self = shift;
29 4 push @$self, [ 'add_file', @_ ];
30 }
31  
32 2 ▶sub write_file {
Subroutine write_file: called CC=1 SCAR=0.0
Pod documented
33 2 my $self = shift;
34 2 $self->proxy_methods($_[0])->write_file(@_);
35 }
36  
37 2 ▶sub write_filehandle {
Subroutine write_filehandle: called CC=1 SCAR=0.0
Pod documented
38 2 my $self = shift;
39 2 $self->proxy_methods($_[1])->write_filehandle(@_);
40 }
41  
42 4 ▶sub proxy_methods {
Subroutine proxy_methods: called CC=4 SCAR=13.9
Pod undocumented
43 4 my $self = shift;
44 4 my($file) = @_;
45  
46 4 my @methods = @$self;
47  
48 4 ▶ $file =~ /$re/ or throw Archive::Any::Create::Error(error => "Can't detect archive type via filename $file");
Branch: 1 branch
BranchTrueFalseTotal
$file =~ /$re/ or "Archive::Any::Create::Error"->throw("error", "Can't detect archive type via filename $file") 4 0 4
49 4 my($subclass, $opt) = @{ $Type2Class{$1} };
50 4 ▶ $subclass->require or die $@;
Branch: 1 branch
BranchTrueFalseTotal
$subclass->require or die $@ 4 0 4
51 4 $self = bless { }, $subclass;
52 4 $self->init($opt);
53  
54 4 for my $m (@methods) {
55 12 my($method, @args) = @$m;
56 12 $self->$method(@args);
57 }
58  
59 4 $self;
60 }
61  
62 3 1;
63 __END__
↑ Summary Create/Tar.pm »