App-SD

 view release on metacpan or  search on metacpan

lib/App/SD/Replica/gcode/PushEncoder.pm  view on Meta::CPAN

package App::SD::Replica::gcode::PushEncoder;
use Any::Moose;
use Params::Validate;
use Net::Google::Code::Issue;
use Net::Google::Code;
use Try::Tiny;

has sync_source => (
    isa => 'App::SD::Replica::gcode',
    is  => 'rw',
);

sub integrate_change {
    my $self = shift;
    my ( $change, $changeset ) = validate_pos(
        @_,
        { isa => 'Prophet::Change' },
        { isa => 'Prophet::ChangeSet' }
    );
    my ( $id, $record );

# if the original_sequence_no of this changeset is <=
# the last changeset our sync source for the original_sequence_no, we can skip it.
# XXX TODO - this logic should be at the changeset level, not the cahnge level, as it applies to all
# changes in the changeset
#    warn $self->sync_source->app_handle->handle->last_changeset_from_source(
#        $changeset->original_source_uuid ), "\n";
    return
      if $self->sync_source->app_handle->handle->last_changeset_from_source(
        $changeset->original_source_uuid ) >= $changeset->original_sequence_no;

    my $before_integration = time();

    # grab any email/password that may have been specified in the --to url
    my ( $email, $password ) = ($self->sync_source->gcode->email,
                                $self->sync_source->gcode->password);

    ($email, $password) = $self->sync_source->login_loop(
        uri => 'gcode:' . $self->sync_source->project,
        username => $email, password => $password,
        # remind the user that gcode logins are email addresses
        username_prompt => sub {
            my $project = shift;
            return "Login email for $project: ";
        },
        login_callback => sub {
            my ($self, $email, $password) = @_;

            # gcode.pm's BUILD has already been called, so we don't need to
            # create the initial object, just specify auth
            $self->gcode->email($email);
            $self->gcode->password($email);
            $self->gcode->sign_in;
        },
        catch_callback => sub {
            my $error = shift;
            $error =~ s/at .* line [0-9]+\.//;

            warn "\n$error\n";
        },
    );

    try {
        if (    $change->record_type eq 'ticket'
            and $change->change_type eq 'add_file' )
        {



( run in 0.488 second using v1.01-cache-2.11-cpan-39bf76dae61 )