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#
10use strict;
11use warnings;
12
13package Dist::Metadata::Tar;
14our $AUTHORITY = 'cpan:RWSTAUNER';
15# ABSTRACT: Enable Dist::Metadata for tar files
16$Dist::Metadata::Tar::VERSION = '0.926';
17use Archive::Tar 1 ();   # 0.07 isn't good enough
18use Carp (); # core
19use parent 'Dist::Metadata::Archive';
20
21push(@Dist::Metadata::CARP_NOT, __PACKAGE__);
22
23sub file_content {
24  my ( $self, $file ) = @_;
25  return $self->archive->get_content( $self->full_path($file) );
26}
27
28sub find_files {
29  my ($self) = @_;
30  return
31    map  { $_->full_path }
32    grep { $_->is_file   }
33      $self->archive->get_files;
34}
35
36sub read_archive {
37  my ($self, $file) = @_;
38
39  my $archive = Archive::Tar->new();
40  $archive->read($file);
41
42  return $archive;
43}
44
45sub tar {
46  warn __PACKAGE__ . '::tar() is deprecated.  Use archive() instead.';
47  return $_[0]->archive;
48}
49
501;
51
52__END__
53
54=pod
55
56=encoding UTF-8
57
58=for :stopwords Randy Stauner ACKNOWLEDGEMENTS TODO dist dists dir unix checksum checksums
59David Jeffrey Ryan Sawyer Steinbrunner Thalhammer X
60
61=head1 NAME
62
63Dist::Metadata::Tar - Enable Dist::Metadata for tar files
64
65=head1 VERSION
66
67version 0.926
68
69=head1 SYNOPSIS
70
71  my $dist = Dist::Metadata->new(file => $path_to_archive);
72
73=head1 DESCRIPTION
74
75This is a subclass of L<Dist::Metadata::Dist>
76(actually of L<Dist::Metadata::Archive>)
77to enable determining the metadata from a tar file.
78
79This is probably the most useful subclass.
80
81It's probably not very useful on it's own though,
82and should be used from L<Dist::Metadata/new>.
83
84=for Pod::Coverage tar
85
86=for test_synopsis my $path_to_archive;
87
88=head1 AUTHOR
89
90Randy Stauner <rwstauner@cpan.org>
91
92=head1 COPYRIGHT AND LICENSE
93
94This software is copyright (c) 2011 by Randy Stauner.
95
96This is free software; you can redistribute it and/or modify it under
97the same terms as the Perl 5 programming language system itself.
98
99=cut
100