[Catalyst-commits] r10698 - in trunk/Catalyst-Plugin-ConfigLoader:
. lib/Catalyst/Plugin t t/mockapp
t0m at dev.catalyst.perl.org
t0m at dev.catalyst.perl.org
Sun Jun 28 13:31:20 GMT 2009
Author: t0m
Date: 2009-06-28 13:31:18 +0000 (Sun, 28 Jun 2009)
New Revision: 10698
Modified:
trunk/Catalyst-Plugin-ConfigLoader/Changes
trunk/Catalyst-Plugin-ConfigLoader/lib/Catalyst/Plugin/ConfigLoader.pm
trunk/Catalyst-Plugin-ConfigLoader/t/21-mock_load_env.t
trunk/Catalyst-Plugin-ConfigLoader/t/mockapp/mockapp.pl
Log:
Patch to add an __ENV(foo)__ macro to configloader from Stuart Watt, from -devel list
Modified: trunk/Catalyst-Plugin-ConfigLoader/Changes
===================================================================
--- trunk/Catalyst-Plugin-ConfigLoader/Changes 2009-06-28 02:19:56 UTC (rev 10697)
+++ trunk/Catalyst-Plugin-ConfigLoader/Changes 2009-06-28 13:31:18 UTC (rev 10698)
@@ -1,6 +1,7 @@
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
Modified: trunk/Catalyst-Plugin-ConfigLoader/lib/Catalyst/Plugin/ConfigLoader.pm
===================================================================
--- trunk/Catalyst-Plugin-ConfigLoader/lib/Catalyst/Plugin/ConfigLoader.pm 2009-06-28 02:19:56 UTC (rev 10697)
+++ trunk/Catalyst-Plugin-ConfigLoader/lib/Catalyst/Plugin/ConfigLoader.pm 2009-06-28 13:31:18 UTC (rev 10698)
@@ -280,6 +280,8 @@
=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
@@ -305,6 +307,17 @@
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 );
@@ -329,6 +342,8 @@
=item * David Kamholz E<lt>dkamholz at cpan.orgE<gt> - L<Data::Visitor> integration
+=item * Stuart Watt - Addition of ENV macro.
+
=back
Work to this module has been generously sponsored by:
Modified: trunk/Catalyst-Plugin-ConfigLoader/t/21-mock_load_env.t
===================================================================
--- trunk/Catalyst-Plugin-ConfigLoader/t/21-mock_load_env.t 2009-06-28 02:19:56 UTC (rev 10697)
+++ trunk/Catalyst-Plugin-ConfigLoader/t/21-mock_load_env.t 2009-06-28 13:31:18 UTC (rev 10698)
@@ -1,6 +1,6 @@
package MockApp;
-use Test::More tests => 9;
+use Test::More tests => 10;
use Cwd;
local %ENV;
@@ -23,3 +23,4 @@
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' );
Modified: trunk/Catalyst-Plugin-ConfigLoader/t/mockapp/mockapp.pl
===================================================================
--- trunk/Catalyst-Plugin-ConfigLoader/t/mockapp/mockapp.pl 2009-06-28 02:19:56 UTC (rev 10697)
+++ trunk/Catalyst-Plugin-ConfigLoader/t/mockapp/mockapp.pl 2009-06-28 13:31:18 UTC (rev 10698)
@@ -4,5 +4,6 @@
'Model::Baz' => { qux => 'xyzzy' },
foo_sub => '__foo(x,y)__',
literal_macro => '__literal(__DATA__)__',
+ environment_macro => '__ENV(CATALYST_HOME)__/mockapp.pl',
Plugin => { Zot => { zoot => 'zooot' } },
}
More information about the Catalyst-commits
mailing list