line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package XAS::Lib::Mixins::Configs; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
623
|
use Try::Tiny; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
49
|
|
6
|
1
|
|
|
1
|
|
639
|
use Config::IniFiles; |
|
1
|
|
|
|
|
13405
|
|
|
1
|
|
|
|
|
43
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use XAS::Class |
9
|
1
|
|
|
|
|
7
|
debug => 0, |
10
|
|
|
|
|
|
|
version => $VERSION, |
11
|
|
|
|
|
|
|
base => 'XAS::Base', |
12
|
|
|
|
|
|
|
utils => ':validation dotid compress', |
13
|
|
|
|
|
|
|
mixins => 'load_config', |
14
|
1
|
|
|
1
|
|
6
|
; |
|
1
|
|
|
|
|
1
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# ---------------------------------------------------------------------- |
17
|
|
|
|
|
|
|
# Public Methods |
18
|
|
|
|
|
|
|
# ---------------------------------------------------------------------- |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub load_config { |
21
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
22
|
0
|
|
|
|
|
|
my ($filename, $handle) = validate_params(\@_, [ |
23
|
|
|
|
|
|
|
{ optional => 1, isa => 'Badger::Filesystem::File', default => $self->env->cfg_file }, |
24
|
|
|
|
|
|
|
{ optional => 1, default => 'cfg' }, |
25
|
|
|
|
|
|
|
]); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
# really... using carp() as an exception handler is lame |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
local $SIG{__WARN__} = sub { |
30
|
0
|
|
|
0
|
|
|
my $error = shift; |
31
|
|
|
|
|
|
|
|
32
|
0
|
|
|
|
|
|
my ($reason) = $error =~ /(.*)at\s+/; |
33
|
|
|
|
|
|
|
|
34
|
0
|
|
|
|
|
|
$self->throw_msg( |
35
|
|
|
|
|
|
|
dotid($self->class) . '.load_config.badini', |
36
|
|
|
|
|
|
|
'config_badini', |
37
|
|
|
|
|
|
|
$filename->path, |
38
|
|
|
|
|
|
|
$reason, |
39
|
|
|
|
|
|
|
); |
40
|
|
|
|
|
|
|
|
41
|
0
|
|
|
|
|
|
}; |
42
|
|
|
|
|
|
|
|
43
|
0
|
|
|
|
|
|
$self->{$handle} = Config::IniFiles->new(-file => $filename->path); |
44
|
|
|
|
|
|
|
|
45
|
0
|
0
|
|
|
|
|
unless (defined($self->{$handle})) { |
46
|
|
|
|
|
|
|
|
47
|
0
|
|
|
|
|
|
$self->throw_msg( |
48
|
|
|
|
|
|
|
dotid($self->class) . '.load_config.badini', |
49
|
|
|
|
|
|
|
'config_badini', |
50
|
|
|
|
|
|
|
$filename->path, |
51
|
|
|
|
|
|
|
compress(join('', @Config::IniFiles::errors)), |
52
|
|
|
|
|
|
|
); |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
# ---------------------------------------------------------------------- |
59
|
|
|
|
|
|
|
# Private Methods |
60
|
|
|
|
|
|
|
# ---------------------------------------------------------------------- |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
1; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
__END__ |