[Bps-public-commit] r16240 - in sd/trunk/lib/App/SD/Replica: hm
ruz at bestpractical.com
ruz at bestpractical.com
Tue Oct 7 20:25:44 EDT 2008
Author: ruz
Date: Tue Oct 7 20:25:43 2008
New Revision: 16240
Modified:
sd/trunk/lib/App/SD/Replica/hm.pm
sd/trunk/lib/App/SD/Replica/hm/PushEncoder.pm
Log:
* first pass on syncing HM takss with particular props
Modified: sd/trunk/lib/App/SD/Replica/hm.pm
==============================================================================
--- sd/trunk/lib/App/SD/Replica/hm.pm (original)
+++ sd/trunk/lib/App/SD/Replica/hm.pm Tue Oct 7 20:25:43 2008
@@ -11,6 +11,7 @@
has hm => ( isa => 'Net::Jifty', is => 'rw');
has remote_url => ( isa => 'Str', is => 'rw');
has hm_username => ( isa => 'Str', is => 'rw');
+has props => ( isa => 'HashRef[Str]', is => 'rw');
use constant scheme => 'hm';
use App::SD::Replica::rt;
@@ -28,8 +29,8 @@
my $self = shift;
require Net::Jifty;
- my ($server) = $self->{url} =~ m/^hm:(.*?)$/
- or die "Can't parse Hiveminder server spec. Expected hm:http://hiveminder.com";
+ my ($server, $props) = $self->{url} =~ m/^hm:(.*?)(?:\|(.*))?$/
+ or die "Can't parse Hiveminder server spec. Expected hm:http://hiveminder.com or hm:http://hiveminder.com|props";
$self->url($server);
my $uri = URI->new($server);
my ( $username, $password );
@@ -38,9 +39,13 @@
$uri->userinfo(undef);
}
$self->remote_url("$uri");
-
( $username, $password ) = $self->prompt_for_login( $uri, $username ) unless $password;
+ if ( $props ) {
+ my %props = split /=|;/, $props;
+ $self->props( \%props );
+ }
+
$self->hm(
Net::Jifty->new(
site => $self->remote_url,
@@ -98,7 +103,7 @@
group => 0,
requestor => 'me',
not_complete => 1,
-
+ %{ $self->props || {} },
)->{content}->{tasks};
return $tasks;
}
Modified: sd/trunk/lib/App/SD/Replica/hm/PushEncoder.pm
==============================================================================
--- sd/trunk/lib/App/SD/Replica/hm/PushEncoder.pm (original)
+++ sd/trunk/lib/App/SD/Replica/hm/PushEncoder.pm Tue Oct 7 20:25:43 2008
@@ -68,8 +68,7 @@
complete => 0,
will_complete => 1,
repeat_stacking => 0,
- %{ $self->_recode_props_for_integrate($change) }
-
+ %{ $self->_recode_props_for_create($change) }
);
my $txns = $self->sync_source->hm->search( 'TaskTransaction', task_id => $task->{content}->{id} );
@@ -90,6 +89,26 @@
warn "update not implemented yet";
}
+sub _recode_props_for_create {
+ my $self = shift;
+ my $attr = $self->_recode_props_for_integrate(@_);
+ my $source_props = $self->sync_source->props;
+ return $attr unless $source_props;
+
+ if ( $source_props->{'tag'} ) {
+ if ( defined $attr->{'tags'} && length $attr->{'tags'} ) {
+ $attr->{'tags'} .= ', '. $source_props->{'tag'};
+ } else {
+ $attr->{'tags'} .= ', '. $source_props->{'tag'};
+ }
+ }
+ if ( $source_props->{'tag_not'} ) {
+ die "TODO: not sure what to do here and with other *_not search arguments";
+ }
+
+ return { %$attr, %$source_props };
+}
+
sub _recode_props_for_integrate {
my $self = shift;
my ($change) = validate_pos( @_, { isa => 'Prophet::Change' } );
More information about the Bps-public-commit
mailing list