Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
config files are often used to change the logger, so do not log confi…
…g files anymore
  • Loading branch information
kraih committed Jun 23, 2016
1 parent b368c81 commit c781639
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 18 deletions.
2 changes: 1 addition & 1 deletion Changes
@@ -1,5 +1,5 @@

7.0 2016-06-22
7.0 2016-06-23
- Code name "Nerd Face", this is a major release.
- Removed Mojolicious::Plugin::Charset.
- Removed squish method from Mojo::ByteStream.
Expand Down
15 changes: 6 additions & 9 deletions lib/Mojolicious/Plugin/Config.pm
Expand Up @@ -4,11 +4,7 @@ use Mojo::Base 'Mojolicious::Plugin';
use File::Spec::Functions 'file_name_is_absolute';
use Mojo::Util qw(decode slurp);

sub load {
my ($self, $file, $conf, $app) = @_;
$app->log->debug(qq{Reading configuration file "$file"});
return $self->parse(decode('UTF-8', slurp $file), $file, $conf, $app);
}
sub load { $_[0]->parse(decode('UTF-8', slurp $_[1]), @_[1, 2, 3]) }

sub parse {
my ($self, $content, $file, $conf, $app) = @_;
Expand Down Expand Up @@ -99,10 +95,11 @@ L<Mojolicious::Plugin::Config> is a Perl-ish configuration plugin.
The application object can be accessed via C<$app> or the C<app> function,
L<strict>, L<warnings>, L<utf8> and Perl 5.10 L<features|feature> are
automatically enabled. You can extend the normal configuration file
C<$moniker.conf> with C<mode> specific ones like C<$moniker.$mode.conf>. A
default configuration filename will be generated from the value of
L<Mojolicious/"moniker">.
automatically enabled. A default configuration filename in the application home
directory will be generated from the value of L<Mojolicious/"moniker">
(C<$moniker.conf>). You can extend the normal configuration file
C<$moniker.conf> with C<mode> specific ones like C<$moniker.$mode.conf>, which
will be detected automatically.
The code of this plugin is a good example for learning to build new plugins,
you're welcome to fork it.
Expand Down
9 changes: 5 additions & 4 deletions lib/Mojolicious/Plugin/JSONConfig.pm
Expand Up @@ -74,10 +74,11 @@ Mojolicious::Plugin::JSONConfig - JSON configuration plugin
L<Mojolicious::Plugin::JSONConfig> is a JSON configuration plugin that
preprocesses its input with L<Mojo::Template>.
The application object can be accessed via C<$app> or the C<app> function. You
can extend the normal configuration file C<$moniker.json> with C<mode> specific
ones like C<$moniker.$mode.json>. A default configuration filename will be
generated from the value of L<Mojolicious/"moniker">.
The application object can be accessed via C<$app> or the C<app> function. A
default configuration filename in the application home directory will be
generated from the value of L<Mojolicious/"moniker"> (C<$moniker.json>). You can
extend the normal configuration file C<$moniker.json> with C<mode> specific ones
like C<$moniker.$mode.json>, which will be detected automatically.
The code of this plugin is a good example for learning to build new plugins,
you're welcome to fork it.
Expand Down
4 changes: 0 additions & 4 deletions t/mojolicious/json_config_lite_app.t
Expand Up @@ -23,12 +23,8 @@ like $@, qr/Malformed JSON/, 'right error';
# Load plugins
my $config
= plugin j_s_o_n_config => {default => {foo => 'baz', hello => 'there'}};
my $log = '';
my $cb = app->log->on(message => sub { $log .= pop });
my $path = abs_path catfile(dirname(__FILE__), 'json_config_lite_app_abs.json');
plugin JSONConfig => {file => $path};
like $log, qr/Reading configuration file "\Q$path\E"/, 'right message';
app->log->unsubscribe(message => $cb);
is $config->{foo}, 'bar', 'right value';
is $config->{hello}, 'there', 'right value';
is $config->{utf}, 'утф', 'right value';
Expand Down

0 comments on commit c781639

Please sign in to comment.