[Catalyst] Doc patch for ConfigLoader.
Louis Erickson
lerickson at rdwarf.net
Thu May 14 05:02:36 GMT 2009
I wrote a blog entry the other day about ConfigLoader and what the file
names generated by MYAPP_CONFIG_LOCAL_SUFFIX etc. are. t0m suggested I
write a patch. I've done so.
I checked Catalyst out of subversion just to make sure I didn't
finger-fumble and break the pod tests, and to have a look about.
Having done that, I am confident I used the most current code. =)
I also began to see why it's hard to catch these, as I noticed that this
behavior is documented in the existing docs if you understand how it works
already.
A patch containing only changes to the POD is attached. It's a unified
diff as requested on the wiki. I've never generated a patch before, so
I'm not sure it's quite right.
With these docs in place, I would have found what I was looking for and
not spent time debugging.
Please let me know if you have any suggestions, changes, or if the patch
does not work for some reason.
--
Louis Erickson - lerickson at rdwarf.net - http://www.rdwarf.com/~wwonko/
One man's theology is another man's belly laugh.
-------------- next part --------------
diff -r -u -b Catalyst-Plugin-ConfigLoader-orig/lib/Catalyst/Plugin/ConfigLoader/Manual.pod Catalyst-Plugin-ConfigLoader/lib/Catalyst/Plugin/ConfigLoader/Manual.pod
--- Catalyst-Plugin-ConfigLoader-orig/lib/Catalyst/Plugin/ConfigLoader/Manual.pod 2009-05-13 19:17:30.000000000 -0700
+++ Catalyst-Plugin-ConfigLoader/lib/Catalyst/Plugin/ConfigLoader/Manual.pod 2009-05-13 09:50:25.000000000 -0700
@@ -187,5 +187,39 @@
}
} );
+=head2 Using a local configuration file
+
+When ConfigLoader reads configurations, it starts by reading the configuration
+file for C<myapp> with one of the supported extensions as listed
+L<above|/Config Formats>.
+
+For example, A L<Config::General> config file is C<myapp.conf>.
+
+If a configuration file called C<myapp_local> exists with one of the supported
+file extensions, it will also be read, and values from that file will
+override values from the main config file.
+
+A L<Config::General> local configuration file would be called
+C<myapp_local.conf>.
+
+The C<local> suffix can be changed. See
+L<Catalyst::Plugin::ConfigLoader/get_config_local_suffix> for the details of
+how.
+
+This is useful because it allows different people or environments to have
+different configuration files. A project with three developers,
+I<Tom>, I<Dick>, and I<Harry> as well as a production environment can have
+a C<myapp_tom.conf>, a C<myapp_dick.conf>, a C<myapp_harry.conf>, and a
+C<myapp_production.conf>.
+
+Each developer, and the web server, would set the environment variable
+to load their proper configuration file. All of the configurations can
+be stored properly in source control.
+
+If there is no C<myapp.local>, and the individual configuration files contain
+something required to start the application, such as the Model's data source
+definition, the applicaton won't start unless the environment variable
+is set properly.
+
=cut
diff -r -u -b Catalyst-Plugin-ConfigLoader-orig/lib/Catalyst/Plugin/ConfigLoader.pm Catalyst-Plugin-ConfigLoader/lib/Catalyst/Plugin/ConfigLoader.pm
--- Catalyst-Plugin-ConfigLoader-orig/lib/Catalyst/Plugin/ConfigLoader.pm 2009-05-13 19:17:30.000000000 -0700
+++ Catalyst-Plugin-ConfigLoader/lib/Catalyst/Plugin/ConfigLoader.pm 2009-05-13 09:27:20.000000000 -0700
@@ -53,7 +53,9 @@
To support the distinction between development and production environments,
this module will also attemp to load a local config (e.g. myapp_local.yaml)
-which will override any duplicate settings.
+which will override any duplicate settings. See
+L<get_config_local_suffix|/get_config_local_suffix>
+for details on how this is configured.
=head1 METHODS
@@ -194,7 +196,8 @@
=head2 get_config_local_suffix
Determines the suffix of files used to override the main config. By default
-this value is C<local>, but it can be specified in the following order of preference:
+this value is C<local>, which will load C<myapp_local.conf>. The suffix can
+be specified in the following order of preference:
=over 4
@@ -206,6 +209,13 @@
=back
+The first one of these values found replaces the default of C<local> in the
+name of the local config file to be loaded.
+
+For example, if C< $ENV{ MYAPP_CONFIG_LOCAL_SUFFIX }> is set to C<testing>,
+ConfigLoader will try and load C<myapp_testing.conf> instead of
+C<myapp_local.conf>.
+
=cut
sub get_config_local_suffix {
More information about the Catalyst
mailing list