line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
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
|
|
|
5
|
|
1172
|
use strict; |
|
5
|
|
|
|
|
8
|
|
|
5
|
|
|
|
|
167
|
|
11
|
5
|
|
|
5
|
|
20
|
use warnings; |
|
5
|
|
|
|
|
5
|
|
|
5
|
|
|
|
|
268
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
package Dist::Metadata::Archive; |
14
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:RWSTAUNER'; |
15
|
|
|
|
|
|
|
# ABSTRACT: Base class for Dist::Metadata archive files |
16
|
|
|
|
|
|
|
$Dist::Metadata::Archive::VERSION = '0.926'; |
17
|
5
|
|
|
5
|
|
19
|
use Carp (); # core |
|
5
|
|
|
|
|
7
|
|
|
5
|
|
|
|
|
61
|
|
18
|
5
|
|
|
5
|
|
356
|
use parent 'Dist::Metadata::Dist'; |
|
5
|
|
|
|
|
211
|
|
|
5
|
|
|
|
|
26
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
push(@Dist::Metadata::CARP_NOT, __PACKAGE__); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub new { |
24
|
30
|
|
|
30
|
1
|
2956
|
my $class = shift; |
25
|
30
|
|
|
|
|
175
|
my $self = $class->SUPER::new(@_); |
26
|
|
|
|
|
|
|
|
27
|
27
|
100
|
|
|
|
71
|
if( $class eq __PACKAGE__ ){ |
28
|
21
|
100
|
|
|
|
123
|
my $subclass = 'Dist::Metadata::' . |
29
|
|
|
|
|
|
|
( $self->{file} =~ /\.zip$/ ? 'Zip' : 'Tar' ); |
30
|
|
|
|
|
|
|
|
31
|
21
|
50
|
|
|
|
1416
|
eval "require $subclass" |
32
|
|
|
|
|
|
|
or Carp::croak $@; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# rebless into format specific subclass |
35
|
21
|
|
|
|
|
111
|
bless $self, $subclass; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
27
|
|
|
|
|
79
|
return $self; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
33
|
|
|
33
|
1
|
86
|
sub required_attribute { 'file' } |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub archive { |
45
|
73
|
|
|
73
|
1
|
2339
|
my ($self) = @_; |
46
|
73
|
|
100
|
|
|
474
|
return $self->{archive} ||= do { |
47
|
24
|
|
|
|
|
96
|
my $file = $self->file; |
48
|
|
|
|
|
|
|
|
49
|
24
|
100
|
|
|
|
1156
|
Carp::croak "File '$file' does not exist" |
50
|
|
|
|
|
|
|
unless -e $file; |
51
|
|
|
|
|
|
|
|
52
|
21
|
|
|
|
|
83
|
$self->read_archive($file); # return |
53
|
|
|
|
|
|
|
}; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
|
57
|
21
|
|
|
21
|
1
|
89
|
sub default_file_spec { 'Unix' } |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub determine_name_and_version { |
61
|
22
|
|
|
22
|
1
|
39
|
my ($self) = @_; |
62
|
22
|
|
|
|
|
58
|
$self->set_name_and_version( $self->parse_name_and_version( $self->file ) ); |
63
|
22
|
|
|
|
|
159
|
return $self->SUPER::determine_name_and_version(@_); |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub file { |
68
|
48
|
|
|
48
|
1
|
214
|
return $_[0]->{file}; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub read_archive { |
73
|
0
|
|
|
0
|
1
|
|
Carp::croak q[Method 'read_archive' not defined]; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
1; |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
__END__ |