modify schema for new CPE stats
[APKPM.git] / lib / APKPM / Config.pm
1 package APKPM::Config;
2
3 use Moose::Role;
4
5 use File::Slurp;
6 use Data::Dump qw(dump);
7
8 our $config;
9
10 sub config {
11         my ( $self, $name ) = @_;
12         if ( ! $config ) {
13                 my $code = read_file '/opt/managment_tools/etc/config.pl';
14                 $code =~ s/\$(\w+)/\$config->{$1}/gs;
15                 $code =~ s/\@(\w+)/\@{\$config->{$1}}/gs;
16                 eval $code;
17                 die $@ if $@;
18         }
19         die "no $name in ",dump $config unless exists $config->{$name};
20         return $config->{$name};
21 }
22
23 1;