View on
MetaCPAN is shutting down
For details read Perl NOC. After June 25th this page will redirect to
Brian Duggan > Data-Downloader-0.9905 > Data::Downloader::MetadataTransformation



Annotate this POD


New  1
Open  0
View/Report Bugs
Source   Latest Release: Data-Downloader-0.9907




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.


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":

     - 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.



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"} );
     $self->input    is foo
     $self->output   is boo
     $self->function_name is split
    [ { foo => "bar baz", boo => "bar" },
      { foo => "bar baz", boo => "baz" } ]
syntax highlighting: