Skip to content

Commit

Permalink
Remove attr config_files from Dancer2::Core::Role::Config
Browse files Browse the repository at this point in the history
Signed-off-by: Mikko Johannes Koivunalho <[email protected]>
  • Loading branch information
mikkoi committed Mar 27, 2022
1 parent 72efbd3 commit 3eb359f
Show file tree
Hide file tree
Showing 7 changed files with 0 additions and 84 deletions.
2 changes: 0 additions & 2 deletions lib/Dancer2/Core/App.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
22 changes: 0 additions & 22 deletions lib/Dancer2/Core/Role/Config.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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) = @_;
Expand Down Expand Up @@ -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<ConfigReader> classes.
=head1 METHODS
=head2 settings
Expand Down
17 changes: 0 additions & 17 deletions t/config-files-logged.t

This file was deleted.

5 changes: 0 additions & 5 deletions t/config_file_extended.t
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
4 changes: 0 additions & 4 deletions t/config_many.t
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 0 additions & 4 deletions t/config_multiapp.t
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down
30 changes: 0 additions & 30 deletions t/config_role.t
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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',
Expand Down

0 comments on commit 3eb359f

Please sign in to comment.