eneric DiaColloDB utilities
package DiaColloDB::Utils;
use DiaColloDB::Logger;
use Exporter;
use JSON;
use IO::Handle;
use IO::File;
use IPC::Run;
use File::Basename qw(basename dirname);
use File::P
ags fcread fcwrite fctrunc fccreat fcperl fcopen fcgetfl)],
json => [qw(jsonxs loadJsonString loadJsonFile saveJsonString saveJsonFile)],
sort => [qw(sortCmd csort_to csortuc_to)],
ru
===
## Functions: JSON
##--------------------------------------------------------------
## JSON: load
## $data = PACKAGE::loadJsonString( $string,%opts)
## $data = PACKAGE::loadJsonString(\$string,%
to a
local non-directory path. Configuration files accepted by this method
are expected to be in JSON format as accepted by
L<DiaColloDB::Persistent::readHeaderFile()|DiaColloDB::Persistent/readHeade
=========
## I/O: JSON
$thingy = $obj->TO_JSON();
$str = $obj->saveJsonString(%opts);
$bool = $obj->saveJsonFile($filename_or_handle, %opts);
$obj = $CLASS_OR_OBJECT->loadJsonData( $data,%opts)
;
$obj = $CLASS_OR_OBJECT->loadJsonString( $string,%opts);
$obj = $CLASS_OR_OBJECT->loadJsonFile($filename_or_handle,%opts);
##====================================================================
ble methods for
determining disk usage and file timestamps,
text I/O,
and object metadata I/O via JSON header files.
=cut
##----------------------------------------------------------------
## DESCRI
B::Corpus;
use DiaColloDB::Document;
use DiaColloDB::Document::DDCTabs;
use DiaColloDB::Document::JSON;
use DiaColloDB::Document::Storable;
#use DiaColloDB::Document::TCF; ##-- only loaded on request
#&& !$opts{glob}
&& -e "$sources->[0]/header.json"
)) {
require DiaColloDB::Corpus::Compiled;
bless($corpus,'DiaCo
pFile;
use DiaColloDB::Logger;
use DiaColloDB::Persistent;
use DiaColloDB::Utils qw(:fcntl :file :json :pack);
use Fcntl qw(:DEFAULT :seek);
use File::Basename qw(basename dirname);
use version;
use s
---------------------------------------
## I/O: JSON
## #+ INHERITED from DiaCollocDB::Persistent
BEGIN {
# *TO_JSON = \&TO_JSON__table;
}
sub TO_JSON__table {
my $p = shift;
my @fnames = (grep
(map {$key=$_; [(map {$_->{$key}} @funcs), split(/\t/,$key)]} @keys),
],
};
}
sub TO_JSON__flat {
my $p = shift;
my $keyf = (grep {defined($p->{$_})} qw(f2 f12),$p->scoreKeys)[0];
m
onents(
"InflateColumn::DateTime",
"InflateColumn::Serializer",
"InflateColumn::Serializer::JSON",
);
__PACKAGE__->table("coverage");
__PACKAGE__->add_columns(
"event_uuid",
{ data_type => "
onents(
"InflateColumn::DateTime",
"InflateColumn::Serializer",
"InflateColumn::Serializer::JSON",
);
__PACKAGE__->table("test_files");
__PACKAGE__->add_columns(
"test_file_id",
{
data_t
undef
result <required>
rownr <required>
values undef
=over 2
=item answer => JSON
The JSON structure from the result which represents this row.
=item doc => L<Couch::DB::Document|Cou
ault to
the C<answer>.
=back
=back
=head2 Accessors
=over 4
=item $obj-E<gt>B<answer>()
The JSON fragment from the result answer which contains the information
about this row.
=item $obj-E<gt>B
onents(
"InflateColumn::DateTime",
"InflateColumn::Serializer",
"InflateColumn::Serializer::JSON",
);
__PACKAGE__->table("coverage_manager");
__PACKAGE__->add_columns(
"coverage_manager_id",
warnings;
our $VERSION = '2.000006'; # TRIAL
use Term::Table;
use Test2::Harness::Util::JSON qw/decode_json/;
use App::Yath::Schema::Util qw/schema_config_from_settings/;
use parent 'App::Yath::Co
,
);
my $data = [];
while (my $run = $runs->next) {
push @$data => $run->TO_JSON;
}
return undef unless @$data;
return $data;
}
sub get_from_http {
my $self =
->{status}: $res->{reason}\n$res->{content}\n"
unless $res->{success};
return decode_json($res->{content});
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
App::Yath::Command::recent
onents(
"InflateColumn::DateTime",
"InflateColumn::Serializer",
"InflateColumn::Serializer::JSON",
);
__PACKAGE__->table("sweeps");
__PACKAGE__->add_columns(
"sweep_id",
{
data_type
onents(
"InflateColumn::DateTime",
"InflateColumn::Serializer",
"InflateColumn::Serializer::JSON",
);
__PACKAGE__->table("source_subs");
__PACKAGE__->add_columns(
"source_sub_id",
{
data
onents(
"InflateColumn::DateTime",
"InflateColumn::Serializer",
"InflateColumn::Serializer::JSON",
);
__PACKAGE__->table("api_keys");
__PACKAGE__->add_columns(
"value",
{ data_type => "uuid"
onents(
"InflateColumn::DateTime",
"InflateColumn::Serializer",
"InflateColumn::Serializer::JSON",
);
__PACKAGE__->table("projects");
__PACKAGE__->add_columns(
"project_id",
{ data_type => "
onents(
"InflateColumn::DateTime",
"InflateColumn::Serializer",
"InflateColumn::Serializer::JSON",
);
__PACKAGE__->table("coverage_manager");
__PACKAGE__->add_columns(
"coverage_manager_id",
onents(
"InflateColumn::DateTime",
"InflateColumn::Serializer",
"InflateColumn::Serializer::JSON",
);
__PACKAGE__->table("events");
__PACKAGE__->add_columns(
"event_uuid",
{ data_type => "uu
ype => "boolean", is_nullable => 0 },
"facets",
{ data_type => "jsonb", is_nullable => 1 },
"rendered",
{ data_type => "jsonb", is_nullable => 1 },
);
__PACKAGE__->set_primary_key("event_id");
eeper;
use App::Yath::Server::Response qw/resp error/;
use Test2::Harness::Util::JSON qw/encode_json encode_pretty_json/;
use parent 'App::Yath::Server::Controller';
use Test2::Harness::Util::HashBas
tent_type($ct);
if ($ct eq 'application/json') {
$res->raw_body($purged);
}
else {
$res->raw_body("<pre>" . encode_pretty_json($purged) . "</pre>");
}
return $res
onents(
"InflateColumn::DateTime",
"InflateColumn::Serializer",
"InflateColumn::Serializer::JSON",
);
__PACKAGE__->table("reporting");
__PACKAGE__->add_columns(
"reporting_id",
{ data_type =
:InflateColumn::Serializer::JSON->get_unfreezer('data', {}),
deflate => DBIx::Class::InflateColumn::Serializer::JSON->get_freezer('data', {}),
},
);
sub TO_JSON {
my $self = shift;
my %cols = $self->get_all_fields;
$cols{data} = decode_json($cols{data}) if $cols{data} && !ref($cols{data});
return \%cols;
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
App::Yath::Sc