dtRdr::Annotation::SyncRules - rules engine
my $sr = dtRdr::Annotation::SyncRules->new( current => \@current, deleted => \@deleted, manifest => \%s_man, error => sub {die @_, "..."}, ); while(my @ans = $sr->next) { my ($action, $object) = @ans; # then do something with them } # and maybe something to finish
my $sr = dtRdr::Annotation::SyncRules->new( current => [@current], deleted => [@deleted], manifest => {%s_man}, error => sub {die @_}, )->init;
The references will be modified in-place, so deref accordingly.
FRESHEN is really just GET, but is an update. By definition, if we're talking to check_srev, we have it and so does the server.
deleted: (implies mine) verify srev and DELETE; finish_delete current: (mine) shas: Y: check_srev ? PUT : FRESHEN :: NOOP # quaternary? N: has_prev ? (really_delete) : POST notmine: shas: Y: check_srev ? die : FRESHEN :: NOOP N: really_delete
Where:
check_srev := {(rev > prev) ? ((srev > prev) ? CONFLICT : 1) : (srev > prev ? 0 : (srev < prev ? ERROR : SKIP)))}
Ok, so that's a ternary boolean. It returns true if we should push, false if we should pull, SKIP if nothing changed. (Aside: (srev < prev) is an error in-general and can be checked beforehand.)
What's left in the server manifest after that should be only new incoming annotations.
Returns one of FRESHEN|PUT|SKIP|CONFLICT
my $ans = $self->check_srev($rev, $public_rev, $server_rev);
my @ans = $sr->next;
$self = $self->init;
$self->error(@list);
Eric Wilhelm <ewilhelm at cpan dot org>
http://scratchcomputing.com/
Copyright (C) 2007 Eric L. Wilhelm and OSoft, All Rights Reserved.
Absolutely, positively NO WARRANTY, neither express or implied, is offered with this software. You use this software at your own risk. In case of loss, no person or entity owes you anything whatsoever. You have been warned.
The dotReader(TM) is OSI Certified Open Source Software licensed under the GNU General Public License (GPL) Version 2, June 1991. Non-encrypted and encrypted packages are usable in connection with the dotReader(TM). The ability to create, edit, or otherwise modify content of such encrypted packages is self-contained within the packages, and NOT provided by the dotReader(TM), and is addressed in a separate commercial license.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
To install dtRdr, copy and paste the appropriate command in to your terminal.
cpanm
cpanm dtRdr
CPAN shell
perl -MCPAN -e shell install dtRdr
For more information on module installation, please visit the detailed CPAN module installation guide.