Jason W. May > Data-Library-0.2 > Data::Library::OnePerFile

Download:
Data-Library-0.2.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.2   Source  

NAME ^

Data::Library::OnePerFile - one-item-per-file repository support class

SYNOPSIS ^

Provides a general repository service. This package supports source data in files, where each file contains a single source item. A tag corresponds to a filename (tag.EXTENSION where EXTENSION is specified at initialization). Searching will be done through a list of directories. The first matching file will be used. Conflicts are not detected.

OnePerFile recognizes when a source file is changed.

METHODS ^

new
  my $library = new Data::Library::OnePerFile
                  ({ name => "value" ... });

Supported Library::OnePerFile parameters:

  LIB         Search path for data files.  Defaults to current directory.

  EXTENSION   Filename extension for data files.  Defaults to "data".
lookup
  $library->lookup($tag);

Returns cached data items. If the source has changed since it was cached, returns false.

find
  $library->find($tag);

Searches through the directory path in LIB for a file named "$tag.EXTENSION". Returns the contents of that file if successful, and records the path for subsequent checking by lookup().

cache
  $library->cache($tag, $data);

Caches data by tag for later fetching via lookup().

toc
  my @array = $library->toc();

Search through the library and return a list of all available entries. Does not import any of the items.

reset
  $library->reset;

Erase all entries from the cache.

AUTHOR ^

Jason W. May <jmay@pobox.com>

COPYRIGHT ^

Copyright (C) 2001,2002 Jason W. May. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

syntax highlighting: