[kdesrc-build/make_it_mojo] /: mojo: Use Mojo::JSON instead of requiring JSON::{PP, XS}.
Michael Pyne
null at kde.org
Tue Oct 9 00:40:40 BST 2018
Git commit e04c9e204aa6a9ee0f00db4f9debb92a07849d31 by Michael Pyne.
Committed on 08/10/2018 at 19:14.
Pushed by mpyne into branch 'make_it_mojo'.
mojo: Use Mojo::JSON instead of requiring JSON::{PP,XS}.
It's present anyways and already falls back to a faster one if needed,
so no reason to have other JSON-based dependencies.
M +4 -1 doc/index.docbook
M +1 -1 kdesrc-build
M +0 -7 modules/ksb/Application.pm
M +4 -20 modules/ksb/BuildContext.pm
M +1 -1 modules/ksb/Updater/KDEProjectMetadata.pm
M +4 -1 modules/ksb/UserInterface/TTY.pm
https://commits.kde.org/kdesrc-build/e04c9e204aa6a9ee0f00db4f9debb92a07849d31
diff --git a/doc/index.docbook b/doc/index.docbook
index 1a03236..fdb7cdb 100644
--- a/doc/index.docbook
+++ b/doc/index.docbook
@@ -314,8 +314,11 @@ will warn if they are not present):</para>
<itemizedlist>
<listitem><para>IO::Socket::SSL</para></listitem>
- <listitem><para>JSON::PP or JSON::XS</para></listitem>
<listitem><para>YAML::PP, YAML::XS, or YAML::Syck</para></listitem>
+ <listitem><para>The <ulink url="https://mojolicious.org/">Mojolicious web
+ framework</ulink>. It is small, self-contained, and allows &kdesrc-build;
+ to support interfaces beyond the simple command-line interface while
+ continuing to permit high performance.</para></listitem>
</itemizedlist>
</listitem>
diff --git a/kdesrc-build b/kdesrc-build
index 84f8728..aae861f 100755
--- a/kdesrc-build
+++ b/kdesrc-build
@@ -205,7 +205,7 @@ sub findMissingModules
# Assume if Mojolicious::Lite is present, that whole framework is properly installed
'Mojolicious::Lite',
'Mojo::Promise', # That was a bad assumption
- [qw(JSON::XS JSON::PP)],
+ 'Mojo::JSON',
[qw(YAML::XS YAML::PP YAML::Syck)]
);
my @missingModules;
diff --git a/modules/ksb/Application.pm b/modules/ksb/Application.pm
index efb8587..3e386c4 100644
--- a/modules/ksb/Application.pm
+++ b/modules/ksb/Application.pm
@@ -25,15 +25,8 @@ use ksb::DependencyResolver 0.20;
use ksb::Updater::Git;
use ksb::Version qw(scriptVersion);
-use Mojo::Asset::File;
-use Mojo::File;
use Mojo::IOLoop;
-use Mojo::JSON qw(encode_json);
-use Mojo::Message::Request;
use Mojo::Promise;
-use Mojo::Reactor;
-use Mojo::Server::Daemon;
-use Mojo::Template;
use Fcntl; # For sysopen
use List::Util qw(first min);
diff --git a/modules/ksb/BuildContext.pm b/modules/ksb/BuildContext.pm
index b6ecb28..a9a1415 100644
--- a/modules/ksb/BuildContext.pm
+++ b/modules/ksb/BuildContext.pm
@@ -14,7 +14,8 @@ use File::Basename; # dirname
use IO::File;
use POSIX qw(strftime);
use Errno qw(:POSIX);
-use JSON::PP;
+
+use Mojo::JSON qw(encode_json decode_json);
# We derive from ksb::Module so that BuildContext acts like the 'global'
# ksb::Module, with some extra functionality.
@@ -810,23 +811,7 @@ sub loadPersistentOptions
$persistent_data = <$fh>;
}
- my $persistent_options;
-
- eval { $persistent_options = decode_json($persistent_data); };
- if ($@) {
- # Apparently wasn't JSON, try falling back to old format for compat.
- # Previously, this was a Perl code which, when evaluated would give
- # us a hash called persistent_options which we can then merge into our
- # persistent options.
- # TODO: Remove compat code after 2018-06-30
- eval $persistent_data; # Runs Perl code read from file
- if ($@)
- {
- # Failed.
- error ("Failed to read persistent module data: r[b[$@]");
- return;
- }
- }
+ my $persistent_options = decode_json($persistent_data);
# We need to keep persistent data with the context instead of with the
# applicable modules since otherwise we might forget to write out
@@ -853,7 +838,6 @@ sub storePersistentOptions
return if pretending();
my $fh = IO::File->new($self->persistentOptionFileName(), '>');
- my $json = JSON::PP->new->ascii->pretty;
if (!$fh)
{
@@ -861,7 +845,7 @@ sub storePersistentOptions
return;
}
- my $encodedJSON = $json->encode($self->{persistent_options});
+ my $encodedJSON = encode_json ($self->{persistent_options});
print $fh $encodedJSON;
undef $fh; # Closes the file
}
diff --git a/modules/ksb/Updater/KDEProjectMetadata.pm b/modules/ksb/Updater/KDEProjectMetadata.pm
index ddeb9ad..396dcac 100644
--- a/modules/ksb/Updater/KDEProjectMetadata.pm
+++ b/modules/ksb/Updater/KDEProjectMetadata.pm
@@ -12,7 +12,7 @@ use parent qw(ksb::Updater::KDEProject);
use ksb::Util;
use ksb::Debug;
-use JSON::PP;
+use Mojo::JSON qw(decode_json);
sub name
{
diff --git a/modules/ksb/UserInterface/TTY.pm b/modules/ksb/UserInterface/TTY.pm
index 6452ba7..1845822 100755
--- a/modules/ksb/UserInterface/TTY.pm
+++ b/modules/ksb/UserInterface/TTY.pm
@@ -94,7 +94,10 @@ sub start
# Open a file to log the event stream
my $ctx = $app->context();
my $separator = ' ';
- open my $event_stream, '>', $ctx->getLogDirFor($ctx) . '/event-stream'
+ my $dest = pretending()
+ ? '/dev/null'
+ : $ctx->getLogDirFor($ctx) . '/event-stream';
+ open my $event_stream, '>', $dest
or croak_internal("Unable to open event log $!");
$event_stream->say("["); # Try to make it valid JSON syntax
More information about the kde-doc-english
mailing list