package lxd::instance;
use strict;
use warnings;
use JSON;
use Data::Dumper;
sub state {
my ($elf, $lxd, %params) = @_;
my $wait = delete $params{wait} // 1;
my $f = $lxd->instance_stat
ction {
my ($elf, $lxd, $action, %params) = @_;
$params{stateful} //= JSON::false;
$params{force} //= JSON::false;
$params{timeout} //= 30;
my $wait = delete $params{wait} // 1
Data::Dumper;
$Data::Dumper::Indent = 1;
our $VERSION = '0.03';
use Encode qw(encode_utf8);
use JSON;
use HTTP::Status qw(:constants);
use Moose;
use Log::Log4perl qw(:easy);
Log::Log4perl->easy_
nfig
config - Creates an initial default configuration file.
This file will be named C<dist-mgr.json> and will be placed in your C<HOME>
directory on Unix systems, and in your C<USERPROFILE> directo
.*},
q{*.tar.gz},
q{_build/},
q{blib/},
q{Build/},
q{META.json},
q{META.yml},
q{*.old},
q{*.orig},
q{pm_to_blib},
q{.met
hgignore$},
q{^_build/},
q{^Build$},
q{^MYMETA\.yml$},
q{^MYMETA\.json$},
q{^README.bak$},
q{^Makefile$},
q{.metadata/},
q{.idea/},
;
use 5.012000;
use strict;
use warnings;
use JSON::XS ();
use Time::HiRes ();
my $header = qq|{"format":"json","version":1}\n|;
my $json = JSON::XS->new->utf8;
sub new {
my $class = shif
} //= Time::HiRes::time();
my $sock = AWS::XRay::sock() or return;
$sock->print($header, $json->encode({%$self}));
}
sub trace_header {
my $self = shift;
my $h = sprintf("Root=%s;P
:AnyEvent)],
modules_init => {
"WebSocket::AnyEvent" => {
mount => '/ws',
serializer => "json",
},
},
# in application's build method
my $ws = $self->websocket;
$ws->add(message => s
default, an exception will be re-thrown, and effectively the connection will be closed.
If Kelp JSON module is initialized with I<'allow_nonref'> flag then this event will never occur.
C<$error> wi
ist->{summary};
}
# dzil also wants to get abstract for main module to put in dist's
# META.{yml,json}
sub before_build {
my $self = shift;
my $name = $self->zilla->name;
my $class = $name
=> 1,
# allow_encodings => undef, # or ['base64','json',...]
# disallow_encodings => undef, # or ['base64','json',...]
# allow_directives => undef, # or ['include','merge
as verbatim. Example:
name = !json null
With C<enable_encoding> turned off, value will not be undef but will be string
with the value of (as Perl literal) C<"!json null">.
B<NOTE: Turning this se
f violates IOD specification.>
=head2 enable_bracket => bool (default: 1)
If set to false, then JSON literal array will be parsed as verbatim. Example:
name = [1,2,3]
With C<enable_bracket> turne
ike to
write out, or read from. Default is C<$ENV{USERPROFILE}/dist-mgr.json> on
Windows systems, and C<$ENV{HOME}/dist-mgr.json> on Unix systems.
I<Returns>: The reference to the C<%args> hash you s
of the default configuration file. this is
C<$ENV{USERPROFILE}/dist-mgr.json> on Windows systems, and
C<$ENV{HOME}/dist-mgr.json> on Unix systems.
=head2 copyright_bump
Finds and updates the copyrig
package AnyEvent::Sway;
# vim:ts=4:sw=4:expandtab
use strict;
use warnings;
use JSON::XS;
use AnyEvent::Handle;
use AnyEvent::Socket;
use AnyEvent;
use Encode;
use Scalar::Util qw(tainted);
use Carp;
defined($self->{callbacks}->{$type});
my $cb = $self->{callbacks}->{$type};
$cb->(decode_json $payload);
return if ($type & $event_mask) == $event_mask;
# If this was a one-time cal
tets
$payload = encode_utf8($content);
} else {
$payload = encode_json $content;
}
}
my $message = $magic . pack("LL", length($payload), $type) . $paylo
nput => <<'_',
name=!json "1\n2"
_
dies => 1,
);
test_read_iod(
args => {allow_encodings=>['json']},
input => <<'_',
name=!json "1\n2"
name2=!j "3\
allow_encodings=>['json']},
input => <<'_',
name=!json "1\n2"
_
dies => 1,
);
test_read_iod(
args => {disallow_encodings=>['json']},
in
t_read_iod(
args => {disallow_encodings=>['hex']},
input => <<'_',
name=!json "1\n2"
_
result => {GLOBAL=>{name=>"1\n2"}},
);
};
subtest "opt: all
e::Copy::Recursive qw(rmove_glob);
use File::Path qw(make_path rmtree);
use File::Find::Rule;
use JSON;
use Module::Starter;
use PPI;
use Term::ReadKey;
use Tie::File;
use Exporter qw(import);
our @I
export_private(),
);
our $VERSION = '1.13';
use constant {
CONFIG_FILE => 'dist-mgr.json',
GITHUB_CI_FILE => 'github_ci_default.yml',
GITHUB_CI_PATH => '.github/workflo
h, '<', $file or croak "Can't open config file $file: $!";
my $json = <$fh>;
$conf = decode_json $json;
for (keys %{ $conf }) {
delete $conf->{$_}
$4, # COL_V_COMMENT
] if $needs_res;
# canonicalize shorthands
$enc = "json" if $enc eq 'j';
$enc = "hex" if $enc eq 'h';
$enc = "expr" if $enc eq 'e';
if grep {$_ eq $enc} @{$self->{disallow_encodings}};
}
if ($enc eq 'json') {
# XXX imperfect regex for simplicity, comment should not contain
# "
)(.*) )?
\z/x or return ("Invalid syntax in JSON-encoded value");
my $decode_res = $self->_decode_json($val);
return ($decode_res->[1]) unless $decode_res-
=> 1,
# allow_encodings => undef, # or ['base64','json',...]
# disallow_encodings => undef, # or ['base64','json',...]
# allow_directives => undef, # or ['include','merge
as verbatim. Example:
name = !json null
With C<enable_encoding> turned off, value will not be undef but will be string
with the value of (as Perl literal) C<"!json null">.
B<NOTE: Turning this se
f violates IOD specification.>
=head2 enable_bracket => bool (default: 1)
If set to false, then JSON literal array will be parsed as verbatim. Example:
name = [1,2,3]
With C<enable_bracket> turne
=encoding UTF-8
=head1 NAME
JSON::Server - JSON-only server
=head1 SYNOPSIS
use JSON::Server;
my $js = JSON::Server->new (handler => \& hello, port => '7777', data => 'OK');
wh
}
(This example is included as L<F<synopsis.pl>|https://fastapi.metacpan.org/source/BKB/JSON-Server-0.03/examples/synopsis.pl> in the distribution.)
Then test your server:
$ perl exam
}
{"JSON::Server::control":"close"}
{
"JSON::Server::response":"closing"
}
Connection closed by foreign host.
=head1 VERSION
This documents version 0.03 of JSON-Server
my($self, $dist) = @_;
my @meta;
my $finder = sub {
if (m!\b$dist-.*[\\/]MYMETA.json!) {
my $meta = CPAN::Meta->load_file($_);
push @meta, $meta if $meta->nam
tware/install/bin/perl
use warnings;
use strict;
use utf8;
use FindBin '$Bin';
use lib "$Bin/../lib";
use JSON::Server;
my $server = JSON::Server->new (port => 3737, verbose => 1);
$server->serve ();
talls;
my $wanted = sub {
if ($_ eq 'install.json') {
push @installs, [ $File::Find::name, "$File::Find::dir/MYMETA.json" ];
}
};
File::Find::find($wanted, $lib
eturn 1;
}
};
for my $file (@installs) {
my $module = Carton::Util::load_json($file->[0]);
my $prereqs = -f $file->[1] ? CPAN::Meta->load_file($file->[1])->effective_p
;
use strict;
use warnings;
sub load_json {
my $file = shift;
open my $fh, "<", $file or die "$file: $!";
from_json(join '', <$fh>);
}
sub dump_json {
my($data, $file) = @_;
op
h;
print $fh to_json($data);
}
sub from_json {
require JSON::PP;
JSON::PP->new->utf8->decode($_[0])
}
sub to_json {
my($data) = @_;
require JSON::PP;
JSON::PP->new->utf8->pre
heck> will warn you about this:
$ carton check
Following dependencies are not satisfied.
JSON has version 2.51. Needs 2.52
Run `carton install` to install them.
You can run C<carton instal
=encoding UTF-8
=head1 NAME
JSON::Client - Example client for JSON::Server
=head1 VERSION
This documents version 0.03 of JSON::Client
corresponding to L<git commit ad3eb95dc23ace0b097b7e253b1c4
enkasminbullock/json-server/commit/ad3eb95dc23ace0b097b7e253b1c4047a2c243bd> released on Sat Apr 30 14:09:31 2022 +0900.
=head1 DESCRIPTION
This is an example client module for L<JSON::Server> which
a JSON::Server server.
=head1 SYNOPSIS
my $client = JSON::Client->new (
port => '5555', # This is the port of the server we are using
);
=head1 METHODS
=head2 new
Make a new JSON