line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package JIP::Conf; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
3923
|
use 5.006; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
45
|
|
4
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
40
|
|
5
|
1
|
|
|
1
|
|
24
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
60
|
|
6
|
1
|
|
|
1
|
|
9528
|
use Hash::AsObject; |
|
1
|
|
|
|
|
1355
|
|
|
1
|
|
|
|
|
7
|
|
7
|
1
|
|
|
1
|
|
27
|
use Carp qw(croak); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
63
|
|
8
|
1
|
|
|
1
|
|
3
|
use English qw(-no_match_vars); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
9
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub init { |
13
|
8
|
|
|
8
|
0
|
17993
|
my ($path_to_file, $path_to_variable) = @ARG; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# First arg |
16
|
8
|
100
|
100
|
|
|
283
|
croak q{Bad argument "path_to_file"} |
17
|
|
|
|
|
|
|
unless defined $path_to_file and length $path_to_file; |
18
|
6
|
100
|
|
|
|
368
|
croak(sprintf q{No such file "%s"}, $path_to_file) |
19
|
|
|
|
|
|
|
unless -f $path_to_file; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# Second arg |
22
|
5
|
100
|
100
|
|
|
498
|
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
|
|
|
|
6
|
eval { require $path_to_file } or do { |
|
3
|
|
|
|
|
824
|
|
27
|
1
|
|
|
|
|
652
|
croak(sprintf qq{Can't parse config "%s": %s}, $path_to_file, $EVAL_ERROR); |
28
|
|
|
|
|
|
|
}; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
# Fetch hash_ref from package |
31
|
2
|
|
|
|
|
6
|
my $data_from_file; |
32
|
2
|
|
|
|
|
3
|
eval { |
33
|
1
|
|
|
1
|
|
673
|
no strict 'refs'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
125
|
|
34
|
2
|
|
|
|
|
5
|
$data_from_file = ${ $path_to_variable }; |
|
2
|
|
|
|
|
12
|
|
35
|
|
|
|
|
|
|
}; |
36
|
2
|
100
|
66
|
|
|
22
|
if ($EVAL_ERROR or ref $data_from_file ne 'HASH') { |
37
|
1
|
|
|
|
|
175
|
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
|
|
|
|
|
21
|
return Hash::AsObject->new($data_from_file); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
1; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
__END__ |