Config-INI-0.021000755000766000766 012230773753 12446 5ustar00rjbsrjbs000000000000README100644000766000766 44112230773753 13366 0ustar00rjbsrjbs000000000000Config-INI-0.021 This archive contains the distribution Config-INI, version 0.021: simple .ini-file format This software is copyright (c) 2007 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 435212230773753 14026 0ustar00rjbsrjbs000000000000Config-INI-0.021Changelog for Config-INI 0.021 2013-10-20 11:33:59 America/New_York - throw an exception if line 1 appears to start with a UTF-8 BOM - typo fixes in docs (thanks, David Steinbrunner!) 0.020 2013-07-01 21:30:50 America/New_York update bugtracker 0.019 2011-12-15 17:03:14 America/New_York provide handle_unparsed_line 0.018 2011-06-02 21:51:50 America/New_York bump up version of IO::File required (thanks, ABH!) 0.017 2010-12-11 10:20:34 America/New_York avoid test failures on Win32 by using . instead of TMPDIR for writing test files (thanks, Ahmad M. Zawawi) 0.016 2010-09-04 add Mixin::Linewise to CARP_NOT -- better reporting of error location 0.015 2010-08-22 documentation improvements (thanks, castaway) 0.014 2009-01-16 add repo to metadata 0.013 2008-06-05 refactored some of the read_* write_* stuff to Mixin::Linewise 0.012 2008-04-12 BUG FIX: allow for different error message on cygwin fixed typo in docs (thanks HDP) 0.011 2007-11-19 BUG FIX: "0" was not a valid section name 0.010 2007-11-04 BUG FIX: detect when we're dumping something we won't be able to read BUG FIX: fix tests when filetest.pm is not available (pre-5.6) (thanks to CPAN tester srezic) DOCS: documentation of core file format in Config::INI 0.009 2007-11-01 add placeholding Config::INI (content soon!) 0.008 2007-10-31 update Module::Install 0.007 2007-08-21 use filetest.pm in tests to avoid -r-related failures on Cygwin 0.006 2007-08-15 use -T instead of -t in tests; -t is a perl 5.008 feature 0.005 2007-08-13 add finalize method, lazy-load starting section method (this means that you can have starting_section die to prevent properties outside of explicity setting) added Config::INI::Writer (largely done by Florian Ragwitz) further improved subclassability of Reader (thanks again, Florian!) 0.004 2007-05-12 fix asinine error in test, poorly adapted from Config::Tiny 0.003 2007-05-10 first release LICENSE100644000766000766 4366112230773753 13566 0ustar00rjbsrjbs000000000000Config-INI-0.021This software is copyright (c) 2007 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) 2007 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) 2007 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 22212230773753 14147 0ustar00rjbsrjbs000000000000Config-INI-0.021name = Config-INI author = Ricardo Signes license = Perl_5 copyright_holder = Ricardo Signes copyright_year = 2007 [@RJBS] META.yml100644000766000766 1230012230773753 14014 0ustar00rjbsrjbs000000000000Config-INI-0.021--- abstract: 'simple .ini-file format' author: - 'Ricardo Signes ' build_requires: Capture::Tiny: 0 Test::More: 0.96 blib: 0 configure_requires: ExtUtils::MakeMaker: 6.30 dynamic_config: 0 generated_by: 'Dist::Zilla version 4.300037, 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-INI requires: Carp: 0 IO::File: 1.14 IO::String: 0 Mixin::Linewise::Readers: 0 Mixin::Linewise::Writers: 0 strict: 0 warnings: 0 resources: bugtracker: https://github.com/rjbs/Config-INI/issues homepage: https://github.com/rjbs/Config-INI repository: https://github.com/rjbs/Config-INI.git version: 0.021 x_Dist_Zilla: perl: version: 5.016002 plugins: - class: Dist::Zilla::Plugin::Git::GatherDir name: '@RJBS/Git::GatherDir' version: 2.014 - class: Dist::Zilla::Plugin::CheckPrereqsIndexed name: '@RJBS/CheckPrereqsIndexed' version: 0.007 - class: Dist::Zilla::Plugin::CheckExtraTests name: '@RJBS/CheckExtraTests' version: 0.007 - class: Dist::Zilla::Plugin::PruneCruft name: '@RJBS/@Filter/PruneCruft' version: 4.300037 - class: Dist::Zilla::Plugin::ManifestSkip name: '@RJBS/@Filter/ManifestSkip' version: 4.300037 - class: Dist::Zilla::Plugin::MetaYAML name: '@RJBS/@Filter/MetaYAML' version: 4.300037 - class: Dist::Zilla::Plugin::License name: '@RJBS/@Filter/License' version: 4.300037 - class: Dist::Zilla::Plugin::Readme name: '@RJBS/@Filter/Readme' version: 4.300037 - class: Dist::Zilla::Plugin::ExecDir name: '@RJBS/@Filter/ExecDir' version: 4.300037 - class: Dist::Zilla::Plugin::ShareDir name: '@RJBS/@Filter/ShareDir' version: 4.300037 - class: Dist::Zilla::Plugin::MakeMaker name: '@RJBS/@Filter/MakeMaker' version: 4.300037 - class: Dist::Zilla::Plugin::Manifest name: '@RJBS/@Filter/Manifest' version: 4.300037 - class: Dist::Zilla::Plugin::TestRelease name: '@RJBS/@Filter/TestRelease' version: 4.300037 - class: Dist::Zilla::Plugin::ConfirmRelease name: '@RJBS/@Filter/ConfirmRelease' version: 4.300037 - class: Dist::Zilla::Plugin::UploadToCPAN name: '@RJBS/@Filter/UploadToCPAN' version: 4.300037 - class: Dist::Zilla::Plugin::AutoPrereqs name: '@RJBS/AutoPrereqs' version: 4.300037 - class: Dist::Zilla::Plugin::Git::NextVersion name: '@RJBS/Git::NextVersion' version: 2.014 - class: Dist::Zilla::Plugin::PkgVersion name: '@RJBS/PkgVersion' version: 4.300037 - class: Dist::Zilla::Plugin::MetaConfig name: '@RJBS/MetaConfig' version: 4.300037 - class: Dist::Zilla::Plugin::MetaJSON name: '@RJBS/MetaJSON' version: 4.300037 - class: Dist::Zilla::Plugin::NextRelease name: '@RJBS/NextRelease' version: 4.300037 - class: Dist::Zilla::Plugin::Test::ChangesHasContent name: '@RJBS/Test::ChangesHasContent' version: 0.006 - class: Dist::Zilla::Plugin::PodSyntaxTests name: '@RJBS/PodSyntaxTests' version: 4.300037 - 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.300037 - class: Dist::Zilla::Plugin::PodWeaver name: '@RJBS/PodWeaver' version: 3.101641 - 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.300037 - class: Dist::Zilla::Plugin::FinderCode name: ':IncModules' version: 4.300037 - class: Dist::Zilla::Plugin::FinderCode name: ':TestFiles' version: 4.300037 - class: Dist::Zilla::Plugin::FinderCode name: ':ExecFiles' version: 4.300037 - class: Dist::Zilla::Plugin::FinderCode name: ':ShareFiles' version: 4.300037 - class: Dist::Zilla::Plugin::FinderCode name: ':MainModule' version: 4.300037 zilla: class: Dist::Zilla::Dist::Builder config: is_trial: 0 version: 4.300037 MANIFEST100644000766000766 45212230773753 13641 0ustar00rjbsrjbs000000000000Config-INI-0.021Changes LICENSE MANIFEST META.json META.yml Makefile.PL README dist.ini examples/simple.ini lib/Config/INI.pm lib/Config/INI/Reader.pm lib/Config/INI/Writer.pm t/00-compile.t t/000-report-versions-tiny.t t/reader-err.t t/reader.t t/writer.t xt/release/changes_has_content.t xt/release/pod-syntax.t META.json100644000766000766 2022612230773753 14172 0ustar00rjbsrjbs000000000000Config-INI-0.021{ "abstract" : "simple .ini-file format", "author" : [ "Ricardo Signes " ], "dynamic_config" : 0, "generated_by" : "Dist::Zilla version 4.300037, CPAN::Meta::Converter version 2.120921", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : "2" }, "name" : "Config-INI", "prereqs" : { "configure" : { "requires" : { "ExtUtils::MakeMaker" : "6.30" } }, "develop" : { "requires" : { "Test::Pod" : "1.41", "version" : "0.9901" } }, "runtime" : { "requires" : { "Carp" : "0", "IO::File" : "1.14", "IO::String" : "0", "Mixin::Linewise::Readers" : "0", "Mixin::Linewise::Writers" : "0", "strict" : "0", "warnings" : "0" } }, "test" : { "requires" : { "Capture::Tiny" : "0", "Test::More" : "0.96", "blib" : "0" } } }, "release_status" : "stable", "resources" : { "bugtracker" : { "web" : "https://github.com/rjbs/Config-INI/issues" }, "homepage" : "https://github.com/rjbs/Config-INI", "repository" : { "type" : "git", "url" : "https://github.com/rjbs/Config-INI.git", "web" : "https://github.com/rjbs/Config-INI" } }, "version" : "0.021", "x_Dist_Zilla" : { "perl" : { "version" : "5.016002" }, "plugins" : [ { "class" : "Dist::Zilla::Plugin::Git::GatherDir", "name" : "@RJBS/Git::GatherDir", "version" : "2.014" }, { "class" : "Dist::Zilla::Plugin::CheckPrereqsIndexed", "name" : "@RJBS/CheckPrereqsIndexed", "version" : "0.007" }, { "class" : "Dist::Zilla::Plugin::CheckExtraTests", "name" : "@RJBS/CheckExtraTests", "version" : "0.007" }, { "class" : "Dist::Zilla::Plugin::PruneCruft", "name" : "@RJBS/@Filter/PruneCruft", "version" : "4.300037" }, { "class" : "Dist::Zilla::Plugin::ManifestSkip", "name" : "@RJBS/@Filter/ManifestSkip", "version" : "4.300037" }, { "class" : "Dist::Zilla::Plugin::MetaYAML", "name" : "@RJBS/@Filter/MetaYAML", "version" : "4.300037" }, { "class" : "Dist::Zilla::Plugin::License", "name" : "@RJBS/@Filter/License", "version" : "4.300037" }, { "class" : "Dist::Zilla::Plugin::Readme", "name" : "@RJBS/@Filter/Readme", "version" : "4.300037" }, { "class" : "Dist::Zilla::Plugin::ExecDir", "name" : "@RJBS/@Filter/ExecDir", "version" : "4.300037" }, { "class" : "Dist::Zilla::Plugin::ShareDir", "name" : "@RJBS/@Filter/ShareDir", "version" : "4.300037" }, { "class" : "Dist::Zilla::Plugin::MakeMaker", "name" : "@RJBS/@Filter/MakeMaker", "version" : "4.300037" }, { "class" : "Dist::Zilla::Plugin::Manifest", "name" : "@RJBS/@Filter/Manifest", "version" : "4.300037" }, { "class" : "Dist::Zilla::Plugin::TestRelease", "name" : "@RJBS/@Filter/TestRelease", "version" : "4.300037" }, { "class" : "Dist::Zilla::Plugin::ConfirmRelease", "name" : "@RJBS/@Filter/ConfirmRelease", "version" : "4.300037" }, { "class" : "Dist::Zilla::Plugin::UploadToCPAN", "name" : "@RJBS/@Filter/UploadToCPAN", "version" : "4.300037" }, { "class" : "Dist::Zilla::Plugin::AutoPrereqs", "name" : "@RJBS/AutoPrereqs", "version" : "4.300037" }, { "class" : "Dist::Zilla::Plugin::Git::NextVersion", "name" : "@RJBS/Git::NextVersion", "version" : "2.014" }, { "class" : "Dist::Zilla::Plugin::PkgVersion", "name" : "@RJBS/PkgVersion", "version" : "4.300037" }, { "class" : "Dist::Zilla::Plugin::MetaConfig", "name" : "@RJBS/MetaConfig", "version" : "4.300037" }, { "class" : "Dist::Zilla::Plugin::MetaJSON", "name" : "@RJBS/MetaJSON", "version" : "4.300037" }, { "class" : "Dist::Zilla::Plugin::NextRelease", "name" : "@RJBS/NextRelease", "version" : "4.300037" }, { "class" : "Dist::Zilla::Plugin::Test::ChangesHasContent", "name" : "@RJBS/Test::ChangesHasContent", "version" : "0.006" }, { "class" : "Dist::Zilla::Plugin::PodSyntaxTests", "name" : "@RJBS/PodSyntaxTests", "version" : "4.300037" }, { "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.300037" }, { "class" : "Dist::Zilla::Plugin::PodWeaver", "name" : "@RJBS/PodWeaver", "version" : "3.101641" }, { "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.300037" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":IncModules", "version" : "4.300037" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":TestFiles", "version" : "4.300037" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":ExecFiles", "version" : "4.300037" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":ShareFiles", "version" : "4.300037" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":MainModule", "version" : "4.300037" } ], "zilla" : { "class" : "Dist::Zilla::Dist::Builder", "config" : { "is_trial" : "0" }, "version" : "4.300037" } } } t000755000766000766 012230773753 12632 5ustar00rjbsrjbs000000000000Config-INI-0.021reader.t100644000766000766 414112230773753 14421 0ustar00rjbsrjbs000000000000Config-INI-0.021/t#!perl use strict; use IO::File; use IO::String; use Test::More tests => 8; # Check their perl version use_ok('Config::INI::Reader'); # Try to read in a config my $hashref = Config::INI::Reader->read_file( 'examples/simple.ini' ); isa_ok($hashref, 'HASH', "return of Config::INI::Reader->read_file"); # Check the structure of the config my $expected = { '_' => { root => 'something', }, section => { one => 'two', Foo => 'Bar', this => 'Your Mother!', blank => '', moo => 'kooh', }, 'Section Two' => { 'something else' => 'blah', 'remove' => 'whitespace', }, }; is_deeply($hashref, $expected, 'Config structure matches expected'); # Add some stuff to the trivial config and check read_string() for it my $Trivial = {}; $Trivial->{_} = { root1 => 'root2' }; $Trivial->{section} = { foo => 'bar', this => 'that', blank => '', }; $Trivial->{section2} = { 'this little piggy' => 'went to market' }; my $string = <read_string( $string ); isa_ok($hashref, 'HASH', "return of Config::INI::Reader->read_string"); is_deeply( $hashref, $Trivial, '->read_string returns expected value' ); } { # Test read_handle my $fh = IO::File->new('examples/simple.ini', 'r'); my $data = do { local $/ = undef; <$fh> }; is_deeply( Config::INI::Reader->new->read_handle( IO::String->new($data) ), $expected, '->read_handle returns expected value' ); } ##################################################################### # Bugs that happened we don't want to happen again { # Reading in an empty file, or a defined but zero length string, should yield # a valid, but empty, object. my $empty = Config::INI::Reader->read_string(''); is_deeply($empty, {}, "an empty string gets an empty hashref"); } { # "0" is a valid section name my $config = Config::INI::Reader->read_string("[0]\nfoo = 1\n"); is_deeply( $config, { 0 => { foo => 1 } }, "we can use 0 as a section name", ); } writer.t100644000766000766 715512230773753 14503 0ustar00rjbsrjbs000000000000Config-INI-0.021/t#!perl use strict; use Test::More tests => 20; my $R = 'Config::INI::Reader'; my $W = 'Config::INI::Writer'; use_ok($_) for $R, $W; my $data = { _ => { a => 1, b => 2, c => 3, }, foo => { bar => 'baz', baz => 'bar', }, }; is_deeply( $R->read_string($W->write_string($data)), $data, 'we can round-trip hashy data', ); is_deeply( $R->read_string($W->new->write_string($data)), $data, 'we can round-trip hashy data, object method', ); my $starting_first = [ _ => [ a => 1, b => 2, c => 3, ], foo => [ bar => 'baz', baz => 'bar', quux => undef, ], ]; my $expected = <<'END_INI'; a = 1 b = 2 c = 3 [foo] bar = baz baz = bar END_INI is( $W->write_string($starting_first), $expected, 'stringifying AOA, _ first', ); is( $W->new->write_string($starting_first), $expected, 'stringifying AOA, _ first, object method', ); { my $expected = <<'END_INI'; [foo] bar = baz baz = bar [_] a = 1 b = 2 c = 3 [foo] fer = agin END_INI my $starting_later = [ foo => [ bar => 'baz', baz => 'bar', quux => undef, ], _ => [ a => 1, b => 2, c => 3, ], foo => [ fer => 'agin', ], ]; is( $W->write_string($starting_later), $expected, 'stringifying AOA, _ later', ); is( $W->new->write_string($starting_later), $expected, 'stringifying AOA, _ later, object method', ); } { my @possibilities = ( [ a => [ b => 1 ] ], [ a => { b => 1 } ], { a => { b => 1 } }, { a => [ b => 1 ] }, ); my $reference = $W->write_string(shift @possibilities); my $failures = 0; $failures++ unless $W->write_string(shift @possibilities) eq $reference; ok(!$failures, "all array/hash combinations seem miscible"); } eval { $W->write_string([ A => [ B => 1 ], A => [ B => 2 ] ]); }; like($@, qr/multiple/, "you can't set property B in section A more than once"); SKIP: { eval "require File::Temp;" or skip "File::Temp not availabe", 3; # This could probably be limited to being required for Cygwin. eval "require filetest;" or skip "filetest.pm not available", 3; filetest->import('access'); my ($fh, $fn) = File::Temp::tempfile('tempXXXXX', UNLINK => 1); close $fh; unlink $fn; $W->write_file($data, $fn); is_deeply( $R->read_file($fn), $data, "round-trip data->file->data", ); my $new_data = { foo => { a => 1, b => 69101 } }; $W->write_file($new_data, $fn); is_deeply( $R->read_file($fn), $new_data, "round-trip data->file->data, clobbering file", ); chmod 0444, $fn; if (-w $fn) { chmod 0666, $fh; skip "chmoding file 0444 left it -w", 1; } eval { Config::INI::Writer->write_file($data, $fn); }; like($@, qr/couldn't write/, "can't clobber an unwriteable file"); chmod 0666, $fh; } eval { $W->write_file($data); }; like($@, qr/no filename/, "you can't set write to a file without a filename"); eval { $W->write_file($data, 't'); }; like($@, qr/not a plain file/, "you can't write to a file that's -e -d"); eval { $W->write_string(sub { 1 }) }; like($@, qr/can't output CODE/, "you can't write out non-ARRAY/HASH data"); eval { $W->write_string({ "[=]" => { a => 1 } }) }; is($@, '', "a stupid section header ([=]) is allowed"); eval { $W->write_string({ "[\n]" => { a => 1 } }) }; like($@, qr/illegal/, "...but an impossible to parse one is not"); eval { $W->write_string({ "[foo ;bar]" => { a => 1 } }) }; like($@, qr/illegal/, "...we also can't emit things that would be comments"); eval { $W->write_string({ "[foo;bar]" => { a => 1 } }) }; is($@, '', "...but things -almost- like comments are okay"); Makefile.PL100644000766000766 304612230773753 14504 0ustar00rjbsrjbs000000000000Config-INI-0.021 use strict; use warnings; use ExtUtils::MakeMaker 6.30; my %WriteMakefileArgs = ( "ABSTRACT" => "simple .ini-file format", "AUTHOR" => "Ricardo Signes ", "BUILD_REQUIRES" => {}, "CONFIGURE_REQUIRES" => { "ExtUtils::MakeMaker" => "6.30" }, "DISTNAME" => "Config-INI", "EXE_FILES" => [], "LICENSE" => "perl", "NAME" => "Config::INI", "PREREQ_PM" => { "Carp" => 0, "IO::File" => "1.14", "IO::String" => 0, "Mixin::Linewise::Readers" => 0, "Mixin::Linewise::Writers" => 0, "strict" => 0, "warnings" => 0 }, "TEST_REQUIRES" => { "Capture::Tiny" => 0, "Test::More" => "0.96", "blib" => 0 }, "VERSION" => "0.021", "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); reader-err.t100644000766000766 317212230773753 15212 0ustar00rjbsrjbs000000000000Config-INI-0.021/t#!perl use strict; use Config::INI::Reader; use Test::More tests => 7; eval { Config::INI::Reader->read_file; }; like($@, qr/no filename specified/i, 'read_file without args'); { my $filename = q{t/does/not/exist}; Carp::croak "unexpected file found in test directory t" if -e 't/does/not/exist'; eval { Config::INI::Reader->read_file($filename); }; like( $@, qr/file '$filename' does not exist/i, 'read_file with non-existent file' ); } { my $filename = 'lib'; eval { Config::INI::Reader->read_file($filename); }; like($@, qr/not a plain file/i, 'read_file on non-plain-file'); } SKIP: { eval "require File::Temp;" or skip "File::Temp not available", 1; # This could probably be limited to being required for Cygwin. eval "require filetest;" or skip "filetest.pm not available", 1; filetest->import('access'); my ($fh, $fn) = File::Temp::tempfile('tempXXXXX', UNLINK => 1); close $fh; chmod 0222, $fn; if (-r $fn) { chmod 0666, $fh; skip "chmoding file 0222 left it -r", 1; } eval { Config::INI::Reader->read_file($fn); }; like($@, qr/(?:couldn't|can't) read/, "can't read an unreadable file"); chmod 0666, $fh; } eval { Config::INI::Reader->read_string; }; like($@, qr/no string provided/i, 'read_string without args'); { my $input = 'foo bar moo'; eval { Config::INI::Reader->read_string($input); }; like($@, qr/Syntax error at line 1: '$input'/i, 'syntax error'); } { # looks like a comment my $input = "[foo ; bar]\nvalue = 1\n"; my $data = eval { Config::INI::Reader->read_string($input); }; like($@, qr/Syntax error at line 1:/i, 'syntax error'); } 00-compile.t100644000766000766 117612230773753 15031 0ustar00rjbsrjbs000000000000Config-INI-0.021/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/INI.pm Config/INI/Reader.pm Config/INI/Writer.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; Config000755000766000766 012230773753 14342 5ustar00rjbsrjbs000000000000Config-INI-0.021/libINI.pm100644000766000766 623112230773753 15461 0ustar00rjbsrjbs000000000000Config-INI-0.021/lib/Configuse strict; use warnings; package Config::INI; { $Config::INI::VERSION = '0.021'; } # ABSTRACT: simple .ini-file format 1; __END__ =pod =head1 NAME Config::INI - simple .ini-file format =head1 VERSION version 0.021 =head1 SYNOPSIS Config-INI comes with code for reading F<.ini> files: my $config_hash = Config::INI::Reader->read_file('config.ini'); ...and for writing C<.ini> files: Config::INI::Writer->write_file({ somekey => 'somevalue' }, 'config.ini'); See L and L for more examples. =head1 GRAMMAR This section describes the format parsed and produced by Config::INI::Reader and ::Writer. It is not an exhaustive and rigorously tested formal grammar, it's just a description of this particular implementation of the not-quite-standardized "INI" format. ini-file = {
| } empty-line = [ ] section = { | } section-header = [ ] "[" "]" [ ] section-name = string value-assignment = [ ] [ ] "=" [ ] [ ] property-name = string-without-equals value = string comment = ";" [ ] line-ending = [ ] space = ( | " " ) * string-without-equals = string - "=" string = ? 1+ characters; not ";" or EOL; begins and ends with non-space ? Of special note is the fact that I escaping mechanism is defined, meaning that there is no way to include an EOL or semicolon (for example) in a value, property name, or section name. If you need this, either subclass, wait for a subclass to be written for you, or find one of the many other INI-style parsers on the CPAN. The order of sections and value assignments within a section are not significant, except that given multiple assignments to one property name within a section, only the final one is used. A section name may be used more than once; this will have the identical meaning as having all property assignments in all sections of that name in sequence. =head1 DON'T FORGET The definitions above refer to the format used by the Reader and Writer classes bundled in the Config-INI distribution. These classes are designed for easy subclassing, so it should be easy to replace their behavior with whatever behavior your want. Patches, feature requests, and bug reports are welcome -- but I'm more interested in making sure you can write a subclass that does what you need, and less in making Config-INI do what you want directly. =head1 THANKS Thanks to Florian Ragwitz for improving the subclassability of Config-INI's modules, and for helping me do some of my first merging with git(7). =head1 ORIGIN Originaly derived from L, by Adam Kennedy. =head1 AUTHOR Ricardo Signes =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2007 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 examples000755000766000766 012230773753 14205 5ustar00rjbsrjbs000000000000Config-INI-0.021simple.ini100644000766000766 22312230773753 16314 0ustar00rjbsrjbs000000000000Config-INI-0.021/examplesroot=something [section] one=two Foo=Bar this=Your Mother! blank= [section] moo=kooh [Section Two] something else=blah remove = whitespace release000755000766000766 012230773753 14442 5ustar00rjbsrjbs000000000000Config-INI-0.021/xtpod-syntax.t100644000766000766 21212230773753 17050 0ustar00rjbsrjbs000000000000Config-INI-0.021/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(); INI000755000766000766 012230773753 14761 5ustar00rjbsrjbs000000000000Config-INI-0.021/lib/ConfigReader.pm100644000766000766 1654212230773753 16711 0ustar00rjbsrjbs000000000000Config-INI-0.021/lib/Config/INIuse strict; use warnings; package Config::INI::Reader; { $Config::INI::Reader::VERSION = '0.021'; } use Mixin::Linewise::Readers; # ABSTRACT: a subclassable .ini-file parser use Carp (); use IO::File 1.14; use IO::String; our @CARP_NOT = qw(Mixin::Linewise::Readers); sub read_handle { my ($invocant, $handle) = @_; my $self = ref $invocant ? $invocant : $invocant->new; # parse the file LINE: while (my $line = $handle->getline) { if ($handle->input_line_number == 1 && $line =~ /\A\x{FEFF}/) { Carp::confess("input handle appears to start with a BOM"); } next LINE if $self->can_ignore($line); $self->preprocess_line(\$line); # Handle section headers if (defined (my $name = $self->parse_section_header($line))) { # Create the sub-hash if it doesn't exist. # Without this sections without keys will not # appear at all in the completed struct. $self->change_section($name); next LINE; } if (my ($name, $value) = $self->parse_value_assignment($line)) { $self->set_value($name, $value); next LINE; } $self->handle_unparsed_line($handle, $line); } $self->finalize; return $self->{data}; } sub current_section { defined $_[0]->{section} ? $_[0]->{section} : $_[0]->starting_section; } sub parse_section_header { return $1 if $_[1] =~ /^\s*\[\s*(.+?)\s*\]\s*$/; return; } sub change_section { my ($self, $section) = @_; $self->{section} = $section; if (!exists $self->{data}{$section}) { $self->{data}{$section} = {}; } } sub parse_value_assignment { return ($1, $2) if $_[1] =~ /^\s*([^=\s][^=]*?)\s*=\s*(.*?)\s*$/; return; } sub set_value { my ($self, $name, $value) = @_; $self->{data}{ $self->current_section }{$name} = $value; } sub starting_section { q{_} } sub can_ignore { my ($self, $line) = @_; # Skip comments and empty lines return $line =~ /\A\s*(?:;|$)/ ? 1 : 0; } sub preprocess_line { my ($self, $line) = @_; # Remove inline comments ${$line} =~ s/\s+;.*$//g; } sub handle_unparsed_line { my ($self, $handle, $line) = @_; my $lineno = $handle->input_line_number; Carp::croak "Syntax error at line $lineno: '$line'"; } sub finalize { } sub new { my ($class) = @_; my $self = { data => {}, }; bless $self => $class; } 1; __END__ =pod =head1 NAME Config::INI::Reader - a subclassable .ini-file parser =head1 VERSION version 0.021 =head1 SYNOPSIS If F contains: admin = rjbs [rjbs] awesome = yes height = 5' 10" [mj] awesome = totally height = 23" Then when your program contains: my $hash = Config::INI::Reader->read_file('family.ini'); C<$hash> will contain: { '_' => { admin => 'rjbs' }, rjbs => { awesome => 'yes', height => q{5' 10"}, }, mj => { awesome => 'totally', height => '23"', }, } =head1 DESCRIPTION Config::INI::Reader is I config module implementing I slightly different take on the undeniably easy to read L<".ini" file format|Config::INI>. Its default behavior is quite similar to that of L, on which it is based. The chief difference is that Config::INI::Reader is designed to be subclassed to allow for side-effects and self-reconfiguration to occur during the course of reading its input. =head1 METHODS FOR READING CONFIG These methods are all that most users will need: they read configuration from a source of input, then they return the data extracted from that input. There are three reader methods, C, C, and C. The first two are implemented in terms of the third. It iterates over lines in a file, calling methods on the reader when events occur. Those events are detailed below in the L section. All of the reader methods return an unblessed reference to a hash. All throw an exception when they encounter an error. =head2 read_file my $hash_ref = Config::INI::Reader->read_file($filename); Given a filename, this method returns a hashref of the contents of that file. =head2 read_string my $hash_ref = Config::INI::Reader->read_string($string); Given a string, this method returns a hashref of the contents of that string. =head2 read_handle my $hash_ref = Config::INI::Reader->read_handle($io_handle); Given an IO::Handle, this method returns a hashref of the contents of that handle. =head1 METHODS FOR SUBCLASSING These are the methods you need to understand and possibly change when subclassing Config::INI::Reader to handle a different format of input. =head2 current_section my $section_name = $reader->current_section; This method returns the name of the current section. If no section has yet been set, it returns the result of calling the C method. =head2 parse_section_header my $name = $reader->parse_section_header($line); Given a line of input, this method decides whether the line is a section-change declaration. If it is, it returns the name of the section to which to change. If the line is not a section-change, the method returns false. =head2 change_section $reader->change_section($section_name); This method is called whenever a section change occurs in the file. The default implementation is to change the current section into which data is being read and to initialize that section to an empty hashref. =head2 parse_value_assignment my ($name, $value) = $reader->parse_value_assignment($line); Given a line of input, this method decides whether the line is a property value assignment. If it is, it returns the name of the property and the value being assigned to it. If the line is not a property assignment, the method returns false. =head2 set_value $reader->set_value($name, $value); This method is called whenever an assignment occurs in the file. The default behavior is to change the value of the named property to the given value. =head2 starting_section my $section = Config::INI::Reader->starting_section; This method returns the name of the starting section. The default is: C<_> =head2 can_ignore do_nothing if $reader->can_ignore($line) This method returns true if the given line of input is safe to ignore. The default implementation ignores lines that contain only whitespace or comments. =head2 preprocess_line $reader->preprocess_line(\$line); This method is called to preprocess each line after it's read but before it's parsed. The default implementation just strips inline comments. Alterations to the line are made in place. =head2 handle_unparsed_line $reader->handle_unparsed_line( $io, $line ); This method is called when the reader encounters a line that doesn't look like anything it recognizes. By default, it throws an exception. =head2 finalize $reader->finalize; This method is called when the reader has finished reading in every line of the file. =head2 new my $reader = Config::INI::Reader->new; This method returns a new reader. This generally does not need to be called by anything but the various C methods, which create a reader object only ephemerally. =head1 ORIGIN Originaly derived from L, by Adam Kennedy. =head1 AUTHOR Ricardo Signes =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2007 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 Writer.pm100644000766000766 2650512230773753 16763 0ustar00rjbsrjbs000000000000Config-INI-0.021/lib/Config/INIuse strict; use warnings; package Config::INI::Writer; { $Config::INI::Writer::VERSION = '0.021'; } use Mixin::Linewise::Writers; # ABSTRACT: a subclassable .ini-file emitter use Carp (); our @CARP_NOT = qw(Mixin::Linewise::Writers); sub write_handle { my ($invocant, $input, $handle) = @_; my $self = ref $invocant ? $invocant : $invocant->new; $input = $self->preprocess_input($input); $self->validate_input($input); my $starting_section_name = $self->starting_section; SECTION: for (my $i = 0; $i < $#$input; $i += 2) { my ($section_name, $section_data) = @$input[ $i, $i + 1 ]; $self->change_section($section_name); $handle->print($self->stringify_section($section_data)) or Carp::croak "error writing section $section_name: $!"; $self->finish_section; } } sub preprocess_input { my ($self, $data) = @_; my @new_data; if (ref $data eq 'HASH') { my $starting_section_name = $self->starting_section; for my $name ( $starting_section_name, grep { $_ ne $starting_section_name } keys %$data ) { my $props = $data->{ $name }; next unless defined $props; push @new_data, $name => ((ref($props) || '') eq 'HASH') ? [ %$props ] : $props; } } elsif (ref $data eq 'ARRAY') { for (my $i = 0; $i < $#$data; $i += 2) { my ($name, $props) = @$data[ $i, $i + 1 ]; push @new_data, $name, (ref $props eq 'HASH') ? [ %$props ] : $props; } } else { my $class = ref $self; Carp::croak "can't output $data via $class"; } return \@new_data; } sub validate_input { my ($self, $input) = @_; my %seen; for (my $i = 0; $i < $#$input; $i += 2) { my ($name, $props) = @$input[ $i, $i + 1 ]; $seen{ $name } ||= {}; Carp::croak "illegal section name '$name'" if $name =~ /(?:\n|\s;|^\s|\s$)/; for (my $j = 0; $j < $#$props; $j += 2) { my $property = $props->[ $j ]; my $value = $props->[ $j + 1 ]; Carp::croak "property name '$property' contains illegal character" if $property =~ /(?:\n|\s;|^\s|\s|=$)/; Carp::croak "value for $name.$property contains illegal character" if defined $value and $value =~ /(?:\n|\s;|^\s|\s$)/; if ( $seen{ $name }{ $property }++ ) { Carp::croak "multiple assignments found for $name.$property"; } } } } sub change_section { my ($self, $section_name) = @_; $self->{current_section} = $section_name; } sub current_section { my ($self) = @_; return $self->{current_section}; } sub finish_section { my ($self) = @_; return $self->{did_section}{ $self->current_section }++; } sub done_sections { my ($self) = @_; return keys %{ $self->{did_section} }; } sub stringify_section { my ($self, $section_data) = @_; my $output = ''; my $current_section_name = $self->current_section; my $starting_section_name = $self->starting_section; unless ( $starting_section_name and $starting_section_name eq $current_section_name and ! $self->done_sections and ! $self->explicit_starting_header ) { $output .= $self->stringify_section_header($self->current_section); } $output .= $self->stringify_section_data($section_data); return $output; } sub stringify_section_data { my ($self, $values) = @_; my $output = ''; for (my $i = 0; $i < $#$values; $i += 2) { $output .= $self->stringify_value_assignment(@$values[ $i, $i + 1]); } return $output; } sub stringify_value_assignment { my ($self, $name, $value) = @_; return '' unless defined $value; return $name . ' = ' . $self->stringify_value($value) . "\n"; } sub stringify_value { my ($self, $value) = @_; $value = defined $value ? $value : ''; return $value; } sub stringify_section_header { my ($self, $section_name) = @_; my $output = ''; $output .= "\n" if $self->done_sections; $output .= "[$section_name]\n"; return $output; } sub starting_section { return '_' } sub explicit_starting_header { 0 } sub new { my ($class) = @_; my $self = bless { did_section => {} } => $class; return $self; } 1; __END__ =pod =head1 NAME Config::INI::Writer - a subclassable .ini-file emitter =head1 VERSION version 0.021 =head1 SYNOPSIS If <$hash> contains: { '_' => { admin => 'rjbs' }, rjbs => { awesome => 'yes', height => q{5' 10"}, }, mj => { awesome => 'totally', height => '23"', }, } Then when your program contains: Config::INI::Writer->write_file($hash, 'family.ini'); F will contains: admin = rjbs [rjbs] awesome = yes height = 5' 10" [mj] awesome = totally height = 23" =head1 DESCRIPTION Config::INI::Writer is I config module implementing I slightly different take on the undeniably easy to read L<".ini" file format|Config::INI>. Its default behavior is quite similar to that of L, on which it is based. The chief difference is that Config::INI::Writer is designed to be subclassed to allow for side-effects and self-reconfiguration to occur during the course of reading its input. =head1 METHODS FOR WRITING CONFIG There are three writer methods, C, C, and C. The first two are implemented in terms of the third. It iterates over a collection of data, emitting lines to the filehandle as it goes. The lines are generated by events produced by iterating over the data. Those events are detailed below in the L section. The given data should be a hashref of hashrefs: { section_name_1 => { prop1 => 'value1', prop2 => 'value2' }, section_name_2 => ... } ...or an arrayref of section name and arrayref pairs: [ section_name_1 => [ prop1 => 'value1', prop2 => 'value2' ], section_name_2 => ... ] ...or a combination of those: [ section_name_1 => { prop1 => 'value1', prop2 => 'value2' }, section_name_2 => [ prop3 => 'value3', prop4 => 'value4' ], section_name_3 => ... ] All the reader methods throw an exception when they encounter an error. =head2 write_file Config::INI::Writer->write_file($input, $filename); This method writes out the configuration represented by C<$data> to the file named by C<$filename>. If a file by that name exists, it is overwritten. This method will either succeed or raise an exception. (Its return value is not defined.) =head2 write_string my $string = Config::INI::Writer->write_string($input); This method returns a string containing the INI content describing the given data. =head2 write_handle Config::INI::Writer->write_handle($input, $handle); This method writes the data in C<$data> to the IO::Handle-like object in C<$handle>. This method should either succeed or throw an exception. =head1 METHODS FOR SUBCLASSING These are the methods you need to understand and possibly change when subclassing Config::INI::Reader to handle a different format of input. =head2 preprocess_input my $processed_input = $writer->preprocess_input($input_data); This method is called to ensure that the data given to the C methods are in a canonical form for processing and emitting. The default implementation converts hashrefs to arrayrefs and, if the input is a hashref, moves the L to the beginning of the produced arrayref. In other words, given: { section_1 => { a => 1, b => 2 }, section_2 => { c => 3, c => 4 }, _ => { d => 5, e => 6 }, } This method will return: [ _ => [ d => 5, e => 6 ], section_2 => [ c => 3, c => 4 ], section_1 => [ a => 1, b => 2 ], ] The only guaranteed ordering when hashes are provided as input is that the starting section will appear first. =head2 validate_input $writer->validate_input($input); This method is called on the input data once they've been preprocessed by C>. It ensures that the processed input is structurally sound before beginning to output it. For example, it ensures that no property is ever assigned more than once in a given section. This method either raises an exception or it doesn't. =head2 change_section $writer->change_section($section_name); This method is called each time a new section is going to be written out. If the same section appears twice in a row in the input, this method will still be called between instances of that section. In other words, given this input: [ section_1 => [ a => 1 ], section_1 => [ b => 2 ], ] C will be called twice: once before the first C and once before the second C. =head2 current_section $writer->current_section This method returns the section currently being written out. =head2 finish_section $writer->finish_section This method is called after all of the current section's properties have been written. =head2 done_sections my @names = $writer->done_sections; This method returns a list of all sections that have been written out and finished. The fact that a section name is returned by C does not mean that there will be no more data for that section, but that at least one entire set of data has been written out for it. =head2 stringify_section my $string = $writer->stringify_section($props); This method returns a string assigning all the properties set in the given data. This still will include the section header, if needed. (The only case in which it is not needed is when the C> method returns false, no other sections have been done, and the section about to be stringified is the C>. This method is implemented in terms of C> and C>. =head2 stringify_section_data my $string = $writer->stringify_section_data($props) This method returns a string containing a series of lines, each containing a value assignment for the given properties. =head2 stringify_value_assignment my $string = $writer->stringify_value_assignment($name => $value); This method returns a string that assigns a value to a named property. If the value is undefined, an empty string is returned. =head2 stringify_value my $string = $writer->stringify_value($value); This method returns the string that will represent the given value in a property assignment. =head2 stringify_section_header my $string = $writer->stringify_section_header($section_name); This method returns the string (a line) that represents the given section name. Basically, this returns: [section_name] =head2 starting_section This method returns the name of the starting section. If this section appears first (as it will, when given a hashref as input) and if C> returns false, its section header can be omitted. =head2 explicit_starting_header If this method returns true (which it does I, by default), then the section header for the starting section will be emitted, even if it appears first. =head2 new my $reader = Config::INI::Writer->new; This method returns a new writer. This generally does not need to be called by anything but the various C methods, which create a writer object only ephemerally. =head1 AUTHOR Ricardo Signes =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2007 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 472012230773753 17621 0ustar00rjbsrjbs000000000000Config-INI-0.021/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('Carp','any version') }; eval { $v .= pmver('ExtUtils::MakeMaker','6.30') }; eval { $v .= pmver('IO::File','1.14') }; eval { $v .= pmver('IO::String','any version') }; eval { $v .= pmver('Mixin::Linewise::Readers','any version') }; eval { $v .= pmver('Mixin::Linewise::Writers','any version') }; eval { $v .= pmver('Test::More','0.96') }; eval { $v .= pmver('Test::Pod','1.41') }; eval { $v .= pmver('blib','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; changes_has_content.t100644000766000766 201112230773753 20756 0ustar00rjbsrjbs000000000000Config-INI-0.021/xt/release#!perl use Test::More tests => 2; note 'Checking Changes'; my $changes_file = 'Changes'; my $newver = '0.021'; 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; }