summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2019-03-20 09:19:18 +0100
committerSergey Poznyakoff <gray@gnu.org.ua>2019-03-20 09:19:18 +0100
commita6040f631367a33f4e96759ce6ceefb759303f25 (patch)
tree41f2add536a02ae1ae3be70143c47d6d661924c0
parent023d027a1a0f5e227bd251d281ea65bb98accd5d (diff)
downloadslackbuilder-a6040f631367a33f4e96759ce6ceefb759303f25.tar.gz
slackbuilder-a6040f631367a33f4e96759ce6ceefb759303f25.tar.bz2
Use YAML format for requests
Both JSON and YAML are now supported. * lib/SlackBuild/Request/Auto.pm (req): Parse YAML requests. Guess if the file is JSON or YAML by its first character. Valid JSON requests start with a curly brace.
-rw-r--r--Makefile.PL1
-rw-r--r--lib/SlackBuild/Request/Auto.pm6
2 files changed, 6 insertions, 1 deletions
diff --git a/Makefile.PL b/Makefile.PL
index e738c9a..776890c 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -20,12 +20,13 @@ WriteMakefile(NAME => 'slackbuilder',
'File::stat' => 0,
'HTML::Parser' => '3.72',
'HTTP::Request' => 0,
'HTTP::Response' => 0,
'HTTP::Status' => 0,
'JSON' => 0.,
+ 'YAML' => '1.20',
'LWP::UserAgent' => '6.29',
'List::Regexp' => '1.03',
#Net::SBo
'POSIX' => 0,
'POSIX::Run::Capture' => 0,
'Safe' => 0,
diff --git a/lib/SlackBuild/Request/Auto.pm b/lib/SlackBuild/Request/Auto.pm
index 08832d6..576d39d 100644
--- a/lib/SlackBuild/Request/Auto.pm
+++ b/lib/SlackBuild/Request/Auto.pm
@@ -3,24 +3,28 @@ use strict;
use warnings;
use parent 'SlackBuild::Request';
use File::Basename;
use File::Spec;
use Net::SBo;
use JSON;
+use YAML;
use Carp;
sub req {
my ($class, $reqname) = @_;
my $req;
if (-f $reqname) {
local $/ = undef;
open(my $fd, $reqname) or croak "can't open file $reqname: $!";
my $string = <$fd>;
close $fd;
- return decode_json($string);
+ if ($string =~ /^\{/) {
+ return decode_json($string);
+ }
+ return YAML::Load($string);
}
if (-d $reqname) {
if (my $file =
(glob File::Spec->catfile($reqname, '*.SlackBuild'))[0]) {
my ($package,$path,$suffix) = fileparse($file, '.SlackBuild');

Return to:

Send suggestions and report system problems to the System administrator.