NAME

File::Sticker::Derive - derive values from existing meta-data

VERSION

version 4.9

SYNOPSIS

use File::Sticker::Derive;

my $deriver = File::Sticker::Derive->new(%args);

my $derived_meta = $deriver->derive(filename=>$filename,meta=>$meta);

DESCRIPTION

This will derive values from existing meta-data.

This is a plug-in, different plug-ins will do different derivations.

DEBUGGING

whoami

Used for debugging info

METHODS

new

Create a new object, setting global values for the object.

my $obj = File::Sticker::Derive->new();

init

Initialize the object.

$deriver->init(%args);

name

The name of the deriver; this is basically the last component of the module name. This works as either a class function or a method.

$name = $self->name();

$name = File::Sticker::Derive::name($class);

order

The order of this deriver, ranging from 0 to 99. This makes sure that the deriver is applied in order; useful because a later deriver may depend on data created by an earlier deriver.

This must be overridden by the specific deriver class.

derive

Derive common values from the existing meta-data. This UPDATES the passed-in meta hash.

This must be overridden by the specific deriver class.

my $newmeta = $deriver->derive(filename=>$filename, meta=>$meta, overwrite=>\%overwrite);

Helper Functions

Private interface.

_overwrite_allowed

Check whether the given field is allowed to be overwritten. This is true when the value of the field is empty, or if the field name is in the passed-in "overwrite" hash.

my $okay = $deriver->_overwrite_allowed(meta=>$meta,field=>$field,overwrite=>\%overwrite);

_set_field

Set the value of the given field in the meta hash, checking whether it is allowed to be overwritten.

my $meta = $deriver->_set_field(meta=>$meta,field=>$field,value=>$value,overwrite=>\%overwrite);

BUGS

Please report any bugs or feature requests to the author.