Eric Wilhelm > dotReader > dtRdr::Annotation::SyncRules

Download:
dotReader-v0.11.2.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  2
Open  1
View/Report Bugs
Source  

NAME ^

dtRdr::Annotation::SyncRules - rules engine

SYNOPSIS ^

  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

Constructor ^

new

  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.

Rulings ^

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.

check_srev

Returns one of FRESHEN|PUT|SKIP|CONFLICT

  my $ans = $self->check_srev($rev, $public_rev, $server_rev);

next

  my @ans = $sr->next;

Internals ^

init

  $self = $self->init;

error

  $self->error(@list);

AUTHOR ^

Eric Wilhelm <ewilhelm at cpan dot org>

http://scratchcomputing.com/

COPYRIGHT ^

Copyright (C) 2007 Eric L. Wilhelm and OSoft, All Rights Reserved.

NO WARRANTY ^

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.

LICENSE ^

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.

syntax highlighting: