Config-ZOMG-1.000000000755001750001750 012205513327 13002 5ustar00frewfrew000000000000README100644001750001750 1223512205513327 13766 0ustar00frewfrew000000000000Config-ZOMG-1.000000NAME Config::ZOMG - Yet Another Catalyst::Plugin::ConfigLoader-style layer over Config::Any VERSION version 1.000000 DESCRIPTION "Config::ZOMG" is a fork of Config::JFDI. It removes a couple of unusual features and passes the same tests three times faster than Config::JFDI. "Config::ZOMG" is an implementation of Catalyst::Plugin::ConfigLoader that exists outside of Catalyst. "Config::ZOMG" will scan a directory for files matching a certain name. If such a file is found which also matches an extension that Config::Any can read, then the configuration from that file will be loaded. "Config::ZOMG" will also look for special files that end with a "_local" suffix. Files with this special suffix will take precedence over any other existing configuration file, if any. The precedence takes place by merging the local configuration with the "standard" configuration via Hash::Merge::Simple. Finally you can override/modify the path search from outside your application, by setting the "${NAME}_CONFIG" variable outside your application (where $NAME is the uppercase version of what you passed to Config::ZOMG->new). SYNPOSIS use Config::ZOMG; my $config = Config::ZOMG->new( name => 'my_application', path => 'path/to/my/application', ); my $config_hash = $config->load; This will look for something like (depending on what Config::Any will find): path/to/my/application/my_application_local.{yml,yaml,cnf,conf,jsn,json,...} and path/to/my/application/my_application.{yml,yaml,cnf,conf,jsn,json,...} ... and load the found configuration information appropiately, with "_local" taking precedence. You can also specify a file directly: my $config = Config::ZOMG->new(file => '/path/to/my/application/my_application.cnf'); To later reload your configuration: $config->reload; METHODS new $config = Config::ZOMG->new(...) Returns a new "Config::ZOMG" object You can configure the $config object by passing the following to new: name The name specifying the prefix of the configuration file to look for and the ENV variable to read. This can be a package name. In any case, :: will be substituted with _ in "name" and the result will be lowercased. To prevent modification of "name", pass it in as a scalar reference. "path" The directory to search in "file" Directly read the configuration from this file. "Config::Any" must recognize the extension. Setting this will override "path" "no_local" Disable lookup of a local configuration. The "local_suffix" option will be ignored. Off by default "local_suffix" The suffix to match when looking for a local configuration. "local" by default "no_env" Set this to ignore ENV. "env_lookup" will be ignored. Off by default "env_lookup" Additional ENV to check if $ENV{...} is not found "driver" A hash consisting of "Config::" driver information. This is passed directly through to "Config::Any" "default" A hash filled with default keys/values open $config_hash = Config::ZOMG->open( ... ) As an alternative way to load a config "open" will pass given arguments to "new" then attempt to do "load" Unlike "load" if no configuration files are found "open" will return "undef" (or the empty list) This is so you can do something like: my $config_hash = Config::ZOMG->open( '/path/to/application.cnf' ) or die "Couldn't find config file!" In scalar context "open" will return the config hash, not the config object. If you want the config object call "open" in list context: my ($config_hash, $config) = Config::ZOMG->open( ... ) You can pass any arguments to "open" that you would to "new" load $config->load Load a config as specified by "new" and "ENV" and return a hash This will only load the configuration once, so it's safe to call multiple times without incurring any loading-time penalty found $config->found Returns a list of files found If the list is empty then no files were loaded/read find $config->find Returns a list of files that configuration will be loaded from. Use this method to check whether configuration files have changed, without actually reloading. clone $config->clone Return a clone of the configuration hash using Clone This will load the configuration first, if it hasn't already reload $config->reload Reload the configuration, examining ENV and scanning the path anew Returns a hash of the configuration SEE ALSO Config::JFDI Catalyst::Plugin::ConfigLoader Config::Any Catalyst Config::Merge Config::General AUTHORS * Arthur Axel "fREW" Schmidt * Robert Krimen COPYRIGHT AND LICENSE This software is copyright (c) 2013 by Arthur Axel "fREW" Schmidt. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Changes100644001750001750 126612205513327 14363 0ustar00frewfrew000000000000Config-ZOMG-1.000000Revision history for Config-ZOMG 1.000000 2013-08-22 17:55:17 CST6CDT - Make ->found not trigger a call to ->read (Jakob Voss) !!! Note that the above change could break your code, if you depended on it (though that seems unlikely) !!! 0.002000 2013-04-04 18:55:29 CST6CDT - add find method for searching for files again (Jakob Voss) 0.001000 2011-01-11 22:16:52 CST6CDT - Initial fork of Config::JFDI - Stop using carp, people can use Carp::Always if they need it - lots and lots of cleanup for more idiomatic Moose code - Remove isa checks - Remove install_accessor feature - Remove substitute feature - Switch to Moo - No longer support config_local_suffix LICENSE100644001750001750 4372512205513327 14123 0ustar00frewfrew000000000000Config-ZOMG-1.000000This software is copyright (c) 2013 by Arthur Axel "fREW" Schmidt. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. 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) 2013 by Arthur Axel "fREW" Schmidt. 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, Suite 500, Boston, MA 02110-1335 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) 2013 by Arthur Axel "fREW" Schmidt. 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 dist.ini100644001750001750 126612205513327 14534 0ustar00frewfrew000000000000Config-ZOMG-1.000000name = Config-ZOMG author = Arthur Axel "fREW" Schmidt author = Robert Krimen license = Perl_5 copyright_holder = Arthur Axel "fREW" Schmidt version = 1.000000 [NextRelease] [@Git] [@Basic] [MetaResources] repository.url = git://github.com/frioux/Config-ZOMG.git repository.web = http://github.com/frioux/Config-ZOMG repository.type = git bugtracker.web = https://github.com/frioux/Config-ZOMG/issues [MetaJSON] [PodWeaver] [Repository] [PkgVersion] [ReadmeFromPod] [PodSyntaxTests] [Prereqs / TestRequires] Test::More = 0 Test::Warn = 0 Test::Deep = 0 [Prereqs] Config::Any = 0 Clone = 0 Hash::Merge::Simple = 0 List::Util = 0 Moo = 0 META.yml100644001750001750 137612205513327 14343 0ustar00frewfrew000000000000Config-ZOMG-1.000000--- abstract: 'Yet Another Catalyst::Plugin::ConfigLoader-style layer over Config::Any' author: - "Arthur Axel \"fREW\" Schmidt " - 'Robert Krimen ' build_requires: Test::Deep: 0 Test::More: 0 Test::Warn: 0 configure_requires: ExtUtils::MakeMaker: 6.30 dynamic_config: 0 generated_by: 'Dist::Zilla version 4.300035, CPAN::Meta::Converter version 2.120921' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 name: Config-ZOMG requires: Clone: 0 Config::Any: 0 Hash::Merge::Simple: 0 List::Util: 0 Moo: 0 resources: bugtracker: https://github.com/frioux/Config-ZOMG/issues repository: git://github.com/frioux/Config-ZOMG.git version: 1.000000 MANIFEST100644001750001750 143412205513327 14216 0ustar00frewfrew000000000000Config-ZOMG-1.000000Changes LICENSE MANIFEST META.json META.yml Makefile.PL README dist.ini lib/Config/ZOMG.pm lib/Config/ZOMG/Source/Loader.pm t/10-loader.t t/11-loader-env.t t/12-loader-file.t t/13-loader-no-env.t t/14-loader-env-lookup.t t/16-loader-order.t t/17-found.t t/18-open.t t/22-default.t t/9bug-rt47237-path-undefined.t t/9bug-rt53886.t t/9bug-taking-extension-from-path.t t/assets/default.pl t/assets/dir.cnf/keep t/assets/dotdot.conf t/assets/order/xyzzy.cnf t/assets/order/xyzzy.conf t/assets/order/xyzzy.perl t/assets/order/xyzzy.pl t/assets/order/xyzzy_local.cnf t/assets/order/xyzzy_local.conf t/assets/order/xyzzy_local.perl t/assets/order/xyzzy_local.pl t/assets/path_to.pl t/assets/some_random_file.pl t/assets/xyzzy.pl t/assets/xyzzy_catalyst.pl t/assets/xyzzy_local.pl t/release-pod-syntax.t META.json100644001750001750 270612205513327 14511 0ustar00frewfrew000000000000Config-ZOMG-1.000000{ "abstract" : "Yet Another Catalyst::Plugin::ConfigLoader-style layer over Config::Any", "author" : [ "Arthur Axel \"fREW\" Schmidt ", "Robert Krimen " ], "dynamic_config" : 0, "generated_by" : "Dist::Zilla version 4.300035, CPAN::Meta::Converter version 2.120921", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : "2" }, "name" : "Config-ZOMG", "prereqs" : { "configure" : { "requires" : { "ExtUtils::MakeMaker" : "6.30" } }, "develop" : { "requires" : { "Test::Pod" : "1.41" } }, "runtime" : { "requires" : { "Clone" : "0", "Config::Any" : "0", "Hash::Merge::Simple" : "0", "List::Util" : "0", "Moo" : "0" } }, "test" : { "requires" : { "Test::Deep" : "0", "Test::More" : "0", "Test::Warn" : "0" } } }, "release_status" : "stable", "resources" : { "bugtracker" : { "web" : "https://github.com/frioux/Config-ZOMG/issues" }, "repository" : { "type" : "git", "url" : "git://github.com/frioux/Config-ZOMG.git", "web" : "https://github.com/frioux/Config-ZOMG" } }, "version" : "1.000000" } t000755001750001750 012205513327 13166 5ustar00frewfrew000000000000Config-ZOMG-1.00000018-open.t100644001750001750 160512205513327 14704 0ustar00frewfrew000000000000Config-ZOMG-1.000000/tuse strict; use warnings; use Test::More; use Test::Warn; use Config::ZOMG; sub has_Config_General { return eval "require Config::General;"; } { my $config = Config::ZOMG->open( 't/assets/some_random_file.pl' ); ok( $config ); ok( keys %{ $config } ); } { my $config = Config::ZOMG->open( qw{ name xyzzy path t/assets } ); ok( $config ); ok( keys %{ $config } ); } { my $config = Config::ZOMG->open( 't/assets/missing-file.pl' ); ok( ! $config ); } { my $config = Config::ZOMG->new( file => 't/assets/some_random_file.pl' ); warning_like { $config->open( '...' ) } qr/You called ->open on an instantiated object with arguments/; } { my ($config_hash, $config) = Config::ZOMG->open( qw{ name xyzzy path t/assets } ); ok( $config_hash ); is( ref $config_hash, 'HASH' ); ok( $config->isa('Config::ZOMG') ); } done_testing; Makefile.PL100644001750001750 312512205513327 15036 0ustar00frewfrew000000000000Config-ZOMG-1.000000 use strict; use warnings; use ExtUtils::MakeMaker 6.30; my %WriteMakefileArgs = ( "ABSTRACT" => "Yet Another Catalyst::Plugin::ConfigLoader-style layer over Config::Any", "AUTHOR" => "Arthur Axel \"fREW\" Schmidt , Robert Krimen ", "BUILD_REQUIRES" => {}, "CONFIGURE_REQUIRES" => { "ExtUtils::MakeMaker" => "6.30" }, "DISTNAME" => "Config-ZOMG", "EXE_FILES" => [], "LICENSE" => "perl", "NAME" => "Config::ZOMG", "PREREQ_PM" => { "Clone" => 0, "Config::Any" => 0, "Hash::Merge::Simple" => 0, "List::Util" => 0, "Moo" => 0 }, "TEST_REQUIRES" => { "Test::Deep" => 0, "Test::More" => 0, "Test::Warn" => 0 }, "VERSION" => "1.000000", "test" => { "TESTS" => "t/*.t" } ); unless ( eval { ExtUtils::MakeMaker->VERSION(6.63_03) } ) { my $tr = delete $WriteMakefileArgs{TEST_REQUIRES}; my $br = $WriteMakefileArgs{BUILD_REQUIRES}; for my $mod ( keys %$tr ) { if ( exists $br->{$mod} ) { $br->{$mod} = $tr->{$mod} if $tr->{$mod} > $br->{$mod}; } else { $br->{$mod} = $tr->{$mod}; } } } unless ( eval { ExtUtils::MakeMaker->VERSION(6.56) } ) { my $br = delete $WriteMakefileArgs{BUILD_REQUIRES}; my $pp = $WriteMakefileArgs{PREREQ_PM}; for my $mod ( keys %$br ) { if ( exists $pp->{$mod} ) { $pp->{$mod} = $br->{$mod} if $br->{$mod} > $pp->{$mod}; } else { $pp->{$mod} = $br->{$mod}; } } } delete $WriteMakefileArgs{CONFIGURE_REQUIRES} unless eval { ExtUtils::MakeMaker->VERSION(6.52) }; WriteMakefile(%WriteMakefileArgs); 17-found.t100644001750001750 237512205513327 15062 0ustar00frewfrew000000000000Config-ZOMG-1.000000/tuse strict; use warnings; use Test::More; use Test::Deep; use Config::ZOMG; sub has_Config_General { return eval "require Config::General;"; } { my $config = Config::ZOMG->new( file => 't/assets/some_random_file.pl', quiet_deprecation => 1 ); ok( $config->load ); ok( keys %{ $config->load } ); ok( $config->found ); cmp_deeply( [ $config->found ], bag( 't/assets/some_random_file.pl' ) ); } { my $config = Config::ZOMG->new( qw{ name xyzzy path t/assets } ); cmp_deeply( [ $config->find ], bag( 't/assets/xyzzy.pl', 't/assets/xyzzy_local.pl' ) ); ok( $config->load ); ok( keys %{ $config->load } ); ok( $config->found ); cmp_deeply( [ $config->found ], bag( 't/assets/xyzzy.pl', 't/assets/xyzzy_local.pl' ) ); } { my $config = Config::ZOMG->new( file => 't/assets/missing-file.pl', quiet_deprecation => 1 ); ok( $config->load ); cmp_deeply( $config->load, {} ); ok( !$config->found ); } { my $config = Config::ZOMG->new( file => 't/assets/some_random_file.pl', quiet_deprecation => 1 ); ok( !$config->found ); # Don't do ->read via ->found ok( $config->load ); ok( keys %{ $config->load } ); cmp_deeply( [ $config->found ], bag( 't/assets/some_random_file.pl' ) ); } done_testing; 10-loader.t100644001750001750 117712205513327 15205 0ustar00frewfrew000000000000Config-ZOMG-1.000000/tuse strict; use warnings; use Test::More; use Config::ZOMG; my $config = Config::ZOMG->new(qw{ name xyzzy path t/assets }); ok($config->load); is($config->load->{'Controller::Foo'}->{foo}, 'bar'); is($config->load->{'Controller::Foo'}->{new}, 'key'); is($config->load->{'Model::Baz'}->{qux}, 'xyzzy'); is($config->load->{'Model::Baz'}->{another}, 'new key'); is($config->load->{'view'}, 'View::TT::New'); is($config->load->{'foo_sub'}, '__foo(x,y)__'); is($config->load->{'literal_macro'}, '__literal(__DATA__)__'); done_testing; 22-default.t100644001750001750 61412205513327 15341 0ustar00frewfrew000000000000Config-ZOMG-1.000000/tuse strict; use warnings; use Test::More; plan qw/no_plan/; use Config::ZOMG; my $config; $config = Config::ZOMG->new( qw{ name default path t/assets }, default => { home => 'a-galaxy-far-far-away', test => 'alpha', }, ); is($config->load->{home}, 'a-galaxy-far-far-away'); is($config->load->{path_to}, '__path_to(tatooine)__'); is($config->load->{test}, 'beta'); 9bug-rt53886.t100644001750001750 47612205513327 15411 0ustar00frewfrew000000000000Config-ZOMG-1.000000/t#!/usr/bin/env perl use strict; use warnings; use Test::More; use Test::Warn; use Config::ZOMG; warning_is { Config::ZOMG->new( local_suffix => 'local' ) } undef; warning_like { Config::ZOMG->new( file => 'xyzzy',local_suffix => 'local' ) } qr/will be ignored if 'file' is given, use 'path' instead/; done_testing; 11-loader-env.t100644001750001750 112512205513327 15765 0ustar00frewfrew000000000000Config-ZOMG-1.000000/tuse strict; use warnings; use Test::More; use Config::ZOMG; $ENV{XYZZY_CONFIG} = "t/assets/some_random_file.pl"; my $config = Config::ZOMG->new(qw{ name xyzzy path t/assets }); ok($config->load); is($config->load->{'Controller::Foo'}->{foo}, 'bar'); is($config->load->{'Model::Baz'}->{qux}, 'xyzzy'); is($config->load->{'view'}, 'View::TT'); is($config->load->{'random'}, 1); $ENV{XYZZY_CONFIG} = "t/assets/some_non_existent_file.pl"; $config->reload; ok($config->load); is(scalar keys %{ $config->load }, 0); done_testing; assets000755001750001750 012205513327 14470 5ustar00frewfrew000000000000Config-ZOMG-1.000000/txyzzy.pl100644001750001750 37612205513327 16370 0ustar00frewfrew000000000000Config-ZOMG-1.000000/t/assets{ name => 'TestApp', view => 'View::TT', 'Controller::Foo' => { foo => 'bar' }, 'Model::Baz' => { qux => 'xyzzy' }, foo_sub => '__foo(x,y)__', literal_macro => '__literal(__DATA__)__', } Config000755001750001750 012205513327 14676 5ustar00frewfrew000000000000Config-ZOMG-1.000000/libZOMG.pm100644001750001750 1711212205513327 16172 0ustar00frewfrew000000000000Config-ZOMG-1.000000/lib/Configpackage Config::ZOMG; { $Config::ZOMG::VERSION = '1.000000'; } # ABSTRACT: Yet Another Catalyst::Plugin::ConfigLoader-style layer over Config::Any use Moo; use Sub::Quote 'quote_sub'; use Config::ZOMG::Source::Loader; use Config::Any; use Hash::Merge::Simple; has package => ( is => 'ro', ); has source => ( is => 'rw', handles => [qw/ driver local_suffix no_env env_lookup path found find /], ); has load_once => ( is => 'ro', default => quote_sub q{ 1 }, ); has loaded => ( is => 'rw', default => quote_sub q{ 0 }, ); has default => ( is => 'ro', default => quote_sub q[ {} ], ); has path_to => ( is => 'ro', reader => '_path_to', builder => '_build_path_to', lazy => 1, ); sub _build_path_to { my $self = shift; return $self->load->{home} if $self->load->{home}; return $self->source->path unless $self->source->path_is_file; return '.'; } has _config => ( is => 'rw', ); sub BUILD { my $self = shift; my $given = shift; my ($source, %source); if ($given->{file}) { $given->{path} = $given->{file}; $source{path_is_file} = 1; } { for (qw/ name path driver no_local local_suffix no_env env_lookup /) { $source{$_} = $given->{$_} if exists $given->{$_}; } warn "Warning, 'local_suffix' will be ignored if 'file' is given, use 'path' instead" if exists $source{local_suffix} && exists $given->{file}; $source = Config::ZOMG::Source::Loader->new( %source ); } $self->source($source); } sub open { unless ( ref $_[0] ) { my $class = shift; return $class->new( @_ == 1 ? (file => $_[0]) : @_ )->open; } my $self = shift; warn "You called ->open on an instantiated object with arguments" if @_; my $config_hash = $self->load; return unless $self->found; return wantarray ? ($config_hash, $self) : $config_hash; } sub load { my $self = shift; return $self->_config if $self->loaded && $self->load_once; $self->_config($self->default); $self->_load($_) for $self->source->read; $self->loaded(1); return $self->_config; } sub clone { require Clone; Clone::clone($_[0]->config) } sub reload { my $self = shift; $self->loaded(0); return $self->load; } sub _load { my $self = shift; my $cfg = shift; my ($file, $hash) = %$cfg; $self->_config(Hash::Merge::Simple->merge($self->_config, $hash)); } 1; __END__ =pod =head1 NAME Config::ZOMG - Yet Another Catalyst::Plugin::ConfigLoader-style layer over Config::Any =head1 VERSION version 1.000000 =head1 DESCRIPTION C is a fork of L. It removes a couple of unusual features and passes the same tests three times faster than L. C is an implementation of L that exists outside of L. C will scan a directory for files matching a certain name. If such a file is found which also matches an extension that L can read, then the configuration from that file will be loaded. C will also look for special files that end with a C<_local> suffix. Files with this special suffix will take precedence over any other existing configuration file, if any. The precedence takes place by merging the local configuration with the "standard" configuration via L. Finally you can override/modify the path search from outside your application, by setting the C<< ${NAME}_CONFIG >> variable outside your application (where C<$NAME> is the uppercase version of what you passed to L<< Config::ZOMG->new|/new >>). =head1 SYNPOSIS use Config::ZOMG; my $config = Config::ZOMG->new( name => 'my_application', path => 'path/to/my/application', ); my $config_hash = $config->load; This will look for something like (depending on what L will find): path/to/my/application/my_application_local.{yml,yaml,cnf,conf,jsn,json,...} and path/to/my/application/my_application.{yml,yaml,cnf,conf,jsn,json,...} ... and load the found configuration information appropiately, with C<_local> taking precedence. You can also specify a file directly: my $config = Config::ZOMG->new(file => '/path/to/my/application/my_application.cnf'); To later reload your configuration: $config->reload; =head1 METHODS =head2 new $config = Config::ZOMG->new(...) Returns a new C object You can configure the C<$config> object by passing the following to new: =over 2 =item name The name specifying the prefix of the configuration file to look for and the ENV variable to read. This can be a package name. In any case, :: will be substituted with _ in C and the result will be lowercased. To prevent modification of C, pass it in as a scalar reference. =item C The directory to search in =item C Directly read the configuration from this file. C must recognize the extension. Setting this will override C =item C Disable lookup of a local configuration. The C option will be ignored. Off by default =item C The suffix to match when looking for a local configuration. C by default =item C Set this to ignore ENV. C will be ignored. Off by default =item C Additional ENV to check if C<< $ENV{...} >> is not found =item C A hash consisting of C driver information. This is passed directly through to C =item C A hash filled with default keys/values =back =head2 open $config_hash = Config::ZOMG->open( ... ) As an alternative way to load a config C will pass given arguments to L then attempt to do L Unlike L if no configuration files are found C will return C (or the empty list) This is so you can do something like: my $config_hash = Config::ZOMG->open( '/path/to/application.cnf' ) or die "Couldn't find config file!" In scalar context C will return the config hash, B the config object. If you want the config object call C in list context: my ($config_hash, $config) = Config::ZOMG->open( ... ) You can pass any arguments to C that you would to L =head2 load $config->load Load a config as specified by L and C and return a hash This will only load the configuration once, so it's safe to call multiple times without incurring any loading-time penalty =head2 found $config->found Returns a list of files found If the list is empty then no files were loaded/read =head2 find $config->find Returns a list of files that configuration will be loaded from. Use this method to check whether configuration files have changed, without actually reloading. =head2 clone $config->clone Return a clone of the configuration hash using L This will load the configuration first, if it hasn't already =head2 reload $config->reload Reload the configuration, examining ENV and scanning the path anew Returns a hash of the configuration =head1 SEE ALSO L L L L L L =head1 AUTHORS =over 4 =item * Arthur Axel "fREW" Schmidt =item * Robert Krimen =back =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2013 by Arthur Axel "fREW" Schmidt. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut 12-loader-file.t100644001750001750 360212205513327 16117 0ustar00frewfrew000000000000Config-ZOMG-1.000000/tuse strict; use warnings; use Test::More; use Test::Deep; use Test::Warn; use Config::ZOMG; sub has_Config_General { return eval "require Config::General;"; } { my $config = Config::ZOMG->new( file => "t/assets/some_random_file.pl" ); ok($config->load); is($config->load->{'Controller::Foo'}->{foo}, 'bar'); is($config->load->{'Model::Baz'}->{qux}, 'xyzzy'); is($config->load->{'view'}, 'View::TT'); is($config->load->{'random'}, 1); } SKIP: { skip 'Config::General required' unless has_Config_General; my $config; $config = Config::ZOMG->new( path => "t/assets/order/../", name => "dotdot", ); ok($config->load, 'Load a config from a directory path ending with ../'); cmp_deeply( $config->load, { test => 'paths ending with ../', } ); $config = Config::ZOMG->new( path => "t/assets/order/xyzzy.cnf" ); cmp_deeply( $config->load, { cnf => 1, last => 'local_cnf', local_cnf => 1, } ); $config = Config::ZOMG->new( file => "t/assets/order/xyzzy.cnf" ); cmp_deeply( $config->load, { cnf => 1, last => 'cnf', } ); $config = Config::ZOMG->new( path => "t/assets/order/xyzzy.cnf", no_local => 1 ); cmp_deeply( $config->load, { cnf => 1, last => 'cnf', } ); warning_is { $config = Config::ZOMG->new( file => "t/assets/order/xyzzy.cnf", ) } undef; warning_is { $config = Config::ZOMG->new( file => "t/assets/order/xyzzy.cnf", no_06_warning => 1 ) } ''; warning_is { $config = Config::ZOMG->new( file => "t/assets/order/xyzzy.cnf", quiet_deprecation => 1 ) } ''; $config = Config::ZOMG->new( file => "t/assets/file-does-not-exist.cnf" ); cmp_deeply( $config->load, { } ); } done_testing; 16-loader-order.t100644001750001750 62512205513327 16301 0ustar00frewfrew000000000000Config-ZOMG-1.000000/tuse strict; use warnings; use Test::More; plan skip_all => "Config::General is required for this test" unless eval "require Config::General;"; use Config::ZOMG; my $config = Config::ZOMG->new(qw{ name xyzzy path t/assets/order }); ok($config->load); is($config->load->{'last'}, 'local_pl'); is($config->load->{$_}, 1) for qw/pl perl local_pl local_perl cnf local_cnf conf local_conf/; done_testing; default.pl100644001750001750 10312205513327 16563 0ustar00frewfrew000000000000Config-ZOMG-1.000000/t/assets{ path_to => '__path_to(tatooine)__', test => 'beta', } path_to.pl100644001750001750 12412205513327 16600 0ustar00frewfrew000000000000Config-ZOMG-1.000000/t/assets{ home => 'a-galaxy-far-far-away', path_to => '__path_to(tatooine)__', } 13-loader-no-env.t100644001750001750 126712205513327 16410 0ustar00frewfrew000000000000Config-ZOMG-1.000000/tuse strict; use warnings; use Test::More; use Config::ZOMG; $ENV{XYZZY_CONFIG} = "t/assets/some_non_existent_file.pl"; my $config = Config::ZOMG->new(qw{ name xyzzy path t/assets no_env 1 }); ok($config->load); is($config->load->{'Controller::Foo'}->{foo}, 'bar'); is($config->load->{'Controller::Foo'}->{new}, 'key'); is($config->load->{'Model::Baz'}->{qux}, 'xyzzy'); is($config->load->{'Model::Baz'}->{another}, 'new key'); is($config->load->{'view'}, 'View::TT::New'); is($config->load->{'foo_sub'}, '__foo(x,y)__' ); is($config->load->{'literal_macro'}, '__literal(__DATA__)__'); done_testing; dotdot.conf100644001750001750 3312205513327 16730 0ustar00frewfrew000000000000Config-ZOMG-1.000000/t/assetstest paths ending with ../ dir.cnf000755001750001750 012205513327 16013 5ustar00frewfrew000000000000Config-ZOMG-1.000000/t/assetskeep100644001750001750 012205513327 16730 0ustar00frewfrew000000000000Config-ZOMG-1.000000/t/assets/dir.cnfrelease-pod-syntax.t100644001750001750 45012205513327 17216 0ustar00frewfrew000000000000Config-ZOMG-1.000000/t#!perl BEGIN { unless ($ENV{RELEASE_TESTING}) { require Test::More; Test::More::plan(skip_all => 'these tests are for release candidate testing'); } } use Test::More; eval "use Test::Pod 1.41"; plan skip_all => "Test::Pod 1.41 required for testing POD" if $@; all_pod_files_ok(); xyzzy_local.pl100644001750001750 20712205513327 17533 0ustar00frewfrew000000000000Config-ZOMG-1.000000/t/assets{ view => 'View::TT::New', 'Controller::Foo' => { new => 'key' }, 'Model::Baz' => { 'another' => 'new key' }, } order000755001750001750 012205513327 15603 5ustar00frewfrew000000000000Config-ZOMG-1.000000/t/assetsxyzzy.pl100644001750001750 5212205513327 17452 0ustar00frewfrew000000000000Config-ZOMG-1.000000/t/assets/order{ last => 'pl', pl => 1, } 14-loader-env-lookup.t100644001750001750 222312205513327 17277 0ustar00frewfrew000000000000Config-ZOMG-1.000000/tuse strict; use warnings; use Test::More; use Config::ZOMG; eval { delete $ENV{$_} for qw/CATALYST_CONFIG_LOCAL_SUFFIX/; }; $ENV{CATALYST_CONFIG} = "t/assets/some_random_file.pl"; my $config = Config::ZOMG->new(qw{ name xyzzy path t/assets env_lookup CATALYST }); ok($config->load); is($config->load->{'Controller::Foo'}->{foo}, 'bar'); is($config->load->{'Model::Baz'}->{qux}, 'xyzzy'); is($config->load->{'view'}, 'View::TT'); is($config->load->{'random'}, 1); $ENV{XYZZY_CONFIG} = "t/assets/xyzzy.pl"; $config = Config::ZOMG->new(qw{ name xyzzy path t/assets }, env_lookup => [qw/CATALYST/]); ok($config->load); is($config->load->{'Controller::Foo'}->{foo}, 'bar'); is($config->load->{'Controller::Foo'}->{new}, 'key'); is($config->load->{'Model::Baz'}->{qux}, 'xyzzy'); is($config->load->{'Model::Baz'}->{another}, 'new key'); is($config->load->{'view'}, 'View::TT::New'); is($config->load->{'foo_sub'}, '__foo(x,y)__' ); is($config->load->{'literal_macro'}, '__literal(__DATA__)__'); done_testing; xyzzy.cnf100644001750001750 1712205513327 17606 0ustar00frewfrew000000000000Config-ZOMG-1.000000/t/assets/orderlast cnf cnf 1 xyzzy.conf100644001750001750 2112205513327 17760 0ustar00frewfrew000000000000Config-ZOMG-1.000000/t/assets/orderlast conf conf 1 xyzzy.perl100644001750001750 4512205513327 20003 0ustar00frewfrew000000000000Config-ZOMG-1.000000/t/assets/order{ last => 'perl', perl => 1, } xyzzy_catalyst.pl100644001750001750 37612205513327 20274 0ustar00frewfrew000000000000Config-ZOMG-1.000000/t/assets{ name => 'TestApp', view => 'View::TT', 'Controller::Foo' => { foo => 'bar' }, 'Model::Baz' => { qux => 'xyzzy' }, foo_sub => '__foo(x,y)__', literal_macro => '__literal(__DATA__)__', } some_random_file.pl100644001750001750 27712205513327 20455 0ustar00frewfrew000000000000Config-ZOMG-1.000000/t/assets{ name => 'TestApp', view => 'View::TT', 'Controller::Foo' => { foo => 'bar' }, 'Model::Baz' => { qux => 'xyzzy' }, random => 1, } xyzzy_local.pl100644001750001750 5512205513327 20627 0ustar00frewfrew000000000000Config-ZOMG-1.000000/t/assets/order{ last => 'local_pl', local_pl => 1, } xyzzy_local.cnf100644001750001750 3312205513327 20756 0ustar00frewfrew000000000000Config-ZOMG-1.000000/t/assets/orderlast local_cnf local_cnf 1 9bug-rt47237-path-undefined.t100644001750001750 30712205513327 20264 0ustar00frewfrew000000000000Config-ZOMG-1.000000/t#!/usr/bin/env perl use strict; use warnings; use Test::More; use Test::Warn; use Config::ZOMG; my $config = Config::ZOMG->new( name => '' ); warning_is { $config->_path_to } undef; done_testing; xyzzy_local.conf100644001750001750 3512205513327 21137 0ustar00frewfrew000000000000Config-ZOMG-1.000000/t/assets/orderlast local_conf local_conf 1 xyzzy_local.perl100644001750001750 6112205513327 21153 0ustar00frewfrew000000000000Config-ZOMG-1.000000/t/assets/order{ last => 'local_perl', local_perl => 1, } Source000755001750001750 012205513327 16712 5ustar00frewfrew000000000000Config-ZOMG-1.000000/lib/Config/ZOMGLoader.pm100644001750001750 1173512205513327 20645 0ustar00frewfrew000000000000Config-ZOMG-1.000000/lib/Config/ZOMG/Sourcepackage Config::ZOMG::Source::Loader; { $Config::ZOMG::Source::Loader::VERSION = '1.000000'; } use Moo; use Sub::Quote 'quote_sub'; use Config::Any; use List::Util 'first'; has name => ( is => 'rw', ); has path => ( is => 'ro', default => quote_sub q{ '.' }, ); has driver => ( is => 'ro', default => quote_sub q[ {} ], ); has local_suffix => ( is => 'ro', default => quote_sub q{ 'local' }, ); has no_env => ( is => 'ro', default => quote_sub q{ 0 }, ); has no_local => ( is => 'ro', default => quote_sub q{ 0 }, ); has env_lookup => ( is => 'ro', default => quote_sub q{ [] }, ); has path_is_file => ( is => 'ro', default => quote_sub q{ 0 }, ); has _found => ( is => 'rw', ); sub _env (@) { my $key = uc join "_", @_; $key =~ s/::/_/g; $key =~ s/\W/_/g; return $ENV{$key}; } sub BUILD { my $self = shift; my $given = shift; if (defined( my $name = $self->name )) { if (ref $name eq "SCALAR") { $name = $$name; } else { $name =~ s/::/_/g; $name = lc $name; } $self->name($name); } $self->{env_lookup} = [ $self->env_lookup ] if defined $self->env_lookup && ref $self->env_lookup ne 'ARRAY'; } sub read { my $self = shift; my @files = $self->_find_files; my $cfg_files = $self->_load_files(\@files); my %cfg_files = map { (%$_)[0] => $_ } reverse @$cfg_files; $self->_found( [ map { (%$_)[0] } @$cfg_files ] ); my (@cfg, @local_cfg); { # Anything that is local takes precedence my $local_suffix = $self->_get_local_suffix; for (sort keys %cfg_files) { my $cfg = $cfg_files{$_}; if (m{$local_suffix\.}ms) { push @local_cfg, $cfg; } else { push @cfg, $cfg; } } } return $self->no_local ? @cfg : (@cfg, @local_cfg); } sub found { my $self = shift; return ( $self->_found ? @{ $self->_found } : () ); } sub find { my $self = shift; return grep { -f $_ } $self->_find_files; } sub _load_files { my $self = shift; my $files = shift; return Config::Any->load_files({ files => $files, use_ext => 1, driver_args => $self->driver, }); } sub _find_files { # Doesn't really find files...hurm... my $self = shift; if ($self->path_is_file) { my $path = $self->_env_lookup('CONFIG') unless $self->no_env; $path ||= $self->path; return ($path); } else { my ($path, $extension) = $self->_get_path; my $local_suffix = $self->_get_local_suffix; my @extensions = $self->_get_extensions; my $no_local = $self->no_local; my @files; if ($extension) { die "Can't handle file extension $extension" unless first { $_ eq $extension } @extensions; push @files, $path; unless ($no_local) { (my $local_path = $path) =~ s{\.$extension$}{_$local_suffix.$extension}; push @files, $local_path; } } else { push @files, map { "$path.$_" } @extensions; push @files, map { "${path}_${local_suffix}.$_" } @extensions unless $no_local; } return @files; } } sub _env_lookup { my $self = shift; my @suffix = @_; my $name = $self->name; my $env_lookup = $self->env_lookup; my @lookup; push @lookup, $name if $name; push @lookup, @$env_lookup; for my $prefix (@lookup) { my $value = _env($prefix, @suffix); return $value if defined $value; } return; } sub _get_local_suffix { my $self = shift; my $name = $self->name; my $suffix; $suffix = $self->_env_lookup('CONFIG_LOCAL_SUFFIX') unless $self->no_env; $suffix ||= $self->local_suffix; return $suffix; } sub _get_extensions { @{ Config::Any->extensions } } sub file_extension ($) { my $path = shift; return if -d $path; my ($extension) = $path =~ m{\.([^/\.]{1,4})$}; return $extension; } sub _get_path { my $self = shift; my $name = $self->name; my $path; $path = $self->_env_lookup('CONFIG') unless $self->no_env; $path ||= $self->path; my $extension = file_extension $path; if (-d $path) { $path =~ s{[\/\\]$}{}; # Remove any trailing slash, e.g. apple/ or apple\ => apple $path .= "/$name"; # Look for a file in path with $self->name, e.g. apple => apple/name } return ($path, $extension); } 1; __END__ =pod =head1 NAME Config::ZOMG::Source::Loader =head1 VERSION version 1.000000 =head1 AUTHORS =over 4 =item * Arthur Axel "fREW" Schmidt =item * Robert Krimen =back =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2013 by Arthur Axel "fREW" Schmidt. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut 9bug-taking-extension-from-path.t100644001750001750 66712205513327 21532 0ustar00frewfrew000000000000Config-ZOMG-1.000000/t#!/usr/bin/env perl use strict; use warnings; use Test::More; use Config::ZOMG::Source::Loader; sub file_extension ($) { Config::ZOMG::Source::Loader::file_extension shift } is( file_extension 'test.conf', 'conf' ); is( file_extension '...', undef ); is( file_extension '../.', undef ); is( file_extension '.../.', undef ); is( file_extension 't/assets/order/..', undef ); is( file_extension 't/assets/dir.cnf', undef ); done_testing;