| 1 | package Catalyst::Plugin::Config::Perl; | ||||||||||||||||||||
| 2 | 5 | ▶ | use 5.012; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 3 | 5 | ▶ | use Config::MorePerl; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | |||||||||||||||||||||
| 5 | 5 | our $VERSION = '1.1.0'; | |||||||||||||||||||
| 6 | |||||||||||||||||||||
| 7 | 5 | ▶ | use Class::Accessor::Inherited::XS inherited => [qw/cfg dev config_initial/]; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 8 | |||||||||||||||||||||
| 9 | 4 | ▶ | sub setup { | ||||||||||||||||||
|
Subroutine
setup: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 10 | 4 | my $class = shift; | |||||||||||||||||||
| 11 | 4 | my $initial_cfg = $class->config; | |||||||||||||||||||
| 12 | 4 | $class->config_initial($initial_cfg); | |||||||||||||||||||
| 13 | 4 | $class->cfg($initial_cfg); | |||||||||||||||||||
| 14 | 4 | $class->config_reload; | |||||||||||||||||||
| 15 | 4 | $class->next::method(@_); | |||||||||||||||||||
| 16 | } | ||||||||||||||||||||
| 17 | |||||||||||||||||||||
| 18 | 5 | ▶ | sub config_reload { | ||||||||||||||||||
|
Subroutine
config_reload: called CC=9 SCAR=22.1
Pod
documented
| |||||||||||||||||||||
| 19 | 5 | ▶ | my $class = ref($_[0]) || $_[0]; | ||||||||||||||||||
|
Condition33%1/3
ref $_[0] || $_[0]
MC/DC0%0/2
ref $_[0] || $_[0]
ref $_[0]
$_[0]
Truth table33%1/3
A || B
A= ref $_[0]B= $_[0]
| |||||||||||||||||||||
| 20 | #my $start = Time::HiRes::time(); | ||||||||||||||||||||
| 21 | 5 | my $initial_cfg = $class->config_initial; | |||||||||||||||||||
| 22 | 5 | ▶ | my $self_cfg = $initial_cfg->{'Plugin::Config::Perl'} || {}; | ||||||||||||||||||
|
Condition100%2/2
$initial_cfg->{'Plugin::Config::Perl'} || {}
MC/DC100%1/1
$initial_cfg->{'Plugin::Config::Perl'} || {}
$initial_cfg->{'Plugin::Config::Perl'}
Truth table100%2/2
A
A= $initial_cfg->{'Plugin::Config::Perl'}
| |||||||||||||||||||||
| 23 | 5 | ▶ | $initial_cfg->{home} = Path::Class::Dir->new($initial_cfg->{home}) unless ref $initial_cfg->{home}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 24 | |||||||||||||||||||||
| 25 | 5 | my $conf_file; | |||||||||||||||||||
| 26 | 5 | ▶ | if ($self_cfg->{file}) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 27 | 2 | $conf_file = $initial_cfg->{home}->file($self_cfg->{file}); | |||||||||||||||||||
| 28 | } else { | ||||||||||||||||||||
| 29 | 3 | my $local_file = $initial_cfg->{home}->file('local.conf'); | |||||||||||||||||||
| 30 | 3 | ▶ | if (-f $local_file) { $conf_file = $local_file } | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 31 | else { | ||||||||||||||||||||
| 32 | 1 | my $main_file = $initial_cfg->{home}->file('conf/'.lc($class).'.conf'); | |||||||||||||||||||
| 33 | 1 | ▶ | $conf_file = $main_file if -f $main_file; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 34 | } | ||||||||||||||||||||
| 35 | } | ||||||||||||||||||||
| 36 | |||||||||||||||||||||
| 37 | 5 | ▶ | if ($conf_file) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 38 | 5 | my $cfg = Config::MorePerl->process($conf_file, $initial_cfg); | |||||||||||||||||||
| 39 | 5 | my $old = $class->setup_finished; | |||||||||||||||||||
| 40 | 5 | $class->setup_finished(0); # work around fucking and annoying Catalyst | |||||||||||||||||||
| 41 | 5 | $class->config($cfg); | |||||||||||||||||||
| 42 | 5 | $class->setup_finished($old); | |||||||||||||||||||
| 43 | 5 | $class->cfg($cfg); | |||||||||||||||||||
| 44 | } | ||||||||||||||||||||
| 45 | |||||||||||||||||||||
| 46 | 5 | $class->dev($class->cfg->{dev}); | |||||||||||||||||||
| 47 | |||||||||||||||||||||
| 48 | #print "ConfigSuite Init took ".((Time::HiRes::time() - $start)*1000)."\n"; | ||||||||||||||||||||
| 49 | 5 | my $sub = $class->can('finalize_config'); | |||||||||||||||||||
| 50 | 5 | ▶ | $sub->($class) if $sub; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 51 | |||||||||||||||||||||
| 52 | 5 | $class->dev($class->cfg->{dev}); | |||||||||||||||||||
| 53 | } | ||||||||||||||||||||
| 54 | |||||||||||||||||||||
| 55 | 5 | 1; | |||||||||||||||||||