1 package BackPAN::Index::File;
6 use File::Basename qw(basename);
9 q[""] => sub { $_[0]->path },
12 use BackPAN::Index::Role::AsHash;
15 return qw(path date size);
20 return "http://backpan.cpan.org/" . $self->path;
25 return basename $self->path;
28 # Backwards compatibility with PBP
37 my $schema = $self->result_source->schema;
38 my($release) = $schema->resultset("Release")
39 ->search({ file => $self->path }, { rows => 1 })
51 BackPAN::Index::File - Represent a file on BackPAN
55 my $b = BackPAN::Index->new();
56 my $file = $b->file("authors/id/L/LB/LBROCARD/Acme-Colour-0.16.tar.gz");
57 print " Date: " . $file->date . "\n";
58 print " Path: " . $file->path . "\n";
59 print " Size: " . $file->size . "\n";
60 print " URL: " . $file->url . "\n";
64 BackPAN::Index::File objects represent files on BackPAN. It may
65 represent a release, a readme or meta file or just some random stuff
72 my $date = $file->date;
74 Returns the upload date of the file, in UNIX epoch seconds.
78 my $path = $file->path;
80 Returns the full path to the file on CPAN.
84 my $size = $file->size;
86 Returns the size of the file in bytes.
92 Returns a URL to the file on a BackPAN mirror.
96 my $filename = $file->filename;
98 Returns the filename part of the path.
102 my $release = $file->release;
104 Returns the release associated with this file, if any, as a
105 L<BackPAN::Index::Release> instance.
109 my $data = $file->as_hash;
111 Returns a hash ref containing the data inside C<$file>.
116 Leon Brocard <acme@astray.com>
120 Copyright (C) 2005-2009, Leon Brocard
122 This module is free software; you can redistribute it or modify it under
123 the same terms as Perl itself.
127 L<BackPAN::Index>, L<BackPAN::Index::Release>