summaryrefslogtreecommitdiffabout
path: root/lib/SlackBuild/Request/Loader/file.pm
Side-by-side diff
Diffstat (limited to 'lib/SlackBuild/Request/Loader/file.pm') (more/less context) (ignore whitespace changes)
-rw-r--r--lib/SlackBuild/Request/Loader/file.pm25
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/SlackBuild/Request/Loader/file.pm b/lib/SlackBuild/Request/Loader/file.pm
new file mode 100644
index 0000000..2a8cae6
--- a/dev/null
+++ b/lib/SlackBuild/Request/Loader/file.pm
@@ -0,0 +1,25 @@
+package SlackBuild::Request::Loader::file;
+use strict;
+use warnings;
+use JSON;
+use YAML ();
+use Carp;
+
+our $PRIORITY = 10;
+
+sub Load {
+ my ($class, $reqname) = @_;
+ if (-f $reqname) {
+ local $/ = undef;
+ open(my $fd, $reqname) or croak "can't open file $reqname: $!";
+ my $string = <$fd>;
+ close $fd;
+ if ($string =~ /^\{/) {
+ return decode_json($string);
+ }
+ return YAML::Load($string);
+ }
+}
+
+1;
+

Return to:

Send suggestions and report system problems to the System administrator.