Revision history for Perl extension Catalyst::Plugin::ConfigLoader.
0.24 XXX
+ - Add an __ENV(foo)__ macro + tests (Stuart Watt)
- Document CATALYST_CONFIG_LOCAL_SUFFIX and MYAPP_LOCAL_CONFIG_SUFFIX
much better (Louis Erickson)
- Fix so that having CATALYST_CONFIG_LOCAL_SUFFIX set in $ENV{} doesn't
=item * C<__HOME__> - replaced with C<$c-E<gt>path_to('')>
+=item * C<__ENV(foo)__> - replaced with the value of C<$ENV{foo}>
+
=item * C<__path_to(foo/bar)__> - replaced with C<$c-E<gt>path_to('foo/bar')>
=item * C<__literal(__FOO__)__> - leaves __FOO__ alone (allows you to use
my $subs = $c->config->{ 'Plugin::ConfigLoader' }->{ substitutions }
|| {};
$subs->{ HOME } ||= sub { shift->path_to( '' ); };
+ $subs->{ ENV } ||=
+ sub {
+ my ( $c, $v ) = @_;
+ if (! defined($ENV{$v})) {
+ Catalyst::Exception->throw( message =>
+ "Missing environment variable: $v" );
+ return "";
+ } else {
+ return $ENV{ $v };
+ }
+ };
$subs->{ path_to } ||= sub { shift->path_to( @_ ); };
$subs->{ literal } ||= sub { return $_[ 1 ]; };
my $subsre = join( '|', keys %$subs );
=item * David Kamholz E<lt>dkamholz@cpan.orgE<gt> - L<Data::Visitor> integration
+=item * Stuart Watt - Addition of ENV macro.
+
=back
Work to this module has been generously sponsored by:
package MockApp;
-use Test::More tests => 9;
+use Test::More tests => 10;
use Cwd;
local %ENV;
is( __PACKAGE__->config->{ 'view' }, 'View::TT::New' );
is( __PACKAGE__->config->{ 'foo_sub' }, 'x-y' );
is( __PACKAGE__->config->{ 'literal_macro' }, '__DATA__' );
+is( __PACKAGE__->config->{ 'environment_macro' }, $ENV{ CATALYST_HOME }.'/mockapp.pl' );
'Model::Baz' => { qux => 'xyzzy' },
foo_sub => '__foo(x,y)__',
literal_macro => '__literal(__DATA__)__',
+ environment_macro => '__ENV(CATALYST_HOME)__/mockapp.pl',
Plugin => { Zot => { zoot => 'zooot' } },
}