/usr/share/perl5/Dist/Metadata/Archive.pm is in libdist-metadata-perl 0.925-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 | # vim: set ts=2 sts=2 sw=2 expandtab smarttab:
#
# This file is part of Dist-Metadata
#
# This software is copyright (c) 2011 by Randy Stauner.
#
# This is free software; you can redistribute it and/or modify it under
# the same terms as the Perl 5 programming language system itself.
#
use strict;
use warnings;
package Dist::Metadata::Archive;
{
$Dist::Metadata::Archive::VERSION = '0.925';
}
BEGIN {
$Dist::Metadata::Archive::AUTHORITY = 'cpan:RWSTAUNER';
}
# ABSTRACT: Base class for Dist::Metadata archive files
use Carp (); # core
use parent 'Dist::Metadata::Dist';
push(@Dist::Metadata::CARP_NOT, __PACKAGE__);
sub new {
my $class = shift;
my $self = $class->SUPER::new(@_);
if( $class eq __PACKAGE__ ){
my $subclass = 'Dist::Metadata::' .
( $self->{file} =~ /\.zip$/ ? 'Zip' : 'Tar' );
eval "require $subclass"
or Carp::croak $@;
# rebless into format specific subclass
bless $self, $subclass;
}
return $self;
}
sub required_attribute { 'file' }
sub archive {
my ($self) = @_;
return $self->{archive} ||= do {
my $file = $self->file;
Carp::croak "File '$file' does not exist"
unless -e $file;
$self->read_archive($file); # return
};
}
sub default_file_spec { 'Unix' }
sub determine_name_and_version {
my ($self) = @_;
$self->set_name_and_version( $self->parse_name_and_version( $self->file ) );
return $self->SUPER::determine_name_and_version(@_);
}
sub file {
return $_[0]->{file};
}
sub read_archive {
Carp::croak q[Method 'read_archive' not defined];
}
1;
__END__
=pod
=encoding utf-8
=for :stopwords Randy Stauner ACKNOWLEDGEMENTS TODO dist dists dir unix checksum checksums
=head1 NAME
Dist::Metadata::Archive - Base class for Dist::Metadata archive files
=head1 VERSION
version 0.925
=head1 SYNOPSIS
my $dist = Dist::Metadata->new(file => $path_to_archive);
=head1 DESCRIPTION
This is a subclass of L<Dist::Metadata::Dist>
to enable determining the metadata from an archive file.
It is a base class for archive file formats:
=over 4
=item *
L<Dist::Metadata::Tar>
=item *
L<Dist::Metadata::Zip>
=back
It's not useful on it's own
and should be used from L<Dist::Metadata/new>.
=head1 METHODS
=head2 new
$dist = Dist::Metadata::Archive->new(file => $path);
Accepts a single C<file> argument that should be a path to a file.
If called from this base class
C<new()> will delegate to a subclass based on the filename
and return a blessed instance of that subclass.
=head2 archive
Returns an object representing the archive file.
=head2 default_file_spec
Returns C<Unix> since most archive files are be in unix format.
=head2 determine_name_and_version
Attempts to parse name and version from file name.
=head2 file
The C<file> attribute passed to the constructor,
used to load L</archive>.
=head2 read_archive
$dist->read_archive($file);
Returns a format-specific object representing the specified file.
This B<must> be defined by subclasses.
=for test_synopsis my $path_to_archive;
=head1 AUTHOR
Randy Stauner <rwstauner@cpan.org>
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2011 by Randy Stauner.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
=cut
|