package Anyevent::JSONRPC::Utils;
use base qw(Exporter);
our @EXPORT_OK = qw(
delegate
do_moose
do_exporter
);
sub delegate {
my $object = shift;
croak("delegate needs a ble
ssed object as parameter") unless blessed $object;
if ( $object->isa("AnyEvent::JSONRPC::Client") ) {
# Any call is proxied to the client
return sub {
my $cv = shif
_
=head1 NAME
AnyEvent::JSONRPC::Utils - Helper functions for use with AnyEvent::JSONRPC
=head1 SYNOPSIS
# XXX being either TCP or HTTP
my $server = AnyEvent::JSONRPC::XXX::Server->new();
e AnyEvent::JSONRPC::Client;
use Any::Moose;
no Any::Moose;
__PACKAGE__->meta->make_immutable;
1;
__END__
=encoding utf-8
=head1 NAME
AnyEvent::JSONRPC::Client - Base class for JSON-RPC clients
=head1 SYNOPSIS
use AnyEvent::JSONRPC::XXX::Client;
my $client = AnyEvent::JSONRPC::XXX::Client->new(
...
);
# blocking interface
my $res = $client->call( echo
s for clients in the L<AnyEvent::JSONRPC> suite of
modules. Current implementations includes a
L<TCP|AnyEvent::JSONRPC::TCP::Client> client and a
L<HTTP|AnyEvent::JSONRPC::HTTP::Client> client. See th
package AnyEvent::JSONRPC::Server;
use Moose;
use JSON::XS;
has json => (
is => "ro",
default => sub {
JSON::XS->new->allow_blessed(1)->convert_blessed(1);
},
);
no Moose;
D__
=head1 NAME
AnyEvent::JSONRPC::Server - Base class for JSON-RPC Servers
=head1 SYNOPSIS
use AnyEvent::JSONRPC::XXX::Server;
my $server = AnyEvent::JSONRPC::TCP::Server->new( ... )
s for servers in the L<AnyEvent::JSONRPC> suite of
modules. Current implementations includes a
L<TCP|AnyEvent::JSONRPC::TCP::Server> client and a
L<HTTP|AnyEvent::JSONRPC::HTTP::Server> client. See th
package AnyEvent::JSONRPC::TCP::Client;
use Any::Moose;
use Any::Moose '::Util::TypeConstraints';
extends 'AnyEvent::JSONRPC::Client';
use Carp;
use Scalar::Util 'weaken';
use AnyEvent;
use AnyEven
t::Socket;
use AnyEvent::Handle;
use JSON::RPC::Common::Procedure::Call;
use JSON::RPC::Common::Procedure::Return;
has host => (
is => 'ro',
isa => 'Str',
required => 1,
);
h
ead(json => sub {
$self->_handle_response( $_[1] );
});
});
while (my $pooled = shift @{ $self->_request_pool }) {
$handle->push_write( json =>
package AnyEvent::JSONRPC::CondVar;
use Any::Moose;
use AnyEvent;
has cv => (
is => 'ro',
isa => 'AnyEvent::CondVar',
default => sub {
AnyEvent->condvar;
},
hand
les => [qw( send recv cb )],
);
has call => (
is => 'ro',
isa => 'JSON::RPC::Common::Procedure::Call',
required => 1,
handles => [qw( is_notification )],
);
no Any::Moos
AnyEvent::JSONRPC::CondVar - Condvar object used in
AnyEvent::JSONRPC::TCP::Server and AnyEvent::JSONRPC::HTTP::Server
=head1 SEE ALSO
L<AnyEvent::JSONRPC::TCP::Server> and L<AnyEvent::JSONRPC::HTTP
ect = MyClass->new;
my $result = $object->do_work();
if ($self->is_ajax) {
return to_json($result);
}
else {
my $t = $self->load_tmpl('myrunmode.tmpl');
$t->param(RESUL
:ImgData version 0.0.3
=head1 SYNOPSIS
use MyWebApp;
use CGI::Application::Plugin::JSON qw(to_json);
use CGI::Application::Plugin::AJAXUpload;
use Data::FormValidator::Filters::ImgDa
Ix::Class ':all';
use CGI::Application::Plugin::Redirect;
use Net::Lujoyglamour qw(is_valid);
use JSON;
sub cgiapp_init {
my $self = shift;
my (%args ) = @_;
croak "No DSN" if !$args{'PA
eq 'JSON' ) {
my $json;
if ($new_short_url ne '') {
$json = to_json( { shortu => $self->param('domain')."/".$new_short_url,
longu => $long_url} );
} else {
$json = to_json( {m
sg => $@} );
}
$self->header_props(-type=>'application/json');
return $json;
}
}
sub redirect_url {
my $self = shift;
my $url = $self->param('url');
my $long_url = $self->s
ile);
};
if ($@) {
carp $@;
return $c->to_json({status=> 'Internal Error'});
}
return $r;
}
);
return;
$dfv_profile = shift;
my $httpdocs_dir = $self->ajax_upload_httpdocs;
return $self->to_json({status => 'No document root specified'})
if not defined $httpdocs_dir;
my $full_upl
');
return $self->to_json({status=>'No file handle obtained'})
if !defined $lightweight_fh;
my $fh = $lightweight_fh->handle;
return $self->to_json({status => 'No file han
Optional bits for extra L<benchmark_template_engines> behaviour:
L<Term::ProgressBar::Simple>
L<JSON::Any>
=item Modules required by multiple plugins:
L<File::Spec>
L<File::Spec> needed by plugin
e ) = @_;
if ( $type ne 'jsontext' ) {
confess q{the only valid value is 'jsontext'};
}
},
);
has [
qw{
key
jsonp
}
] => (
is => 'r
is C<jsontext>. Responds with mime-type text/json, if set.
=head2 C<key>
Accepts a key and validates this request to a specific application.
=head2 C<jsonp>
If set, the response returns JSON with
Padding instead of standard JSON.
=head1 AUTHOR
Alan Haggai Alavi <alanhaggai@alanhaggai.org>
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2010 by Alan Haggai Alavi.
This is free
s
use Moose;
use Moose::Util::TypeConstraints;
with 'Net::StackExchange::Role::Response';
has 'json' => (
is => 'ro',
isa => 'Str',
required => 1,
);
has 'answers' => (
et::StackExchange::Answers]',
writer => 'set_answers',
reader => 'get_answers',
);
has '_json_decoded' => (
is => 'ro',
isa => 'HashRef',
required => 1,
trigger =>
_object {
my $self = shift;
my $json = $self->json();
my $json_decoded = $self->_json_decoded();
my @answers;
for my $answer_ref ( @{ $json_decoded->{'answers'} } ) {
my
s request
use Moose;
use Moose::Util::TypeConstraints;
use URI;
use LWP::UserAgent;
use JSON qw{ decode_json };
has 'ihq' => (
is => 'rw',
isa => 'Str',
required => 1,
);
ha
t => 'desc',
);
sub execute {
my $self = shift;
my $api_url = 'http://isohunt.com/js/json.php';
my %parametres = (
'ihq' => $self->ihq (),
'start' => $self->start()
t' );
my $json = $ua->get($uri)->decoded_content();
my $json_decoded = decode_json($json);
my $image = Net::isoHunt::Response::Image->new( {
'title' => $json_decoded->{'i
VERSION = '0.102740';
}
# ABSTRACT: Subroutines for internal use
use strict;
use warnings;
use JSON;
use LWP::UserAgent;
use Scalar::Util qw{ blessed };
use URI::Escape;
# transform hash keys and
mail::MIME::Kit::Renderer::TT>
=head3 L<Email::Sender>
=head3 L<Function::Parameters>
=head3 L<JSON>
=head3 L<List::AllUtils>
=head3 L<Method::Signatures::Simple>
=head3 L<Moose>
=head3 L<Moose
ABSTRACT: Request methods for answers
use Moose;
use Moose::Util::TypeConstraints;
use JSON qw{ decode_json };
with 'Net::StackExchange::Role::Request';
has 'id' => (
is => 'ro',
is
$self = shift;
my $json = Net::StackExchange::Core::_execute($self);
my $se = $self->_NSE();
my $json_decoded = decode_json($json);
my $response = Net::Stac
=> $se,
'_json_decoded' => $json_decoded,
'json' => $json,
'total' => $json_decoded->{'total' },
'page' => $json_decoded->{'page' },
ts;
use JSON;
subtype 'List::id'
=> as 'Str'
=> where { $_ =~ /^(?:\d;?)+$/ };
subtype 'JSON::XS::Boolean'
=> as 'JSON::XS::Boolean';
subtype 'JSON::PP::Boolean'
=> as 'JSON::PP::Bo
'
=> from 'JSON::XS::Boolean'
=> via {
if ( JSON::is_bool($_) && $_ == JSON::true ) {
return 'true';
}
return 'false';
}
=> from 'JSON::PP::Boolean'
=> via {
if ( JSON::is_bool($_) && $_ == JSON::true ) {
return 'true';
}
return 'false';
}
=> from 'Int'
=> via {
if ($_) {
ret
ur project. For example, to build in the "dev" context,
there must be a F<dev.yml> file (or F<dev.json> or some other format supported
by L<Config::Any>) in the F<conf/> or F<etc/> directory of your p
ill be used.
=head3 test_env
./Build db --test_env CATALYST_DEBUG=0 CATALYST_CONFIG=conf/test.json
Optional hash reference of environment variables to set for the lifetime of
C<./Build test>. Thi
module_name => 'MyApp',
db_config_key => 'dbi',
replace_config => 'conf/dev.json',
)->create_build_script;
Set to a string or regular expression (using C<qr//>) and, the C<mod
nstraints;
use MooseX::StrictConstructor;
require HTTP::Request;
require HTTP::Response;
require JSON::XS;
require LWP::UserAgent;
use version; our $VERSION = qv('0.0.2');
# DEFAULT VALUES
Readonly
) }
# JSON
has '_json' => (
is => 'ro',
isa => duck_type( 'JSON', [ qw( new decode_json ) ] ),
lazy_build => 1,
required => 1,
);
sub _build__json { return( JSON::XS->n
Accept => 'application/json' );
# send it
my( $response ) = $self->_ua->request( $request );
# what did we get?
if ( $response->is_success ) {
my( $json ) = $response->decode
package Business::AU::Ledger::View::Reconciliation;
use JSON::XS;
use Moose;
extends 'Business::AU::Ledger::View::Base';
use namespace::autoclean;
our $VERSION = '0.88';
# ----------------------
'},
receipts => 0.00,
};
}
$self -> log(__PACKAGE__ . '. Leaving initialize');
return JSON::XS -> new -> encode({results => [@output]});
} # End of initialize.
# ------------------------