Commit | Line | Data |
499ebcdd |
1 | package System::Introspector::Report::Config; |
2 | use Moo; |
3 | use Config::General; |
4 | use Module::Runtime qw( use_module ); |
5 | |
6 | has config_file => (is => 'ro', required => 1); |
7 | has config => (is => 'lazy'); |
8 | |
9 | sub _build_config { |
10 | my ($self) = @_; |
11 | return +{ |
12 | Config::General->new($self->config_file)->getall, |
13 | }; |
14 | } |
15 | |
16 | sub report_types { |
17 | my ($self) = @_; |
18 | my $reports = $self->config->{report} || {}; |
19 | return map { |
20 | [$_, $reports->{$_}]; |
21 | } sort keys %$reports; |
22 | } |
23 | |
24 | sub publishers { |
25 | my ($self, @override) = @_; |
26 | my $publish = $self->config->{publish} || {}; |
27 | return map { |
28 | use_module("System::Introspector::Report::Publish::$_") |
29 | ->new($publish->{$_} || {}); |
30 | } @override ? @override : sort keys %$publish; |
31 | } |
32 | |
33 | 1; |