Catalyst-Plugin-ConfigLoader-0.35/000755 000000 000000 00000000000 13707311671 017120 5ustar00rootwheel000000 000000 Catalyst-Plugin-ConfigLoader-0.35/README000644 000000 000000 00000012566 13707311670 020011 0ustar00rootwheel000000 000000 NAME Catalyst::Plugin::ConfigLoader - Load config files of various types SYNOPSIS package MyApp; # ConfigLoader should be first in your list so # other plugins can get the config information use Catalyst qw( ConfigLoader ... ); # by default myapp.* will be loaded # you can specify a file if you'd like __PACKAGE__->config( 'Plugin::ConfigLoader' => { file => 'config.yaml' } ); In the file, assuming it's in YAML format: foo: bar Accessible through the context object, or the class itself $c->config->{foo} # bar MyApp->config->{foo} # bar DESCRIPTION This module will attempt to load find and load a configuration file of various types. Currently it supports YAML, JSON, XML, INI and Perl formats. Special configuration for a particular driver format can be stored in "MyApp->config->{ 'Plugin::ConfigLoader' }->{ driver }". For example, to pass arguments to Config::General, use the following: __PACKAGE__->config( 'Plugin::ConfigLoader' => { driver => { 'General' => { -LowerCaseNames => 1 } } } ); See Config::Any's "driver_args" parameter for more information. 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. See "get_config_local_suffix" for details on how this is configured. METHODS setup( ) This method is automatically called by Catalyst's setup routine. It will attempt to use each plugin and, once a file has been successfully loaded, set the "config()" section. load_config This method handles loading the configuration data into the Catalyst context object. It does not return a value. find_files This method determines the potential file paths to be used for config loading. It returns an array of paths (up to the filename less the extension) to pass to Config::Any for loading. get_config_path This method determines the path, filename prefix and file extension to be used for config loading. It returns the path (up to the filename less the extension) to check and the specific extension to use (if it was specified). The order of preference is specified as: * $ENV{ MYAPP_CONFIG } * $ENV{ CATALYST_CONFIG } * "$c->config->{ 'Plugin::ConfigLoader' }->{ file }" * "$c->path_to( $application_prefix )" If either of the first two user-specified options are directories, the application prefix will be added on to the end of the path. get_config_local_suffix Determines the suffix of files used to override the main config. By default this value is "local", which will load "myapp_local.conf". The suffix can be specified in the following order of preference: * $ENV{ MYAPP_CONFIG_LOCAL_SUFFIX } * $ENV{ CATALYST_CONFIG_LOCAL_SUFFIX } * "$c->config->{ 'Plugin::ConfigLoader' }->{ config_local_suffix }" The first one of these values found replaces the default of "local" in the name of the local config file to be loaded. For example, if $ENV{ MYAPP_CONFIG_LOCAL_SUFFIX } is set to "testing", ConfigLoader will try and load myapp_testing.conf instead of myapp_local.conf. finalize_config This method is called after the config file is loaded. It can be used to implement tuning of config values that can only be done at runtime. If you need to do this to properly configure any plugins, it's important to load ConfigLoader before them. ConfigLoader provides a default "finalize_config" method which walks through the loaded config hash and calls the config_substitutions method on any string. config_substitutions( $value ) This method substitutes macros found with calls to a function. There are a number of default macros: * "__HOME__" - replaced with "$c->path_to('')" * "__ENV(foo)__" - replaced with the value of $ENV{foo} * "__path_to(foo/bar)__" - replaced with "$c->path_to('foo/bar')" * "__literal(__FOO__)__" - leaves __FOO__ alone (allows you to use "__DATA__" as a config value, for example) The parameter list is split on comma (","). You can override this method to do your own string munging, or you can define your own macros in "MyApp->config->{ 'Plugin::ConfigLoader' }->{ substitutions }". Example: MyApp->config->{ 'Plugin::ConfigLoader' }->{ substitutions } = { baz => sub { my $c = shift; qux( @_ ); } } The above will respond to "__baz(x,y)__" in config strings. AUTHOR Brian Cassidy CONTRIBUTORS The following people have generously donated their time to the development of this module: * Joel Bernstein - Rewrite to use Config::Any * David Kamholz - Data::Visitor integration * Stuart Watt - Addition of ENV macro. Work to this module has been generously sponsored by: * Portugal Telecom - Work done by Joel Bernstein COPYRIGHT AND LICENSE Copyright 2006-2010 by Brian Cassidy This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. SEE ALSO * Catalyst * Catalyst::Plugin::ConfigLoader::Manual * Config::Any Catalyst-Plugin-ConfigLoader-0.35/Changes000644 000000 000000 00000013636 13707311625 020423 0ustar00rootwheel000000 000000 Revision history for Perl extension Catalyst::Plugin::ConfigLoader. 0.35 - 2020-07-26 - Removed use of Module::Install, fixing installing without . in @INC - Moved pod tests to be only run for authors - Fix tests when run with CATALYST_CONFIG environment variable set - Minor Pod cleanups - Remove Path::Class test dependency - Metadata updates and cleanups 0.34 Wed Apr 16 2014 - Repackage without non-standard tarball headers. 0.33 Mon Jan 13 2014 - Fix config loading so that if passed a directory including a . in the file name, then loading it as a directory works (would have previously tried to force a specific filename and failed) - More comprehensive tests 0.32 Thu Mar 14 2013 - Don't ship .git inside the tarball, whoops. 0.31 Sat Mar 09 2013 - Fix repository location in metadata. 0.30 Fri Aug 20 2010 - Fix for Windows regarding changes from 0.29 0.29 Fri Aug 20 2010 - Fix issue with 2 character app names that are kept in versioned directories (e.g. app called QX in QX-2.1.5/) - bump dep on Config::Any to use the -ForceArray Config::General option (caelum) 0.28 Wed Jun 30 2010 - Pod Fixes related to config_substitutions() (Oleg Kostyuk) - Pod fix for the "Using a local configuration file" section of the Manual (RT #48823) - Expand XML config example in the manual (teejay, Kieren Diment) 0.27 Thu Aug 13 2009 - Require Catalyst 5.8 for tests that use ctx_request() (RT #48651) 0.26 Mon Aug 10 2009 - Fix test to not need "parent" (RT #48547) - Do not localize %ENV, rather, remove potentially conflicting k-v pairs (RT #48557) 0.25 Fri Aug 07 2009 - Fix get_config_local_suffix and get_config_path when finding values from ENV vars (RT #47937) 0.24 Mon Jun 29 2009 - 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 cause the tests to break. 0.23 Sat Apr 18 2009 - Update Data::Visitor 0.22 Mon Jan 05 2009 - add a cookbook entry re: UTF-8 and Config::General (Octavian Rasnita) - switch from NEXT to MRO::Compat 0.21 Mon Aug 11 2008 - add a cookbook entry for converting an existing config to Config::General format - fix up pod to explain in more detail how to pass options to each driver class (Sergio Salvi) - add nice syntax for plugins to match models/views/controllers (ilmari) 0.20 Fri May 02 2008 - sort configs by filename for loading (RT #31498) - updated pod with new example - die() instead of silently skip files with extensions we can't handle [THINGS THAT MAY BREAK YOUR CODE] - deprecation notices removed, support for old keys removed. 0.19 Wed Nov 21 2007 - fixed suffix appending to explicit config paths [NOTE] - Deprecation notices scream a little louder and sleep for 3 seconds as this should be the last release for them 0.18 Sat Oct 13 2007 - fix indentation on manual entry for DBIC::Schema config (Jeremy Wall) RT #29967 [NOTE] - Deprecation notices will remain intact 0.17 Fri Aug 24 2007 - Requires Catalyst::Runtime 5.7008 for env_value() [NOTE] - Deprecation notices will hold for another release 0.16 Thu Aug 23 2007 - separated out the macro expansion code into config_substitutions() (Jason Kohles) - allow users to specify their own macros in the "substitutions" config (Johnathan Rockway) - pass special constructor arguments to Config::Any. Requires Config::Any 0.08 (Gareth Kirwan) [DEPRECATION NOTICE] - the "file" and "config_local_suffix" config keys are now to be explicitly set under the Plugin::ConfigLoader key. Support for these keys will be removed in the next release. [THINGS THAT MAY BREAK YOUR CODE] - use Catalyst::Utils::env_value() to get $ENV values. This means that MYAPP_* is of higher precedence than CATALYST_* -- this differs from the behavior of older releases. 0.15 Tue Aug 21 2007 - Allow multiple __HOME__ and __path_to()__ replaces in one string (Greg Sheard) 0.14 Tue Apr 03 2007 - switch to Module::Install - added a user manual 0.13 Fri Aug 25 2006 - loading code factored out into Config::Any [rataxis@cpan.org] sponsored by Portugal Telecom 0.12 Wed Jul 12 2006 - made the "local" suffix overrideable - fixed __path_to()__ docs 0.11 Tue Jul 11 2006 - remember, kids: 09 > 1 0.1 Tue Jul 11 2006 - remove hash merging since it is now a core behavior - added C/M/V legacy shortcuts - fixed debug output some - switched to Module::Pluggable::Object 0.09 Wed May 24 2006 - ignore non-ref model/view/controller/component keys 0.08 Tue May 23 2006 - added get_config_path() which extracts the path finding code - added the ability to specify a MYAPP_CONFIG ENV variable - more granular merging of top-level hashrefs - more comprehensive tests 0.07 Mon May 01 2006 - added Config::General support - added nicer syntax for specifying models/views/controllers where available 0.06 Wed Apr 26 2006 - remove "last;" so that _local configs will be processed 0.05 Thu Apr 18 2006 - __HOME__ now corresponds to $c->path_to( '' ) and nothing else - __path_to( 'foo/bar' )__ turns in to $c->path_to( 'foo', 'bar' ) - attemps to load ${config}_local.$ext after ${config}.$ext for an overriding effect 0.04 Wed Feb 08 2006 - add finalize_config method - make default finalize_config traverse the config and substitute things beginning __HOME__/* with real path - don't use File::Slurp, produces annoying warnings on some systems 0.03 Mon Jan 30 2006 - pod fixes 0.02 Sun Jan 29 2006 - refactoring (suggested by Christian Hansen) 0.01 Sat Jan 28 2006 - original version Catalyst-Plugin-ConfigLoader-0.35/MANIFEST000644 000000 000000 00000002701 13707311671 020251 0ustar00rootwheel000000 000000 Changes lib/Catalyst/Plugin/ConfigLoader.pm lib/Catalyst/Plugin/ConfigLoader/Manual.pod maint/Makefile.PL.include Makefile.PL MANIFEST This list of files t/01-use.t t/10-live_auto.t t/20-mock_load.t t/21-mock_load_env.t t/22-suffix_env.t t/23-path_env.t t/24-mock-shortappname.t t/25-setting-config-file.t t/lib/TestApp.pm t/lib/TestApp/Controller/Config.pm t/lib/TestApp/Controller/Root.pm t/lib/TestApp/testapp.pl t/lib/TestApp1.pm t/lib/TestApp1/Controller/Config.pm t/lib/TestApp1/Controller/Root.pm t/lib/TestApp1/customconfig.pl t/lib/TestApp1/testapp1.pl t/lib/TestApp2.pm t/lib/TestApp2/Controller/Config.pm t/lib/TestApp2/Controller/Root.pm t/lib/TestApp2/customconfig.pl t/lib/TestApp2/testapp2.pl t/lib/TestApp3.pm t/lib/TestApp3/config/another_file.pl t/lib/TestApp3/config/testapp3.pl t/lib/TestApp3/Controller/Config.pm t/lib/TestApp3/Controller/Root.pm t/lib/TestApp3/testapp3.pl t/lib/TestApp4.pm t/lib/TestApp4/config.d/another_file.pl t/lib/TestApp4/config.d/testapp4.pl t/lib/TestApp4/Controller/Config.pm t/lib/TestApp4/Controller/Root.pm t/lib/TestApp4/testapp.pl t/mockapp/mockapp.pl t/mockapp/mockapp_local.pl xt/pod-coverage.t xt/pod.t META.yml Module YAML meta-data (added by MakeMaker) META.json Module JSON meta-data (added by MakeMaker) README README file (added by Distar) LICENSE LICENSE file (added by Distar) Catalyst-Plugin-ConfigLoader-0.35/LICENSE000644 000000 000000 00000043425 13707311671 020135 0ustar00rootwheel000000 000000 Terms of the Perl programming language system itself a) the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version, or b) the "Artistic License" --- The GNU General Public License, Version 1, February 1989 --- This software is Copyright (c) 2020 by Brian Cassidy . This is free software, licensed under: The GNU General Public License, Version 1, February 1989 GNU GENERAL PUBLIC LICENSE Version 1, February 1989 Copyright (C) 1989 Free Software Foundation, Inc. 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The license agreements of most software companies try to keep users at the mercy of those companies. By contrast, our General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. The General Public License applies to the Free Software Foundation's software and to any other program whose authors commit to using it. You can use it for your programs, too. When we speak of free software, we are referring to freedom, not price. Specifically, the General Public License is designed to make sure that you have the freedom to give away or sell copies of free software, that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of a such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must tell them their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any work containing the Program or a portion of it, either verbatim or with modifications. Each licensee is addressed as "you". 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this General Public License and to the absence of any warranty; and give any other recipients of the Program a copy of this General Public License along with the Program. You may charge a fee for the physical act of transferring a copy. 2. You may modify your copy or copies of the Program or any portion of it, and copy and distribute such modifications under the terms of Paragraph 1 above, provided that you also do the following: a) cause the modified files to carry prominent notices stating that you changed the files and the date of any change; and b) cause the whole of any work that you distribute or publish, that in whole or in part contains the Program or any part thereof, either with or without modifications, to be licensed at no charge to all third parties under the terms of this General Public License (except that you may choose to grant warranty protection to some or all third parties, at your option). c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the simplest and most usual way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this General Public License. d) You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. Mere aggregation of another independent work with the Program (or its derivative) on a volume of a storage or distribution medium does not bring the other work under the scope of these terms. 3. You may copy and distribute the Program (or a portion or derivative of it, under Paragraph 2) in object code or executable form under the terms of Paragraphs 1 and 2 above provided that you also do one of the following: a) accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Paragraphs 1 and 2 above; or, b) accompany it with a written offer, valid for at least three years, to give any third party free (except for a nominal charge for the cost of distribution) a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Paragraphs 1 and 2 above; or, c) accompany it with the information you received as to where the corresponding source code may be obtained. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form alone.) Source code for a work means the preferred form of the work for making modifications to it. For an executable file, complete source code means all the source code for all modules it contains; but, as a special exception, it need not include source code for modules which are standard libraries that accompany the operating system on which the executable file runs, or for standard header files or definitions files that accompany that operating system. 4. You may not copy, modify, sublicense, distribute or transfer the Program except as expressly provided under this General Public License. Any attempt otherwise to copy, modify, sublicense, distribute or transfer the Program is void, and will automatically terminate your rights to use the Program under this License. However, parties who have received copies, or rights to use copies, from you under this General Public License will not have their licenses terminated so long as such parties remain in full compliance. 5. By copying, distributing or modifying the Program (or any work based on the Program) you indicate your acceptance of this license to do so, and all its terms and conditions. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. 7. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of the license which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the license, you may choose any version ever published by the Free Software Foundation. 8. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to humanity, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19xx name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (a program to direct compilers to make passes at assemblers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice That's all there is to it! --- The Artistic License 1.0 --- This software is Copyright (c) 2020 by Brian Cassidy . This is free software, licensed under: The Artistic License 1.0 The Artistic License Preamble The intent of this document is to state the conditions under which a Package may be copied, such that the Copyright Holder maintains some semblance of artistic control over the development of the package, while giving the users of the package the right to use and distribute the Package in a more-or-less customary fashion, plus the right to make reasonable modifications. Definitions: - "Package" refers to the collection of files distributed by the Copyright Holder, and derivatives of that collection of files created through textual modification. - "Standard Version" refers to such a Package if it has not been modified, or has been modified in accordance with the wishes of the Copyright Holder. - "Copyright Holder" is whoever is named in the copyright or copyrights for the package. - "You" is you, if you're thinking about copying or distributing this Package. - "Reasonable copying fee" is whatever you can justify on the basis of media cost, duplication charges, time of people involved, and so on. (You will not be required to justify it to the Copyright Holder, but only to the computing community at large as a market that must bear the fee.) - "Freely Available" means that no fee is charged for the item itself, though there may be fees involved in handling the item. It also means that recipients of the item may redistribute it under the same conditions they received it. 1. You may make and give away verbatim copies of the source form of the Standard Version of this Package without restriction, provided that you duplicate all of the original copyright notices and associated disclaimers. 2. You may apply bug fixes, portability fixes and other modifications derived from the Public Domain or from the Copyright Holder. A Package modified in such a way shall still be considered the Standard Version. 3. You may otherwise modify your copy of this Package in any way, provided that you insert a prominent notice in each changed file stating how and when you changed that file, and provided that you do at least ONE of the following: a) place your modifications in the Public Domain or otherwise make them Freely Available, such as by posting said modifications to Usenet or an equivalent medium, or placing the modifications on a major archive site such as ftp.uu.net, or by allowing the Copyright Holder to include your modifications in the Standard Version of the Package. b) use the modified Package only within your corporation or organization. c) rename any non-standard executables so the names do not conflict with standard executables, which must also be provided, and provide a separate manual page for each non-standard executable that clearly documents how it differs from the Standard Version. d) make other distribution arrangements with the Copyright Holder. 4. You may distribute the programs of this Package in object code or executable form, provided that you do at least ONE of the following: a) distribute a Standard Version of the executables and library files, together with instructions (in the manual page or equivalent) on where to get the Standard Version. b) accompany the distribution with the machine-readable source of the Package with your modifications. c) accompany any non-standard executables with their corresponding Standard Version executables, giving the non-standard executables non-standard names, and clearly documenting the differences in manual pages (or equivalent), together with instructions on where to get the Standard Version. d) make other distribution arrangements with the Copyright Holder. 5. You may charge a reasonable copying fee for any distribution of this Package. You may charge any fee you choose for support of this Package. You may not charge a fee for this Package itself. However, you may distribute this Package in aggregate with other (possibly commercial) programs as part of a larger (possibly commercial) software distribution provided that you do not advertise this Package as a product of your own. 6. The scripts and library files supplied as input to or produced as output from the programs of this Package do not automatically fall under the copyright of this Package, but belong to whomever generated them, and may be sold commercially, and may be aggregated with this Package. 7. C or perl subroutines supplied by you and linked into this Package shall not be considered part of this Package. 8. The name of the Copyright Holder may not be used to endorse or promote products derived from this software without specific prior written permission. 9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. The End Catalyst-Plugin-ConfigLoader-0.35/t/000755 000000 000000 00000000000 13707311664 017365 5ustar00rootwheel000000 000000 Catalyst-Plugin-ConfigLoader-0.35/xt/000755 000000 000000 00000000000 13707311664 017555 5ustar00rootwheel000000 000000 Catalyst-Plugin-ConfigLoader-0.35/META.yml000644 000000 000000 00000001621 13707311665 020374 0ustar00rootwheel000000 000000 --- abstract: 'Load config files of various types' author: - 'Brian Cassidy ' build_requires: Test::More: '0.96' configure_requires: ExtUtils::MakeMaker: '0' dynamic_config: 1 generated_by: 'ExtUtils::MakeMaker version 7.44, CPAN::Meta::Converter version 2.150010' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: Catalyst-Plugin-ConfigLoader no_index: directory: - t - xt requires: Catalyst::Runtime: '5.7008' Config::Any: '0.20' Data::Visitor: '0.24' MRO::Compat: '0.09' resources: IRC: irc://irc.perl.org/#catalyst bugtracker: https://rt.cpan.org/Public/Dist/Display.html?Name=Catalyst-Plugin-ConfigLoader license: http://dev.perl.org/licenses/ repository: git://git.shadowcat.co.uk/catagits/Catalyst-Plugin-ConfigLoader.git version: '0.35' x_serialization_backend: 'CPAN::Meta::YAML version 0.018' Catalyst-Plugin-ConfigLoader-0.35/META.json000644 000000 000000 00000003433 13707311667 020551 0ustar00rootwheel000000 000000 { "abstract" : "Load config files of various types", "author" : [ "Brian Cassidy " ], "dynamic_config" : 1, "generated_by" : "ExtUtils::MakeMaker version 7.44, CPAN::Meta::Converter version 2.150010", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : 2 }, "name" : "Catalyst-Plugin-ConfigLoader", "no_index" : { "directory" : [ "t", "xt" ] }, "prereqs" : { "build" : {}, "configure" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "develop" : { "requires" : { "Test::Pod" : "1.00", "Test::Pod::Coverage" : "1.00" } }, "runtime" : { "requires" : { "Catalyst::Runtime" : "5.7008", "Config::Any" : "0.20", "Data::Visitor" : "0.24", "MRO::Compat" : "0.09" } }, "test" : { "requires" : { "Test::More" : "0.96" } } }, "release_status" : "stable", "resources" : { "bugtracker" : { "mailto" : "bug-Catalyst-Plugin-ConfigLoader@rt.cpan.org", "web" : "https://rt.cpan.org/Public/Dist/Display.html?Name=Catalyst-Plugin-ConfigLoader" }, "license" : [ "http://dev.perl.org/licenses/" ], "repository" : { "type" : "git", "url" : "git://git.shadowcat.co.uk/catagits/Catalyst-Plugin-ConfigLoader.git", "web" : "http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits/Catalyst-Plugin-ConfigLoader.git" }, "x_IRC" : "irc://irc.perl.org/#catalyst" }, "version" : "0.35", "x_serialization_backend" : "JSON::PP version 4.04" } Catalyst-Plugin-ConfigLoader-0.35/lib/000755 000000 000000 00000000000 13707311664 017670 5ustar00rootwheel000000 000000 Catalyst-Plugin-ConfigLoader-0.35/maint/000755 000000 000000 00000000000 13707311664 020232 5ustar00rootwheel000000 000000 Catalyst-Plugin-ConfigLoader-0.35/Makefile.PL000644 000000 000000 00000005720 13707311104 021065 0ustar00rootwheel000000 000000 use strict; use warnings FATAL => 'all'; use 5.008; my %META = ( name => 'Catalyst-Plugin-ConfigLoader', license => 'perl_5', prereqs => { configure => { requires => { 'ExtUtils::MakeMaker' => 0, } }, test => { requires => { 'Test::More' => '0.96', }, }, runtime => { requires => { 'Catalyst::Runtime' => '5.7008', # needed for env_value() 'Data::Visitor' => '0.24', 'Config::Any' => '0.20', 'MRO::Compat' => '0.09', }, }, develop => { requires => { 'Test::Pod' => '1.00', 'Test::Pod::Coverage' => '1.00', }, }, }, resources => { repository => { # rw: catagits@git.shadowcat.co.uk:Catalyst-Plugin-ConfigLoader.git url => 'git://git.shadowcat.co.uk/catagits/Catalyst-Plugin-ConfigLoader.git', web => 'http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits/Catalyst-Plugin-ConfigLoader.git', type => 'git', }, x_IRC => 'irc://irc.perl.org/#catalyst', bugtracker => { web => 'https://rt.cpan.org/Public/Dist/Display.html?Name=Catalyst-Plugin-ConfigLoader', mailto => 'bug-Catalyst-Plugin-ConfigLoader@rt.cpan.org', }, license => [ 'http://dev.perl.org/licenses/' ], }, no_index => { directory => [ 't', 'xt' ] }, ); my %MM_ARGS = (); ## BOILERPLATE ############################################################### require ExtUtils::MakeMaker; (do './maint/Makefile.PL.include' or die $@) unless -f 'META.yml'; # have to do this since old EUMM dev releases miss the eval $VERSION line my $eumm_version = eval $ExtUtils::MakeMaker::VERSION; my $mymeta = $eumm_version >= 6.57_02; my $mymeta_broken = $mymeta && $eumm_version < 6.57_07; ($MM_ARGS{NAME} = $META{name}) =~ s/-/::/g; ($MM_ARGS{VERSION_FROM} = "lib/$MM_ARGS{NAME}.pm") =~ s{::}{/}g; $META{license} = [ $META{license} ] if $META{license} && !ref $META{license}; $MM_ARGS{LICENSE} = $META{license}[0] if $META{license} && $eumm_version >= 6.30; $MM_ARGS{NO_MYMETA} = 1 if $mymeta_broken; $MM_ARGS{META_ADD} = { 'meta-spec' => { version => 2 }, %META } unless -f 'META.yml'; for (qw(configure build test runtime)) { my $key = $_ eq 'runtime' ? 'PREREQ_PM' : uc $_.'_REQUIRES'; my $r = $MM_ARGS{$key} = { %{$META{prereqs}{$_}{requires} || {}}, %{delete $MM_ARGS{$key} || {}}, }; defined $r->{$_} or delete $r->{$_} for keys %$r; } $MM_ARGS{MIN_PERL_VERSION} = delete $MM_ARGS{PREREQ_PM}{perl} || 0; delete $MM_ARGS{MIN_PERL_VERSION} if $eumm_version < 6.47_01; $MM_ARGS{BUILD_REQUIRES} = {%{$MM_ARGS{BUILD_REQUIRES}}, %{delete $MM_ARGS{TEST_REQUIRES}}} if $eumm_version < 6.63_03; $MM_ARGS{PREREQ_PM} = {%{$MM_ARGS{PREREQ_PM}}, %{delete $MM_ARGS{BUILD_REQUIRES}}} if $eumm_version < 6.55_01; delete $MM_ARGS{CONFIGURE_REQUIRES} if $eumm_version < 6.51_03; ExtUtils::MakeMaker::WriteMakefile(%MM_ARGS); ## END BOILERPLATE ########################################################### Catalyst-Plugin-ConfigLoader-0.35/maint/Makefile.PL.include000644 000000 000000 00000000374 13706313353 023626 0ustar00rootwheel000000 000000 BEGIN { -e 'Distar' or system("git clone git://git.shadowcat.co.uk/p5sagit/Distar.git") } use lib 'Distar/lib'; use Distar 0.001; author 'Brian Cassidy '; manifest_include 't/mockapp' => '.pl'; manifest_include 't/lib' => '.pl'; 1; Catalyst-Plugin-ConfigLoader-0.35/lib/Catalyst/000755 000000 000000 00000000000 13707311664 021454 5ustar00rootwheel000000 000000 Catalyst-Plugin-ConfigLoader-0.35/lib/Catalyst/Plugin/000755 000000 000000 00000000000 13707311664 022712 5ustar00rootwheel000000 000000 Catalyst-Plugin-ConfigLoader-0.35/lib/Catalyst/Plugin/ConfigLoader/000755 000000 000000 00000000000 13707311664 025246 5ustar00rootwheel000000 000000 Catalyst-Plugin-ConfigLoader-0.35/lib/Catalyst/Plugin/ConfigLoader.pm000644 000000 000000 00000023370 13707311225 025602 0ustar00rootwheel000000 000000 package Catalyst::Plugin::ConfigLoader; use strict; use warnings; use Config::Any; use MRO::Compat; use Data::Visitor::Callback; use Catalyst::Utils (); our $VERSION = '0.35'; =head1 NAME Catalyst::Plugin::ConfigLoader - Load config files of various types =head1 SYNOPSIS package MyApp; # ConfigLoader should be first in your list so # other plugins can get the config information use Catalyst qw( ConfigLoader ... ); # by default myapp.* will be loaded # you can specify a file if you'd like __PACKAGE__->config( 'Plugin::ConfigLoader' => { file => 'config.yaml' } ); In the file, assuming it's in YAML format: foo: bar Accessible through the context object, or the class itself $c->config->{foo} # bar MyApp->config->{foo} # bar =head1 DESCRIPTION This module will attempt to load find and load a configuration file of various types. Currently it supports YAML, JSON, XML, INI and Perl formats. Special configuration for a particular driver format can be stored in C<< MyApp->config->{ 'Plugin::ConfigLoader' }->{ driver } >>. For example, to pass arguments to L, use the following: __PACKAGE__->config( 'Plugin::ConfigLoader' => { driver => { 'General' => { -LowerCaseNames => 1 } } } ); See L's C parameter for more information. To support the distinction between development and production environments, this module will also attemp to load a local config (e.g. F) which will override any duplicate settings. See L for details on how this is configured. =head1 METHODS =head2 setup( ) This method is automatically called by Catalyst's setup routine. It will attempt to use each plugin and, once a file has been successfully loaded, set the C section. =cut sub setup { my $c = shift; my @files = $c->find_files; my $cfg = Config::Any->load_files( { files => \@files, filter => \&_fix_syntax, use_ext => 1, driver_args => $c->config->{ 'Plugin::ConfigLoader' }->{ driver } || {}, } ); # map the array of hashrefs to a simple hash my %configs = map { %$_ } @$cfg; # split the responses into normal and local cfg my $local_suffix = $c->get_config_local_suffix; my ( @main, @locals ); for ( sort keys %configs ) { if ( m{$local_suffix\.}ms ) { push @locals, $_; } else { push @main, $_; } } # load all the normal cfgs, then the local cfgs last so they can override # normal cfgs $c->load_config( { $_ => $configs{ $_ } } ) for @main, @locals; $c->finalize_config; $c->next::method( @_ ); } =head2 load_config This method handles loading the configuration data into the Catalyst context object. It does not return a value. =cut sub load_config { my $c = shift; my $ref = shift; my ( $file, $config ) = %$ref; $c->config( $config ); $c->log->debug( qq(Loaded Config "$file") ) if $c->debug; return; } =head2 find_files This method determines the potential file paths to be used for config loading. It returns an array of paths (up to the filename less the extension) to pass to L for loading. =cut sub find_files { my $c = shift; my ( $path, $extension ) = $c->get_config_path; my $suffix = $c->get_config_local_suffix; my @extensions = @{ Config::Any->extensions }; my @files; if ( $extension ) { die "Unable to handle files with the extension '${extension}'" unless grep { $_ eq $extension } @extensions; ( my $local = $path ) =~ s{\.$extension}{_$suffix.$extension}; push @files, $path, $local; } else { @files = map { ( "$path.$_", "${path}_${suffix}.$_" ) } @extensions; } @files; } =head2 get_config_path This method determines the path, filename prefix and file extension to be used for config loading. It returns the path (up to the filename less the extension) to check and the specific extension to use (if it was specified). The order of preference is specified as: =over 4 =item * C<$ENV{ MYAPP_CONFIG }> =item * C<$ENV{ CATALYST_CONFIG }> =item * C<< $c->config->{ 'Plugin::ConfigLoader' }->{ file } >> =item * C<< $c->path_to( $application_prefix ) >> =back If either of the first two user-specified options are directories, the application prefix will be added on to the end of the path. =cut sub get_config_path { my $c = shift; my $appname = ref $c || $c; my $prefix = Catalyst::Utils::appprefix( $appname ); my $path = Catalyst::Utils::env_value( $appname, 'CONFIG' ) || $c->config->{ 'Plugin::ConfigLoader' }->{ file } || $c->path_to( $prefix ); ## don't look for extension if this is a dir my ( $extension ) = !-d $path ? ( $path =~ m{\.([^\/\\.]{1,4})$} ) : () ; if ( -d $path ) { $path =~ s{[\/\\]$}{}; $path .= "/$prefix"; } return ( $path, $extension ); } =head2 get_config_local_suffix Determines the suffix of files used to override the main config. By default this value is C, which will load C. The suffix can be specified in the following order of preference: =over 4 =item * C<$ENV{ MYAPP_CONFIG_LOCAL_SUFFIX }> =item * C<$ENV{ CATALYST_CONFIG_LOCAL_SUFFIX }> =item * C<< $c->config->{ 'Plugin::ConfigLoader' }->{ config_local_suffix } >> =back The first one of these values found replaces the default of C in the name of the local config file to be loaded. For example, if C< $ENV{ MYAPP_CONFIG_LOCAL_SUFFIX }> is set to C, ConfigLoader will try and load F instead of F. =cut sub get_config_local_suffix { my $c = shift; my $appname = ref $c || $c; my $suffix = Catalyst::Utils::env_value( $appname, 'CONFIG_LOCAL_SUFFIX' ) || $c->config->{ 'Plugin::ConfigLoader' }->{ config_local_suffix } || 'local'; return $suffix; } sub _fix_syntax { my $config = shift; my @components = ( map +{ prefix => $_ eq 'Component' ? '' : $_ . '::', values => delete $config->{ lc $_ } || delete $config->{ $_ } }, grep { ref $config->{ lc $_ } || ref $config->{ $_ } } qw( Component Model M View V Controller C Plugin ) ); foreach my $comp ( @components ) { my $prefix = $comp->{ prefix }; foreach my $element ( keys %{ $comp->{ values } } ) { $config->{ "$prefix$element" } = $comp->{ values }->{ $element }; } } } =head2 finalize_config This method is called after the config file is loaded. It can be used to implement tuning of config values that can only be done at runtime. If you need to do this to properly configure any plugins, it's important to load ConfigLoader before them. ConfigLoader provides a default C method which walks through the loaded config hash and calls the L method on any string. =cut sub finalize_config { my $c = shift; my $v = Data::Visitor::Callback->new( plain_value => sub { return unless defined $_; $c->config_substitutions( $_ ); } ); $v->visit( $c->config ); } =head2 config_substitutions( $value ) This method substitutes macros found with calls to a function. There are a number of default macros: =over 4 =item * C<__HOME__> - replaced with C<$c-Epath_to('')> =item * C<__ENV(foo)__> - replaced with the value of C<$ENV{foo}> =item * C<__path_to(foo/bar)__> - replaced with C<$c-Epath_to('foo/bar')> =item * C<__literal(__FOO__)__> - leaves __FOO__ alone (allows you to use C<__DATA__> as a config value, for example) =back The parameter list is split on comma (C<,>). You can override this method to do your own string munging, or you can define your own macros in C<< MyApp->config->{ 'Plugin::ConfigLoader' }->{ substitutions } >>. Example: MyApp->config->{ 'Plugin::ConfigLoader' }->{ substitutions } = { baz => sub { my $c = shift; qux( @_ ); } } The above will respond to C<__baz(x,y)__> in config strings. =cut sub config_substitutions { my $c = shift; 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 ); for ( @_ ) { s{__($subsre)(?:\((.+?)\))?__}{ $subs->{ $1 }->( $c, $2 ? split( /,/, $2 ) : () ) }eg; } } =head1 AUTHOR Brian Cassidy =head1 CONTRIBUTORS The following people have generously donated their time to the development of this module: =over 4 =item * Joel Bernstein - Rewrite to use L =item * David Kamholz - L integration =item * Stuart Watt - Addition of ENV macro. =back Work to this module has been generously sponsored by: =over 4 =item * Portugal Telecom L - Work done by Joel Bernstein =back =head1 COPYRIGHT AND LICENSE Copyright 2006-2010 by Brian Cassidy This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO =over 4 =item * L =item * L =item * L =back =cut 1; Catalyst-Plugin-ConfigLoader-0.35/lib/Catalyst/Plugin/ConfigLoader/Manual.pod000644 000000 000000 00000011567 13706423025 027173 0ustar00rootwheel000000 000000 =head1 NAME Catalyst::Plugin::ConfigLoader::Manual - Guide to using the ConfigLoader plugin =head1 BASIC USAGE package MyApp; use Catalyst qw( ConfigLoader ... ); =head1 ENVIRONMENT VARIABLES =over 4 =item * C - specific config file to load for "MyApp" =item * C - global suffix for extra config files =item * C - suffix specifically for "MyApp" =back =head1 CONFIG FORMATS =head2 Config::General =head3 Extensions =over 4 =item * cnf =item * conf =back =head3 Example Config name = TestApp foo bar qux xyzzy =head2 INI =head3 Extensions =over 4 =item * ini =back =head3 Example Config name=TestApp [Controller::Foo] foo=bar [Model::Baz] qux=xyzzy =head2 JSON =head3 Extensions =over 4 =item * jsn =item * json =back =head3 Example Config { "name": "TestApp", "Controller::Foo": { "foo": "bar" }, "Model::Baz": { "qux": "xyzzy" } } =head2 Perl =head3 Extensions =over 4 =item * pl =item * perl =back =head3 Example Config { name => 'TestApp', 'Controller::Foo' => { foo => 'bar' }, 'Model::Baz' => { qux => 'xyzzy' } } =head2 XML =head3 Extensions =over 4 =item * xml =back =head3 Example Config MyApp::CMS /var/www/docs/myapp-cms/uploads dbi:mysql:cmsdb user password __path_to(root,templates)__ UTF-8 1 2 2 Note that the name attribute for the C tag should be the relative namespace of the Catalyst model, not the absolute one. That is for C the C attribute should be C. =head2 YAML =head3 Extensions =over 4 =item * yml =item * yaml =back =head3 Example Config --- name: TestApp Controller::Foo: foo: bar Model::Baz: qux: xyzzy =head1 COOKBOOK =head2 Configuring a Catalyst::Model::DBIC::Schema model from a YAML config Model::MyModel: schema_class: MyApp::MySchema connect_info: - dbi:SQLite:myapp.db - '' - '' - AutoCommit: 1 =head2 Converting your existing config to Config::General format As of L 1.07, a newly created application will use L for configuration. If you wish to convert your existing config, run the following one-liner (replacing MyApp with your app's name): perl -Ilib -MMyApp -MConfig::General -e 'Config::General->new->save_file("myapp.conf", MyApp->config);' =head2 Using UTF-8 strings in a Config::General file If you have UTF-8 strings in your L-based config file, you should add the following config information to MyApp.pm: __PACKAGE__->config( 'Plugin::ConfigLoader' => { driver => { 'General' => { -UTF8 => 1 }, } } ); =head2 Using a local configuration file When ConfigLoader reads configurations, it starts by reading the configuration file for C with one of the supported extensions as listed L. For example, A L config file is F. If a configuration file called C 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 local configuration file would be called F. The C suffix can be changed. See L 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, I, and I as well as a production environment can have a F, a F, a F, and a F. 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 F (where C<.ext> is a supported extension), 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 Catalyst-Plugin-ConfigLoader-0.35/xt/pod.t000644 000000 000000 00000000123 13706415421 020513 0ustar00rootwheel000000 000000 use strict; use warnings; use Test::More; use Test::Pod 1.00; all_pod_files_ok(); Catalyst-Plugin-ConfigLoader-0.35/xt/pod-coverage.t000644 000000 000000 00000000140 13706415616 022311 0ustar00rootwheel000000 000000 use strict; use warnings; use Test::More; use Test::Pod::Coverage 1.00; all_pod_coverage_ok(); Catalyst-Plugin-ConfigLoader-0.35/t/24-mock-shortappname.t000644 000000 000000 00000001043 13707310522 023413 0ustar00rootwheel000000 000000 use strict; use warnings; use Test::More; BEGIN { # Remove all relevant env variables to avoid accidental fail foreach my $name ( grep { m{^(CATALYST)} } keys %ENV ) { delete $ENV{ $name }; } } { package QX; use strict; use warnings; use base 'Catalyst::Plugin::ConfigLoader'; sub config { {} } sub path_to { shift; '/home/foo/QX-0.9.5/' . shift; } } my $app = bless {}, 'QX'; my ($path, $extension) = $app->get_config_path; is $path, '/home/foo/QX-0.9.5/qx'; is $extension, undef; done_testing; Catalyst-Plugin-ConfigLoader-0.35/t/25-setting-config-file.t000644 000000 000000 00000005170 13706310557 023635 0ustar00rootwheel000000 000000 use strict; use warnings; use FindBin; use lib "$FindBin::Bin/lib"; use Test::More; BEGIN { # Remove all relevant env variables to avoid accidental fail foreach my $name ( grep { m{^(CATALYST|MOCKAPP)} } keys %ENV ) { delete $ENV{ $name }; } eval { require Catalyst; Catalyst->VERSION( '5.80001' ); }; plan skip_all => 'Catalyst 5.80001 required' if $@; plan tests => 18; use Catalyst::Test (); } ## TestApp1: a .conf config file exists but should not be loaded { Catalyst::Test->import('TestApp1'); note( "TestApp1" ); ok my ( $res, $c ) = ctx_request( '/' ), 'context object'; isa_ok( $c, "TestApp1" ); subtest "normal config loaded" => sub { is( get( '/appconfig/foo' ), "bar1", "config var foo ok" ); ## a config var not set will give a blank web page hence "" is( get( '/appconfig/bar' ), "", "config var in custom config" ); }; is( get( '/appconfig/bar' ), "", "custom config not loaded" ); } ## TestApp2: config points to a file in addition to normal config and ## should get loaded { Catalyst::Test->import('TestApp2'); note( "TestApp2" ); ok my ( $res, $c ) = ctx_request( '/' ), 'context object'; isa_ok( $c, "TestApp2" ); subtest "normal config loaded" => sub { is( get( '/appconfig/foo' ), "bar2", "config var foo" ); is( get( '/appconfig/unspecified_variable' ), "", "unknown config var" ); }; is( get( '/appconfig/bar' ), "baz2", "custom config loaded" ); } ## TestApp3: config points to a directory { Catalyst::Test->import('TestApp3'); note( "TestApp3" ); ok my ( $res, $c ) = ctx_request( '/' ), 'context object'; isa_ok( $c, "TestApp3" ); subtest "normal config loaded" => sub { is( get( '/appconfig/foo' ), "bar3", "config var foo" ); is( get( '/appconfig/unspecified_variable' ), "", "unknown config var" ); }; is( get( '/appconfig/test3_conf3' ), "a_value", "custom config var3 set" ); is( get( '/appconfig/test3_conf4' ), "", "custom config var4 not set" ); } ## TestApp4: config points to a directory with a suffix { Catalyst::Test->import('TestApp4'); note( "TestApp4" ); ok my ( $res, $c ) = ctx_request( '/' ), 'context object'; isa_ok( $c, "TestApp4" ); subtest "normal config loaded" => sub { is( get( '/appconfig/foo' ), "bar4", "config var foo" ); is( get( '/appconfig/unspecified_variable' ), "", "unknown config var" ); }; is( get( '/appconfig/test4_conf3' ), "a_value", "custom config var3 set" ); is( get( '/appconfig/test4_conf4' ), "", "custom config var4 not set" ); } Catalyst-Plugin-ConfigLoader-0.35/t/01-use.t000644 000000 000000 00000000126 13706310557 020562 0ustar00rootwheel000000 000000 use Test::More tests => 1; BEGIN { use_ok( 'Catalyst::Plugin::ConfigLoader' ); } Catalyst-Plugin-ConfigLoader-0.35/t/22-suffix_env.t000644 000000 000000 00000000703 13706310557 022146 0ustar00rootwheel000000 000000 use strict; use warnings; use FindBin; use lib "$FindBin::Bin/lib"; use Test::More; BEGIN { eval { require Catalyst; Catalyst->VERSION( '5.80001' ); }; plan skip_all => 'Catalyst 5.80001 required' if $@; plan tests => 3; $ENV{ TESTAPP_CONFIG_LOCAL_SUFFIX } = 'test'; use_ok 'Catalyst::Test', 'TestApp'; } ok my ( $res, $c ) = ctx_request( '/' ), 'context object'; is $c->get_config_local_suffix, 'test', 'suffix is "test"'; Catalyst-Plugin-ConfigLoader-0.35/t/20-mock_load.t000644 000000 000000 00000001757 13706310557 021732 0ustar00rootwheel000000 000000 package MockApp; use Test::More tests => 10; use Cwd; # Remove all relevant env variables to avoid accidental fail foreach my $name ( grep { m{^(CATALYST)} } keys %ENV ) { delete $ENV{ $name }; } $ENV{ CATALYST_HOME } = cwd . '/t/mockapp'; use_ok( 'Catalyst', qw( ConfigLoader ) ); __PACKAGE__->config->{ 'Plugin::ConfigLoader' }->{ substitutions } = { foo => sub { shift; join( '-', @_ ); } }; __PACKAGE__->setup; ok( __PACKAGE__->config ); is( __PACKAGE__->config->{ 'Controller::Foo' }->{ foo }, 'bar' ); is( __PACKAGE__->config->{ 'Controller::Foo' }->{ new }, 'key' ); is( __PACKAGE__->config->{ 'Model::Baz' }->{ qux }, 'xyzzy' ); is( __PACKAGE__->config->{ 'Model::Baz' }->{ another }, 'new key' ); is( __PACKAGE__->config->{ 'view' }, 'View::TT::New' ); is( __PACKAGE__->config->{ 'foo_sub' }, 'x-y' ); is( __PACKAGE__->config->{ 'literal_macro' }, '__DATA__' ); is( __PACKAGE__->config->{ 'Plugin::Zot' }->{ zoot }, 'zooot'); Catalyst-Plugin-ConfigLoader-0.35/t/lib/000755 000000 000000 00000000000 13707311664 020133 5ustar00rootwheel000000 000000 Catalyst-Plugin-ConfigLoader-0.35/t/mockapp/000755 000000 000000 00000000000 13707311664 021017 5ustar00rootwheel000000 000000 Catalyst-Plugin-ConfigLoader-0.35/t/10-live_auto.t000644 000000 000000 00000002004 13706416246 021754 0ustar00rootwheel000000 000000 use strict; use warnings; use FindBin; use lib "$FindBin::Bin/lib"; use Test::More tests => 5; BEGIN { # Remove all relevant env variables to avoid accidental fail foreach my $name ( grep { m{^(CATALYST)} } keys %ENV ) { delete $ENV{ $name }; } } use Catalyst::Test 'TestApp'; { my $response; ok( $response = request( 'http://localhost/config/' ), 'request ok' ); is( $response->content, 'foo', 'config ok' ); $response = request( 'http://localhost/appconfig/cache' ); ok( $response->content !~ /^__HOME__/, 'home dir substituted in config var' ); $response = request( 'http://localhost/appconfig/foo' ); is( $response->content, 'bar', 'app finalize_config works' ); $response = request( 'http://localhost/appconfig/multi' ); my $home = TestApp->config->{ home }; my $path = join( ',', $home, TestApp->path_to( 'x' ), $home, TestApp->path_to( 'y' ) ); is( $response->content, $path, 'vars substituted in config var, twice' ); } Catalyst-Plugin-ConfigLoader-0.35/t/21-mock_load_env.t000644 000000 000000 00000002125 13706310557 022571 0ustar00rootwheel000000 000000 package MockApp; use Test::More tests => 10; use Cwd; # Remove all relevant env variables to avoid accidental fail foreach my $name ( grep { m{^(CATALYST|MOCKAPP)} } keys %ENV ) { delete $ENV{ $name }; } $ENV{ CATALYST_HOME } = cwd . '/t/mockapp'; $ENV{ MOCKAPP_CONFIG } = $ENV{ CATALYST_HOME } . '/mockapp.pl'; use_ok( 'Catalyst', qw( ConfigLoader ) ); __PACKAGE__->config->{ 'Plugin::ConfigLoader' }->{ substitutions } = { foo => sub { shift; join( '-', @_ ); } }; __PACKAGE__->setup; ok( __PACKAGE__->config ); is( __PACKAGE__->config->{ 'Controller::Foo' }->{ foo }, 'bar' ); is( __PACKAGE__->config->{ 'Controller::Foo' }->{ new }, 'key' ); is( __PACKAGE__->config->{ 'Model::Baz' }->{ qux }, 'xyzzy' ); is( __PACKAGE__->config->{ 'Model::Baz' }->{ another }, 'new key' ); 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' ); Catalyst-Plugin-ConfigLoader-0.35/t/23-path_env.t000644 000000 000000 00000000723 13706310557 021601 0ustar00rootwheel000000 000000 use strict; use warnings; use FindBin; use lib "$FindBin::Bin/lib"; use Test::More; BEGIN { eval { require Catalyst; Catalyst->VERSION( '5.80001' ); }; plan skip_all => 'Catalyst 5.80001 required' if $@; plan tests => 3; $ENV{ TESTAPP_CONFIG } = 'test.perl'; use_ok 'Catalyst::Test', 'TestApp'; } ok my ( $res, $c ) = ctx_request( '/' ), 'context object'; is_deeply [ $c->get_config_path ], [ qw( test.perl perl ) ], 'path is "test.perl"'; Catalyst-Plugin-ConfigLoader-0.35/t/mockapp/mockapp_local.pl000644 000000 000000 00000000237 13706310557 024161 0ustar00rootwheel000000 000000 { view => 'View::TT::New', 'Controller::Foo' => { new => 'key' }, Component => { 'Model::Baz' => { 'another' => 'new key' } } } Catalyst-Plugin-ConfigLoader-0.35/t/mockapp/mockapp.pl000644 000000 000000 00000000565 13706310557 023013 0ustar00rootwheel000000 000000 { name => 'TestApp', view => 'View::TT', 'Controller::Foo' => { foo => 'bar' }, 'Model::Baz' => { qux => 'xyzzy' }, foo_sub => '__foo(x,y)__', literal_macro => '__literal(__DATA__)__', environment_macro => '__ENV(CATALYST_HOME)__/mockapp.pl', Plugin => { Zot => { zoot => 'zooot' } }, } Catalyst-Plugin-ConfigLoader-0.35/t/lib/TestApp.pm000644 000000 000000 00000000367 13706310557 022056 0ustar00rootwheel000000 000000 package TestApp; use strict; use warnings; use MRO::Compat; use Catalyst qw/ConfigLoader/; our $VERSION = '0.01'; __PACKAGE__->setup; sub finalize_config { my $c = shift; $c->config( foo => 'bar' ); $c->next::method( @_ ); } 1; Catalyst-Plugin-ConfigLoader-0.35/t/lib/TestApp3.pm000644 000000 000000 00000000551 13706310557 022134 0ustar00rootwheel000000 000000 package TestApp3; use strict; use warnings; use MRO::Compat; use Catalyst qw/ConfigLoader/; our $VERSION = '0.01'; __PACKAGE__->config( "Plugin::ConfigLoader" => { file => __PACKAGE__->path_to( "config" ) } ); __PACKAGE__->setup; sub finalize_config { my $c = shift; $c->config( foo => 'bar3' ); $c->next::method( @_ ); } 1; Catalyst-Plugin-ConfigLoader-0.35/t/lib/TestApp/000755 000000 000000 00000000000 13707311664 021513 5ustar00rootwheel000000 000000 Catalyst-Plugin-ConfigLoader-0.35/t/lib/TestApp1/000755 000000 000000 00000000000 13707311664 021574 5ustar00rootwheel000000 000000 Catalyst-Plugin-ConfigLoader-0.35/t/lib/TestApp2.pm000644 000000 000000 00000000664 13706310557 022140 0ustar00rootwheel000000 000000 package TestApp2; use strict; use warnings; use MRO::Compat; use Catalyst qw/ConfigLoader/; __PACKAGE__->config( "Plugin::ConfigLoader", { file => __PACKAGE__->path_to( "customconfig.pl" ) } ); our $VERSION = '0.01'; __PACKAGE__->setup; sub finalize_config { my $c = shift; $c->config( foo => 'bar2' ); $c->next::method( @_ ); } 1; Catalyst-Plugin-ConfigLoader-0.35/t/lib/TestApp1.pm000644 000000 000000 00000000371 13706310557 022132 0ustar00rootwheel000000 000000 package TestApp1; use strict; use warnings; use MRO::Compat; use Catalyst qw/ConfigLoader/; our $VERSION = '0.01'; __PACKAGE__->setup; sub finalize_config { my $c = shift; $c->config( foo => 'bar1' ); $c->next::method( @_ ); } 1; Catalyst-Plugin-ConfigLoader-0.35/t/lib/TestApp4.pm000644 000000 000000 00000000553 13706310557 022137 0ustar00rootwheel000000 000000 package TestApp4; use strict; use warnings; use MRO::Compat; use Catalyst qw/ConfigLoader/; our $VERSION = '0.01'; __PACKAGE__->config( "Plugin::ConfigLoader" => { file => __PACKAGE__->path_to( "config.d" ) } ); __PACKAGE__->setup; sub finalize_config { my $c = shift; $c->config( foo => 'bar4' ); $c->next::method( @_ ); } 1; Catalyst-Plugin-ConfigLoader-0.35/t/lib/TestApp3/000755 000000 000000 00000000000 13707311664 021576 5ustar00rootwheel000000 000000 Catalyst-Plugin-ConfigLoader-0.35/t/lib/TestApp4/000755 000000 000000 00000000000 13707311664 021577 5ustar00rootwheel000000 000000 Catalyst-Plugin-ConfigLoader-0.35/t/lib/TestApp2/000755 000000 000000 00000000000 13707311664 021575 5ustar00rootwheel000000 000000 Catalyst-Plugin-ConfigLoader-0.35/t/lib/TestApp2/customconfig.pl000644 000000 000000 00000000026 13706310557 024627 0ustar00rootwheel000000 000000 { bar => "baz2" } Catalyst-Plugin-ConfigLoader-0.35/t/lib/TestApp2/testapp2.pl000644 000000 000000 00000000315 13706310557 023672 0ustar00rootwheel000000 000000 { name => 'TestApp2', Controller::Config => { foo => 'foo' }, cache => '__HOME__/cache', multi => '__HOME__,__path_to(x)__,__HOME__,__path_to(y)__', } Catalyst-Plugin-ConfigLoader-0.35/t/lib/TestApp2/Controller/000755 000000 000000 00000000000 13707311664 023720 5ustar00rootwheel000000 000000 Catalyst-Plugin-ConfigLoader-0.35/t/lib/TestApp2/Controller/Root.pm000644 000000 000000 00000000412 13706310557 025175 0ustar00rootwheel000000 000000 package TestApp2::Controller::Root; use strict; use warnings; use base 'Catalyst::Controller'; __PACKAGE__->config->{namespace} = ''; sub default :Path { my ( $self, $c ) = @_; $c->response->body( 'Page not found' ); $c->response->status(404); } 1; Catalyst-Plugin-ConfigLoader-0.35/t/lib/TestApp2/Controller/Config.pm000644 000000 000000 00000000457 13706310557 025470 0ustar00rootwheel000000 000000 package TestApp2::Controller::Config; use strict; use warnings; use base qw( Catalyst::Controller ); sub index : Private { my ( $self, $c ) = @_; $c->res->output( $self->{ foo } ); } sub appconfig : Global { my ( $self, $c, $var ) = @_; $c->res->body( $c->config->{ $var } ); } 1; Catalyst-Plugin-ConfigLoader-0.35/t/lib/TestApp4/config.d/000755 000000 000000 00000000000 13707311664 023266 5ustar00rootwheel000000 000000 Catalyst-Plugin-ConfigLoader-0.35/t/lib/TestApp4/Controller/000755 000000 000000 00000000000 13707311664 023722 5ustar00rootwheel000000 000000 Catalyst-Plugin-ConfigLoader-0.35/t/lib/TestApp4/testapp.pl000644 000000 000000 00000000314 13706310557 023611 0ustar00rootwheel000000 000000 { name => 'TestApp', Controller::Config => { foo => 'foo' }, cache => '__HOME__/cache', multi => '__HOME__,__path_to(x)__,__HOME__,__path_to(y)__', } Catalyst-Plugin-ConfigLoader-0.35/t/lib/TestApp4/Controller/Root.pm000644 000000 000000 00000000412 13706310557 025177 0ustar00rootwheel000000 000000 package TestApp4::Controller::Root; use strict; use warnings; use base 'Catalyst::Controller'; __PACKAGE__->config->{namespace} = ''; sub default :Path { my ( $self, $c ) = @_; $c->response->body( 'Page not found' ); $c->response->status(404); } 1; Catalyst-Plugin-ConfigLoader-0.35/t/lib/TestApp4/Controller/Config.pm000644 000000 000000 00000000456 13706310557 025471 0ustar00rootwheel000000 000000 package TestApp4::Controller::Config; use strict; use warnings; use base qw( Catalyst::Controller ); sub index : Private { my ( $self, $c ) = @_; $c->res->output( $self->{ foo } ); } sub appconfig : Global { my ( $self, $c, $var ) = @_; $c->res->body( $c->config->{ $var } ); } 1; Catalyst-Plugin-ConfigLoader-0.35/t/lib/TestApp4/config.d/another_file.pl000644 000000 000000 00000000050 13706310557 026254 0ustar00rootwheel000000 000000 { test4_conf => "this is not set" } Catalyst-Plugin-ConfigLoader-0.35/t/lib/TestApp4/config.d/testapp4.pl000644 000000 000000 00000000037 13706310557 025366 0ustar00rootwheel000000 000000 { test4_conf3 => "a_value" } Catalyst-Plugin-ConfigLoader-0.35/t/lib/TestApp3/config/000755 000000 000000 00000000000 13707311664 023043 5ustar00rootwheel000000 000000 Catalyst-Plugin-ConfigLoader-0.35/t/lib/TestApp3/testapp3.pl000644 000000 000000 00000000314 13706310557 023673 0ustar00rootwheel000000 000000 { name => 'TestApp', Controller::Config => { foo => 'foo' }, cache => '__HOME__/cache', multi => '__HOME__,__path_to(x)__,__HOME__,__path_to(y)__', } Catalyst-Plugin-ConfigLoader-0.35/t/lib/TestApp3/Controller/000755 000000 000000 00000000000 13707311664 023721 5ustar00rootwheel000000 000000 Catalyst-Plugin-ConfigLoader-0.35/t/lib/TestApp3/Controller/Root.pm000644 000000 000000 00000000412 13706310557 025176 0ustar00rootwheel000000 000000 package TestApp3::Controller::Root; use strict; use warnings; use base 'Catalyst::Controller'; __PACKAGE__->config->{namespace} = ''; sub default :Path { my ( $self, $c ) = @_; $c->response->body( 'Page not found' ); $c->response->status(404); } 1; Catalyst-Plugin-ConfigLoader-0.35/t/lib/TestApp3/Controller/Config.pm000644 000000 000000 00000000456 13706310557 025470 0ustar00rootwheel000000 000000 package TestApp3::Controller::Config; use strict; use warnings; use base qw( Catalyst::Controller ); sub index : Private { my ( $self, $c ) = @_; $c->res->output( $self->{ foo } ); } sub appconfig : Global { my ( $self, $c, $var ) = @_; $c->res->body( $c->config->{ $var } ); } 1; Catalyst-Plugin-ConfigLoader-0.35/t/lib/TestApp3/config/another_file.pl000644 000000 000000 00000000050 13706310557 026031 0ustar00rootwheel000000 000000 { test4_conf => "this is not set" } Catalyst-Plugin-ConfigLoader-0.35/t/lib/TestApp3/config/testapp3.pl000644 000000 000000 00000000037 13706310557 025142 0ustar00rootwheel000000 000000 { test3_conf3 => "a_value" } Catalyst-Plugin-ConfigLoader-0.35/t/lib/TestApp1/testapp1.pl000644 000000 000000 00000000315 13706310557 023670 0ustar00rootwheel000000 000000 { name => 'TestApp2', Controller::Config => { foo => 'foo' }, cache => '__HOME__/cache', multi => '__HOME__,__path_to(x)__,__HOME__,__path_to(y)__', } Catalyst-Plugin-ConfigLoader-0.35/t/lib/TestApp1/customconfig.pl000644 000000 000000 00000000025 13706310557 024625 0ustar00rootwheel000000 000000 { bar => "baz" } Catalyst-Plugin-ConfigLoader-0.35/t/lib/TestApp1/Controller/000755 000000 000000 00000000000 13707311664 023717 5ustar00rootwheel000000 000000 Catalyst-Plugin-ConfigLoader-0.35/t/lib/TestApp1/Controller/Root.pm000644 000000 000000 00000000412 13706310557 025174 0ustar00rootwheel000000 000000 package TestApp1::Controller::Root; use strict; use warnings; use base 'Catalyst::Controller'; __PACKAGE__->config->{namespace} = ''; sub default :Path { my ( $self, $c ) = @_; $c->response->body( 'Page not found' ); $c->response->status(404); } 1; Catalyst-Plugin-ConfigLoader-0.35/t/lib/TestApp1/Controller/Config.pm000644 000000 000000 00000000457 13706310557 025467 0ustar00rootwheel000000 000000 package TestApp1::Controller::Config; use strict; use warnings; use base qw( Catalyst::Controller ); sub index : Private { my ( $self, $c ) = @_; $c->res->output( $self->{ foo } ); } sub appconfig : Global { my ( $self, $c, $var ) = @_; $c->res->body( $c->config->{ $var } ); } 1; Catalyst-Plugin-ConfigLoader-0.35/t/lib/TestApp/Controller/000755 000000 000000 00000000000 13707311664 023636 5ustar00rootwheel000000 000000 Catalyst-Plugin-ConfigLoader-0.35/t/lib/TestApp/testapp.pl000644 000000 000000 00000000314 13706310557 023525 0ustar00rootwheel000000 000000 { name => 'TestApp', Controller::Config => { foo => 'foo' }, cache => '__HOME__/cache', multi => '__HOME__,__path_to(x)__,__HOME__,__path_to(y)__', } Catalyst-Plugin-ConfigLoader-0.35/t/lib/TestApp/Controller/Root.pm000644 000000 000000 00000000411 13706310557 025112 0ustar00rootwheel000000 000000 package TestApp::Controller::Root; use strict; use warnings; use base 'Catalyst::Controller'; __PACKAGE__->config->{namespace} = ''; sub default :Path { my ( $self, $c ) = @_; $c->response->body( 'Page not found' ); $c->response->status(404); } 1; Catalyst-Plugin-ConfigLoader-0.35/t/lib/TestApp/Controller/Config.pm000644 000000 000000 00000000455 13706310557 025404 0ustar00rootwheel000000 000000 package TestApp::Controller::Config; use strict; use warnings; use base qw( Catalyst::Controller ); sub index : Private { my ( $self, $c ) = @_; $c->res->output( $self->{ foo } ); } sub appconfig : Global { my ( $self, $c, $var ) = @_; $c->res->body( $c->config->{ $var } ); } 1;