| 1 | package Mojolicious::Plugin::ConfigSimple; | ||||||||||||||
| 2 | 1 | ▶ | use Mojo::Base 'Mojolicious::Plugin'; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 3 | 1 | ▶ | use Config::Simple::Extended; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 4 | |||||||||||||||
| 5 | 1 | our $VERSION = '0.06'; | |||||||||||||
| 6 | |||||||||||||||
| 7 | 4 | ▶ | sub register { | ||||||||||||
|
Subroutine
register: called CC=7 SCAR=19.7
Pod
documented
| |||||||||||||||
| 8 | 4 | my ($self, $app, $args) = @_; | |||||||||||||
| 9 | 4 | my $cfg; | |||||||||||||
| 10 | 4 | ▶ | if(exists($args->{'config_file'})){ | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 11 | 1 | ▶ | unless( ref $args->{'config_file'} eq 'SCALAR' ){ | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 12 | 1 | die 'config_file key requires a SCALAR'; | |||||||||||||
| 13 | } | ||||||||||||||
| 14 | $cfg = Config::Simple->new( | ||||||||||||||
| 15 | 0 | $args->{'config_file'} ); | |||||||||||||
| 16 | } elsif(exists($args->{'config_files'})){ | ||||||||||||||
| 17 | 3 | ▶ | unless( ref $args->{'config_files'} eq 'ARRAY' ){ | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 18 | 1 | die 'config_files key requires an ARRAYREF'; | |||||||||||||
| 19 | } | ||||||||||||||
| 20 | 2 | undef($cfg); | |||||||||||||
| 21 | 2 | foreach my $file (@{$args->{'config_files'}}){ | |||||||||||||
| 22 | 2 | $cfg = Config::Simple::Extended->inherit({ | |||||||||||||
| 23 | base_config => $cfg, | ||||||||||||||
| 24 | filename => $file }); | ||||||||||||||
| 25 | } | ||||||||||||||
| 26 | } else { | ||||||||||||||
| 27 | 0 | die "Constructor invoked with no Confirguration File, see perldoc for details." | |||||||||||||
| 28 | } | ||||||||||||||
| 29 | 2 | ▶ | return wantarray ? ( \%{$cfg->vars}, $cfg ) : \%{$cfg->vars}; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 30 | } | ||||||||||||||
| 31 | |||||||||||||||
| 32 | 1 | ▶ | sub version { | ||||||||||||
|
Subroutine
version: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||
| 33 | 1 | return <<"END"; | |||||||||||||
| 34 | Config::Simple => $Config::Simple::VERSION | ||||||||||||||
| 35 | Config::Simple::Extended => $Config::Simple::Extended::VERSION | ||||||||||||||
| 36 | Mojolicious::Plugin::ConfigSimple => $VERSION | ||||||||||||||
| 37 | END | ||||||||||||||
| 38 | |||||||||||||||
| 39 | } | ||||||||||||||
| 40 | |||||||||||||||
| 41 | 1 | 1; | |||||||||||||
| 42 | __END__ | ||||||||||||||