onnects to the Puppet Orchestrator API (i.e. Puppet Tasks)
package Puppet::Orchestrator;
use JSON;
use LWP::UserAgent;
use HTTP::Request;
use Log::MixedColor;
use 5.10.0;
use Moose;
use Moose::Ex
ge' )){
require MooseX::Storage;
MooseX::Storage->import();
with Storage('format' => 'JSON', 'io' => 'File', traits => ['DisableCycleDetection']);
}
my $log = Log::MixedColor->new;
has
opts );
if( $type eq 'POST' ){
$data = encode_json( $data ) if ref $data;
$req->header( 'Content-Type' => 'application/json' );
$req->content( $data );
}
my $respon
age Puppet::DB;
use 5.10.0;
use strict;
use warnings;
use LWP::UserAgent;
use HTTP::Request;
use JSON;
use Time::Local;
use Moose;
use Moose::Exporter;
use String::ShortHostname;
use Module::Load::Co
the following code can silently fail
#eval {
#require MooseX::Storage;
#with Storage('format' => 'JSON', 'io' => 'File', traits => ['DisableCycleDetection']);
#1;
#};
if ( check_install( module => 'Mo
require MooseX::Storage;
MooseX::Storage->import();
with Storage(
'format' => 'JSON',
'io' => 'File',
traits => ['DisableCycleDetection']
);
}
# Connect
e::Client';
our $VERSION = '0.2001'; # VERSION
use Carp qw(croak);
use MIME::Entity;
use JSON qw(encode_json);
has auth_token => ( is => 'ro', required => 1 );
has '+base_url' => ( default => 'htt
my $msg_json = encode_json({ message => $msg });
$Mime->attach(
Type => 'application/json',
Encoding => '7bit',
Data => $msg_json,
);
=head2 update_room
update_room($room, {
is_archived => JSON::false,
is_guest_accessible => JSON::false,
name => "Jokes",
owner
##############################################################
# Modules
use WWW::Mechanize;
use JSON;
###########################################################################
# Variables
my $AM
th ));
}
}
# The images
my ($json) = $html =~ /var colorImages = ([^;]+);/si;
if($json) {
my $code = decode_json($json);
my @order = grep {$_} $code->{initial}
##############################################################
# Modules
use WWW::Mechanize;
use JSON;
###########################################################################
# Variables
my $AM
on} =~ s! +! !g;
}
# The images
my ($json) = $html =~ /var colorImages = ([^;]+);/si;
if($json) {
my $code = decode_json($json);
my @order = grep {$_} $code->{initial}
SEE ALSO
L<https://www.reddit.com/r/perl/comments/czhwe6/syntax_differences_from_data_dumper_to_json/ez95r7c?utm_source=share&utm_medium=web2x>
=head1 AUTHOR
perlancar <perlancar@cpan.org>
=head1
ACT: Connects to the Puppet Classifier API (PE Console groups)
package Puppet::Classify;
use JSON;
use LWP::UserAgent;
use HTTP::Request;
use Puppet::DB;
use Log::MixedColor;
use 5.10.0;
use Moos
ge' )){
require MooseX::Storage;
MooseX::Storage->import();
with Storage('format' => 'JSON', 'io' => 'File', traits => ['DisableCycleDetection']);
}
my $log = Log::MixedColor->new;
ar
opts );
if( $type eq 'POST' ){
$data = encode_json( $data ) if ref $data;
$req->header( 'Content-Type' => 'application/json' );
$req->content( $data );
}
my $respon
";
return;
}
sub keep_patches {
keep_file($_) for grep { /\.patch$/ } read_dir('.banshee');
return;
}
sub keep_config {
keep_file($_) for grep { /\.json$/ } read_dir('.banshee');
return;
}
1;
ving (.*?)$/ms;
}
return @updated;
}
sub add_meta {
my ($files, $meta) = @_;
$files->{'META.json'} = $meta->as_string;
$files->{'META.yml'} = $meta->as_string({ version => 1.4 });
return;
}
= $self->{ua}->get($url);
$self->{last_transaction} = $get_req;
my $res = $get_req->res->json;
if ( ref( $res->{available_to} ) eq 'ARRAY' ) {
my @dates;
for my $interva
aero/ru/flights?from=' . $from . '&to=' . $to;
my $res = $self->{ua}->get($url)->res->json;
say $i;
$res{$from} = $to if ( ref( $res->{available_to} ) ne 'ARRAY' );
print $rm->all_cities()
print join(',' map { "\'". $_ ."\'" } $rm->all_cities() ); # for json array
=head2 get
Universal accessor function for route map, wrapper under L<WWW::AzimuthAero::R
'MOW',
date => '23.06.2019'
}
};
}
sub filename {
return 't/ua_mock.json';
}
sub generate {
my $self = shift;
my $mock_data = $self->mock_data->{get};
cks
=head2 mock_data
Return data that is used for mock at unit tests
=head2 generate
Generate json mock data
=head1 AUTHOR
Pavel Serikov <pavelsr@cpan.org>
=head1 COPYRIGHT AND LICENSE
This so
v.json
-- -- meta.json
-- -- summary.json
-- -- testinfo.json
-- -- preprocess.txt
-- -- postprocess.txt
-- -- result/
-- -- -- init.pl.json
-- -- -- basic_file_handling_setup.pl.json
ture_processing_setup.pl.json
-- -- -- filehandl/
-- -- -- -- fh1.pl.json
-- -- -- -- fh2.pl.json
-- -- -- picproc/
-- -- -- -- pp1.pl.json
-- -- -- -- pp2.pl.json
-- -- tap/
-- -- --
- -- -- -- fh2.pl.tap
-- -- -- picproc/
-- -- -- -- pp1.pl.tap
-- -- -- -- pp2.pl.tap
All 'json' files are in UTF-8.
The described format version here is '1.0', and is indicated in the meta-da
ile::Copy::Recursive qw(dircopy);
use File::Temp qw(tempdir);
use File::Slurp qw(write_file);
use JSON;
use Net::Domain qw(hostfqdn);
use POSIX qw(uname);
# CTOR
#
sub new
{
my $class = shift;
my $
kdir/save/testontap/tap"),
result => slashify("$workdir/save/testontap/result"),
json => JSON->new()->utf8()->pretty()->canonical(),
orderstrategy => undef,
dispensedorder =>
my $name = shift;
my $data = shift;
my $file = slashify("$name.json");
mkpath(dirname($file));
write_file($file, $self->{json}->encode($data)) || die("Failed to write '$file': $!\n");
}
sub __
:Notifier::Transport::Pg;
use Mojo::Base 'Minion::Notifier::Transport';
use Mojo::Pg;
use Mojo::JSON;
has pg => sub { die 'A Mojo::Pg instance is required' };
has channel => 'minion_notifier_job';
o::JSON::decode_json $payload;
$self->emit(notified => @$args);
});
}
sub send {
my ($self, $id, $message) = @_;
$self->pg->pubsub->notify(
$self->channel,
Mojo::JSON::encode_json([
er::Transport::Redis;
use Mojo::Base 'Minion::Notifier::Transport';
use Mojo::Redis2;
use Mojo::JSON;
has redis => sub { die 'A Mojo::Redis2 instance is required' };
has channel => 'minion_notifie
jo::JSON::decode_json $payload;
$self->emit(notified => @$args);
});
$self->redis->subscribe([$channel], sub {});
}
sub send {
my ($self, $id, $message) = @_;
my $payload = Mojo::JSON::en
code_json([$id, $message]);
Mojo::IOLoop->delay(sub{
$self->redis->publish($self->channel, $payload, shift->begin);
})->wait;
}
1;
my $self = shift;
$self->ua->websocket($self->url => sub {
my ($ua, $tx) = @_;
$tx->on(json => sub {
my ($tx, $data) = @_;
$self->emit(notified => @$data);
});
});
}
sub
send {
my ($self, $id, $message) = @_;
$self->ua->websocket($self->url => sub {
my ($ua, $tx) = @_;
$tx->send({json => [$id, $message]}); #TODO finish after send?
});
}
1;
age Mojo::RabbitMQ::Client::Publisher;
use Mojo::Base -base;
use Mojo::Promise;
use Mojo::JSON qw(encode_json);
use Scalar::Util 'weaken';
require Mojo::RabbitMQ::Client;
use constant DEBUG => $ENV{
%$headers);
if (ref($body)) {
$headers{content_type} = 'application/json';
$body = encode_json $body;
}
return $self->channel->publish_p(
exchange => $ex
.0.1:5672/?exchange=mojo&routing_key=mojo'
);
$publisher->publish_p(
{encode => { to => 'json'}},
routing_key => 'mojo_mq'
)->then(sub {
say "Message published";
})->catch(sub {
=mojo'
);
$publisher->publish('plain text');
$publisher->publish(
{encode => { to => 'json'}},
routing_key => 'mojo_mq'
)->then(sub {
say "Message published";
})->catch(sub {
st::MD5 qw(md5_hex);
use File::Path qw(make_path);
use Path::Tiny qw(path);
use Getopt::Long;
use JSON::MaybeXS;
use Sereal qw(encode_sereal decode_sereal);
use Devel::QuickCover::Report;
my $QC_DATA
"$COVERDB/runs/";
my $JSON = JSON::MaybeXS->new->utf8->indent;
my $DEVEL_COVER_DB_FORMAT = 'Sereal';
$ENV{DEVEL_COVER_DB_FORMAT}
and $DEVEL_COVER_DB_FORMAT = 'JSON';
exit main();
sub m
DB_FORMAT eq 'JSON') {
return $JSON->decode(shift);
}
return decode_sereal(shift);
}
sub coverdb_encode {
if ($DEVEL_COVER_DB_FORMAT eq 'JSON') {
return $JSON->encode(shift