Config-MVP-2.200006000755000766000766 012215715500 12705 5ustar00rjbsrjbs000000000000README100644000766000766 47712215715500 13636 0ustar00rjbsrjbs000000000000Config-MVP-2.200006 This archive contains the distribution Config-MVP, version 2.200006: multivalue-property package-oriented configuration This software is copyright (c) 2013 by Ricardo Signes. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Changes100644000766000766 1003512215715500 14300 0ustar00rjbsrjbs000000000000Config-MVP-2.200006Revision history for Config-MVP 2.200006 2013-09-17 08:58:53 Asia/Tokyo - fix repository data 2.200005 2013-09-17 08:56:36 Asia/Tokyo - removed use of deprecated Class::MOP::load_class (thanks, Karen Etheridge) 2.200004 2013-08-27 12:09:19 America/New_York - pass the arguments to missing_plugin in the right order 2.200003 2013-01-30 21:35:34 America/New_York - doc fixes (Thanks, George Hartzell!) 2.200002 2012-03-15 21:16:16 America/New_York - documentation fixes (Thanks, Gregor Herrmann of Debian!) - depend on at least version 0.17 of Class::Load, to work around a bug with perl5.8.8 and Module::Runtime 0.012. (Karen Etheridge) 2.200001 2011-02-11 11:13:20 America/New_York - when throwing "package not installed", add a "package" attribute to Error 2.200000 2011-02-08 11:05:12 America/New_York - add Config::MVP::Error for common exceptions - allow class loading and class-not-found handling to be subclassed (thanks, Kent Fredric!) 2.101650 2010-06-14 20:22:42 America/New_York - require Moose 0.91 for native trait support 2.101540 2010-06-03 00:28:57 America/New_York - improve if_none to return from the proper scope (i.e., now it works) 2.101480 2010-05-28 22:59:18 America/New_York - add an if_none callback to Reader::Finder; for now, private 2.101460 2010-05-26 22:29:43 America/New_York [BREAKS BACKWARD COMPATIBILITY] - I apologize for breaking backcompat twice in a week. I do not expect this to happen again. -- rjbs - Config::MVP::Reader is now a base class rather than a role. This significantly simplifies the use of Config::MVP readers and makes things easier to document. 1.101451 2010-05-25 22:38:06 America/New_York - always finalize sections added by bundles 1.101450 2010-05-25 18:13:19 America/New_York [BREAKS BACKWARD COMPATIBILITY] - The Reader interface has been substantially overhauled. - Readers no longer have persistent Assembler, but now must be handed one (or will generate one as needed) - the arguments for Reader->read_config have changed - classes implementing Reader are required to provide a read_into_assembler method, now - Reader::Findable has been broken into Findable and Findable::ByExtension 0.101410 2010-05-21 22:09:48 America/New_York Sections, Sequences, and Assemblers can now be finalized the Assembler finalizes things as appropriate Sections can refer to their containing Sequence Sequences can refer to their constructing Assembler bundles now can (and should) provide payload as an arrayref Assembler->begin_section can be given a reference to a package name to skip rewriting the replace_bundle_with_contents method is used by Assembler::WithBundles to convert bundle sections into contents 0.100780 2010-03-19 22:16:16 America/New_York the alias attr on Section is now lazy so that mvp_aliases is called 0.093350 2009-12-01 06:58:48 America/New_York added Config::MVP::Reader::Hash for use by adapter writers 0.093330 2009-11-29 17:40:08 America/New_York rebuild to include META.yml for sake of cpandeps scanner 0.093120 2009-11-08 add missing prereq 0.093000 2009-10-27 bundles for Assembler::WithBundles can now be nested 0.092990 2009-10-26 add Config::MVP::Reader and associated packages, from Dist::Zilla 0.092360 2009-08-24 add "begin_section" and "end_section" methods, mostly for wrapping with extra behavior in subclasses 0.092211 2009-08-09 much more documentation yet again 0.092210 2009-08-09 package interrogation (for mvp_* settings) is now done in Section initialization; this means you don't need to use the Assembler to benefit from this feature much more documentation LICENSE100644000766000766 4366112215715500 14025 0ustar00rjbsrjbs000000000000Config-MVP-2.200006This software is copyright (c) 2013 by Ricardo Signes. 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 Ricardo Signes. 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 Ricardo Signes. 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.ini100644000766000766 45212215715500 14413 0ustar00rjbsrjbs000000000000Config-MVP-2.200006name = Config-MVP author = Ricardo Signes license = Perl_5 copyright_holder = Ricardo Signes [Prereqs] Moose = 0 ; min ver unknown Tie::IxHash = 0 ; min ver unknown Module::Pluggable::Object = 0 ; min ver unknown Test::More = 0.88 [@RJBS] version = 2 github_issues = 1 t000755000766000766 012215715500 13071 5ustar00rjbsrjbs000000000000Config-MVP-2.200006hash.t100644000766000766 430312215715500 14341 0ustar00rjbsrjbs000000000000Config-MVP-2.200006/tuse strict; use warnings; use Test::More; use lib 't/lib'; { package CMRFBA; use Moose; extends 'Config::MVP::Assembler'; with 'Config::MVP::Assembler::WithBundles'; } { package CMRFB; use Moose; extends 'Config::MVP::Reader::Hash'; sub build_assembler { CMRFBA->new; } } { my $config = CMRFB->new->read_config({ 'Foo::Bar' => { x => 1, y => [ 2, 4 ], z => 3, }, 'bz' => { __package => 'Foo::Baz', single => 1, multi => [ 2, 3 ], }, 'Foo::Metaboondle' => { }, 'Foo::Quux' => { a => 1, b => 2, c => 3, } }); my @sections = $config->sections; is(@sections, 7, "there are seven sections"); @sections = sort { lc $a->name cmp lc $b->name } @sections; my ($b_1, $b_2, $b_3, $b_b, $baz, $bar, $quux) = @sections; is($bar->name, 'Foo::Bar', '1st is Foo::Bar (name)'); is($bar->package, 'Foo::Bar', '1st is Foo::Bar (pkg)'); is($baz->name, 'bz', '2nd is bz (name)'); is($baz->package, 'Foo::Baz', '2nd is Foo::Baz (pkg)'); is($b_1->name, 'boondle_1', '2nd is boondle_1 (name)'); is($b_1->package, 'Foo::Boo1', '2nd is Foo::Boo1 (pkg)'); is($b_2->name, 'boondle_2', '2nd is boondle_2 (name)'); is($b_2->package, 'Foo::Boo2', '2nd is Foo::Boo2 (pkg)'); is($b_b->name, 'boondle_B', '3rd is boondle_B (name)'); is($b_b->package, 'Foo::Bar', '3rd is Foo::Bar (pkg)'); is($b_3->name, 'boondle_3', '4th is boondle_3 (name)'); is($b_3->package, 'Foo::Boo2', '4th is Foo::Boo2 (pkg)'); is($quux->name, 'Foo::Quux', '5th is Foo::Quux (name)'); is($quux->package, 'Foo::Quux', '5th is Foo::Quux (pkg)'); } { my $config = CMRFB->new->read_config({ 'Foo::BoondleHref' => { }, }); my @sections = $config->sections; is(@sections, 3, "we get 2 sections"); is_deeply( $sections[2]->payload, { y => [ 1, 2, 3 ] }, "boondle_B has expected contents", ); } { my $config = CMRFB->new->read_config({ 'Foo::BoondleHref' => { }, }); my @sections = $config->sections; is(@sections, 3, "we get 2 sections"); is_deeply( $sections[2]->payload, { y => [ 1, 2, 3 ] }, "boondle_B has expected contents", ); } done_testing; META.yml100644000766000766 1326312215715500 14264 0ustar00rjbsrjbs000000000000Config-MVP-2.200006--- abstract: 'multivalue-property package-oriented configuration' author: - 'Ricardo Signes ' build_requires: Capture::Tiny: 0 Test::Fatal: 0 Test::More: 0.96 blib: 0 lib: 0 configure_requires: ExtUtils::MakeMaker: 6.30 dynamic_config: 0 generated_by: 'Dist::Zilla version 4.300038, CPAN::Meta::Converter version 2.132140' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 name: Config-MVP requires: Class::Load: 0.17 File::Spec: 0 Module::Pluggable::Object: 0 Module::Runtime: 0 Moose: 0.91 Moose::Role: 0 Moose::Util::TypeConstraints: 0 MooseX::OneArgNew: 0 Params::Util: 0 Role::HasMessage: 0 Role::Identifiable::HasIdent: 0 StackTrace::Auto: 0 Test::More: 0.88 Throwable: 0 Tie::IxHash: 0 Try::Tiny: 0 overload: 0 strict: 0 warnings: 0 resources: bugtracker: https://github.com/rjbs/Config-MVP/issues homepage: https://github.com/rjbs/Config-MVP repository: https://github.com/rjbs/Config-MVP.git version: 2.200006 x_Dist_Zilla: perl: version: 5.019003 plugins: - class: Dist::Zilla::Plugin::Prereqs config: Dist::Zilla::Plugin::Prereqs: phase: runtime type: requires name: Prereqs version: 4.300038 - class: Dist::Zilla::Plugin::Git::GatherDir name: '@RJBS/Git::GatherDir' version: 2.014 - class: Dist::Zilla::Plugin::CheckPrereqsIndexed name: '@RJBS/CheckPrereqsIndexed' version: 0.009 - class: Dist::Zilla::Plugin::CheckExtraTests name: '@RJBS/CheckExtraTests' version: 0.011 - class: Dist::Zilla::Plugin::PruneCruft name: '@RJBS/@Filter/PruneCruft' version: 4.300038 - class: Dist::Zilla::Plugin::ManifestSkip name: '@RJBS/@Filter/ManifestSkip' version: 4.300038 - class: Dist::Zilla::Plugin::MetaYAML name: '@RJBS/@Filter/MetaYAML' version: 4.300038 - class: Dist::Zilla::Plugin::License name: '@RJBS/@Filter/License' version: 4.300038 - class: Dist::Zilla::Plugin::Readme name: '@RJBS/@Filter/Readme' version: 4.300038 - class: Dist::Zilla::Plugin::ExecDir name: '@RJBS/@Filter/ExecDir' version: 4.300038 - class: Dist::Zilla::Plugin::ShareDir name: '@RJBS/@Filter/ShareDir' version: 4.300038 - class: Dist::Zilla::Plugin::MakeMaker name: '@RJBS/@Filter/MakeMaker' version: 4.300038 - class: Dist::Zilla::Plugin::Manifest name: '@RJBS/@Filter/Manifest' version: 4.300038 - class: Dist::Zilla::Plugin::TestRelease name: '@RJBS/@Filter/TestRelease' version: 4.300038 - class: Dist::Zilla::Plugin::ConfirmRelease name: '@RJBS/@Filter/ConfirmRelease' version: 4.300038 - class: Dist::Zilla::Plugin::UploadToCPAN name: '@RJBS/@Filter/UploadToCPAN' version: 4.300038 - class: Dist::Zilla::Plugin::AutoPrereqs name: '@RJBS/AutoPrereqs' version: 4.300038 - class: Dist::Zilla::Plugin::Git::NextVersion name: '@RJBS/Git::NextVersion' version: 2.014 - class: Dist::Zilla::Plugin::PkgVersion name: '@RJBS/PkgVersion' version: 4.300038 - class: Dist::Zilla::Plugin::MetaConfig name: '@RJBS/MetaConfig' version: 4.300038 - class: Dist::Zilla::Plugin::MetaJSON name: '@RJBS/MetaJSON' version: 4.300038 - class: Dist::Zilla::Plugin::NextRelease name: '@RJBS/NextRelease' version: 4.300038 - class: Dist::Zilla::Plugin::Test::ChangesHasContent name: '@RJBS/Test::ChangesHasContent' version: 0.006 - class: Dist::Zilla::Plugin::PodSyntaxTests name: '@RJBS/PodSyntaxTests' version: 4.300038 - class: Dist::Zilla::Plugin::ReportVersions::Tiny name: '@RJBS/ReportVersions::Tiny' version: 1.09 - class: Dist::Zilla::Plugin::Test::Compile config: Dist::Zilla::Plugin::Test::Compile: module_finder: - ':InstallModules' script_finder: - ':ExecFiles' name: '@RJBS/Test::Compile' version: 2.018 - class: Dist::Zilla::Plugin::Prereqs config: Dist::Zilla::Plugin::Prereqs: phase: test type: requires name: '@RJBS/TestMoreWithSubtests' version: 4.300038 - class: Dist::Zilla::Plugin::PodWeaver name: '@RJBS/PodWeaver' version: 3.101642 - class: Dist::Zilla::Plugin::GithubMeta name: '@RJBS/GithubMeta' version: 0.30 - class: Dist::Zilla::Plugin::Git::Check name: '@RJBS/@Git/Check' version: 2.014 - class: Dist::Zilla::Plugin::Git::Commit name: '@RJBS/@Git/Commit' version: 2.014 - class: Dist::Zilla::Plugin::Git::Tag name: '@RJBS/@Git/Tag' version: 2.014 - class: Dist::Zilla::Plugin::Git::Push name: '@RJBS/@Git/Push' version: 2.014 - class: Dist::Zilla::Plugin::FinderCode name: ':InstallModules' version: 4.300038 - class: Dist::Zilla::Plugin::FinderCode name: ':IncModules' version: 4.300038 - class: Dist::Zilla::Plugin::FinderCode name: ':TestFiles' version: 4.300038 - class: Dist::Zilla::Plugin::FinderCode name: ':ExecFiles' version: 4.300038 - class: Dist::Zilla::Plugin::FinderCode name: ':ShareFiles' version: 4.300038 - class: Dist::Zilla::Plugin::FinderCode name: ':MainModule' version: 4.300038 zilla: class: Dist::Zilla::Dist::Builder config: is_trial: 0 version: 4.300038 MANIFEST100644000766000766 142312215715500 14117 0ustar00rjbsrjbs000000000000Config-MVP-2.200006Changes LICENSE MANIFEST META.json META.yml Makefile.PL README dist.ini lib/Config/MVP.pm lib/Config/MVP/Assembler.pm lib/Config/MVP/Assembler/WithBundles.pm lib/Config/MVP/Error.pm lib/Config/MVP/Reader.pm lib/Config/MVP/Reader/Findable.pm lib/Config/MVP/Reader/Findable/ByExtension.pm lib/Config/MVP/Reader/Finder.pm lib/Config/MVP/Reader/Hash.pm lib/Config/MVP/Section.pm lib/Config/MVP/Sequence.pm t/00-compile.t t/000-report-versions-tiny.t t/basic.t t/eg/config.mvp-test t/final-hooks.t t/hash.t t/lib/Config/MVP/Reader/Test.pm t/lib/Foo/Bar.pm t/lib/Foo/Baz.pm t/lib/Foo/Boo1.pm t/lib/Foo/Boo2.pm t/lib/Foo/Boondle.pm t/lib/Foo/BoondleHref.pm t/lib/Foo/CompileError.pm t/lib/Foo/Metaboondle.pm t/lib/Foo/Quux.pm t/reader.t xt/release/changes_has_content.t xt/release/pod-syntax.t basic.t100644000766000766 314212215715500 14477 0ustar00rjbsrjbs000000000000Config-MVP-2.200006/t#!perl use strict; use warnings; use lib 't/lib'; use Test::More; use Test::Fatal; require_ok( 'Config::MVP::Assembler' ); my $assembler = Config::MVP::Assembler->new; my $section = Config::MVP::Section->new({ name => '_', }); $assembler->sequence->add_section($section); $assembler->add_value(foo => 10); $assembler->add_value(bar => 11); $assembler->change_section('Foo::Bar'); $assembler->add_value(x => 10); $assembler->add_value(y => 20); $assembler->add_value(y => 30); $assembler->add_value(z => -123); $assembler->change_section('Foo::Bar', 'baz'); $assembler->add_value(x => 1); $assembler->finalize; my @sections = $assembler->sequence->sections; is(@sections, 3, "there are three sections"); is($sections[0]->name, '_'); is($sections[1]->name, 'Foo::Bar'); is($sections[2]->name, 'baz'); is($sections[0]->package, undef); is($sections[1]->package, 'Foo::Bar'); is($sections[2]->package, 'Foo::Bar'); is_deeply($sections[0]->payload, { bar => 11, foo => 10 }); is_deeply($sections[1]->payload, { x => 10, y => [ 20, 30 ], z => -123 }); is_deeply($sections[2]->payload, { x => 1 }); { my $assembler = Config::MVP::Assembler->new; my $err = exception { $assembler->change_section('Foo::CompileError'); }; like($err, qr/"\$x"/, "strict failures are propagated"); } { my $assembler = Config::MVP::Assembler->new; my $err = exception { $assembler->change_section('Foo::Missing'); }; is( $err->ident, 'package not installed', "we get a well-identifier 'not installed' exception", ); is( $err->package, 'Foo::Missing', 'and we stored the package', ); } done_testing; META.json100644000766000766 2175712215715500 14443 0ustar00rjbsrjbs000000000000Config-MVP-2.200006{ "abstract" : "multivalue-property package-oriented configuration", "author" : [ "Ricardo Signes " ], "dynamic_config" : 0, "generated_by" : "Dist::Zilla version 4.300038, CPAN::Meta::Converter version 2.132140", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : "2" }, "name" : "Config-MVP", "prereqs" : { "configure" : { "requires" : { "ExtUtils::MakeMaker" : "6.30" } }, "develop" : { "requires" : { "Test::Pod" : "1.41", "version" : "0.9901" } }, "runtime" : { "requires" : { "Class::Load" : "0.17", "File::Spec" : "0", "Module::Pluggable::Object" : "0", "Module::Runtime" : "0", "Moose" : "0.91", "Moose::Role" : "0", "Moose::Util::TypeConstraints" : "0", "MooseX::OneArgNew" : "0", "Params::Util" : "0", "Role::HasMessage" : "0", "Role::Identifiable::HasIdent" : "0", "StackTrace::Auto" : "0", "Test::More" : "0.88", "Throwable" : "0", "Tie::IxHash" : "0", "Try::Tiny" : "0", "overload" : "0", "strict" : "0", "warnings" : "0" } }, "test" : { "requires" : { "Capture::Tiny" : "0", "Test::Fatal" : "0", "Test::More" : "0.96", "blib" : "0", "lib" : "0" } } }, "release_status" : "stable", "resources" : { "bugtracker" : { "web" : "https://github.com/rjbs/Config-MVP/issues" }, "homepage" : "https://github.com/rjbs/Config-MVP", "repository" : { "type" : "git", "url" : "https://github.com/rjbs/Config-MVP.git", "web" : "https://github.com/rjbs/Config-MVP" } }, "version" : "2.200006", "x_Dist_Zilla" : { "perl" : { "version" : "5.019003" }, "plugins" : [ { "class" : "Dist::Zilla::Plugin::Prereqs", "config" : { "Dist::Zilla::Plugin::Prereqs" : { "phase" : "runtime", "type" : "requires" } }, "name" : "Prereqs", "version" : "4.300038" }, { "class" : "Dist::Zilla::Plugin::Git::GatherDir", "name" : "@RJBS/Git::GatherDir", "version" : "2.014" }, { "class" : "Dist::Zilla::Plugin::CheckPrereqsIndexed", "name" : "@RJBS/CheckPrereqsIndexed", "version" : "0.009" }, { "class" : "Dist::Zilla::Plugin::CheckExtraTests", "name" : "@RJBS/CheckExtraTests", "version" : "0.011" }, { "class" : "Dist::Zilla::Plugin::PruneCruft", "name" : "@RJBS/@Filter/PruneCruft", "version" : "4.300038" }, { "class" : "Dist::Zilla::Plugin::ManifestSkip", "name" : "@RJBS/@Filter/ManifestSkip", "version" : "4.300038" }, { "class" : "Dist::Zilla::Plugin::MetaYAML", "name" : "@RJBS/@Filter/MetaYAML", "version" : "4.300038" }, { "class" : "Dist::Zilla::Plugin::License", "name" : "@RJBS/@Filter/License", "version" : "4.300038" }, { "class" : "Dist::Zilla::Plugin::Readme", "name" : "@RJBS/@Filter/Readme", "version" : "4.300038" }, { "class" : "Dist::Zilla::Plugin::ExecDir", "name" : "@RJBS/@Filter/ExecDir", "version" : "4.300038" }, { "class" : "Dist::Zilla::Plugin::ShareDir", "name" : "@RJBS/@Filter/ShareDir", "version" : "4.300038" }, { "class" : "Dist::Zilla::Plugin::MakeMaker", "name" : "@RJBS/@Filter/MakeMaker", "version" : "4.300038" }, { "class" : "Dist::Zilla::Plugin::Manifest", "name" : "@RJBS/@Filter/Manifest", "version" : "4.300038" }, { "class" : "Dist::Zilla::Plugin::TestRelease", "name" : "@RJBS/@Filter/TestRelease", "version" : "4.300038" }, { "class" : "Dist::Zilla::Plugin::ConfirmRelease", "name" : "@RJBS/@Filter/ConfirmRelease", "version" : "4.300038" }, { "class" : "Dist::Zilla::Plugin::UploadToCPAN", "name" : "@RJBS/@Filter/UploadToCPAN", "version" : "4.300038" }, { "class" : "Dist::Zilla::Plugin::AutoPrereqs", "name" : "@RJBS/AutoPrereqs", "version" : "4.300038" }, { "class" : "Dist::Zilla::Plugin::Git::NextVersion", "name" : "@RJBS/Git::NextVersion", "version" : "2.014" }, { "class" : "Dist::Zilla::Plugin::PkgVersion", "name" : "@RJBS/PkgVersion", "version" : "4.300038" }, { "class" : "Dist::Zilla::Plugin::MetaConfig", "name" : "@RJBS/MetaConfig", "version" : "4.300038" }, { "class" : "Dist::Zilla::Plugin::MetaJSON", "name" : "@RJBS/MetaJSON", "version" : "4.300038" }, { "class" : "Dist::Zilla::Plugin::NextRelease", "name" : "@RJBS/NextRelease", "version" : "4.300038" }, { "class" : "Dist::Zilla::Plugin::Test::ChangesHasContent", "name" : "@RJBS/Test::ChangesHasContent", "version" : "0.006" }, { "class" : "Dist::Zilla::Plugin::PodSyntaxTests", "name" : "@RJBS/PodSyntaxTests", "version" : "4.300038" }, { "class" : "Dist::Zilla::Plugin::ReportVersions::Tiny", "name" : "@RJBS/ReportVersions::Tiny", "version" : "1.09" }, { "class" : "Dist::Zilla::Plugin::Test::Compile", "config" : { "Dist::Zilla::Plugin::Test::Compile" : { "module_finder" : [ ":InstallModules" ], "script_finder" : [ ":ExecFiles" ] } }, "name" : "@RJBS/Test::Compile", "version" : "2.018" }, { "class" : "Dist::Zilla::Plugin::Prereqs", "config" : { "Dist::Zilla::Plugin::Prereqs" : { "phase" : "test", "type" : "requires" } }, "name" : "@RJBS/TestMoreWithSubtests", "version" : "4.300038" }, { "class" : "Dist::Zilla::Plugin::PodWeaver", "name" : "@RJBS/PodWeaver", "version" : "3.101642" }, { "class" : "Dist::Zilla::Plugin::GithubMeta", "name" : "@RJBS/GithubMeta", "version" : "0.30" }, { "class" : "Dist::Zilla::Plugin::Git::Check", "name" : "@RJBS/@Git/Check", "version" : "2.014" }, { "class" : "Dist::Zilla::Plugin::Git::Commit", "name" : "@RJBS/@Git/Commit", "version" : "2.014" }, { "class" : "Dist::Zilla::Plugin::Git::Tag", "name" : "@RJBS/@Git/Tag", "version" : "2.014" }, { "class" : "Dist::Zilla::Plugin::Git::Push", "name" : "@RJBS/@Git/Push", "version" : "2.014" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":InstallModules", "version" : "4.300038" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":IncModules", "version" : "4.300038" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":TestFiles", "version" : "4.300038" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":ExecFiles", "version" : "4.300038" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":ShareFiles", "version" : "4.300038" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":MainModule", "version" : "4.300038" } ], "zilla" : { "class" : "Dist::Zilla::Dist::Builder", "config" : { "is_trial" : "0" }, "version" : "4.300038" } } } reader.t100644000766000766 246312215715500 14665 0ustar00rjbsrjbs000000000000Config-MVP-2.200006/tuse strict; use warnings; use Test::More; use lib 't/lib'; { package CMRFBA; use Moose; extends 'Config::MVP::Assembler'; with 'Config::MVP::Assembler::WithBundles'; } { package CMRFB; use Moose; extends 'Config::MVP::Reader::Finder'; sub build_assembler { CMRFBA->new; } } my $config = CMRFB->read_config('t/eg/config'); my @sections = $config->sections; is(@sections, 7, "there are seven sections"); my ($bar, $baz, $b_1, $b_2, $b_b, $b_3, $quux) = @sections; is($bar->name, 'Foo::Bar', '1st is Foo::Bar (name)'); is($bar->package, 'Foo::Bar', '1st is Foo::Bar (pkg)'); is($baz->name, 'bz', '2nd is bz (name)'); is($baz->package, 'Foo::Baz', '2nd is Foo::Baz (pkg)'); is($b_1->name, 'boondle_1', '2nd is boondle_1 (name)'); is($b_1->package, 'Foo::Boo1', '2nd is Foo::Boo1 (pkg)'); is($b_2->name, 'boondle_2', '2nd is boondle_2 (name)'); is($b_2->package, 'Foo::Boo2', '2nd is Foo::Boo2 (pkg)'); is($b_b->name, 'boondle_B', '3nd is boondle_B (name)'); is($b_b->package, 'Foo::Bar', '3nd is Foo::Bar (pkg)'); is($b_3->name, 'boondle_3', '4th is boondle_3 (name)'); is($b_3->package, 'Foo::Boo2', '4th is Foo::Boo2 (pkg)'); is($quux->name, 'Foo::Quux', '5th is Foo::Quux (name)'); is($quux->package, 'Foo::Quux', '5th is Foo::Quux (pkg)'); done_testing; Makefile.PL100644000766000766 367512215715500 14753 0ustar00rjbsrjbs000000000000Config-MVP-2.200006 use strict; use warnings; use ExtUtils::MakeMaker 6.30; my %WriteMakefileArgs = ( "ABSTRACT" => "multivalue-property package-oriented configuration", "AUTHOR" => "Ricardo Signes ", "BUILD_REQUIRES" => {}, "CONFIGURE_REQUIRES" => { "ExtUtils::MakeMaker" => "6.30" }, "DISTNAME" => "Config-MVP", "EXE_FILES" => [], "LICENSE" => "perl", "NAME" => "Config::MVP", "PREREQ_PM" => { "Class::Load" => "0.17", "File::Spec" => 0, "Module::Pluggable::Object" => 0, "Module::Runtime" => 0, "Moose" => "0.91", "Moose::Role" => 0, "Moose::Util::TypeConstraints" => 0, "MooseX::OneArgNew" => 0, "Params::Util" => 0, "Role::HasMessage" => 0, "Role::Identifiable::HasIdent" => 0, "StackTrace::Auto" => 0, "Test::More" => "0.88", "Throwable" => 0, "Tie::IxHash" => 0, "Try::Tiny" => 0, "overload" => 0, "strict" => 0, "warnings" => 0 }, "TEST_REQUIRES" => { "Capture::Tiny" => 0, "Test::Fatal" => 0, "Test::More" => "0.96", "blib" => 0, "lib" => 0 }, "VERSION" => "2.200006", "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); 00-compile.t100644000766000766 154412215715500 15267 0ustar00rjbsrjbs000000000000Config-MVP-2.200006/tuse strict; use warnings; # This test was generated via Dist::Zilla::Plugin::Test::Compile 2.018 use Test::More 0.88; use Capture::Tiny qw{ capture }; my @module_files = qw( Config/MVP.pm Config/MVP/Assembler.pm Config/MVP/Assembler/WithBundles.pm Config/MVP/Error.pm Config/MVP/Reader.pm Config/MVP/Reader/Findable.pm Config/MVP/Reader/Findable/ByExtension.pm Config/MVP/Reader/Finder.pm Config/MVP/Reader/Hash.pm Config/MVP/Section.pm Config/MVP/Sequence.pm ); my @scripts = qw( ); # no fake home requested my @warnings; for my $lib (@module_files) { my ($stdout, $stderr, $exit) = capture { system($^X, '-Mblib', '-e', qq{require q[$lib]}); }; is($?, 0, "$lib loaded ok"); warn $stderr if $stderr; push @warnings, $stderr if $stderr; } is(scalar(@warnings), 0, 'no warnings found') if $ENV{AUTHOR_TESTING}; done_testing; final-hooks.t100644000766000766 235312215715500 15633 0ustar00rjbsrjbs000000000000Config-MVP-2.200006/tuse strict; use warnings; use Test::More; use lib 't/lib'; { package FAsm; use Moose; extends 'Config::MVP::Assembler'; has notes => ( is => 'ro', isa => 'ArrayRef', default => sub { [] }, ); has '+section_class' => (default => 'FAsm::Sec'); } { package FAsm::Sec; use Moose; extends 'Config::MVP::Section'; my $i = 0; after finalize => sub { my ($self) = @_; push @{ $self->sequence->assembler->notes }, [ $self->name, $i++ ]; }; } my $asm = FAsm->new; # I wish I had an existing simple way to say "just a name, no package" here. # -- rjbs, 2010-05-11 $asm->begin_section(strict => 'S1'); $asm->add_value(foo => 10); is_deeply($asm->notes, [], "no notes to start with"); $asm->change_section(strict => 'S2'); is_deeply($asm->notes, [ [ S1 => 0 ] ], "finalize one section, get notes!"); $asm->end_section; $asm->change_section(strict => 'S3'); is_deeply( $asm->notes, [ [ S1 => 0 ], [ S2 => 1 ], ], "ending section is as good as changing", ); $asm->change_section(strict => 'S4'); $asm->finalize; is_deeply( $asm->notes, [ [ S1 => 0 ], [ S2 => 1 ], [ S3 => 2 ], [ S4 => 3 ], ], "finalize the assembler after more sections, more notes!" ); done_testing; Foo000755000766000766 012215715500 14362 5ustar00rjbsrjbs000000000000Config-MVP-2.200006/t/libBar.pm100644000766000766 6712215715500 15527 0ustar00rjbsrjbs000000000000Config-MVP-2.200006/t/lib/Foopackage Foo::Bar; sub mvp_multivalue_args { qw(y) } 1; Baz.pm100644000766000766 7412215715500 15535 0ustar00rjbsrjbs000000000000Config-MVP-2.200006/t/lib/Foopackage Foo::Baz; sub mvp_multivalue_args { qw(multi) } 1; Config000755000766000766 012215715500 14601 5ustar00rjbsrjbs000000000000Config-MVP-2.200006/libMVP.pm100644000766000766 1652512215715500 15772 0ustar00rjbsrjbs000000000000Config-MVP-2.200006/lib/Configpackage Config::MVP; { $Config::MVP::VERSION = '2.200006'; } # ABSTRACT: multivalue-property package-oriented configuration use strict; use warnings; 1; __END__ =pod =head1 NAME Config::MVP - multivalue-property package-oriented configuration =head1 VERSION version 2.200006 =head1 SYNOPSIS If you want a useful synopsis, consider this code which actually comes from L: my $assembler = Config::MVP::Assembler->new; # Maybe you want a starting section: my $section = $assembler->section_class->new({ name => '_' }); $assembler->sequence->add_section($section); # We'll add some values, which will go to the starting section: $assembler->add_value(x => 10); $assembler->add_value(y => 20); # Change to a new section... $assembler->change_section($moniker); # ...and add values to that section. $assembler->add_value(x => 100); $assembler->add_value(y => 200); This doesn't make sense? Well, read on. =head1 DESCRIPTION MVP is a mechanism for loading configuration (or other information) for libraries. It doesn't read a file or a database. It's a helper for things that do. The idea is that you end up with a L object, and that you can use that object to fully configure your library or application. The sequence will contain a bunch of L objects, each of which is meant to provide configuration for a part of your program. Most of these sections will be directly related to a Perl library that you'll use as a plugin or helper. Each section will have a name, and every name in the sequence will be unique. This is a pretty abstract set of behaviors, so we'll provide some more concrete examples that should help explain how things work. =head1 EXAMPLE Imagine that we've got a program called DeliveryBoy that accepts mail and does stuff with it. The "stuff" is entirely up to the user's configuration. He can set up plugins that will be used on the message. He writes a config file that's read by L, which is a thin wrapper around Config::MVP used to load MVP-style config from F files. Here's the user's configuration: [Whitelist] require_pgp = 1 file = whitelist-family file = whitelist-friends file = whitelist-work [SpamFilter] filterset = standard max_score = 5 action = bounce [SpamFilter / SpamFilter_2] filterset = aggressive max_score = 5 action = tag [VerifyPGP] [Deliver] dest = Maildir The user will end up with a sequence with five sections, which we can represent something like this: { name => 'Whitelist', package => 'DeliveryBoy::Plugin::Whitelist', payload => { require_pgp => 1, files => [ qw(whitelist-family whitelist-friends whitelist-work) ] }, }, { name => 'SpamFilter', package => 'DeliveryBoy::Plugin::SpamFilter', payload => { filterset => 'standard', max_score => 5, action => 'bounce', } }, { name => 'SpamFilter_2', package => 'DeliveryBoy::Plugin::SpamFilter', payload => { filterset => 'aggressive', max_score => 5, action => 'tag', }, }, { name => 'VerifyPGP', package => 'DeliveryBoy::Plugin::VerifyPGP', payload => { }, }, { name => 'Deliver', package => 'DeliveryBoy::Plugin::Deliver', payload => { dest => 'Maildir' }, }, The INI reader uses L to build up configuration section by section as it goes, so that's how we'll talk about what's going on. Every section of the config file was converted into a section in the MVP sequence. Each section has a unique name, which defaults to the name of the INI section. Each section is also associated with a package, which was expanded from the INI section name. The way that names are expanded can be customized by subclassing the assembler. Every section also has a payload -- a hashref of settings. Note that every entry in every payload is a simple scalar except for one. The C entry for the Whitelist section is an arrayref. Also, note that while it appears as C in the final output, it was given as C in the input. Config::MVP provides a mechanism by which packages can define aliases for configuration names and an indication of what names correspond to "multi-value parameters." (That's part of the meaning of the name "MVP.") When the MVP assembler is told to start a section for C it expands the section name, loads the package, and inspects it for aliases and multivalue parameters. Then if multiple entries for a non-multivalue parameter are given, an exception can be raised. Multivalue parameters are always pushed onto arrayrefs and non-multivalue parameters are left as found. =head2 ...so what now? So, once our DeliveryBoy program has loaded its configuration, it needs to initialize its plugins. It can do something like the following: my $sequence = $deliveryboy->load_config; for my $section ($sequence->sections) { my $plugin = $section->package->new( $section->payload ); $deliveryboy->add_plugin( $section->name, $plugin ); } That's it! In fact, allowing this very, very block of code to load configuration and initialize plugins is the goal of Config::MVP. The one thing not depicted is the notion of a "root section" that you might expect to see in an INI file. This can be easily handled by starting your assembler off with a pre-built section where root settings will end up. For more information on this, look at the docs for the specific components. =head1 WHAT NEXT? =head2 Making Packages work with MVP Any package can be used as part of an MVP section. Packages can provide some methods to help MVP work with them. It isn't a problem if they are not defined =head3 mvp_aliases This method should return a hashref of name remappings. For example, if it returned this hashref: { file => 'files', path => 'files', } Then attempting to set either the "file" or "path" setting for the section would actually set the "files" setting. =head3 mvp_multivalue_args This method should return a list of setting names that may have multiple values and that will always be stored in an arrayref. =head2 The Assembler L is a state machine that makes it easy to build up your MVP-style configuration by firing off a series of events: new section, new setting, etc. You might want to subclass it to change the class of sequence or section that's used or to change how section names are expanded into packages. =head2 Sequences and Sections L and L are the two most important classes in MVP. They represent the overall configuration and each section of the configuration, respectively. They're both fairly simple classes, and you probably won't need to subclass them, but it's easy. =head2 Examples in the World For examples of Config::MVP in use, you can look at L or L. =head1 AUTHOR Ricardo Signes =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2013 by Ricardo Signes. 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 Boo1.pm100644000766000766 2612215715500 15616 0ustar00rjbsrjbs000000000000Config-MVP-2.200006/t/lib/Foopackage Foo::Boo1; 1; Boo2.pm100644000766000766 2612215715500 15617 0ustar00rjbsrjbs000000000000Config-MVP-2.200006/t/lib/Foopackage Foo::Boo2; 1; Quux.pm100644000766000766 2612215715500 15760 0ustar00rjbsrjbs000000000000Config-MVP-2.200006/t/lib/Foopackage Foo::Quux; 1; eg000755000766000766 012215715500 13464 5ustar00rjbsrjbs000000000000Config-MVP-2.200006/tconfig.mvp-test100644000766000766 20712215715500 16551 0ustar00rjbsrjbs000000000000Config-MVP-2.200006/t/eg[Foo::Bar] x = 1 y = 2 z = 3 y = 4 [Foo::Baz bz] single = 1 multi = 2 multi = 3 [Foo::Metaboondle] [Foo::Quux] a = 1 b = 2 c = 3 Boondle.pm100644000766000766 33712215715500 16425 0ustar00rjbsrjbs000000000000Config-MVP-2.200006/t/lib/Foopackage Foo::Boondle; sub mvp_bundle_config { return ( [ 'boondle_1', 'Foo::Boo1', [ x => 1 ] ], [ 'boondle_2', 'Foo::Boo2', [ a => 0 ] ], [ 'boondle_B', 'Foo::Bar', [ y => 1, y => 2, y => 3 ] ], ); } 1; MVP000755000766000766 012215715500 15243 5ustar00rjbsrjbs000000000000Config-MVP-2.200006/lib/ConfigError.pm100644000766000766 177012215715500 17037 0ustar00rjbsrjbs000000000000Config-MVP-2.200006/lib/Config/MVPpackage Config::MVP::Error; { $Config::MVP::Error::VERSION = '2.200006'; } use Moose; # ABSTRACT: common exceptions class has message => ( is => 'ro', isa => 'Str', required => 1, lazy => 1, default => sub { $_->ident }, ); sub as_string { my ($self) = @_; join qq{\n}, $self->message, "\n", $self->stack_trace; } use overload (q{""} => 'as_string'); with( 'Throwable', 'Role::Identifiable::HasIdent', 'Role::HasMessage', 'StackTrace::Auto', 'MooseX::OneArgNew' => { type => 'Str', init_arg => 'ident', }, ); no Moose; __PACKAGE__->meta->make_immutable(inline_constructor => 0); 1; __END__ =pod =head1 NAME Config::MVP::Error - common exceptions class =head1 VERSION version 2.200006 =head1 AUTHOR Ricardo Signes =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2013 by Ricardo Signes. 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 release000755000766000766 012215715500 14701 5ustar00rjbsrjbs000000000000Config-MVP-2.200006/xtpod-syntax.t100644000766000766 21212215715500 17307 0ustar00rjbsrjbs000000000000Config-MVP-2.200006/xt/release#!perl 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(); Reader.pm100644000766000766 567712215715500 17162 0ustar00rjbsrjbs000000000000Config-MVP-2.200006/lib/Config/MVPpackage Config::MVP::Reader; { $Config::MVP::Reader::VERSION = '2.200006'; } use Moose; # ABSTRACT: object to read config from storage into an assembler use Config::MVP::Assembler; sub read_config { my ($self, $location, $arg) = @_; $arg ||= {}; $self = $self->new unless blessed $self; my $assembler = $arg->{assembler} || $self->build_assembler; $self->read_into_assembler($location, $assembler); return $assembler->sequence; } sub read_into_assembler { confess 'required method read_into_assembler unimplemented' } sub build_assembler { Config::MVP::Assembler->new; } no Moose; 1; __END__ =pod =head1 NAME Config::MVP::Reader - object to read config from storage into an assembler =head1 VERSION version 2.200006 =head1 SYNOPSIS use Config::MVP::Reader::YAML; # this doesn't really exist my $reader = Config::MVP::Reader::YAML->new; my $sequence = $reader->read_config('/etc/foobar.yml'); =head1 DESCRIPTION A Config::MVP::Reader exists to read configuration data from storage (like a file) and convert that data into instructions to a L, which will in turn convert them into a L, the final product. =head1 METHODS =head2 read_config my $sequence = $reader->read_config($location, \%arg); This method is passed a location, which has no set meaning, but should be the mechanism by which the Reader is told how to locate configuration. It might be a file name, a hashref of parameters, a DBH, or anything else, depending on the needs of the specific Reader subclass. It is also passed a hashref of arguments, of which there is only one valid argument: assembler - the Assembler object into which to read the config If no assembler argument is passed, one will be constructed by calling the Reader's C method. Subclasses should generally not override C, but should instead implement a C method, described below. =head2 read_into_assembler This method should not be called directly. It is called by C with the following parameters: my $sequence = $reader->read_into_assembler( $location, $assembler ); The method should read the configuration found at C<$location> and use it to instruct the C<$assembler> (a L) what configuration to perform. The default implementation of this method will throw an exception complaining that it should have been implemented by a subclass. =head2 build_assembler If no Assembler is provided to C's C parameter, this method will be called on the Reader to construct one. It must return a Config::MVP::Assembler object, and by default will return an entirely generic one. =head1 AUTHOR Ricardo Signes =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2013 by Ricardo Signes. 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 BoondleHref.pm100644000766000766 33512215715500 17230 0ustar00rjbsrjbs000000000000Config-MVP-2.200006/t/lib/Foopackage Foo::BoondleHref; sub mvp_bundle_config { return ( [ 'boondle_1', 'Foo::Boo1', { x => 1 } ], [ 'boondle_2', 'Foo::Boo2', { a => 0 } ], [ 'boondle_B', 'Foo::Bar', { y => [ 1, 2, 3 ] } ], ); } 1; Metaboondle.pm100644000766000766 25612215715500 17274 0ustar00rjbsrjbs000000000000Config-MVP-2.200006/t/lib/Foopackage Foo::Metaboondle; sub mvp_bundle_config { return ( [ 'boondle_X', 'Foo::Boondle', { } ], [ 'boondle_3', 'Foo::Boo2', { xyzzy => 'plugh' } ], ); } 1; Section.pm100644000766000766 1572712215715500 17401 0ustar00rjbsrjbs000000000000Config-MVP-2.200006/lib/Config/MVPpackage Config::MVP::Section; { $Config::MVP::Section::VERSION = '2.200006'; } use Moose 0.91; use Class::Load 0.17 (); use Config::MVP::Error; # ABSTRACT: one section of an MVP configuration sequence has name => ( is => 'ro', isa => 'Str', required => 1 ); has package => ( is => 'ro', isa => 'Str', # should be class-like string, but can't be ClassName required => 0, predicate => 'has_package', ); has multivalue_args => ( is => 'ro', isa => 'ArrayRef', lazy => 1, default => sub { my ($self) = @_; return [] unless $self->has_package and $self->package->can('mvp_multivalue_args'); return [ $self->package->mvp_multivalue_args ]; }, ); has aliases => ( is => 'ro', isa => 'HashRef', lazy => 1, default => sub { my ($self) = @_; return {} unless $self->has_package and $self->package->can('mvp_aliases'); return $self->package->mvp_aliases; }, ); has payload => ( is => 'ro', isa => 'HashRef', init_arg => undef, default => sub { {} }, ); has is_finalized => ( is => 'ro', isa => 'Bool', traits => [ 'Bool' ], init_arg => undef, default => 0, handles => { finalize => 'set' }, ); before finalize => sub { my ($self) = @_; Config::MVP::Error->throw("can't finalize unsequenced Config::MVP::Section") unless $self->sequence; }; has sequence => ( is => 'ro', isa => 'Config::MVP::Sequence', weak_ref => 1, predicate => '_sequence_has_been_set', reader => '_sequence', writer => '__set_sequence', clearer => '_clear_sequence', ); sub _set_sequence { my ($self, $seq) = @_; Config::MVP::Error->throw("Config::MVP::Section cannot be resequenced") if $self->sequence; $self->__set_sequence($seq); } sub sequence { my ($self) = @_; return undef unless $self->_sequence_has_been_set; my $seq = $self->_sequence; Config::MVP::Error->throw("can't access section's destroyed sequence") unless defined $seq; return $seq; } sub add_value { my ($self, $name, $value) = @_; confess "can't add values to finalized section " . $self->name if $self->is_finalized; my $alias = $self->aliases->{ $name }; $name = $alias if defined $alias; my $mva = $self->multivalue_args; if (grep { $_ eq $name } @$mva) { my $array = $self->payload->{$name} ||= []; push @$array, $value; return; } if (exists $self->payload->{$name}) { Carp::croak "multiple values given for property $name in section " . $self->name; } $self->payload->{$name} = $value; } sub load_package { my ($self, $package, $plugin) = @_; Class::Load::load_optional_class($package) or $self->missing_package($package, $plugin); } sub missing_package { my ($self, $package, $plugin) = @_ ; my $class = Moose::Meta::Class->create_anon_class( superclasses => [ 'Config::MVP::Error' ], cached => 1, attributes => [ Moose::Meta::Attribute->new(package => ( is => 'ro', required => 1, )), ], ); $class->name->throw({ ident => 'package not installed', message => "$package (for plugin $plugin) does not appear to be installed", package => $package, }); } sub _BUILD_package_settings { my ($self) = @_; return unless defined (my $pkg = $self->package); confess "illegal package name $pkg" unless Params::Util::_CLASS($pkg); $self->load_package($pkg, $self->name); # We call these accessors for lazy attrs to ensure they're initialized from # defaults if needed. Crash early! -- rjbs, 2009-08-09 $self->multivalue_args; $self->aliases; } sub BUILD { my ($self) = @_; $self->_BUILD_package_settings; } no Moose; 1; __END__ =pod =head1 NAME Config::MVP::Section - one section of an MVP configuration sequence =head1 VERSION version 2.200006 =head1 DESCRIPTION For the most part, you can just consult L to understand what this class is and how it's used. =head1 ATTRIBUTES =head2 name This is the section's name. It's a string, and it must be provided. =head2 package This is the (Perl) package with which the section is associated. It is optional. When the section is instantiated, it will ensure that this package is loaded. =head2 multivalue_args This attribute is an arrayref of value names that should be considered multivalue properties in the section. When added to the section, they will always be wrapped in an arrayref, and they may be added to the section more than once. If this attribute is not given during construction, it will default to the result of calling section's package's C method. If the section has no associated package or if the package doesn't provide that method, it default to an empty arrayref. =head2 aliases This attribute is a hashref of name remappings. For example, if it contains this hashref: { file => 'files', path => 'files', } Then attempting to set either the "file" or "path" setting for the section would actually set the "files" setting. If this attribute is not given during construction, it will default to the result of calling section's package's C method. If the section has no associated package or if the package doesn't provide that method, it default to an empty hashref. =head2 payload This is the storage into which properties are set. It is a hashref of names and values. You should probably not alter the contents of the payload, and should read its contents only. =head2 is_finalized This attribute is true if the section has been marked finalized, which will prevent any new values from being added to it. It can be set with the C method. =head2 sequence This attributes points to the sequence into which the section has been assembled. It may be unset if the section has been created but not yet placed in a sequence. =head1 METHODS =head2 add_value $section->add_value( $name => $value ); This method sets the value for the named property to the given value. If the property is a multivalue property, the new value will be pushed onto the end of an arrayref that will store all values for that property. Attempting to add a value for a non-multivalue property whose value was already added will result in an exception. =head2 load_package $section->load_package($package, $plugin); This method is used to ensure that the given C<$package> is loaded, and is called whenever a section with a package is created. By default, it delegates to L. If the package can't be found, it calls the L method. Errors in compilation are not suppressed. =head2 missing_package $section->missing_package($package, $plugin); This method is called when C encounters a package that is not installed. By default, it throws an exception. =head1 AUTHOR Ricardo Signes =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2013 by Ricardo Signes. 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 CompileError.pm100644000766000766 6312215715500 17421 0ustar00rjbsrjbs000000000000Config-MVP-2.200006/t/lib/Foouse strict; package Foo::CompileError; $x = 10; 1; Sequence.pm100644000766000766 1047712215715500 17542 0ustar00rjbsrjbs000000000000Config-MVP-2.200006/lib/Config/MVPpackage Config::MVP::Sequence; { $Config::MVP::Sequence::VERSION = '2.200006'; } use Moose 0.91; # ABSTRACT: an ordered set of named configuration sections use Tie::IxHash; use Config::MVP::Error; use Config::MVP::Section; use Moose::Util::TypeConstraints (); # This is a private attribute and should not be documented for futzing-with, # most likely. -- rjbs, 2009-08-09 has sections => ( isa => 'HashRef[Config::MVP::Section]', reader => '_sections', init_arg => undef, default => sub { tie my %section, 'Tie::IxHash'; return \%section; }, ); has assembler => ( is => 'ro', isa => Moose::Util::TypeConstraints::class_type('Config::MVP::Assembler'), weak_ref => 1, predicate => '_assembler_has_been_set', reader => '_assembler', writer => '__set_assembler', ); sub _set_assembler { my ($self, $assembler) = @_; Config::MVP::Error->throw("can't alter Config::MVP::Sequence's assembler") if $self->assembler; $self->__set_assembler($assembler); } sub assembler { my ($self) = @_; return undef unless $self->_assembler_has_been_set; my $assembler = $self->_assembler; unless (defined $assembler) { Config::MVP::Error->throw("can't access sequences's destroyed assembler") } return $assembler; } has is_finalized => ( is => 'ro', isa => 'Bool', traits => [ 'Bool' ], init_arg => undef, default => 0, handles => { finalize => 'set' }, ); sub add_section { my ($self, $section) = @_; Config::MVP::Error->throw("can't add sections to finalized sequence") if $self->is_finalized; my $name = $section->name; confess "already have a section named $name" if $self->_sections->{ $name }; $section->_set_sequence($self); if (my @names = $self->section_names) { my $last_section = $self->section_named( $names[-1] ); $last_section->finalize unless $last_section->is_finalized; } $self->_sections->{ $name } = $section; } sub delete_section { my ($self, $name) = @_; Config::MVP::Error->throw("can't delete sections from finalized sequence") if $self->is_finalized; my $sections = $self->_sections; return unless exists $sections->{ $name }; $sections->{ $name }->_clear_sequence; return delete $sections->{ $name }; } sub section_named { my ($self, $name) = @_; my $sections = $self->_sections; return unless exists $sections->{ $name }; return $sections->{ $name }; } sub section_names { my ($self) = @_; return keys %{ $self->_sections }; } sub sections { my ($self) = @_; return values %{ $self->_sections }; } no Moose; 1; __END__ =pod =head1 NAME Config::MVP::Sequence - an ordered set of named configuration sections =head1 VERSION version 2.200006 =head1 DESCRIPTION A Config::MVP::Sequence is an ordered set of configuration sections, each of which has a name unique within the sequence. For the most part, you can just consult L to understand what this class is and how it's used. =head1 ATTRIBUTES =head2 is_finalized This attribute is true if the sequence has been marked finalized, which will prevent any changes (via methods like C or C). It can be set with the C method. =head1 METHODS =head2 add_section $sequence->add_section($section); This method adds the given section to the end of the sequence. If the sequence already contains a section with the same name as the new section, an exception will be raised. =head2 delete_section my $deleted_section = $sequence->delete_section( $name ); This method removes a section from the sequence and returns the removed section. If no section existed, the method returns false. =head2 section_named my $section = $sequence->section_named( $name ); This method returns the section with the given name, if one exists in the sequence. If no such section exists, the method returns false. =head2 section_names my @names = $sequence->section_names; This method returns a list of the names of the sections, in order. =head2 sections my @sections = $sequence->sections; This method returns the section objects, in order. =head1 AUTHOR Ricardo Signes =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2013 by Ricardo Signes. 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 Assembler.pm100644000766000766 1517512215715500 17707 0ustar00rjbsrjbs000000000000Config-MVP-2.200006/lib/Config/MVPpackage Config::MVP::Assembler; { $Config::MVP::Assembler::VERSION = '2.200006'; } use Moose; # ABSTRACT: multivalue-property config-loading state machine use Config::MVP::Error; use Config::MVP::Sequence; use Config::MVP::Section; has sequence_class => ( is => 'ro', isa => 'ClassName', lazy => 1, default => 'Config::MVP::Sequence', ); has section_class => ( is => 'ro', isa => 'ClassName', lazy => 1, default => 'Config::MVP::Section', ); has sequence => ( is => 'ro', isa => 'Config::MVP::Sequence', default => sub { $_[0]->sequence_class->new({ assembler => $_[0] }) }, init_arg => undef, handles => [ qw(is_finalized finalize) ], ); before finalize => sub { my ($self) = @_; $self->end_section if $self->current_section; }; has _between_sections => ( is => 'rw', isa => 'Bool', default => 0, ); sub begin_section { my ($self, $package_moniker, $name) = @_; Config::MVP::Error->throw("can't begin a new section while a section is open") if $self->current_section; $name = $package_moniker unless defined $name and length $name; my $package = ref($package_moniker) ? $$package_moniker : $self->expand_package($package_moniker); my $section = $self->section_class->new({ name => $name, (defined $package ? (package => $package) : ()), }); $self->_between_sections(0); $self->sequence->add_section($section); } sub end_section { my ($self) = @_; Config::MVP::Error->throw("can't end a section when no section is active") unless $self->current_section; $self->current_section->finalize; $self->_between_sections(1); } sub change_section { my $self = shift; $self->end_section if $self->current_section; $self->begin_section(@_); } sub add_value { my ($self, $name, $value) = @_; Config::MVP::Error->throw("can't set value when no section is active") unless my $section = $self->current_section; $section->add_value($name => $value); } sub expand_package { $_[1] } sub current_section { my ($self) = @_; return if $self->_between_sections; my (@sections) = $self->sequence->sections; return $sections[ -1 ] if @sections; return; } no Moose; 1; __END__ =pod =head1 NAME Config::MVP::Assembler - multivalue-property config-loading state machine =head1 VERSION version 2.200006 =head1 DESCRIPTION First, you should probably read the L. If you already know how it works, keep going. Config::MVP::Assembler is a helper for constructing a Config::MVP::Sequence object. It's a very simple state machine that lets you signal what kind of events you've encountered while reading configuration. =head1 ATTRIBUTES =head2 sequence_class This attribute stores the name of the class to be used for the assembler's sequence. It defaults to Config::MVP::Sequence. =head2 section_class This attribute stores the name of the class to be used for sections created by the assembler. It defaults to Config::MVP::Section. =head2 sequence This is the sequence that the assembler is assembling. It defaults to a new instance of the assembler's C. =head1 METHODS =head2 begin_section $assembler->begin_section($package_moniker, $name); $assembler->begin_section($package_moniker); $assembler->begin_section( \$package ); This method tells the assembler that it should begin work on a new section with the given identifier. If it is already working on a section, an error will be raised. See C> for a method to begin a new section, ending the current one if needed. The package moniker is expanded by the C> method. The name, if not given, defaults to the package moniker. These data are used to create a new section and the section is added to the end of the sequence. If the package argument is a reference, it is used as the literal value for the package, and no expansion is performed. If it is a reference to undef, a section with no package is created. =head2 end_section $assembler->end_section; This ends the current section. If there is no current section, an exception is raised. =head2 change_section $assembler->change_section($package_moniker, $name); $assembler->change_section($package_moniker); This method calls C, first calling C if needed. =head2 add_value $assembler->add_value( $name => $value ); This method tells the assembler that it has encountered a named value and should add it to the current section. If there is no current section, an exception is raised. (If this is not the first time we've seen the name in the section and it's not a multivalue property, the section class will raise an exception on its own.) =head2 expand_package This method is passed a short identifier for a package and is expected to return the full name of the module to load and package to interrogate. By default it simply returns the name it was passed, meaning that package names must be given whole to the C method. =head2 current_section This returns the section object onto which the assembler is currently adding values. If no section has yet been created, this method will return false. =head1 TYPICAL USE my $assembler = Config::MVP::Assembler->new; # Maybe you want a starting section: my $starting_section = $assembler->section_class->new({ name => '_' }); $assembler->sequence->add_section($section_starting); # We'll add some values, which will go to the starting section: $assembler->add_value(x => 10); $assembler->add_value(y => 20); # Change to a new section... $assembler->change_section($moniker); # ...and add values to that section. $assembler->add_value(x => 100); $assembler->add_value(y => 200); The code above creates an assembler and populates it step by step. In the end, to get values, you could do something like this: my @output; for my $section ($assembler->sequence->sections) { push @output, [ $section->name, $section->package, $section->payload ]; } When changing sections, the given section "moniker" is used for the new section name. The result of passing that moniker to the assembler's C> method is used as the section's package name. (By default, this method does nothing.) The new section's C and C are determined by calling the C and C methods on the package. =head1 AUTHOR Ricardo Signes =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2013 by Ricardo Signes. 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 000-report-versions-tiny.t100644000766000766 620012215715500 20053 0ustar00rjbsrjbs000000000000Config-MVP-2.200006/tuse strict; use warnings; use Test::More 0.88; # This is a relatively nice way to avoid Test::NoWarnings breaking our # expectations by adding extra tests, without using no_plan. It also helps # avoid any other test module that feels introducing random tests, or even # test plans, is a nice idea. our $success = 0; END { $success && done_testing; } # List our own version used to generate this my $v = "\nGenerated by Dist::Zilla::Plugin::ReportVersions::Tiny v1.09\n"; eval { # no excuses! # report our Perl details my $want = "any version"; $v .= "perl: $] (wanted $want) on $^O from $^X\n\n"; }; defined($@) and diag("$@"); # Now, our module version dependencies: sub pmver { my ($module, $wanted) = @_; $wanted = " (want $wanted)"; my $pmver; eval "require $module;"; if ($@) { if ($@ =~ m/Can't locate .* in \@INC/) { $pmver = 'module not found.'; } else { diag("${module}: $@"); $pmver = 'died during require.'; } } else { my $version; eval { $version = $module->VERSION; }; if ($@) { diag("${module}: $@"); $pmver = 'died during VERSION check.'; } elsif (defined $version) { $pmver = "$version"; } else { $pmver = ''; } } # So, we should be good, right? return sprintf('%-45s => %-10s%-15s%s', $module, $pmver, $wanted, "\n"); } eval { $v .= pmver('Capture::Tiny','any version') }; eval { $v .= pmver('Class::Load','0.17') }; eval { $v .= pmver('ExtUtils::MakeMaker','6.30') }; eval { $v .= pmver('File::Spec','any version') }; eval { $v .= pmver('Module::Pluggable::Object','any version') }; eval { $v .= pmver('Module::Runtime','any version') }; eval { $v .= pmver('Moose','0.91') }; eval { $v .= pmver('Moose::Role','any version') }; eval { $v .= pmver('Moose::Util::TypeConstraints','any version') }; eval { $v .= pmver('MooseX::OneArgNew','any version') }; eval { $v .= pmver('Params::Util','any version') }; eval { $v .= pmver('Role::HasMessage','any version') }; eval { $v .= pmver('Role::Identifiable::HasIdent','any version') }; eval { $v .= pmver('StackTrace::Auto','any version') }; eval { $v .= pmver('Test::Fatal','any version') }; eval { $v .= pmver('Test::More','0.96') }; eval { $v .= pmver('Test::Pod','1.41') }; eval { $v .= pmver('Throwable','any version') }; eval { $v .= pmver('Tie::IxHash','any version') }; eval { $v .= pmver('Try::Tiny','any version') }; eval { $v .= pmver('blib','any version') }; eval { $v .= pmver('lib','any version') }; eval { $v .= pmver('overload','any version') }; eval { $v .= pmver('strict','any version') }; eval { $v .= pmver('version','0.9901') }; eval { $v .= pmver('warnings','any version') }; # All done. $v .= <<'EOT'; Thanks for using my code. I hope it works for you. If not, please try and include this output in the bug report. That will help me reproduce the issue and solve your problem. EOT diag($v); ok(1, "we really didn't test anything, just reporting data"); $success = 1; # Work around another nasty module on CPAN. :/ no warnings 'once'; $Template::Test::NO_FLUSH = 1; exit 0; Reader000755000766000766 012215715500 16445 5ustar00rjbsrjbs000000000000Config-MVP-2.200006/lib/Config/MVPHash.pm100644000766000766 332112215715500 20025 0ustar00rjbsrjbs000000000000Config-MVP-2.200006/lib/Config/MVP/Readerpackage Config::MVP::Reader::Hash; { $Config::MVP::Reader::Hash::VERSION = '2.200006'; } use Moose; extends 'Config::MVP::Reader'; # ABSTRACT: a reader that tries to cope with a plain old hashref sub read_into_assembler { my ($self, $location, $assembler) = @_; confess "no hash given to $self" unless my $hash = $location; for my $name (keys %$hash) { my $payload = { %{ $hash->{ $name } } }; my $package = delete($payload->{__package}) || $name; $assembler->begin_section($package, $name); for my $key (%$payload) { my $val = $payload->{ $key }; my @values = ref $val ? @$val : $val; $assembler->add_value($key => $_) for @values; } $assembler->end_section; } return $assembler->sequence; } no Moose; __PACKAGE__->meta->make_immutable; 1; __END__ =pod =head1 NAME Config::MVP::Reader::Hash - a reader that tries to cope with a plain old hashref =head1 VERSION version 2.200006 =head1 SYNOPSIS my $sequence = Config::MVP::Reader::Hash->new->read_config( \%config ); =head1 DESCRIPTION In some ways, this is the L of last resort. Given a hashref, it attempts to interpret it as a Config::MVP::Sequence. Because hashes are generally unordered, order can't be relied upon unless the hash tied to have order (presumably with L). The hash keys are assumed to be section names and will be used as the section package moniker unless a L<__package> entry is found. =head1 AUTHOR Ricardo Signes =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2013 by Ricardo Signes. 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 Finder.pm100644000766000766 675112215715500 20363 0ustar00rjbsrjbs000000000000Config-MVP-2.200006/lib/Config/MVP/Readerpackage Config::MVP::Reader::Finder; { $Config::MVP::Reader::Finder::VERSION = '2.200006'; } use Moose; extends 'Config::MVP::Reader'; # ABSTRACT: a reader that finds an appropriate file use Config::MVP::Error; use Module::Pluggable::Object; use Try::Tiny; sub default_search_path { return qw(Config::MVP::Reader) } has _module_pluggable_object => ( is => 'ro', init_arg => undef, default => sub { my ($self) = @_; Module::Pluggable::Object->new( search_path => [ $self->default_search_path ], inner => 0, require => 1, ); }, ); sub _which_reader { my ($self, $location) = @_; my @options; for my $pkg ($self->_module_pluggable_object->plugins) { next unless $pkg->isa('Moose::Object'); next unless $pkg->does('Config::MVP::Reader::Findable'); my $location = $pkg->refined_location($location); next unless defined $location; push @options, [ $pkg, $location ]; } Config::MVP::Error->throw("no viable configuration could be found") unless @options; # XXX: Improve this error message -- rjbs, 2010-05-24 Config::MVP::Error->throw("multiple possible config plugins found") if @options > 1; return { 'package' => $options[0][0], 'location' => $options[0][1], }; } has if_none => ( is => 'ro', isa => 'Maybe[Str|CodeRef]', ); sub read_config { my ($self, $location, $arg) = @_; $self = $self->new unless blessed($self); $arg ||= {}; local $arg->{assembler} = $arg->{assembler} || $self->build_assembler; my $which; my $instead; try { $which = $self->_which_reader($location); } catch { die $_ unless $_ =~ /^no viable configuration/; die $_ unless defined (my $handler = $self->if_none); $instead = $self->$handler($location, $arg); }; return $instead unless $which; my $reader = $which->{package}->new; return $reader->read_config( $which->{location}, $arg ); } sub build_assembler { } sub read_into_assembler { confess "This method should never be called or reachable"; } no Moose; __PACKAGE__->meta->make_immutable; 1; __END__ =pod =head1 NAME Config::MVP::Reader::Finder - a reader that finds an appropriate file =head1 VERSION version 2.200006 =head1 DESCRIPTION The Finder reader multiplexes many other readers that implement the L role. It uses L to search for modules, limits them to objects implementing the Findable role, and then selects the those which report that they are able to read a configuration file found in the config root directory. If exactly one findable configuration reader finds a file, it is used to read the file and the configuration sequence is returned. Otherwise, an exception is raised. Config::MVP::Reader::Finder's C method will decline a new assembler, so if none was passed to C, the Findable reader to which reading is delegated will be responsible for building the assembler, unless a Finder subclass overrides C to set a default across all possible delegates. =head1 METHODS =head2 default_search_path This is the default search path used to find configuration readers. This method should return a list, and by default returns: qw( Config::MVP::Reader ) =head1 AUTHOR Ricardo Signes =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2013 by Ricardo Signes. 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 Reader000755000766000766 012215715500 16710 5ustar00rjbsrjbs000000000000Config-MVP-2.200006/t/lib/Config/MVPTest.pm100644000766000766 140112215715500 20321 0ustar00rjbsrjbs000000000000Config-MVP-2.200006/t/lib/Config/MVP/Readerpackage Config::MVP::Reader::Test; use Moose; extends 'Config::MVP::Reader'; with qw(Config::MVP::Reader::Findable::ByExtension); sub default_extension { 'mvp-test' } sub read_into_assembler { my ($self, $location, $assembler) = @_; my $filename = $location; open my $fh, '<', $filename or die "can't read $filename: $!"; LINE: while (my $line = <$fh>) { chomp $line; next if $line =~ m{\A\s*(;.+)?\z}; # skip blanks, comments if ($line =~ m{\A(\S+)\s*=\s*(\S+)\z}) { $assembler->add_value($1, $2); next LINE; } if ($line =~ m{\A\[(\S+)(?:\s+(\S+?))?\]\z}) { $assembler->change_section($1, $2); next LINE; } die "don't know how to handle this line: $line\n"; } return $assembler->sequence; } 1; changes_has_content.t100644000766000766 201412215715500 21220 0ustar00rjbsrjbs000000000000Config-MVP-2.200006/xt/release#!perl use Test::More tests => 2; note 'Checking Changes'; my $changes_file = 'Changes'; my $newver = '2.200006'; my $trial_token = '-TRIAL'; SKIP: { ok(-e $changes_file, "$changes_file file exists") or skip 'Changes is missing', 1; ok(_get_changes($newver), "$changes_file has content for $newver"); } done_testing; # _get_changes copied and adapted from Dist::Zilla::Plugin::Git::Commit # by Jerome Quelin sub _get_changes { my $newver = shift; # parse changelog to find commit message open(my $fh, '<', $changes_file) or die "cannot open $changes_file: $!"; my $changelog = join('', <$fh>); close $fh; my @content = grep { /^$newver(?:$trial_token)?(?:\s+|$)/ ... /^\S/ } # from newver to un-indented split /\n/, $changelog; shift @content; # drop the version line # drop unindented last line and trailing blank lines pop @content while ( @content && $content[-1] =~ /^(?:\S|\s*$)/ ); # return number of non-blank lines return scalar @content; } Findable.pm100644000766000766 232512215715500 20651 0ustar00rjbsrjbs000000000000Config-MVP-2.200006/lib/Config/MVP/Readerpackage Config::MVP::Reader::Findable; { $Config::MVP::Reader::Findable::VERSION = '2.200006'; } use Moose::Role; # ABSTRACT: a config class that Config::MVP::Reader::Finder can find requires 'refined_location'; no Moose::Role; 1; __END__ =pod =head1 NAME Config::MVP::Reader::Findable - a config class that Config::MVP::Reader::Finder can find =head1 VERSION version 2.200006 =head1 DESCRIPTION Config::MVP::Reader::Findable is a role meant to be composed alongside Config::MVP::Reader. =head1 METHODS =head2 refined_location This method is used to decide whether a Findable reader can read a specific thing under the C<$location> argument passed to C. The location could be a directory or base file name or dbh or almost anything else. This method will return false if it can't find anything to read. If it can find something to read, it will return a new (or unchanged) value for C<$location> to be used in reading the config. =head1 AUTHOR Ricardo Signes =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2013 by Ricardo Signes. 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 Assembler000755000766000766 012215715500 17160 5ustar00rjbsrjbs000000000000Config-MVP-2.200006/lib/Config/MVPWithBundles.pm100644000766000766 1043112215715500 22125 0ustar00rjbsrjbs000000000000Config-MVP-2.200006/lib/Config/MVP/Assemblerpackage Config::MVP::Assembler::WithBundles; { $Config::MVP::Assembler::WithBundles::VERSION = '2.200006'; } use Moose::Role; # ABSTRACT: a role to make assemblers expand bundles use Params::Util qw(_HASHLIKE _ARRAYLIKE); use Module::Runtime qw(use_module); sub package_bundle_method { my ($self, $pkg) = @_; return unless $pkg->can('mvp_bundle_config'); return 'mvp_bundle_config'; } after end_section => sub { my ($self) = @_; my $seq = $self->sequence; my ($last) = ($seq->sections)[-1]; return unless $last->package; return unless my $method = $self->package_bundle_method($last->package); $self->replace_bundle_with_contents($last, $method); }; sub replace_bundle_with_contents { my ($self, $bundle_sec, $method) = @_; my $seq = $self->sequence; $seq->delete_section($bundle_sec->name); $self->_add_bundle_contents($method, { name => $bundle_sec->name, package => $bundle_sec->package, payload => $bundle_sec->payload, }); }; sub _add_bundle_contents { my ($self, $method, $arg) = @_; my @bundle_config = $arg->{package}->$method($arg); PLUGIN: for my $plugin (@bundle_config) { my ($name, $package, $payload) = @$plugin; use_module($package); if (my $method = $self->package_bundle_method( $package )) { $self->_add_bundle_contents($method, { name => $name, package => $package, payload => $payload, }); } else { my $section = $self->section_class->new({ name => $name, package => $package, }); if (_HASHLIKE($payload)) { # XXX: Clearly this is a hack. -- rjbs, 2009-08-24 for my $name (keys %$payload) { my @v = ref $payload->{$name} ? @{$payload->{$name}} : $payload->{$name}; $section->add_value($name => $_) for @v; } } elsif (_ARRAYLIKE($payload)) { for (my $i = 0; $i < @$payload; $i += 2) { $section->add_value(@$payload[ $i, $i + 1 ]); } } else { Carp::confess("don't know how to interpret section payload $payload"); } $self->sequence->add_section($section); $section->finalize; } } } no Moose; 1; __END__ =pod =head1 NAME Config::MVP::Assembler::WithBundles - a role to make assemblers expand bundles =head1 VERSION version 2.200006 =head1 DESCRIPTION Config::MVP::Assembler::WithBundles is a role to be composed into a Config::MVP::Assembler subclass. It allows some sections of configuration to be treated as bundles. When any section is ended, if that section represented a bundle, its bundle contents will be unrolled and will replace it in the sequence. A package is considered a bundle if C returns a defined value (which is the name of a method that will be called on that package to retrieve its bundle config). my $method = $assembler->package_bundle_method($package); The default implementation looks for a method called C, but C can be replaced with one that returns the name of a different bundle-identifying method-name. Bundles are expanded by a call to the assembler's C method, like this: $assembler->replace_bundle_with_contents($section, $method); =head2 replace_bundle_with_contents The default C method deletes the section from the sequence. It then gets a description of the new sections to introduce, like this: my @new_config = $bundle_section->package->$method({ name => $bundle_section->name, package => $bundle_section->package, payload => $bundle_section->payload, }); (We pass a hashref rather than a section so that bundles can be expanded synthetically without having to laboriously create a new Section.) The returned C<@new_config> is a list of arrayrefs, each of which has three entries: [ $name, $package, $payload ] Each arrayref is converted into a section in the sequence. The C<$payload> should be an arrayref of name/value pairs to be added to the created section. =head1 AUTHOR Ricardo Signes =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2013 by Ricardo Signes. 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 Findable000755000766000766 012215715500 20151 5ustar00rjbsrjbs000000000000Config-MVP-2.200006/lib/Config/MVP/ReaderByExtension.pm100644000766000766 326112215715500 23120 0ustar00rjbsrjbs000000000000Config-MVP-2.200006/lib/Config/MVP/Reader/Findablepackage Config::MVP::Reader::Findable::ByExtension; { $Config::MVP::Reader::Findable::ByExtension::VERSION = '2.200006'; } use Moose::Role; # ABSTRACT: a Findable Reader that looks for files by extension with qw(Config::MVP::Reader::Findable); use File::Spec; requires 'default_extension'; sub refined_location { my ($self, $location) = @_; my $candidate_name = "$location." . $self->default_extension; return unless -r $candidate_name and -f _; return $candidate_name; } no Moose::Role; 1; __END__ =pod =head1 NAME Config::MVP::Reader::Findable::ByExtension - a Findable Reader that looks for files by extension =head1 VERSION version 2.200006 =head1 METHODS =head2 default_extension This method, B, returns the default extension used by files in the format this reader can read. When the Finder tries to find configuration, it have a directory root and a basename. Each (Findable) reader that it tries in turn will look for a file F in the root directory. If exactly one file is found, that file is read. =head2 refined_location This role provides a default implementation of the L|Config::MVP::Reader::Findable/refined_location> method required by Config::MVP::Reader. It will return a filename based on the original location, if a file exists matching that location plus the reader's C. =head1 AUTHOR Ricardo Signes =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2013 by Ricardo Signes. 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