diff options
Diffstat (limited to 'lib/LXRng/Repo/Plain.pm')
-rw-r--r-- | lib/LXRng/Repo/Plain.pm | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/lib/LXRng/Repo/Plain.pm b/lib/LXRng/Repo/Plain.pm new file mode 100644 index 0000000..c30835e --- /dev/null +++ b/lib/LXRng/Repo/Plain.pm @@ -0,0 +1,38 @@ +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) = @_; + + return bless({root => $root}, $class); +} + +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; |