}
use Any::Moose;
extends 'Prophet::Replica';
use File::Spec;
use Params::Validate qw(:all);
use JSON;
use Prophet::Util;
sub replica_exists {
my $self = shift;
return $self->uuid ? 1 : 0;
_no => 1
}
);
require Prophet::ChangeSet;
my $content_struct = from_json( $args{content}, { utf8 => 1 } );
my $changeset = Prophet::ChangeSet->new_from_hashref($conte
I::Command::Settings::VERSION = '0.751';
}
use Any::Moose;
use Params::Validate qw/validate/;
use JSON;
extends 'Prophet::CLI::Command';
with 'Prophet::CLI::TextEditorCommand';
sub ARG_TRANSLATIONS
ngs edit
${cmd}settings set -- setting "new value"
Note that setting values must be valid JSON.
END_USAGE
}
sub run {
my $self = shift;
$self->print_usage if $self->has_arg('h');
ue to $new_value.\n";
if ( $old_value ne $new_value ) {
$s->set( from_json( $new_value, { utf8 => 1 } ) );
print " -> Changed.\n";
} else {
tting::VERSION = '0.751';
}
use Any::Moose;
extends 'Prophet::Record';
use Params::Validate;
use JSON;
has default => ( is => 'ro', );
has label => (
isa => 'Str|Undef',
is => 'rw',
);
ha
) ) {
$entry = [@_];
} else {
$entry = shift @_;
}
my $content = to_json(
$entry,
{
canonical => 1,
pretty => 0,
nless $self->load( uuid => $self->uuid );
my $content = $self->get_raw;
my $entry = from_json( $content, { utf8 => 1 } );
return $entry;
}
__PACKAGE__->meta->make_immutable;
no Any::Moos
e Prophet::Web::Result;
use Params::Validate qw/:all/;
use File::Spec ();
use Cwd ();
use JSON;
use HTTP::Date;
# Only define a class type constraint for CGI if it's not already defined,
# be
>cgi->param($_) } $self->cgi->param() } );
$self->_send_redirect( to => "/records/$type/$uuid.json" );
}
sub create_record {
my $self = shift;
my $type = shift;
my $record = $self
aram($_) } $self->cgi->param() } );
return $self->_send_redirect( to => "/records/$type/$uuid.json" );
}
sub get_record_prop {
my $self = shift;
my $type = shift;
my $uuid = shi
reference to a hash representation of a change (such as is returned by
L</as_hash> or serialized json) and returns a new Prophet::Change
representation of it.
This method should be invoked as a clas
nflict->has_conflicting_changes;
$self->log_debug( "Conflicting changeset: "
. JSON::to_json( $conflict, { allow_blessed => 1 } ) );
return $conflict;
}
sub _check_db_uuids_on_mer
= shift;
my $default = shift;
my $json = $self->read_userdata( path => $path ) || $default;
require JSON;
return JSON::from_json( $json, { utf8 => 1 } );
}
sub _do_userdata_writ
my $self = shift;
my $path = shift;
my $value = shift;
require JSON;
my $content =
JSON::to_json( $value, { canonical => 1, pretty => 0, utf8 => 1 } );
$self->write_user
entAddressedStore;
{
$Prophet::ContentAddressedStore::VERSION = '0.751';
}
use Any::Moose;
use JSON;
use Digest::SHA qw(sha1_hex);
has fs_root => ( is => 'rw', );
has root => (
isa => 'Str',
$content ) = @_;
$content = $$content
if ref($content) eq 'SCALAR';
$content = to_json( $content, { canonical => 1, pretty => 0, utf8 => 1 } )
if ref($content);
my $fingerpri
te.
use Any::Moose;
use Prophet::Change;
use Params::Validate;
use Digest::SHA qw/sha1_hex/;
use JSON;
has creator => (
is => 'rw',
isa => 'Str|Undef',
);
has created => (
is =>
calculate_sha1 {
my $self = shift;
return sha1_hex( $self->canonical_json_representation );
}
sub canonical_json_representation {
my $self = shift;
my $hash_changeset = $se
ete $hash_changeset->{'sequence_no'};
delete $hash_changeset->{'source_uuid'};
return to_json( $hash_changeset,
{ canonical => 1, pretty => 0, utf8 => 1 } );
}
__PACKAGE__->meta->ma
olutionDB::VERSION = '0.751';
}
use Any::Moose;
use Prophet::Change;
use Prophet::Collection;
use JSON;
use Digest::SHA 'sha1_hex';
extends 'Prophet::Resolver';
sub run {
my $self =
y %answer_count;
for my $answer ( $res->items ) {
my $key = sha1_hex(
to_json(
$answer->get_props, { utf8 => 1, pretty => 1, canonical => 1 }
)
eplica';
use Params::Validate qw(:all);
use File::Spec ();
use File::Path;
use Prophet::Util;
use JSON;
use Digest::SHA qw/sha1_hex/;
use DBI;
has dbh => (
is => 'rw',
isa => 'DBI::d
;
my $cs = $self->_load_changeset_from_db( sha1 => $args{sha1} );
return $cs->canonical_json_representation;
}
sub _load_changeset_from_db {
my $self = shift;
my %args = validate(
e::Find;
use Prophet::Util;
use POSIX qw();
use Memoize;
use Prophet::ContentAddressedStore;
use JSON;
use Digest::SHA qw(sha1_hex);
has '+db_uuid' => (
lazy => 1,
default => sub { shift-
$args{'type'},
uuid => $args{'uuid'}
);
return unless $casfile;
return from_json( $self->_read_file($casfile), { utf8 => 1 } );
}
# XXX TODO: memoize doesn't work on win:
# t\re
ecord_prop( $1, $2, $3 ) };
on qr|^/(.*)/(.*).json$| =>
sub { shift->server->update_record( $1, $2 ) };
on qr|^/(.*).json$| => sub { shift->server->create_record($1) };
}
/static/prophet/(.*)$' =>
sub { shift->server->send_static_file($1) };
on qr'^/records.json' => sub { shift->server->get_record_types };
under qr'/records' => sub {
on qr|^/(.*)
ecord_prop( $1, $2, $3 ); };
on qr|^/(.*)/(.*).json$| =>
sub { shift->server->get_record( $1, $2 ) };
on qr|^/(.*).json$| => sub { shift->server->get_record_list($1) };
'0.751';
}
use Any::Moose;
use Prophet::Meta::Types;
use Prophet::ConflictingPropChange;
use JSON 'to_json';
use Digest::SHA 'sha1_hex';
has record_type => (
is => 'rw',
isa => 'Str',
);
h
( delete $_->{source_new_value}, delete $_->{target_value} ) ];
}
return sha1_hex( to_json( $struct, { utf8 => 1, canonical => 1 } ) );
}
__PACKAGE__->meta->make_immutable;
no Any::Moose;