From 3eb359fd030dac1b657517e29b90b1e33815bc6a Mon Sep 17 00:00:00 2001 From: Mikko Johannes Koivunalho Date: Sun, 27 Mar 2022 16:22:14 +0200 Subject: [PATCH] Remove attr config_files from Dancer2::Core::Role::Config Signed-off-by: Mikko Johannes Koivunalho --- lib/Dancer2/Core/App.pm | 2 -- lib/Dancer2/Core/Role/Config.pm | 22 ---------------------- t/config-files-logged.t | 17 ----------------- t/config_file_extended.t | 5 ----- t/config_many.t | 4 ---- t/config_multiapp.t | 4 ---- t/config_role.t | 30 ------------------------------ 7 files changed, 84 deletions(-) delete mode 100644 t/config-files-logged.t diff --git a/lib/Dancer2/Core/App.pm b/lib/Dancer2/Core/App.pm index b077e6432..31b116b02 100644 --- a/lib/Dancer2/Core/App.pm +++ b/lib/Dancer2/Core/App.pm @@ -1109,8 +1109,6 @@ sub BUILD { my $self = shift; $self->init_route_handlers(); $self->_init_hooks(); - - $self->log(core => 'Built config from files: ' . join(' ', @{$self->config_files})); } sub finish { diff --git a/lib/Dancer2/Core/Role/Config.pm b/lib/Dancer2/Core/Role/Config.pm index 79cb651a1..ca83bdf2a 100644 --- a/lib/Dancer2/Core/Role/Config.pm +++ b/lib/Dancer2/Core/Role/Config.pm @@ -59,13 +59,6 @@ has environment => ( builder => '_build_environment', ); -has config_files => ( - is => 'ro', - lazy => 1, - isa => ArrayRef, - builder => '_build_config_files', -); - has config_readers => ( is => 'ro', lazy => 1, @@ -115,16 +108,6 @@ sub _build_default_config { +{} } sub _build_environment { 'development' } -sub _build_config_files { - my ($self) = @_; - - return [ map { - warn "Merging config_files from @{[ $_->name() ]}\n" if $ENV{DANCER_CONFIG_VERBOSE}; - @{ $_->config_files() } - } @{ $self->config_readers } - ]; -} - # The new config builder sub _build_config { my ($self) = @_; @@ -361,11 +344,6 @@ Returns the whole configuration. Returns the name of the environment. -=attr config_files - -List of all the configuration files. This information -is queried from the B classes. - =head1 METHODS =head2 settings diff --git a/t/config-files-logged.t b/t/config-files-logged.t deleted file mode 100644 index aac1d7822..000000000 --- a/t/config-files-logged.t +++ /dev/null @@ -1,17 +0,0 @@ -use strict; -use warnings; - -use Test::More; -use File::Spec; - -use lib '.'; -use t::app::t3::lib::App4; - -my ($app) = @{ Dancer2->runner->apps }; -my $trap = $app->logger_engine->trapper; -my $logs = $trap->read; - -like( $logs->[0]{message}, qr/Built config from files/, 'log message ok'); - -done_testing; - diff --git a/t/config_file_extended.t b/t/config_file_extended.t index b40946b97..fc4b3323c 100644 --- a/t/config_file_extended.t +++ b/t/config_file_extended.t @@ -19,11 +19,6 @@ use t::app::t_config_file_extended::lib::App1; my $app = Dancer2->runner->apps->[0]; -is_deeply $app->config_files, - [ File::Spec->rel2abs(File::Spec->catfile( 't', 'app', - 't_config_file_extended', 'config.yml' )) ], - $app->name . ": config files found"; - is $app->config->{app}->{config}, 'ok', $app->name . ": config loaded properly"; is $app->config->{extended}->{one}, 'Extended String', diff --git a/t/config_many.t b/t/config_many.t index 4755560db..ab28a66d0 100644 --- a/t/config_many.t +++ b/t/config_many.t @@ -18,10 +18,6 @@ use t::app::t1::lib::App1; my $app = Dancer2->runner->apps->[0]; -is_deeply $app->config_files, - [ File::Spec->rel2abs(File::Spec->catfile( 't', 'app', 't1', 'config.yml' )) ], - $app->name . ": config files found"; - is $app->config->{app}->{config}, 'ok', $app->name . ": config loaded properly"; is $app->config->{dummy}->{dummy_subitem}, 2, diff --git a/t/config_multiapp.t b/t/config_multiapp.t index a2acc6c48..e54eb4426 100644 --- a/t/config_multiapp.t +++ b/t/config_multiapp.t @@ -13,10 +13,6 @@ for my $app ( @{ Dancer2->runner->apps } ) { # Need to determine path to config; use apps' name for now.. my $path = $app->name eq 'App3' ? 't2' : 't1'; - is_deeply $app->config_files, - [ File::Spec->rel2abs(File::Spec->catfile( 't', 'app', $path, 'config.yml' )) ], - $app->name . ": config files found"; - is $app->config->{app}->{config}, 'ok', $app->name . ": config loaded properly" } diff --git a/t/config_role.t b/t/config_role.t index ea432e4ad..e99233d19 100644 --- a/t/config_role.t +++ b/t/config_role.t @@ -76,37 +76,15 @@ my $location2 = File::Spec->rel2abs( path( dirname(__FILE__), 'config2' ) ); } my $d = Dev->new(); -is_deeply $d->config_files, - [ path( $location, 'config.yml' ), ], - "config_files() only sees existing files"; my $f = Prod->new; is $f->does('Dancer2::Core::Role::Config'), 1, "role Dancer2::Core::Role::Config is consumed"; -is_deeply $f->config_files, - [ path( $location, 'config.yml' ), - path( $location, 'environments', 'production.yml' ), - ], - "config_files() works"; - -my $j = Staging->new; -is_deeply $j->config_files, - [ path( $location, 'config.yml' ), - path( $location, 'environments', 'staging.json' ), - ], - "config_files() does JSON too!"; - note "bad YAML file"; my $fail = Failure->new; is $fail->environment, 'failure'; -is_deeply $fail->config_files, - [ path( $location, 'config.yml' ), - path( $location, 'environments', 'failure.yml' ), - ], - "config_files() works"; - like( exception { $fail->config }, qr{Unable to parse the configuration file}, 'Configuration file parsing failure', @@ -126,14 +104,6 @@ is_deeply $m->config->{application}, { my $l = LocalConfig->new; - is_deeply $l->config_files, - [ path( $location2, 'config.yml' ), - path( $location2, 'config_local.yml' ), - path( $location2, 'environments', 'lconfig.yml' ), - path( $location2, 'environments', 'lconfig_local.yml' ), - ], - "config_files() with local config works"; - is_deeply $l->config->{application}, { feature_1 => 'foo', feature_2 => 'alpha',