line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package JIP::Conf; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
2140
|
use 5.006; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
29
|
|
4
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
32
|
|
5
|
1
|
|
|
1
|
|
16
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
25
|
|
6
|
1
|
|
|
1
|
|
9323
|
use Hash::AsObject; |
|
1
|
|
|
|
|
764
|
|
|
1
|
|
|
|
|
5
|
|
7
|
1
|
|
|
1
|
|
25
|
use Carp qw(croak); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
62
|
|
8
|
1
|
|
|
1
|
|
4
|
use English qw(-no_match_vars); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
8
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub init { |
13
|
8
|
|
|
8
|
0
|
7383
|
my ($path_to_file, $path_to_variable) = @ARG; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# First arg |
16
|
8
|
100
|
100
|
|
|
276
|
croak qq{Bad argument "path_to_file"\n} |
17
|
|
|
|
|
|
|
unless defined $path_to_file and length $path_to_file; |
18
|
6
|
100
|
|
|
|
190
|
croak(sprintf qq{No such file "%s"\n}, $path_to_file) |
19
|
|
|
|
|
|
|
unless -f $path_to_file; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# Second arg |
22
|
5
|
100
|
100
|
|
|
183
|
croak qq{Bad argument "path_to_variable"\n} |
23
|
|
|
|
|
|
|
unless defined $path_to_variable and length $path_to_variable; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# Require file |
26
|
3
|
100
|
|
|
|
3
|
eval { require $path_to_file } or do { |
|
3
|
|
|
|
|
506
|
|
27
|
1
|
|
|
|
|
91
|
croak(sprintf qq{Can't parse config "%s": %s\n}, $path_to_file, $EVAL_ERROR); |
28
|
|
|
|
|
|
|
}; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
# Fetch hash_ref from package |
31
|
2
|
|
|
|
|
3
|
my $data_from_file; |
32
|
2
|
|
|
|
|
4
|
eval { |
33
|
1
|
|
|
1
|
|
463
|
no strict 'refs'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
98
|
|
34
|
2
|
|
|
|
|
2
|
$data_from_file = ${ $path_to_variable }; |
|
2
|
|
|
|
|
5
|
|
35
|
|
|
|
|
|
|
}; |
36
|
2
|
100
|
66
|
|
|
14
|
if ($EVAL_ERROR or ref $data_from_file ne 'HASH') { |
37
|
1
|
|
|
|
|
91
|
croak(sprintf qq{Invalid config. Can't fetch \${%s} from "%s"\n}, $path_to_variable, $path_to_file); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
1
|
|
|
|
|
13
|
return Hash::AsObject->new($data_from_file); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
1; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
__END__ |