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
@@ -23,6 +23,7 @@ WriteMakefile(NAME => 'slackbuilder',
23 'HTTP::Response' => 0, 23 'HTTP::Response' => 0,
24 'HTTP::Status' => 0, 24 'HTTP::Status' => 0,
25 'JSON' => 0., 25 'JSON' => 0.,
26 'YAML' => '1.20',
26 'LWP::UserAgent' => '6.29', 27 'LWP::UserAgent' => '6.29',
27 'List::Regexp' => '1.03', 28 'List::Regexp' => '1.03',
28 #Net::SBo 29 #Net::SBo
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
@@ -6,6 +6,7 @@ use File::Basename;
6use File::Spec; 6use File::Spec;
7use Net::SBo; 7use Net::SBo;
8use JSON; 8use JSON;
9use YAML;
9use Carp; 10use Carp;
10 11
11sub req { 12sub req {
@@ -17,7 +18,10 @@ sub req {
17 open(my $fd, $reqname) or croak "can't open file $reqname: $!"; 18 open(my $fd, $reqname) or croak "can't open file $reqname: $!";
18 my $string = <$fd>; 19 my $string = <$fd>;
19 close $fd; 20 close $fd;
20 return decode_json($string); 21 if ($string =~ /^\{/) {
22 return decode_json($string);
23 }
24 return YAML::Load($string);
21 } 25 }
22 26
23 if (-d $reqname) { 27 if (-d $reqname) {

Return to:

Send suggestions and report system problems to the System administrator.