NAME
Data::Downloader::MetadataTransformation
DESCRIPTION
Apply transformations to metadata before making linktrees.
A metadata transformation is an object which is associated with a repository, that describes a transformation that should be applied before the linktree template is filled in.
It consists of :
input - the name of the metadata item to be transformed
output - the name of the variable in the path template (or intermediate variable)
function_name - the function to be applied
function_params - the parameters to be sent to that function
Valid functions are currently :
split - split an incoming piece of metadata using a regular expression.
function_params : optional regex (defaults to whitespeace)
match - match a piece of metadata against a pattern.
function_params : regex to match against.
extract - extract a captured portion of a regular expression.
function_params : a regex with a set of capturing parentheses.
EXAMPLES
Suppose a metadata named "tags" contains a list of words separated by whitespace. The following sequence of transformations would convert this single string into a list of strings, but only include the words which contain the letter "g" or "p":
metadata_transformations:
- input : tags
output : one_tag
function_name : split
order_key : 1
- input : one_tag
output : tag
function_name : match
function_params : "g|p"
order_key : 2
After applying these transformations, the string "<tag>" may be used in the linktree templates.
METHODS
- apply
-
Apply a transformation to a hash of data.
Input : - a hash of data, one of the keys should match the input for this transformation.
Output : - an array of hashes: all of the keys are the same as the input hash, but there is a new key in each hash which corresponds to the output of the transformation.
Example :
$self->apply( { foo => "bar baz"} ); where $self->input is foo $self->output is boo $self->function_name is split produces [ { foo => "bar baz", boo => "bar" }, { foo => "bar baz", boo => "baz" } ]
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 59:
=over without closing =back