NAME

Digest::Directory::BASE - base class for Directory Digests

SYNOPSIS

  use Digest::Directory::BASE;
  
  my($d) = Digest::Directory::BASE->new;
  
  $d->quiet(1);
  $d->include("/etc");
  $d->include("/usr");
  $d->exclude("/usr/local");
  $d->compute();
  $d->save("/var/dirgests/root.dirgests");

REQUIRES

Perl 5.004, Digest::MD5, File::Find, LWP::UserAgent.

EXPORTS

Nothing.

DESCRIPTION

Digest::Directory::BASE is a base class for creating digests of file and directory sets. Clients can specify include and exclude file and directory specifications, and then compute digests over these sets, with optional prefix trimming. Clients can also fetch, load, save, print, compare or export these sets.

METHODS

The following methods are provided:

$dirgest = Digest::Directory::BASE->new( )

Create a dirgest instance; sets up default options, no quiet, no includes, no excludes, zero digest and zero summary.

$dirgest->quiet( $enabled )

Enable quiet operating mode for a dirgest; ensures that no debug trace output is provided during operation.

$enabled => '0' or '1' for whether operation to be quiet or not;

$dirgest->trim( $count )

Enable trimming of file/directory names;

$count => 'n' where 'n' > 0 && 'n' specifies number of leading elements to trim, e.g. '/a/b/c' trim 2 == 'b/c';

$result = $dirgest->configure( $file )

Read a configuration file into a dirgest;

$file => filename to read configuration from;

return => '1' on success, or '0' on failure;

File should contain lines with '+name' or '-name' that are turned into include or exclude file/directory sets. All other names are ignored. Whitespace may be present: ' + name', ' +name', '+ name', etc. Also, '!trim=n' will set trim level, and '!quiet=n' will set quiet level.

$dirgest->include( $name )

Include a name in the compute set for a dirgest;

$name => particular name of file/directory set to include into compute operation.

$dirgest->exclude( $name )

Exclude a name from the compute set for a dirgest;

$name => particular name of file/directory set to exclude from compute operation.

%stats = $dirgest->statistics( )

Return a hash with statistics about the dirgest; the hash contains the following elements:

'include' => number of includes specified;

'exclude' => number of excludes specified;

'digests' => number of digests;

'quiet' => quiet enable or not;

'trim' => trim level in operation;

return => the hash;

$dirgest->clear( )

Clear a dirgest;

'clear' out all of the dirgests, and reset the summary.

$result = $dirgest->fetch( $link, $user, $pass )

Fetch dirgests from a url;

$link => the link to fetch from, should have protocol specifier, e.g. 'http://matthewgream.net', 'file://source.dirgest.org';

$user => the http username for basic authorisation (if desired);

$pass => the http password for basic authorisation (if desired);

return => '1' on success, or '0' on failure;

$result = $dirgest->load( $file )

Load dirgests from a file;

$file => the name of the file to load from;

return => '1' on success, or '0' on failure;

$result = $dirgest->save( $file )

Save dirgests to a file;

$file => the name of the file to save to;

return => '1' on success, or '0' on failure;

$result = $dirgest->compute( )

Compute dirgests from given include/exclude sets;

return => 'n' where 'n' is the number of dirgests computed;

$result = $dirgest->print( $nodetails, $nosummary )

Print a dirgest;

$nodetails => don't print detailed dirgests;

$nosummary => don't print summary dirgests;

return => 'n' where 'n' is the number of dirgests printed;

$string = $dirgest->string( $nodetails, $nosummary )

Export a dirgest;

$nodetails => don't stringify detailed dirgests;

$nosummary => don't stringify summary dirgests;

return => 'n' where 'n' is the number of dirgests printed;

$result = $dirgest->compare( $peer, $nodetails, $nosummary, $showequals )

Compare dirgest with another with options;

$peer => the peer dirgest;

$nodetails => don't compare detailed dirgests;

$nosummary => don't compare summary dirgests;

$showequals => show equal dirgests during activity;

return => 'n' where 'n' is the number of differences found;

AUTHOR

Matthew Gream (MGREAM) <matthew.gream@pobox.com>

VERSION

Version 0.90

RIGHTS

Copyright 2002 Matthew Gream. All Rights Reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.