package Text::Wigwam::Paths;

    use strict;
    use warnings;
    our $VERSION = '0.01';

    use Text::Wigwam::Paths::Class;

    sub new {
        my ($pkg, @pathkeys) = @_;
        my $paths = {};
        $paths->{lc $_} = Text::Wigwam::Paths::Class->new(lc $_) for @pathkeys;
        return bless $paths, ref($pkg) || $pkg;
    }

    sub set {
        my ($self, $path, @args) = @_;
        my $key = $self->_valid_path_opt( $path ) or return;
        return $self->{$key}->set(@args);
    }

    sub add {
        my ($self, $path, @args) = @_;
        my $key = $self->_valid_path_opt( $path ) or return;
        return $self->{$key}->add(@args);
    }

    sub get { $_[0]->add( $_[1] ) }
    sub pre {
        my ($self, $path, @args) = @_;
        my $key = $self->_valid_path_opt( $path ) or return;
        return $self->{$key}->pre(@args);
    }
    sub find_file {
        my ($self, $path, @args) = @_;
        my $key = $self->_valid_path_opt( $path ) or return;
        return $self->{$key}->file(@args);
    }

    sub find_folder {
        my ($self, $path, $folder) = @_;
        my $key = $self->_valid_path_opt( $path ) or return;
        return $self->{$key}->folder($folder);
    }

    sub finder {
        my ($self, $path) = @_;
        my $key = $self->_valid_path_opt( $path ) or return;
        return $self->{$key};
    }

 # Private methods begin here

    sub _valid_path_opt {
        my ($self, $class) = @_;
        my $opts = join( "|", keys %$self );
        return lc $1 if $class =~ /^($opts)/i;
        warn "Invalid path class '$class'";
        return undef;
    }

1;

__END__

This module was designed to manage several lists of arbitrary directory
paths. Each list is identified by a unique name or 'key', which is
defined during the construction phase.

 my $Paths = Text::Wigwam::Paths->new qw( path1 path2 path3 );

Each path list can then be manipulated via a few simple methods.

The set method replaces any pre-existing list with a new list and then
returns the new list.

 $Paths->set( path1 => @pathlist );

The add method appends new list items to the end of any pre-existing
list items, then returns the new list.

 my @path2 = $Paths->add( path2 => '/path/to/alt/files' );

The get method simply returns the specified list.

 my @path3 = $Paths->get qw( path3 );

Keys are designed to be somewhat forgiving. They are not case sensitive,
and will be accepted in many cases even if they contain extra trailing
characters (this may change in future versions, however).

Unrecognized keys will be ignored by all methods, though a quiet warning
will be issued.
