aboutsummaryrefslogtreecommitdiffstats
path: root/lib/LXRng/Repo/Plain.pm
blob: 46fb3f4342c63e31cc7a0ec334abe60e00aafca4 (plain)
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
package LXRng::Repo::Plain;

use strict;
use LXRng::Repo::Plain::Iterator;
use LXRng::Repo::Plain::File;
use LXRng::Repo::Plain::Directory;

sub new {
    my ($class, $root) = @_;

    $root .= '/' unless $root =~ /\/$/;
    return bless({root => $root}, $class);
}

sub cache_key {
    my ($self) = @_;

    return $$self{'root'};
}

sub allversions {
    my ($self) = @_;

    my @ver = (sort
	       grep { $_ ne "." and $_ ne ".." } 
	       map { substr($_, length($$self{'root'})) =~ /([^\/]*)/; $1 }
	       glob($$self{'root'}."*/"));

    return @ver;
}

sub node {
    my ($self, $path, $release) = @_;

    my $realpath = join('/', $$self{'root'}, $release, $path);
    return LXRng::Repo::Plain::File->new($path, $realpath);
}

sub iterator {
    my ($self, $release) = @_;

    return LXRng::Repo::Plain::Iterator->new($self->node('', $release));
}

1;