we can do the work associated with it!
$job->process();
The job data must be serializable to JSON, and it is recommended that you use a hash for it. See below for a list of the supported job opti
compare';
use AptPkg::Config '$_config';
use LWP::Simple 'mirror', 'RC_OK';
use Carp 'croak';
use JSON::Util;
use CPAN::Version;
use Storable 'dclone';
use List::MoreUtils 'uniq';
use File::is;
use D
filename } @existing;
if (mirror($url, $filename) == RC_OK) {
my $json_filename = $filename; $json_filename =~ s/\.bz2$/.json/;
my $content;
my $bz_content = IO::Any->slurp($filename);
b
ror\n";
JSON::Util->encode([$self->_parse_perlpackages_content($content)], $json_filename);
}
}
# remove no longer wanted indexes
foreach my $old_filename (@existing) {
my $json_filename =
:DBI::Test::SQLite;
{
$Hypatia::DBI::Test::SQLite::VERSION = '0.029';
}
use Moose;
use DBI;
use JSON;
use Path::Class;
use namespace::autoclean;
has 'sqlite_dir'=>(isa=>'Str', is=>'ro',default=>sub
my $table=$self->table;
my $json_str="";
$json_str.= " " .$_ while(<DATA>);
my $table_data=JSON->new->relaxed->utf8->decode($json_str);
my $found=0;
fo
EST-y subclass of Catalyst::Request
=head1 SYNOPSIS
if ( $c->request->accepts('application/json') ) {
...
}
my $types = $c->request->accepted_content_types();
=head1 DESCRI
iles (initially XML or ini; the only thing making this difficult for JSON is that queries usually take more than one line, and JSON doesn't support multi-line strings).
=item * Finish up some more of
package Qless::Client;
=head1 NAME
Qless::Client
=cut
use strict; use warnings;
use JSON::XS qw(decode_json);
use Sys::Hostname qw(hostname);
use Time::HiRes qw();
use Qless::Lua;
use Qless::Config
t
sub tags {
my ($self, $offset, $count) = @_;
$offset ||= 0;
$count ||= 100;
return decode_json($self->_tag([], 'top', $offset, $count));
}
=head2 C<event - TBD>
Listen for a single event
=cu
use warnings;
use base 'Qless::BaseJob';
use Qless::Utils qw(fix_empty_array);
use JSON::XS qw(decode_json encode_json);
use Class::Load qw(try_load_class);
use Time::HiRes qw();
sub new {
my $class
ient'}->_put([$queue],
$self->jid,
$self->klass,
encode_json($self->data),
Time::HiRes::time,
$delay||0,
'depends', encode_json($depends||[])
);
}
sub complete {
my ($self, $next, $dela
>worker_name, $self->queue_name,
Time::HiRes::time, encode_json($self->data), 'next', $next, 'delay', $delay||0, 'depends', encode_json($depends||[])
);
}
else {
return $self->client->_comple
f ($response->content_type =~ m'^(application/rdf\+xml|(application|text)/(x-)?(rdf\+)?(turtle|n3|json))'i)
{
if (uc $response->request->method ne 'GET')
{
$self->_ua->max_redirect(3);
$res
le';
$type = 'RDFXML' if $response->content_type =~ /rdf.xml/;
$type = 'RDFJSON' if $response->content_type =~ /json/;
}
else
{
return ($response, undef);
}
$response->is_success or retu
arnings;
use base 'Exporter';
our @EXPORT_OK = qw(fix_empty_array);
# Because of how Lua parses JSON, empty arrays comes through as {}
sub fix_empty_array {
my $val = shift;
if (!$val) {
return
ueues;
=head1 NAME
Qless::Queues
=cut
use strict; use warnings;
use Qless::Queue;
use JSON::XS qw(decode_json);
use Time::HiRes qw();
use Qless::Utils qw(fix_empty_array);
sub new {
my $class = s
;
$self->{'client'} = $client;
$self;
}
sub counts {
my ($self) = @_;
my $results = decode_json($self->{'client'}->_queues([], Time::HiRes::time));
$results = fix_empty_array($results);
retur
package Qless::Config;
=head1 NAME
Qless::Config
=cut
use strict; use warnings;
use JSON::XS qw(decode_json);
sub new {
my $class = shift;
my ($client) = @_;
$class = ref $class if ref $class;
$key) = @_;
if ($key) {
return $self->{'client'}->_config([], 'get', $key);
}
return decode_json($self->{'client'}->_config([], 'get'));
}
sub set {
my ($self, $key, $value) = @_;
return $sel
package Qless::Workers;
=head1 NAME
Qless::Workers
=cut
use strict; use warnings;
use JSON::XS qw(decode_json);
use Time::HiRes qw();
use Qless::Utils qw(fix_empty_array);
sub new {
my $class = s
lts = decode_json($self->{'client'}->_workers([], Time::HiRes::time));
$results = fix_empty_array($results);
return $results;
}
sub item {
my ($self, $name) = @_;
my $rv = decode_json($self->{'cl
less::RecurringJob
=cut
use strict; use warnings;
use base 'Qless::BaseJob';
use JSON::XS qw(decode_json encode_json);
sub new {
my $class = shift;
my ($client, $args) = @_;
$class = ref $clas
', $_[1]) }
sub data { $#_ == 0 ? $_[0]->SUPER::data : $_[0]->_set_key('data', encode_json($_[1])) }
sub klass { $#_ == 0 ? $_[0]->SUPER::klass : $_[0]->_set_key('klass', $_[1]) }
package Catalyst::Action::Serialize::JSONP;
use Moose;
use namespace::autoclean;
extends 'Catalyst::Action::Serialize::JSON';
our $VERSION = '1.06';
$VERSION = eval $VERSION;
after 'execute' => sub
.$c->res->output().');');
} else {
warn 'Callback: '.$callback_value.' will not generate valid Javascript. Falling back to JSON output';
}
}
};
__PACKAGE__->meta->make_immutable;
1;
ipt meta characters by yourself when you put data into
C<< <script> ... </script> >> sections.
C<JSON> module is not suitable because it doesn't escape some meta
characters such as C<< "</script>" >>
se strict;
use Text::Xslate;
use JSON::XS;
use Benchmark qw(:all);
use Config; printf "Perl/%vd %s\n", $^V, $Config{archname};
foreach my $mod(qw(Text::Xslate JSON::XS)){
print $mod, '/', $mod-
>VERSION, "\n";
}
my $n = shift(@ARGV) || 10;
my %vpath = (
json => <<'TX',
<ul>
: for $books ->($item) {
<li><:= $item.title :> (<: $item.author :>)</li>
: }
</ul>
TX
);
my $tx = Text::Xsl
->new(
path => \%vpath,
cache_dir => '.xslate_cache',
cache => 2,
);
my $json = JSON::XS->new();
my %vars = (
books => [(
{ title => 'Islands in the stream',
lization.
=item * C<application/json> => C<JSON>
Uses L<JSON> to generate JSON output. It is strongly advised to also have
L<JSON::XS> installed. The C<text/x-json> content type is supported but i
ns to the json object.
For instance, to relax permissions when deserializing input, add:
__PACKAGE__->config(
json_options => { relaxed => 1 }
)
=item * C<text/javascript> => C<JSONP>
If a c
allback=? parameter is passed, this returns javascript in the form of: $callback($serializedJSON);
Note - this is disabled by default as it can be a security risk if you are unaware.
The usual MIME
ackage Qless::Queue;
=head1 NAME
Qless:Queue
=cut
use strict; use warnings;
use JSON::XS qw(decode_json encode_json);
use Qless::Jobs;
use Qless::Job;
use Time::HiRes qw();
=head1 METHODS
=head2
e'}, $self->{'client'});
}
=head2 C<counts>
=cut
sub counts {
my ($self) = @_;
return decode_json($self->{'client'}->_queues([], Time::HiRes::time, $self->{'name'}));
}
=head2 C<heartbeat>
=cut
_json($data),
Time::HiRes::time,
$args{'delay'} || 0,
'priority', $args{'priority'} || 0,
'tags', encode_json($args{'tags'} || []),
'retries', $args{'retries'} || 5,
'depends', encode_json
ia Type" error. What gives?!
A: Most likely, you haven't set Content-type equal to "application/json", or
one of the accepted return formats. You can do this by setting it in your query
accepted re
mats. You can do this by setting it in your query string
thusly: C<< ?content-type=application%2Fjson (where %2F == / uri escaped). >>
B<NOTE> Apache will refuse %2F unless configured otherwise.
Mak
# cope with invalid (missing required q parameter) header like:
# application/json; charset="utf-8"
# http://tools.ietf.org/html/rfc2616#section-14.1
unless
ing it REST methods and attributes.
=head1 SYNOPSIS
if ( $c->request->accepts('application/json') ) {
...
}
my $types = $c->request->accepted_content_types();
=head1 DESCRI