Michael Aquilina > Data-Pensieve-0.03a > Data::Pensieve

Download:
Data-Pensieve-0.03a.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  1
Open  0
View/Report Bugs
Module Version: 0.03   Source  

NAME ^

Data::Pensieve - Simple tool for interacting with revisioned data

SYNOPSIS ^

    use Data::Pensieve;
    
    my $pensieve = Data::Pensieve->new(
        revision_rs      => $c->model('DB::Revision'),
        revision_data_rs => $c->model('DB::RevisionData'),
        definitions      => {
            lolcats => [ qw/name saying picture/ ],
        },
    );
    
    $pensieve->store_revision(
        lolcats => 1,
        {
            # data
            name    => 'lazy lolcat',
            saying  => 'i cannot brian today. i have the dumb',
            picture => 'lazycat.png',
        },
        {
            # change metadata
            modified_by => 'waffle wizard',
        },
    );

    # oops! a typo! time to denote a change.
    $pensieve->store_revision(
        lolcats => 1,
        {
            # data
            saying => 'i cannot brain today. i have the dumb',
        },
        {
            # change metadata
            modified_by => 'assistant regional manager',
        },
    );
    
    my @revisions = $pensieve->get_revisions(lolcats => 1);
    
    my ($rev1, $rev2) = @revisions;

    my $comparison = $pensieve->compare_revisions($rev1, $rev2);
    # {
    #   saying => [
    #       'i cannot brian today. i have the dumb',
    #       'i cannot brain today. i have the dumb'
    #   ]
    # }

DESCRIPTION ^

"I use the Pensieve. One simply siphons the excess thoughts from one's mind, pours them into the basin, and examines them at one's leisure. It becomes easier to spot patterns and links, you understand, when they are in this form." - Albus Dumbledore

In the world of Harry Potter, a Pensieve is a magical device that allows a wizard to store and review his or her thoughts. Data::Pensieve serves a similar purpose for Perl applications, allowing you to easily record revision histories and analyze differences between revisions.

Data::Pensieve uses a DBIx::Class backend to store revision data.

METHODS ^

new()

Returns a new Data::Pensieve object. Takes the following required parameters.

store_revision()

Given a grouping, item, hash reference of data, and optional hash reference of metadata related to this change, stores a change.

get_revisions()

Given a grouping and item number, returns all associated revisions.

get_last_revision()

Given a grouping and item number, returns the last revision.

compare_revisions()

Given two Data::Pensieve::Revision objects, returns a hash reference, keyed by column name, containing array references of the prior and current version of all changed data between the two provided revisions.

diff_revisions()

Same as compare_revisions(), but returns a diff between the two values instead of an array reference.

SEE ALSO ^

Data::Pensieve is intended as a quick & dirty, plug & play way to easily manage revisioned data.

If you're looking to do something more substantial, you probably want to consider journaling your data at the database level -- check out DBIx::Class::AuditLog or DBIx::Class::Journal.

DEPENDENCIES ^

Carp, DateTime, DateTime::Format::MySQL, DBIx::Class, List::Util, List::MoreUtils, Moose, Storable, Text::Diff

AUTHORS ^

Michael Aquilina <aquilina@cpan.org>

Developed for Grant Street Group's Testafy (http://testafy.com)

syntax highlighting: