Contentment::Transform - Applies file content transformation
use Contentment::Transform; use IO::NestedCapture 'capture_in_out'; my $transformer = $context->transformer; my $in = IO::NestedCapture->get_next_in; # print the input to $in... capture_in_out { $transformer->apply_transformation( from => 'LaTeX', to => 'PDF', ); }; # $out here contains the output of the transformation my $out = IO::NestedCapture->get_last_out;
This module performs several tasks. The primary purpose of this module is to take generated content in some format A and find a way to transform that data into format A'.
The current format of the content is assumed to be that of the value stored in the top_level() accessor of Contentment::Response. The "kind" is just a name for the file format (often a MIME-type might be convenient, but it's just a string name). The goal for the transformation plugin is to find the cheapest translation possible to get from this kind into the final kind. The final kind is determined by the final_kind() accessor of Contentment::Request. This module attempts to find zero or more transformations that will coerce the document of the original kind into a document of the final kind.
top_level()
final_kind()
Each transformer accepts data from a given input kind and produces a document of a given output kind. (Given when the transformer is registered using the add_transformation() method.) Transformers are subroutines similar to hook handlers (see Contentment::Hooks), except they are registered using the add_transformation() method of this class. Each transformation defines a cost attribute, which associates a numeric cost to the transformation---the higher the value the more "costly" the transformation. This module will attempt to use the cheapest transformation available, but may use any found.
add_transformation()
cost
When searching for the best choice of transformers to get from original kind A to final kind A', we use Dijkstra's shortest path algorithm. (That is, an A* search with the heuristic value (H) set to zero for all nodes.)
Attempts to transform the input in STDIN from one type to another and places that output on STDOUT. Currently accepts two arguments in %args:
STDIN
STDOUT
%args
If given, this chooses the kind it will attempt to change the input into. Otherwise it will default to the value of Contentment::Request->final_kind.
Contentment::Request->final_kind
If given, this chooses the kind it will assume the output is currently in. Otherwise it will default to the value of Contentment::Response->top_kind.
Contentment::Response->top_kind
This class adds the following methods to the context:
Returns the current instance of the transformation object.
This handler is for the "Contentment::Response::filter" hook.
This handler is the for the "Contentment::begin" hook and is used to call the "Contentment::Transform::begin" hook.
Handlers for this hook receive the current context as the only argument. The purpose of this hook is to allow handlers the opportunity to register transformers.
Andrew Sterling Hanenkamp, <hanenkamp@cpan.org>
Copyright 2005 Andrew Sterling Hanenkamp. All Rights Reserved.
Contentment is distributed and licensed under the same terms as Perl itself.
2 POD Errors
The following errors were encountered while parsing the POD:
'=item' outside of any '=over'
You forgot a '=back' before '=head2'
To install Contentment, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Contentment
CPAN shell
perl -MCPAN -e shell install Contentment
For more information on module installation, please visit the detailed CPAN module installation guide.