Outthentic/Glue/Bash.pm untested

filter: Statementstmt 0.0% 0 / 23 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 0.0% 0 / 4 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 33 CC 2 SCAR 12.8
CC
2
Cov
0%
json_var
6.0
BEGIN
2.0
BEGIN
2.0
CRAP 3.6
1 package Outthentic::Glue::Bash;
2  
3 use base 'Exporter';
4 use JSON;
5 use strict;
6  
7 our @EXPORT = qw{
8 json_var
9 };
10  
11 sub json_var {
12  
13 my $path = $ARGV[0];
14 my $name = $ARGV[1];
15  
16 open CONF, $path or die "can't open file $path to read: $!";
17 my $data = join "", <CONF>;
18 close CONF;
19
20 my $json = JSON->new;
21 my $conf = $json->decode($data);
22  
23 for my $n (split /\./, $name){
24 $conf = $conf->{$n};
25 }
26  
27 if ( ref $conf eq "ARRAY") {
28 my $conf = join ' ', @$conf ;
29 print '(' . $conf . ')';
30 } else {
31 print $conf;
32 }
33  
34 }
35  
36 1;