Data-Utilities

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

Data::Transformator, Data::Merger, Data::Comparator perform
intelligent operations on nested perl data structures.  The
transformation engine is a general simple transformation engine and
can run in a selective mode or a constructive mode.  In the selective
mode, it behaves like a database query engine.  In the constructive
mode it constructs a result based on the structure of the original
data.  Transformations can be cascaded.  The merger also deals with
general nested perl data structures.  The Comparator generates
structured differences that mirror the structure of the compared data
structures.

To install the module...

perl Makefile.PL
make
make test
make install

lib/Data/Transformator.pm  view on Meta::CPAN

=over 2

=item

Or the data source is literal content (option name 'contents').

=item

Or the data source is an object that implements a '->generate()'
method (option name 'source'). Transformations implement themselves a
'->generate()' method such that transformations can be cascaded
easily.

=back

=item

Tell the transformation what to transform (selection) and how to
transform (generate result).  Data::Transformator uses code references
to generate results, of alternatively simpler things as explained
below.  Whenever a code reference is used, it is called with the

lib/Data/Transformator.pm  view on Meta::CPAN

=item 2

a structural simplification of the selection.

=back

=item 4

Combining the above: a query can be defined as applying (1) a
selective transformation and (2) a constructive transformation in
sequence to a preexisting data source. This is called cascaded
transformations.

=back

=head1 BUGS

Does only work with scalars, hashes and arrays.  Support for
self-referential structures seems broken at the moment.

=head1 AUTHOR

lib/Data/Transformator.pm  view on Meta::CPAN

# generate()
#
# Generate data resulting from this transformation.  This is particularly
# useful when cascading transformations.
#

sub generate
{
    my $self = shift;

    # we are being used in a transformation cascade of some sort

    return $self->transform();
}


sub new
{
    my $proto = shift;
    my $class = ref($proto) || $proto;

lib/Data/Transformator.pm  view on Meta::CPAN

sub transform
{
    my $self = shift;

    my $contents = shift;

    # construct data to be transformed

    my $data = $contents || $self->{contents};

    # if there is a cascade from a related object

    if (!$data
        && $self->{source})
    {
	# construct the data from the source

	my $source = $self->{source};

	$data = $source->generate();
    }



( run in 0.914 second using v1.01-cache-2.11-cpan-49f99fa48dc )