line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package JIP::Conf; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
4759
|
use 5.006; |
|
1
|
|
|
|
|
4
|
|
4
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
22
|
|
5
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
41
|
|
6
|
1
|
|
|
1
|
|
486
|
use Hash::AsObject; |
|
1
|
|
|
|
|
853
|
|
|
1
|
|
|
|
|
7
|
|
7
|
1
|
|
|
1
|
|
33
|
use Carp qw(croak); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
64
|
|
8
|
1
|
|
|
1
|
|
7
|
use English qw(-no_match_vars); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
9
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.021'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub init { |
13
|
8
|
|
|
8
|
0
|
12891
|
my ($path_to_file, $path_to_variable) = @ARG; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# First arg |
16
|
8
|
100
|
100
|
|
|
312
|
croak q{Bad argument "path_to_file"} |
17
|
|
|
|
|
|
|
unless defined $path_to_file and length $path_to_file; |
18
|
6
|
100
|
|
|
|
210
|
croak(sprintf q{No such file "%s"}, $path_to_file) |
19
|
|
|
|
|
|
|
unless -f $path_to_file; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# Second arg |
22
|
5
|
100
|
100
|
|
|
201
|
croak q{Bad argument "path_to_variable"} |
23
|
|
|
|
|
|
|
unless defined $path_to_variable and length $path_to_variable; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# Require file |
26
|
3
|
100
|
|
|
|
4
|
eval { require $path_to_file } or do { |
|
3
|
|
|
|
|
513
|
|
27
|
1
|
|
|
|
|
95
|
croak(sprintf q{Can't parse config "%s": %s}, $path_to_file, $EVAL_ERROR); |
28
|
|
|
|
|
|
|
}; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
# Fetch hash_ref from package |
31
|
2
|
|
|
|
|
5
|
my $data_from_file; |
32
|
2
|
|
|
|
|
3
|
eval { |
33
|
1
|
|
|
1
|
|
480
|
no strict 'refs'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
121
|
|
34
|
2
|
|
|
|
|
2
|
$data_from_file = ${ $path_to_variable }; |
|
2
|
|
|
|
|
7
|
|
35
|
|
|
|
|
|
|
}; |
36
|
2
|
100
|
66
|
|
|
13
|
if ($EVAL_ERROR or ref $data_from_file ne 'HASH') { |
37
|
1
|
|
|
|
|
93
|
croak( |
38
|
|
|
|
|
|
|
sprintf q{Invalid config. Can't fetch ${%s} from "%s"}, |
39
|
|
|
|
|
|
|
$path_to_variable, |
40
|
|
|
|
|
|
|
$path_to_file, |
41
|
|
|
|
|
|
|
); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
1
|
|
|
|
|
25
|
return Hash::AsObject->new($data_from_file); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
1; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
__END__ |