NAME

Posy::Plugin::FileStats - Posy plugin to cache file statistics

VERSION

This describes version 0.11 of Posy::Plugin::FileStats.

SYNOPSIS

    @plugins = qw(Posy::Core
		  ...
		  Posy::Plugin::FileStats
		  ...
		  ));
    @actions = qw(
	....
	index_entries
	index_file_stats
	...
	);

DESCRIPTION

This is a "utility" plugin to be used by other plugins; it maintains a list (and cache) of file statistics in $self->{file_stats} which can be used by other plugins (such as Posy::Plugin::LinkSized).

It provides an action method "index_file_stats" which should be put after "index_entries" in the action list.

The file_stats hash is referenced by the full name of the file.

The statistics kept are:

size

The size of the file in bytes.

size_string

The size of the file as a string (with K or M as appropriate).

mime_type

The MIME type of the file.

mtime

For convenience, copies the mtime from $self->{files} or $self->{others} for the given file.

word_count

The word-count of text and HTML files.

Configuration

The following config values can be set:

file_stats_cachefile

The full name of the file to be used to store the cache. Most people can just leave this at the default.

OBJECT METHODS

Documentation for developers and those wishing to write plugins.

init

Do some initialization; make sure that default config values are set.

Flow Action Methods

Methods implementing actions.

index_file_stats

Find statistics about entry and other files.

Expects $self->{path}, $self->{config}, $self->{files} and $self->{others} to be set.

Helper Methods

Methods which can be called from elsewhere.

get_mime_type

$mime_type = $self->get_mime_type($fullname);

Get the MIME type of the given file.

get_word_count

$word_count = $self->get_word_count($fullname, $mime_type);

Get the word-count of the given file.

Private Methods

Methods which may or may not be here in future.

_size_string

$size_str = $self->_size_string($size);

Given a size in bytes, give a human-friendly size string (for example, so many K).

_fs_init_caching

Initialize the caching stuff used by index_entries

_fs_read_cache

Reads the cached information used by index_entries

_fs_save_cache

Saved the information gathered by index_entries to caches.

REQUIRES

Posy
Posy::Core

File::stat
File::MMagic

Test::More

SEE ALSO

perl(1). Posy

BUGS

Please report any bugs or feature requests to the author.

AUTHOR

Kathryn Andersen (RUBYKAT)
perlkat AT katspace dot com
http://www.katspace.com

COPYRIGHT AND LICENCE

Copyright (c) 2005 by Kathryn Andersen

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