CPAN-Meta-YAML-0.020/000770 000766 000024 00000000000 14730103447 014133 5ustar00etherstaff000000 000000 CPAN-Meta-YAML-0.020/LICENSE000644 000766 000024 00000046427 14730103447 015160 0ustar00etherstaff000000 000000 This software is copyright (c) 2010 by Adam Kennedy. 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) 2010 by Adam Kennedy. This is free software, licensed under: The GNU General Public License, Version 1, February 1989 GNU GENERAL PUBLIC LICENSE Version 1, February 1989 Copyright (C) 1989 Free Software Foundation, Inc. 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The license agreements of most software companies try to keep users at the mercy of those companies. By contrast, our General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. The General Public License applies to the Free Software Foundation's software and to any other program whose authors commit to using it. You can use it for your programs, too. When we speak of free software, we are referring to freedom, not price. Specifically, the General Public License is designed to make sure that you have the freedom to give away or sell copies of free software, that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of a such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must tell them their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any work containing the Program or a portion of it, either verbatim or with modifications. Each licensee is addressed as "you". 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this General Public License and to the absence of any warranty; and give any other recipients of the Program a copy of this General Public License along with the Program. You may charge a fee for the physical act of transferring a copy. 2. You may modify your copy or copies of the Program or any portion of it, and copy and distribute such modifications under the terms of Paragraph 1 above, provided that you also do the following: a) cause the modified files to carry prominent notices stating that you changed the files and the date of any change; and b) cause the whole of any work that you distribute or publish, that in whole or in part contains the Program or any part thereof, either with or without modifications, to be licensed at no charge to all third parties under the terms of this General Public License (except that you may choose to grant warranty protection to some or all third parties, at your option). c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the simplest and most usual way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this General Public License. d) You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. Mere aggregation of another independent work with the Program (or its derivative) on a volume of a storage or distribution medium does not bring the other work under the scope of these terms. 3. You may copy and distribute the Program (or a portion or derivative of it, under Paragraph 2) in object code or executable form under the terms of Paragraphs 1 and 2 above provided that you also do one of the following: a) accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Paragraphs 1 and 2 above; or, b) accompany it with a written offer, valid for at least three years, to give any third party free (except for a nominal charge for the cost of distribution) a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Paragraphs 1 and 2 above; or, c) accompany it with the information you received as to where the corresponding source code may be obtained. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form alone.) Source code for a work means the preferred form of the work for making modifications to it. For an executable file, complete source code means all the source code for all modules it contains; but, as a special exception, it need not include source code for modules which are standard libraries that accompany the operating system on which the executable file runs, or for standard header files or definitions files that accompany that operating system. 4. You may not copy, modify, sublicense, distribute or transfer the Program except as expressly provided under this General Public License. Any attempt otherwise to copy, modify, sublicense, distribute or transfer the Program is void, and will automatically terminate your rights to use the Program under this License. However, parties who have received copies, or rights to use copies, from you under this General Public License will not have their licenses terminated so long as such parties remain in full compliance. 5. By copying, distributing or modifying the Program (or any work based on the Program) you indicate your acceptance of this license to do so, and all its terms and conditions. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. 7. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of the license which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the license, you may choose any version ever published by the Free Software Foundation. 8. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to humanity, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19xx name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (a program to direct compilers to make passes at assemblers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice That's all there is to it! --- The Perl Artistic License 1.0 --- This software is Copyright (c) 2010 by Adam Kennedy. This is free software, licensed under: The Perl 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 as specified below. "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 uunet.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) give non-standard executables non-standard names, and clearly document 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. You may embed this Package's interpreter within an executable of yours (by linking); this shall be construed as a mere form of aggregation, provided that the complete Standard Version of the interpreter is so embedded. 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 whoever generated them, and may be sold commercially, and may be aggregated with this Package. If such scripts or library files are aggregated with this Package via the so-called "undump" or "unexec" methods of producing a binary executable image, then distribution of such an image shall neither be construed as a distribution of this Package nor shall it fall under the restrictions of Paragraphs 3 and 4, provided that you do not represent such an executable image as a Standard Version of this Package. 7. C subroutines (or comparably compiled subroutines in other languages) supplied by you and linked into this Package in order to emulate subroutines and variables of the language defined by this Package shall not be considered part of this Package, but are the equivalent of input as in Paragraph 6, provided these subroutines do not change the language in any way that would cause it to fail the regression tests for the language. 8. Aggregation of this Package with a commercial distribution is always permitted provided that the use of this Package is embedded; that is, when no overt attempt is made to make this Package's interfaces visible to the end user of the commercial distribution. Such use shall not be construed as a distribution of this Package. 9. The name of the Copyright Holder may not be used to endorse or promote products derived from this software without specific prior written permission. 10. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. The End CPAN-Meta-YAML-0.020/Changes000640 000766 000024 00000005734 14730103447 015436 0ustar00etherstaff000000 000000 Revision history for CPAN-Meta-YAML 0.020 2024-12-16 20:01:37Z - Generated from ETHER/YAML-Tiny-1.76.tar.gz - See https://metacpan.org/changes/release/ETHER/YAML-Tiny-1.76 for details 0.019 2024-12-15 22:48:25Z - Generated from ETHER/YAML-Tiny-1.75.tar.gz - See https://metacpan.org/changes/release/ETHER/YAML-Tiny-1.75 for details 0.018 2015-12-11 11:55:44-05:00 America/New_York - Generated from ETHER/YAML-Tiny-1.69.tar.gz - See https://metacpan.org/changes/release/ETHER/YAML-Tiny-1.69 for details 0.017 2015-08-04 06:02:12-04:00 America/New_York (TRIAL RELEASE) - Generated from ETHER/YAML-Tiny-1.69.tar.gz 0.016 2015-05-19 05:34:02-04:00 America/New_York - Generated from ETHER/YAML-Tiny-1.67.tar.gz 0.015 2015-05-11 22:01:58-04:00 America/New_York (TRIAL RELEASE) - Generated from ETHER/YAML-Tiny-1.67.tar.gz 0.014 2015-03-16 19:22:12-04:00 America/New_York - Generated from ETHER/YAML-Tiny-1.66.tar.gz 0.013 2015-03-16 11:32:04-04:00 America/New_York - Generated from ETHER/YAML-Tiny-1.65.tar.gz 0.012 2014-02-24 13:07:18-05:00 America/New_York - Generated from ETHER/YAML-Tiny-1.61.tar.gz 0.011 2014-02-13 20:30:30-05:00 America/New_York - Generated from ETHER/YAML-Tiny-1.60.tar.gz 0.010 2013-09-23 13:11:20 America/New_York - Generated from ETHER/YAML-Tiny-1.55.tar.gz - Fix broken test when copying from YAML-Tiny - updated Makefile.PL logic to support PERL_NO_HIGHLANDER 0.009 2013-09-23 10:16:19 America/New_York - Generated from ETHER/YAML-Tiny-1.55.tar.gz - Makefile.PL will use UNINST=1 on old perls that might have an old version incorrectly installed into the core library path 0.008 2012-03-14 17:13:24 EST5EDT - Generated from ADAMK/YAML-Tiny-1.51.tar.gz - Updated from YAML-Tiny to fix compatibility with older Scalar::Utils 0.007 2012-02-07 22:42:42 EST5EDT - Generated from ADAMK/YAML-Tiny-1.50.tar.gz - Documentation fix to replace missing abstract 0.006 2012-02-06 20:51:47 EST5EDT - Generated from ADAMK/YAML-Tiny-1.50.tar.gz - Set back configure_requires prerequisite for ExtUtils::MakeMaker from 6.30 to 6.17 (per request from Andreas Koenig) 0.005 2011-12-13 12:57:24 EST5EDT - Generated from ADAMK/YAML-Tiny-1.50.tar.gz - Fix documentation to clarify that users are responsible for UTF-8 encoding/decoding 0.004 2011-09-06 09:42:52 America/New_York - Generated from ADAMK/YAML-Tiny-1.50.tar.gz 0.003 2011-01-02 17:32:05 EST5EDT - Generated from ADAMK/YAML-Tiny-1.46.tar.gz - Updated SEE ALSO documentation at Ingy's request - Remove CompileTests plugin from dist.ini 0.002 2010-12-17 12:31:12 EST5EDT - Generated from ADAMK/YAML-Tiny-1.46.tar.gz - Removed source $VERSION and replaced with our own - Added a SYNOPSIS to the generated Pod - Omits the dist.ini from the distribution 0.001 2010-12-17 08:53:42 EST5EDT - Generated from ADAMK/YAML-Tiny-1.46.tar.gz # vim: ts=2 sts=2 sw=2 et: CPAN-Meta-YAML-0.020/MANIFEST000644 000766 000024 00000003201 14730103447 015263 0ustar00etherstaff000000 000000 # This file was automatically generated by Dist::Zilla::Plugin::Manifest v6.032. Changes LICENSE MANIFEST META.json META.yml Makefile.PL README dist.ini lib/CPAN/Meta/YAML.pm t/00-report-prereqs.dd t/00-report-prereqs.t t/01_api.t t/01_compile.t t/10_read.t t/11_read_string.t t/12_write.t t/13_write_string.t t/20_subclass.t t/21_yamlpm_compat.t t/30_yaml_spec_tml.t t/31_local_tml.t t/32_world_tml.t t/86_fail.t t/README.md t/data/ascii.yml t/data/latin1.yml t/data/multibyte.yml t/data/utf_16_le_bom.yml t/data/utf_8_bom.yml t/lib/SubtestCompat.pm t/lib/TestBridge.pm t/lib/TestML/Tiny.pm t/lib/TestUtils.pm t/tml t/tml-local/dump-error/circular.tml t/tml-local/load-error/document.tml t/tml-local/load-error/scalar.tml t/tml-local/load-error/tag.tml t/tml-local/load-warning/document.tml t/tml-local/perl-to-yaml/quoting.tml t/tml-local/yaml-roundtrip/collection.tml t/tml-local/yaml-roundtrip/comment.tml t/tml-local/yaml-roundtrip/document.tml t/tml-local/yaml-roundtrip/mapping.tml t/tml-local/yaml-roundtrip/quoting.tml t/tml-local/yaml-roundtrip/scalar.tml t/tml-local/yaml-roundtrip/sequence.tml t/tml-spec/basic-data.tml t/tml-spec/multiline.tml t/tml-spec/unicode.tml t/tml-world/Acme-Time-Baby.tml t/tml-world/Data-Swap.tml t/tml-world/Games-Nintendo-Wii-Mii.tml t/tml-world/HTML-WebDAO.tml t/tml-world/ITS-SIN-FIDS-Content-XML.tml t/tml-world/Plagger.tml t/tml-world/Spreadsheet-Read.tml t/tml-world/Template-Provider-Unicode-Japanese.tml t/tml-world/Vanilla-Perl.tml t/tml-world/YAML-Tiny-META.tml t/tml-world/toolbar.tml t/tml-world/yaml_org.tml weaver.ini xt/author/00-compile.t xt/author/distmeta.t xt/author/pod-syntax.t xt/author/test-version.t CPAN-Meta-YAML-0.020/t/000770 000766 000024 00000000000 14730103447 014376 5ustar00etherstaff000000 000000 CPAN-Meta-YAML-0.020/xt/000770 000766 000024 00000000000 14730103447 014566 5ustar00etherstaff000000 000000 CPAN-Meta-YAML-0.020/README000644 000766 000024 00000003325 14730103447 015021 0ustar00etherstaff000000 000000 NAME CPAN::Meta::YAML - Read and write a subset of YAML for CPAN Meta files VERSION version 0.020 SYNOPSIS use CPAN::Meta::YAML; # reading a META file open $fh, "<:utf8", "META.yml"; $yaml_text = do { local $/; <$fh> }; $yaml = CPAN::Meta::YAML->read_string($yaml_text) or die CPAN::Meta::YAML->errstr; # finding the metadata $meta = $yaml->[0]; # writing a META file $yaml_text = $yaml->write_string or die CPAN::Meta::YAML->errstr; open $fh, ">:utf8", "META.yml"; print $fh $yaml_text; DESCRIPTION This module implements a subset of the YAML specification for use in reading and writing CPAN metadata files like META.yml and MYMETA.yml. It should not be used for any other general YAML parsing or generation task. NOTE: META.yml (and MYMETA.yml) files should be UTF-8 encoded. Users are responsible for proper encoding and decoding. In particular, the "read" and "write" methods do not support UTF-8 and should not be used. SUPPORT This module is currently derived from YAML::Tiny by Adam Kennedy. If there are bugs in how it parses a particular META.yml file, please file a bug report in the YAML::Tiny bugtracker: SEE ALSO YAML::Tiny, YAML, YAML::XS AUTHORS * Adam Kennedy * David Golden CONTRIBUTOR Karen Etheridge COPYRIGHT AND LICENSE This software is copyright (c) 2010 by Adam Kennedy. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. CPAN-Meta-YAML-0.020/META.yml000644 000766 000024 00000002714 14730103447 015413 0ustar00etherstaff000000 000000 --- abstract: 'Read and write a subset of YAML for CPAN Meta files' author: - 'Adam Kennedy ' - 'David Golden ' build_requires: ExtUtils::MakeMaker: '0' File::Basename: '0' File::Find: '0' File::Spec: '0' File::Spec::Functions: '0' File::Temp: '0.19' IO::Dir: '0' JSON::PP: '0' Test::More: '0.88' base: '0' lib: '0' open: '0' perl: '5.008001' utf8: '0' vars: '0' configure_requires: ExtUtils::MakeMaker: '6.17' perl: '5.008001' dynamic_config: 0 generated_by: 'Dist::Zilla version 6.032, CPAN::Meta::Converter version 2.150010' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: CPAN-Meta-YAML no_index: directory: - corpus - examples - t - xt package: - DB provides: CPAN::Meta::YAML: file: lib/CPAN/Meta/YAML.pm version: '0.020' requires: B: '0' Carp: '0' Exporter: '0' Fcntl: '0' Scalar::Util: '0' perl: '5.008001' strict: '0' warnings: '0' resources: bugtracker: https://github.com/Perl-Toolchain-Gang/YAML-Tiny/issues homepage: https://github.com/Perl-Toolchain-Gang/CPAN-Meta-YAML repository: https://github.com/Perl-Toolchain-Gang/CPAN-Meta-YAML.git version: '0.020' x_authority: cpan:DAGOLDEN x_contributors: - 'Karen Etheridge ' x_generated_by_perl: v5.41.6 x_serialization_backend: 'YAML::Tiny version 1.76' x_spdx_expression: 'Artistic-1.0-Perl OR GPL-1.0-or-later' CPAN-Meta-YAML-0.020/lib/000770 000766 000024 00000000000 14730103447 014701 5ustar00etherstaff000000 000000 CPAN-Meta-YAML-0.020/Makefile.PL000644 000766 000024 00000004157 14730103447 016117 0ustar00etherstaff000000 000000 # This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v6.032. use strict; use warnings; use 5.008001; use ExtUtils::MakeMaker 6.17; my %WriteMakefileArgs = ( "ABSTRACT" => "Read and write a subset of YAML for CPAN Meta files", "AUTHOR" => "Adam Kennedy , David Golden ", "CONFIGURE_REQUIRES" => { "ExtUtils::MakeMaker" => "6.17" }, "DISTNAME" => "CPAN-Meta-YAML", "LICENSE" => "perl", "MIN_PERL_VERSION" => "5.008001", "NAME" => "CPAN::Meta::YAML", "PREREQ_PM" => { "B" => 0, "Carp" => 0, "Exporter" => 0, "Fcntl" => 0, "Scalar::Util" => 0, "strict" => 0, "warnings" => 0 }, "TEST_REQUIRES" => { "ExtUtils::MakeMaker" => 0, "File::Basename" => 0, "File::Find" => 0, "File::Spec" => 0, "File::Spec::Functions" => 0, "File::Temp" => "0.19", "IO::Dir" => 0, "JSON::PP" => 0, "Test::More" => "0.88", "base" => 0, "lib" => 0, "open" => 0, "utf8" => 0, "vars" => 0 }, "VERSION" => "0.020", "test" => { "TESTS" => "t/*.t" } ); my %FallbackPrereqs = ( "B" => 0, "Carp" => 0, "Exporter" => 0, "ExtUtils::MakeMaker" => 0, "Fcntl" => 0, "File::Basename" => 0, "File::Find" => 0, "File::Spec" => 0, "File::Spec::Functions" => 0, "File::Temp" => "0.19", "IO::Dir" => 0, "JSON::PP" => 0, "Scalar::Util" => 0, "Test::More" => "0.88", "base" => 0, "lib" => 0, "open" => 0, "strict" => 0, "utf8" => 0, "vars" => 0, "warnings" => 0 ); unless ( eval { ExtUtils::MakeMaker->VERSION(6.63_03) } ) { delete $WriteMakefileArgs{TEST_REQUIRES}; delete $WriteMakefileArgs{BUILD_REQUIRES}; $WriteMakefileArgs{PREREQ_PM} = \%FallbackPrereqs; } delete $WriteMakefileArgs{CONFIGURE_REQUIRES} unless eval { ExtUtils::MakeMaker->VERSION(6.52) }; # Added by Dist::Zilla::Plugin::MakeMaker::Highlander if ( $] < 5.012 && ! $ENV{PERL_NO_HIGHLANDER} && ! ( $ENV{PERL_MM_OPT} && $ENV{PERL_MM_OPT} =~ /(?:INSTALL_BASE|PREFIX)/ ) && ! grep { /INSTALL_BASE/ || /PREFIX/ } @ARGV ) { $WriteMakefileArgs{UNINST} = 1; } WriteMakefile(%WriteMakefileArgs); CPAN-Meta-YAML-0.020/weaver.ini000644 000766 000024 00000000415 14730103447 016130 0ustar00etherstaff000000 000000 [@CorePrep] [-SingleEncoding] [Name] [Version] [Region / prelude] [Generic / DEPRECATED] [Generic / SYNOPSIS] [Generic / DESCRIPTION] [Generic / USAGE] [Leftovers] [Region / postlude] [Authors] [Contributors] [Legal] [-Transformer / Lists] transformer = List CPAN-Meta-YAML-0.020/META.json000644 000766 000024 00000012446 14730103447 015566 0ustar00etherstaff000000 000000 { "abstract" : "Read and write a subset of YAML for CPAN Meta files", "author" : [ "Adam Kennedy ", "David Golden " ], "dynamic_config" : 0, "generated_by" : "Dist::Zilla version 6.032, CPAN::Meta::Converter version 2.150010", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : 2 }, "name" : "CPAN-Meta-YAML", "no_index" : { "directory" : [ "corpus", "examples", "t", "xt" ], "package" : [ "DB" ] }, "prereqs" : { "configure" : { "requires" : { "ExtUtils::MakeMaker" : "6.17", "perl" : "5.008001" } }, "develop" : { "requires" : { "Dist::Zilla" : "5", "Dist::Zilla::Plugin::AppendExternalData" : "0", "Dist::Zilla::Plugin::Authority" : "0", "Dist::Zilla::Plugin::AutoPrereqs" : "0", "Dist::Zilla::Plugin::CheckChangesHasContent" : "0", "Dist::Zilla::Plugin::CheckMetaResources" : "0", "Dist::Zilla::Plugin::CheckPrereqsIndexed" : "0", "Dist::Zilla::Plugin::ConfirmRelease" : "0", "Dist::Zilla::Plugin::Doppelgaenger" : "0.007", "Dist::Zilla::Plugin::Encoding" : "0", "Dist::Zilla::Plugin::Git::Check" : "0", "Dist::Zilla::Plugin::Git::CheckFor::CorrectBranch" : "0", "Dist::Zilla::Plugin::Git::Commit" : "0", "Dist::Zilla::Plugin::Git::Contributors" : "0", "Dist::Zilla::Plugin::Git::GatherDir" : "0", "Dist::Zilla::Plugin::Git::NextVersion" : "0", "Dist::Zilla::Plugin::Git::Push" : "0", "Dist::Zilla::Plugin::Git::Tag" : "0", "Dist::Zilla::Plugin::GithubMeta" : "0", "Dist::Zilla::Plugin::License" : "0", "Dist::Zilla::Plugin::MakeMaker" : "0", "Dist::Zilla::Plugin::MakeMaker::Highlander" : "0.003", "Dist::Zilla::Plugin::Manifest" : "0", "Dist::Zilla::Plugin::MetaJSON" : "0", "Dist::Zilla::Plugin::MetaNoIndex" : "0", "Dist::Zilla::Plugin::MetaProvides::Package" : "0", "Dist::Zilla::Plugin::MetaResources" : "0", "Dist::Zilla::Plugin::MetaTests" : "0", "Dist::Zilla::Plugin::MetaYAML" : "0", "Dist::Zilla::Plugin::MinimumPerl" : "0", "Dist::Zilla::Plugin::NextRelease" : "5.033", "Dist::Zilla::Plugin::PkgVersion" : "0", "Dist::Zilla::Plugin::Pod2Readme" : "0", "Dist::Zilla::Plugin::PodSyntaxTests" : "0", "Dist::Zilla::Plugin::PodWeaver" : "0", "Dist::Zilla::Plugin::Prereqs::AuthorDeps" : "0", "Dist::Zilla::Plugin::PromptIfStale" : "0", "Dist::Zilla::Plugin::RemovePrereqs" : "0", "Dist::Zilla::Plugin::RunExtraTests" : "0", "Dist::Zilla::Plugin::Test::Compile" : "0", "Dist::Zilla::Plugin::Test::ReportPrereqs" : "0", "Dist::Zilla::Plugin::Test::Version" : "0", "Dist::Zilla::Plugin::TestRelease" : "0", "Dist::Zilla::Plugin::UploadToCPAN" : "0", "File::Spec" : "0", "File::Temp" : "0", "IO::Handle" : "0", "IPC::Open3" : "0", "Software::License::Perl_5" : "0", "Test::CPAN::Meta" : "0", "Test::More" : "0", "Test::Pod" : "1.41", "Test::Version" : "1" } }, "runtime" : { "requires" : { "B" : "0", "Carp" : "0", "Exporter" : "0", "Fcntl" : "0", "Scalar::Util" : "0", "perl" : "5.008001", "strict" : "0", "warnings" : "0" } }, "test" : { "recommends" : { "CPAN::Meta" : "2.120900" }, "requires" : { "ExtUtils::MakeMaker" : "0", "File::Basename" : "0", "File::Find" : "0", "File::Spec" : "0", "File::Spec::Functions" : "0", "File::Temp" : "0.19", "IO::Dir" : "0", "JSON::PP" : "0", "Test::More" : "0.88", "base" : "0", "lib" : "0", "open" : "0", "perl" : "5.008001", "utf8" : "0", "vars" : "0" } } }, "provides" : { "CPAN::Meta::YAML" : { "file" : "lib/CPAN/Meta/YAML.pm", "version" : "0.020" } }, "release_status" : "stable", "resources" : { "bugtracker" : { "web" : "https://github.com/Perl-Toolchain-Gang/YAML-Tiny/issues" }, "homepage" : "https://github.com/Perl-Toolchain-Gang/CPAN-Meta-YAML", "repository" : { "type" : "git", "url" : "https://github.com/Perl-Toolchain-Gang/CPAN-Meta-YAML.git", "web" : "https://github.com/Perl-Toolchain-Gang/CPAN-Meta-YAML" } }, "version" : "0.020", "x_authority" : "cpan:DAGOLDEN", "x_contributors" : [ "Karen Etheridge " ], "x_generated_by_perl" : "v5.41.6", "x_serialization_backend" : "Cpanel::JSON::XS version 4.39", "x_spdx_expression" : "Artistic-1.0-Perl OR GPL-1.0-or-later" } CPAN-Meta-YAML-0.020/dist.ini000640 000766 000024 00000003706 14730103447 015604 0ustar00etherstaff000000 000000 ; This file is generated from dist.ini.meta by dzil bakeini. ; Edit that file or the bundles contained within for long-term changes. name = CPAN-Meta-YAML author = Adam Kennedy author = David Golden license = Perl_5 copyright_holder = Adam Kennedy copyright_year = 2010 [Doppelgaenger] :version = 0.007 source_module = YAML::Tiny strip_pod = 1 strip_version = 1 exclude_filename = t/00-report-prereqs.t exclude_filename = t/00-report-prereqs.dd [Encoding / corpus] encoding = bytes filename = t/README.md matches = ^t/data/ matches = ^t/tml [Git::NextVersion] version_regexp = ^release-(.+)$ [PkgVersion] [AppendExternalData] source_dir = pod [Git::Contributors] ; pick up Changes and .ini files [Git::GatherDir] [PodWeaver] [Pod2Readme] [License] [Test::Compile] fake_home = 1 xt_mode = 1 [Test::ReportPrereqs] [MetaTests] [PodSyntaxTests] [Test::Version] [Authority] authority = cpan:DAGOLDEN do_munging = 0 [MinimumPerl] [AutoPrereqs] skip = ^YAML [RemovePrereqs] remove = JSON::MaybeXS [MetaNoIndex] directory = t directory = xt directory = examples directory = corpus package = DB [MetaProvides::Package] meta_noindex = 1 [GithubMeta] issues = 0 remote = origin remote = github [MetaResources] bugtracker.web = https://github.com/Perl-Toolchain-Gang/YAML-Tiny/issues [Prereqs::AuthorDeps] [MetaYAML] [MetaJSON] [MakeMaker] default_jobs = 9 eumm_version = 6.17 [MakeMaker::Highlander] :version = 0.003 [PromptIfStale] check_all_plugins = 1 modules = Dist::Zilla [Manifest] [Git::CheckFor::CorrectBranch] [Git::Check] [CheckMetaResources] [CheckPrereqsIndexed] [CheckChangesHasContent] [RunExtraTests] default_jobs = 9 [TestRelease] [ConfirmRelease] [UploadToCPAN] [Git::Tag] tag_format = release-%v [NextRelease] :version = 5.033 time_zone = UTC format = %-8v %{yyyy-MM-dd HH:mm:ss'Z'}d%{ (TRIAL RELEASE)}T [Git::Commit] allow_dirty = Changes commit_msg = After release: timestamp Changes [Git::Push] push_to = origin CPAN-Meta-YAML-0.020/lib/CPAN/000770 000766 000024 00000000000 14730103447 015422 5ustar00etherstaff000000 000000 CPAN-Meta-YAML-0.020/lib/CPAN/Meta/000770 000766 000024 00000000000 14730103447 016310 5ustar00etherstaff000000 000000 CPAN-Meta-YAML-0.020/lib/CPAN/Meta/YAML.pm000640 000766 000024 00000064652 14730103447 017424 0ustar00etherstaff000000 000000 use 5.008001; # sane UTF-8 support use strict; use warnings; package CPAN::Meta::YAML; # git description: v1.75-3-g85169f1 # XXX-INGY is 5.8.1 too old/broken for utf8? # XXX-XDG Lancaster consensus was that it was sufficient until # proven otherwise $CPAN::Meta::YAML::VERSION = '0.020'; ; # original $VERSION removed by Doppelgaenger ##################################################################### # The CPAN::Meta::YAML API. # # These are the currently documented API functions/methods and # exports: use Exporter; our @ISA = qw{ Exporter }; our @EXPORT = qw{ Load Dump }; our @EXPORT_OK = qw{ LoadFile DumpFile freeze thaw }; ### # Functional/Export API: sub Dump { return CPAN::Meta::YAML->new(@_)->_dump_string; } # XXX-INGY Returning last document seems a bad behavior. # XXX-XDG I think first would seem more natural, but I don't know # that it's worth changing now sub Load { my $self = CPAN::Meta::YAML->_load_string(@_); if ( wantarray ) { return @$self; } else { # To match YAML.pm, return the last document return $self->[-1]; } } # XXX-INGY Do we really need freeze and thaw? # XXX-XDG I don't think so. I'd support deprecating them. BEGIN { *freeze = \&Dump; *thaw = \&Load; } sub DumpFile { my $file = shift; return CPAN::Meta::YAML->new(@_)->_dump_file($file); } sub LoadFile { my $file = shift; my $self = CPAN::Meta::YAML->_load_file($file); if ( wantarray ) { return @$self; } else { # Return only the last document to match YAML.pm, return $self->[-1]; } } ### # Object Oriented API: # Create an empty CPAN::Meta::YAML object # XXX-INGY Why do we use ARRAY object? # NOTE: I get it now, but I think it's confusing and not needed. # Will change it on a branch later, for review. # # XXX-XDG I don't support changing it yet. It's a very well-documented # "API" of CPAN::Meta::YAML. I'd support deprecating it, but Adam suggested # we not change it until YAML.pm's own OO API is established so that # users only have one API change to digest, not two sub new { my $class = shift; bless [ @_ ], $class; } # XXX-INGY It probably doesn't matter, and it's probably too late to # change, but 'read/write' are the wrong names. Read and Write # are actions that take data from storage to memory # characters/strings. These take the data to/from storage to native # Perl objects, which the terms dump and load are meant. As long as # this is a legacy quirk to CPAN::Meta::YAML it's ok, but I'd prefer not # to add new {read,write}_* methods to this API. sub read_string { my $self = shift; $self->_load_string(@_); } sub write_string { my $self = shift; $self->_dump_string(@_); } sub read { my $self = shift; $self->_load_file(@_); } sub write { my $self = shift; $self->_dump_file(@_); } ##################################################################### # Constants # Printed form of the unprintable characters in the lowest range # of ASCII characters, listed by ASCII ordinal position. my @UNPRINTABLE = qw( 0 x01 x02 x03 x04 x05 x06 a b t n v f r x0E x0F x10 x11 x12 x13 x14 x15 x16 x17 x18 x19 x1A e x1C x1D x1E x1F ); # Printable characters for escapes my %UNESCAPES = ( 0 => "\x00", z => "\x00", N => "\x85", a => "\x07", b => "\x08", t => "\x09", n => "\x0a", v => "\x0b", f => "\x0c", r => "\x0d", e => "\x1b", '\\' => '\\', ); # XXX-INGY # I(ngy) need to decide if these values should be quoted in # CPAN::Meta::YAML or not. Probably yes. # These 3 values have special meaning when unquoted and using the # default YAML schema. They need quotes if they are strings. my %QUOTE = map { $_ => 1 } qw{ null true false }; # The commented out form is simpler, but overloaded the Perl regex # engine due to recursion and backtracking problems on strings # larger than 32,000ish characters. Keep it for reference purposes. # qr/\"((?:\\.|[^\"])*)\"/ my $re_capture_double_quoted = qr/\"([^\\"]*(?:\\.[^\\"]*)*)\"/; my $re_capture_single_quoted = qr/\'([^\']*(?:\'\'[^\']*)*)\'/; # unquoted re gets trailing space that needs to be stripped my $re_capture_unquoted_key = qr/([^:]+(?::+\S(?:[^:]*|.*?(?=:)))*)(?=\s*\:(?:\s+|$))/; my $re_trailing_comment = qr/(?:\s+\#.*)?/; my $re_key_value_separator = qr/\s*:(?:\s+(?:\#.*)?|$)/; ##################################################################### # CPAN::Meta::YAML Implementation. # # These are the private methods that do all the work. They may change # at any time. ### # Loader functions: # Create an object from a file sub _load_file { my $class = ref $_[0] ? ref shift : shift; # Check the file my $file = shift or $class->_error( 'You did not specify a file name' ); $class->_error( "File '$file' does not exist" ) unless -e $file; $class->_error( "'$file' is a directory, not a file" ) unless -f _; $class->_error( "Insufficient permissions to read '$file'" ) unless -r _; # Open unbuffered with strict UTF-8 decoding and no translation layers open( my $fh, "<:unix:encoding(UTF-8)", $file ); unless ( $fh ) { $class->_error("Failed to open file '$file': $!"); } # flock if available (or warn if not possible for OS-specific reasons) if ( _can_flock() ) { flock( $fh, Fcntl::LOCK_SH() ) or warn "Couldn't lock '$file' for reading: $!"; } # slurp the contents my $contents = eval { use warnings FATAL => 'utf8'; local $/; <$fh> }; if ( my $err = $@ ) { $class->_error("Error reading from file '$file': $err"); } # close the file (release the lock) unless ( close $fh ) { $class->_error("Failed to close file '$file': $!"); } $class->_load_string( $contents ); } # Create an object from a string sub _load_string { my $class = ref $_[0] ? ref shift : shift; my $self = bless [], $class; my $string = $_[0]; eval { unless ( defined $string ) { die \"Did not provide a string to load"; } # Check if Perl has it marked as characters, but it's internally # inconsistent. E.g. maybe latin1 got read on a :utf8 layer if ( utf8::is_utf8($string) && ! utf8::valid($string) ) { die \<<'...'; Read an invalid UTF-8 string (maybe mixed UTF-8 and 8-bit character set). Did you decode with lax ":utf8" instead of strict ":encoding(UTF-8)"? ... } # Ensure Unicode character semantics, even for 0x80-0xff utf8::upgrade($string); # Check for and strip any leading UTF-8 BOM $string =~ s/^\x{FEFF}//; # Check for some special cases return $self unless length $string; # Split the file into lines my @lines = grep { ! /^\s*(?:\#.*)?\z/ } split /(?:\015{1,2}\012|\015|\012)/, $string; # Strip the initial YAML header @lines and $lines[0] =~ /^\%YAML[: ][\d\.]+.*\z/ and shift @lines; # A nibbling parser my $in_document = 0; while ( @lines ) { # Do we have a document header? if ( $lines[0] =~ /^---\s*(?:(.+)\s*)?\z/ ) { # Handle scalar documents shift @lines; if ( defined $1 and $1 !~ /^(?:\#.+|\%YAML[: ][\d\.]+)\z/ ) { push @$self, $self->_load_scalar( "$1", [ undef ], \@lines ); next; } $in_document = 1; } if ( ! @lines or $lines[0] =~ /^(?:---|\.\.\.)/ ) { # A naked document push @$self, undef; while ( @lines and $lines[0] !~ /^---/ ) { shift @lines; } $in_document = 0; # XXX The final '-+$' is to look for -- which ends up being an # error later. } elsif ( ! $in_document && @$self ) { # only the first document can be explicit die \"CPAN::Meta::YAML failed to classify the line '$lines[0]'"; } elsif ( $lines[0] =~ /^\s*\-(?:\s|$|-+$)/ ) { # An array at the root my $document = [ ]; push @$self, $document; $self->_load_array( $document, [ 0 ], \@lines ); } elsif ( $lines[0] =~ /^(\s*)\S/ ) { # A hash at the root my $document = { }; push @$self, $document; $self->_load_hash( $document, [ length($1) ], \@lines ); } else { # Shouldn't get here. @lines have whitespace-only lines # stripped, and previous match is a line with any # non-whitespace. So this clause should only be reachable via # a perlbug where \s is not symmetric with \S # uncoverable statement die \"CPAN::Meta::YAML failed to classify the line '$lines[0]'"; } } }; my $err = $@; if ( ref $err eq 'SCALAR' ) { $self->_error(${$err}); } elsif ( $err ) { $self->_error($err); } return $self; } sub _unquote_single { my ($self, $string) = @_; return '' unless length $string; $string =~ s/\'\'/\'/g; return $string; } sub _unquote_double { my ($self, $string) = @_; return '' unless length $string; $string =~ s/\\"/"/g; $string =~ s{\\([Nnever\\fartz0b]|x([0-9a-fA-F]{2}))} {(length($1)>1)?pack("H2",$2):$UNESCAPES{$1}}gex; return $string; } # Load a YAML scalar string to the actual Perl scalar sub _load_scalar { my ($self, $string, $indent, $lines) = @_; # Trim trailing whitespace $string =~ s/\s*\z//; # Explitic null/undef return undef if $string eq '~'; # Single quote if ( $string =~ /^$re_capture_single_quoted$re_trailing_comment\z/ ) { return $self->_unquote_single($1); } # Double quote. if ( $string =~ /^$re_capture_double_quoted$re_trailing_comment\z/ ) { return $self->_unquote_double($1); } # Special cases if ( $string =~ /^[\'\"!&]/ ) { die \"CPAN::Meta::YAML does not support a feature in line '$string'"; } return {} if $string =~ /^{}(?:\s+\#.*)?\z/; return [] if $string =~ /^\[\](?:\s+\#.*)?\z/; # Regular unquoted string if ( $string !~ /^[>|]/ ) { die \"CPAN::Meta::YAML found illegal characters in plain scalar: '$string'" if $string =~ /^(?:-(?:\s|$)|[\@\%\`])/ or $string =~ /:(?:\s|$)/; $string =~ s/\s+#.*\z//; return $string; } # Error die \"CPAN::Meta::YAML failed to find multi-line scalar content" unless @$lines; # Check the indent depth $lines->[0] =~ /^(\s*)/; $indent->[-1] = length("$1"); if ( defined $indent->[-2] and $indent->[-1] <= $indent->[-2] ) { die \"CPAN::Meta::YAML found bad indenting in line '$lines->[0]'"; } # Pull the lines my @multiline = (); while ( @$lines ) { $lines->[0] =~ /^(\s*)/; last unless length($1) >= $indent->[-1]; push @multiline, substr(shift(@$lines), $indent->[-1]); } my $j = (substr($string, 0, 1) eq '>') ? ' ' : "\n"; my $t = (substr($string, 1, 1) eq '-') ? '' : "\n"; return join( $j, @multiline ) . $t; } # Load an array sub _load_array { my ($self, $array, $indent, $lines) = @_; while ( @$lines ) { # Check for a new document if ( $lines->[0] =~ /^(?:---|\.\.\.)/ ) { while ( @$lines and $lines->[0] !~ /^---/ ) { shift @$lines; } return 1; } # Check the indent level $lines->[0] =~ /^(\s*)/; if ( length($1) < $indent->[-1] ) { return 1; } elsif ( length($1) > $indent->[-1] ) { die \"CPAN::Meta::YAML found bad indenting in line '$lines->[0]'"; } if ( $lines->[0] =~ /^(\s*\-\s+)[^\'\"]\S*\s*:(?:\s+|$)/ ) { # Inline nested hash my $indent2 = length("$1"); $lines->[0] =~ s/-/ /; push @$array, { }; $self->_load_hash( $array->[-1], [ @$indent, $indent2 ], $lines ); } elsif ( $lines->[0] =~ /^\s*\-\s*\z/ ) { shift @$lines; unless ( @$lines ) { push @$array, undef; return 1; } if ( $lines->[0] =~ /^(\s*)\-/ ) { my $indent2 = length("$1"); if ( $indent->[-1] == $indent2 ) { # Null array entry push @$array, undef; } else { # Naked indenter push @$array, [ ]; $self->_load_array( $array->[-1], [ @$indent, $indent2 ], $lines ); } } elsif ( $lines->[0] =~ /^(\s*)\S/ ) { push @$array, { }; $self->_load_hash( $array->[-1], [ @$indent, length("$1") ], $lines ); } else { die \"CPAN::Meta::YAML failed to classify line '$lines->[0]'"; } } elsif ( $lines->[0] =~ /^\s*\-(\s*)(.+?)\s*\z/ ) { # Array entry with a value shift @$lines; push @$array, $self->_load_scalar( "$2", [ @$indent, undef ], $lines ); } elsif ( defined $indent->[-2] and $indent->[-1] == $indent->[-2] ) { # This is probably a structure like the following... # --- # foo: # - list # bar: value # # ... so lets return and let the hash parser handle it return 1; } else { die \"CPAN::Meta::YAML failed to classify line '$lines->[0]'"; } } return 1; } # Load a hash sub _load_hash { my ($self, $hash, $indent, $lines) = @_; while ( @$lines ) { # Check for a new document if ( $lines->[0] =~ /^(?:---|\.\.\.)/ ) { while ( @$lines and $lines->[0] !~ /^---/ ) { shift @$lines; } return 1; } # Check the indent level $lines->[0] =~ /^(\s*)/; if ( length($1) < $indent->[-1] ) { return 1; } elsif ( length($1) > $indent->[-1] ) { die \"CPAN::Meta::YAML found bad indenting in line '$lines->[0]'"; } # Find the key my $key; # Quoted keys if ( $lines->[0] =~ s/^\s*$re_capture_single_quoted$re_key_value_separator// ) { $key = $self->_unquote_single($1); } elsif ( $lines->[0] =~ s/^\s*$re_capture_double_quoted$re_key_value_separator// ) { $key = $self->_unquote_double($1); } elsif ( $lines->[0] =~ s/^\s*$re_capture_unquoted_key$re_key_value_separator// ) { $key = $1; $key =~ s/\s+$//; } elsif ( $lines->[0] =~ /^\s*\?/ ) { die \"CPAN::Meta::YAML does not support a feature in line '$lines->[0]'"; } else { die \"CPAN::Meta::YAML failed to classify line '$lines->[0]'"; } if ( exists $hash->{$key} ) { warn "CPAN::Meta::YAML found a duplicate key '$key' in line '$lines->[0]'"; } # Do we have a value? if ( length $lines->[0] ) { # Yes $hash->{$key} = $self->_load_scalar( shift(@$lines), [ @$indent, undef ], $lines ); } else { # An indent shift @$lines; unless ( @$lines ) { $hash->{$key} = undef; return 1; } if ( $lines->[0] =~ /^(\s*)-/ ) { $hash->{$key} = []; $self->_load_array( $hash->{$key}, [ @$indent, length($1) ], $lines ); } elsif ( $lines->[0] =~ /^(\s*)./ ) { my $indent2 = length("$1"); if ( $indent->[-1] >= $indent2 ) { # Null hash entry $hash->{$key} = undef; } else { $hash->{$key} = {}; $self->_load_hash( $hash->{$key}, [ @$indent, length($1) ], $lines ); } } } } return 1; } ### # Dumper functions: # Save an object to a file sub _dump_file { my $self = shift; require Fcntl; # Check the file my $file = shift or $self->_error( 'You did not specify a file name' ); my $fh; # flock if available (or warn if not possible for OS-specific reasons) if ( _can_flock() ) { # Open without truncation (truncate comes after lock) my $flags = Fcntl::O_WRONLY()|Fcntl::O_CREAT(); sysopen( $fh, $file, $flags ) or $self->_error("Failed to open file '$file' for writing: $!"); # Use no translation and strict UTF-8 binmode( $fh, ":raw:encoding(UTF-8)"); flock( $fh, Fcntl::LOCK_EX() ) or warn "Couldn't lock '$file' for reading: $!"; # truncate and spew contents truncate $fh, 0; seek $fh, 0, 0; } else { open $fh, ">:unix:encoding(UTF-8)", $file; } # serialize and spew to the handle print {$fh} $self->_dump_string; # close the file (release the lock) unless ( close $fh ) { $self->_error("Failed to close file '$file': $!"); } return 1; } # Save an object to a string sub _dump_string { my $self = shift; return '' unless ref $self && @$self; # Iterate over the documents my $indent = 0; my @lines = (); eval { foreach my $cursor ( @$self ) { push @lines, '---'; # An empty document if ( ! defined $cursor ) { # Do nothing # A scalar document } elsif ( ! ref $cursor ) { $lines[-1] .= ' ' . $self->_dump_scalar( $cursor ); # A list at the root } elsif ( ref $cursor eq 'ARRAY' ) { unless ( @$cursor ) { $lines[-1] .= ' []'; next; } push @lines, $self->_dump_array( $cursor, $indent, {} ); # A hash at the root } elsif ( ref $cursor eq 'HASH' ) { unless ( %$cursor ) { $lines[-1] .= ' {}'; next; } push @lines, $self->_dump_hash( $cursor, $indent, {} ); } else { die \("Cannot serialize " . ref($cursor)); } } }; if ( ref $@ eq 'SCALAR' ) { $self->_error(${$@}); } elsif ( $@ ) { $self->_error($@); } join '', map { "$_\n" } @lines; } sub _has_internal_string_value { my $value = shift; my $b_obj = B::svref_2object(\$value); # for round trip problem return $b_obj->FLAGS & B::SVf_POK(); } sub _dump_scalar { my $string = $_[1]; my $is_key = $_[2]; # Check this before checking length or it winds up looking like a string! my $has_string_flag = _has_internal_string_value($string); return '~' unless defined $string; return "''" unless length $string; if (Scalar::Util::looks_like_number($string)) { # keys and values that have been used as strings get quoted if ( $is_key || $has_string_flag ) { return qq['$string']; } else { return $string; } } if ( $string =~ /[\x00-\x09\x0b-\x0d\x0e-\x1f\x7f-\x9f\'\n]/ ) { $string =~ s/\\/\\\\/g; $string =~ s/"/\\"/g; $string =~ s/\n/\\n/g; $string =~ s/[\x85]/\\N/g; $string =~ s/([\x00-\x1f])/\\$UNPRINTABLE[ord($1)]/g; $string =~ s/([\x7f-\x9f])/'\x' . sprintf("%X",ord($1))/ge; return qq|"$string"|; } if ( $string =~ /(?:^[~!@#%&*|>?:,'"`{}\[\]]|^-+$|\s|:\z)/ or $QUOTE{$string} ) { return "'$string'"; } return $string; } sub _dump_array { my ($self, $array, $indent, $seen) = @_; if ( $seen->{refaddr($array)}++ ) { die \"CPAN::Meta::YAML does not support circular references"; } my @lines = (); foreach my $el ( @$array ) { my $line = (' ' x $indent) . '-'; my $type = ref $el; if ( ! $type ) { $line .= ' ' . $self->_dump_scalar( $el ); push @lines, $line; } elsif ( $type eq 'ARRAY' ) { if ( @$el ) { push @lines, $line; push @lines, $self->_dump_array( $el, $indent + 1, $seen ); } else { $line .= ' []'; push @lines, $line; } } elsif ( $type eq 'HASH' ) { if ( keys %$el ) { push @lines, $line; push @lines, $self->_dump_hash( $el, $indent + 1, $seen ); } else { $line .= ' {}'; push @lines, $line; } } else { die \"CPAN::Meta::YAML does not support $type references"; } } @lines; } sub _dump_hash { my ($self, $hash, $indent, $seen) = @_; if ( $seen->{refaddr($hash)}++ ) { die \"CPAN::Meta::YAML does not support circular references"; } my @lines = (); foreach my $name ( sort keys %$hash ) { my $el = $hash->{$name}; my $line = (' ' x $indent) . $self->_dump_scalar($name, 1) . ":"; my $type = ref $el; if ( ! $type ) { $line .= ' ' . $self->_dump_scalar( $el ); push @lines, $line; } elsif ( $type eq 'ARRAY' ) { if ( @$el ) { push @lines, $line; push @lines, $self->_dump_array( $el, $indent + 1, $seen ); } else { $line .= ' []'; push @lines, $line; } } elsif ( $type eq 'HASH' ) { if ( keys %$el ) { push @lines, $line; push @lines, $self->_dump_hash( $el, $indent + 1, $seen ); } else { $line .= ' {}'; push @lines, $line; } } else { die \"CPAN::Meta::YAML does not support $type references"; } } @lines; } ##################################################################### # DEPRECATED API methods: # Error storage (DEPRECATED as of 1.57) our $errstr = ''; # Set error sub _error { require Carp; $errstr = $_[1]; $errstr =~ s/ at \S+ line \d+.*//; Carp::croak( $errstr ); } # Retrieve error my $errstr_warned; sub errstr { require Carp; Carp::carp( "CPAN::Meta::YAML->errstr and \$CPAN::Meta::YAML::errstr is deprecated" ) unless $errstr_warned++; $errstr; } ##################################################################### # Helper functions. Possibly not needed. # Use to detect nv or iv use B; # XXX-INGY Is flock CPAN::Meta::YAML's responsibility? # Some platforms can't flock :-( # XXX-XDG I think it is. When reading and writing files, we ought # to be locking whenever possible. People (foolishly) use YAML # files for things like session storage, which has race issues. my $HAS_FLOCK; sub _can_flock { if ( defined $HAS_FLOCK ) { return $HAS_FLOCK; } else { require Config; my $c = \%Config::Config; $HAS_FLOCK = grep { $c->{$_} } qw/d_flock d_fcntl_can_lock d_lockf/; require Fcntl if $HAS_FLOCK; return $HAS_FLOCK; } } # XXX-INGY Is this core in 5.8.1? Can we remove this? # XXX-XDG Scalar::Util 1.18 didn't land until 5.8.8, so we need this ##################################################################### # Use Scalar::Util if possible, otherwise emulate it use Scalar::Util (); BEGIN { local $@; if ( eval { Scalar::Util->VERSION(1.18); } ) { *refaddr = *Scalar::Util::refaddr; } else { eval <<'END_PERL'; # Scalar::Util failed to load or too old sub refaddr { my $pkg = ref($_[0]) or return undef; if ( !! UNIVERSAL::can($_[0], 'can') ) { bless $_[0], 'Scalar::Util::Fake'; } else { $pkg = undef; } "$_[0]" =~ /0x(\w+)/; my $i = do { no warnings 'portable'; hex $1 }; bless $_[0], $pkg if defined $pkg; $i; } END_PERL } } delete $CPAN::Meta::YAML::{refaddr}; 1; # XXX-INGY Doc notes I'm putting up here. Changing the doc when it's wrong # but leaving grey area stuff up here. # # I would like to change Read/Write to Load/Dump below without # changing the actual API names. # # It might be better to put Load/Dump API in the SYNOPSIS instead of the # dubious OO API. # # null and bool explanations may be outdated. =pod =encoding UTF-8 =head1 NAME CPAN::Meta::YAML - Read and write a subset of YAML for CPAN Meta files =head1 VERSION version 0.020 =head1 SYNOPSIS use CPAN::Meta::YAML; # reading a META file open $fh, "<:utf8", "META.yml"; $yaml_text = do { local $/; <$fh> }; $yaml = CPAN::Meta::YAML->read_string($yaml_text) or die CPAN::Meta::YAML->errstr; # finding the metadata $meta = $yaml->[0]; # writing a META file $yaml_text = $yaml->write_string or die CPAN::Meta::YAML->errstr; open $fh, ">:utf8", "META.yml"; print $fh $yaml_text; =head1 DESCRIPTION This module implements a subset of the YAML specification for use in reading and writing CPAN metadata files like F and F. It should not be used for any other general YAML parsing or generation task. NOTE: F (and F) files should be UTF-8 encoded. Users are responsible for proper encoding and decoding. In particular, the C and C methods do B support UTF-8 and should not be used. =head1 SUPPORT This module is currently derived from L by Adam Kennedy. If there are bugs in how it parses a particular META.yml file, please file a bug report in the YAML::Tiny bugtracker: L =head1 SEE ALSO L, L, L =head1 AUTHORS =over 4 =item * Adam Kennedy =item * David Golden =back =head1 CONTRIBUTOR =for stopwords Karen Etheridge Karen Etheridge =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2010 by Adam Kennedy. 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 __END__ # ABSTRACT: Read and write a subset of YAML for CPAN Meta files CPAN-Meta-YAML-0.020/xt/author/000770 000766 000024 00000000000 14730103447 016070 5ustar00etherstaff000000 000000 CPAN-Meta-YAML-0.020/xt/author/test-version.t000644 000766 000024 00000000637 14730103447 020730 0ustar00etherstaff000000 000000 use strict; use warnings; use Test::More; # generated by Dist::Zilla::Plugin::Test::Version 1.09 use Test::Version; my @imports = qw( version_all_ok ); my $params = { is_strict => 0, has_version => 1, multiple => 0, }; push @imports, $params if version->parse( $Test::Version::VERSION ) >= version->parse('1.002'); Test::Version->import(@imports); version_all_ok; done_testing; CPAN-Meta-YAML-0.020/xt/author/00-compile.t000644 000766 000024 00000002663 14730103447 020134 0ustar00etherstaff000000 000000 use 5.006; use strict; use warnings; # this test was generated with Dist::Zilla::Plugin::Test::Compile 2.058 use Test::More; plan tests => 2; my @module_files = ( 'CPAN/Meta/YAML.pm' ); # fake home for cpan-testers use File::Temp; local $ENV{HOME} = File::Temp::tempdir( CLEANUP => 1 ); my @switches = ( -d 'blib' ? '-Mblib' : '-Ilib', ); use File::Spec; use IPC::Open3; use IO::Handle; open my $stdin, '<', File::Spec->devnull or die "can't open devnull: $!"; my @warnings; for my $lib (@module_files) { # see L my $stderr = IO::Handle->new; diag('Running: ', join(', ', map { my $str = $_; $str =~ s/'/\\'/g; q{'} . $str . q{'} } $^X, @switches, '-e', "require q[$lib]")) if $ENV{PERL_COMPILE_TEST_DEBUG}; my $pid = open3($stdin, '>&STDERR', $stderr, $^X, @switches, '-e', "require q[$lib]"); binmode $stderr, ':crlf' if $^O eq 'MSWin32'; my @_warnings = <$stderr>; waitpid($pid, 0); is($?, 0, "$lib loaded ok"); shift @_warnings if @_warnings and $_warnings[0] =~ /^Using .*\bblib/ and not eval { +require blib; blib->VERSION('1.01') }; if (@_warnings) { warn @_warnings; push @warnings, @_warnings; } } is(scalar(@warnings), 0, 'no warnings found') or diag 'got warnings: ', ( Test::More->can('explain') ? Test::More::explain(\@warnings) : join("\n", '', @warnings) ); CPAN-Meta-YAML-0.020/xt/author/pod-syntax.t000644 000766 000024 00000000252 14730103447 020365 0ustar00etherstaff000000 000000 #!perl # This file was automatically generated by Dist::Zilla::Plugin::PodSyntaxTests. use strict; use warnings; use Test::More; use Test::Pod 1.41; all_pod_files_ok(); CPAN-Meta-YAML-0.020/xt/author/distmeta.t000644 000766 000024 00000000223 14730103447 020067 0ustar00etherstaff000000 000000 #!perl # This file was automatically generated by Dist::Zilla::Plugin::MetaTests. use strict; use warnings; use Test::CPAN::Meta; meta_yaml_ok(); CPAN-Meta-YAML-0.020/t/21_yamlpm_compat.t000640 000766 000024 00000003335 14730103447 017732 0ustar00etherstaff000000 000000 use strict; use warnings; use lib 't/lib/'; use Test::More 0.88; use TestBridge; use File::Spec::Functions 'catfile'; use File::Temp 0.19; # newdir #--------------------------------------------------------------------------# # This file test that the YAML.pm compatible Dump/Load/DumpFile/LoadFile # work as documented #--------------------------------------------------------------------------# use CPAN::Meta::YAML; { my $scalar = 'this is a string'; my $arrayref = [ 1 .. 5 ]; my $hashref = { alpha => 'beta', gamma => 'delta' }; my $yamldump = CPAN::Meta::YAML::Dump( $scalar, $arrayref, $hashref ); my @yamldocsloaded = CPAN::Meta::YAML::Load($yamldump); cmp_deeply( [ @yamldocsloaded ], [ $scalar, $arrayref, $hashref ], "Functional interface: Dump to Load roundtrip works as expected" ); } { my $scalar = 'this is a string'; my $arrayref = [ 1 .. 5 ]; my $hashref = { alpha => 'beta', gamma => 'delta' }; my $tempdir = File::Temp->newdir("YTXXXXXX", TMPDIR => 1 ); my $filename = catfile($tempdir, 'compat'); my $rv = CPAN::Meta::YAML::DumpFile( $filename, $scalar, $arrayref, $hashref); ok($rv, "DumpFile returned true value"); my @yamldocsloaded = CPAN::Meta::YAML::LoadFile($filename); cmp_deeply( [ @yamldocsloaded ], [ $scalar, $arrayref, $hashref ], "Functional interface: DumpFile to LoadFile roundtrip works as expected" ); } { my $str = "This is not real YAML"; my @yamldocsloaded; eval { @yamldocsloaded = CPAN::Meta::YAML::Load("$str\n"); }; error_like( qr/CPAN::Meta::YAML failed to classify line '$str'/, "Correctly failed to load non-YAML string" ); } done_testing; CPAN-Meta-YAML-0.020/t/13_write_string.t000640 000766 000024 00000001225 14730103447 017605 0ustar00etherstaff000000 000000 use strict; use warnings; use lib 't/lib/'; use Test::More 0.88; use SubtestCompat; use TestUtils; use TestBridge; use CPAN::Meta::YAML (); #--------------------------------------------------------------------------# # Generally, write_string can be tested with .tml files in t/tml-local/* # # This file is for error tests or conditions that can't be easily tested # via .tml #--------------------------------------------------------------------------# subtest 'write_string as class method' => sub { my $got = eval { CPAN::Meta::YAML->write_string }; is( $@, '', "write_string lives" ); is( $got, '', "returns empty string" ); }; done_testing; CPAN-Meta-YAML-0.020/t/31_local_tml.t000640 000766 000024 00000000742 14730103447 017036 0ustar00etherstaff000000 000000 use strict; use warnings; use lib 't/lib/'; use Test::More 0.88; use TestBridge; use IO::Dir; use File::Spec::Functions qw/catdir/; my $tml_local = "t/tml-local"; for my $dir ( IO::Dir->new($tml_local)->read ) { next if $dir =~ /^\./; my $fn = "test_$dir"; $fn =~ s/-/_/g; $fn =~ s/\.DIR\z//i if $^O eq 'VMS'; my $bridge = TestBridge->can($fn); next unless $bridge; run_all_testml_files( "TestML", catdir($tml_local, $dir), $bridge ); } done_testing; CPAN-Meta-YAML-0.020/t/tml-world/000770 000766 000024 00000000000 14730103447 016317 5ustar00etherstaff000000 000000 CPAN-Meta-YAML-0.020/t/20_subclass.t000640 000766 000024 00000001755 14730103447 016712 0ustar00etherstaff000000 000000 # Testing documents that should fail use strict; use warnings; use lib 't/lib/'; use Test::More 0.88; use TestUtils; use File::Spec::Functions ':ALL'; ##################################################################### # Customized Class SCOPE: { package Foo; use CPAN::Meta::YAML; use vars qw{@ISA}; BEGIN { @ISA = 'CPAN::Meta::YAML'; } # XXX-INGY subclasses should not use private methods… or if they # do they should expect method name changes. # sub _write_scalar { sub _dump_scalar { my $self = shift; my $string = shift; my $is_key = shift; if ( defined $is_key ) { return scalar reverse $string; } else { return $string; } } 1; } ##################################################################### # Generate the value my $object = Foo->new( { foo => 'bar' } ); is( $object->write_string, "---\noof: bar\n", 'Subclassing works' ); done_testing; CPAN-Meta-YAML-0.020/t/12_write.t000640 000766 000024 00000005421 14730103447 016220 0ustar00etherstaff000000 000000 use utf8; use strict; use warnings; use lib 't/lib/'; use Test::More 0.88; use SubtestCompat; use TestBridge; use TestUtils; use CPAN::Meta::YAML; use File::Basename qw/basename/; use File::Spec::Functions 'catfile'; use File::Temp 0.19; # newdir #--------------------------------------------------------------------------# # Error conditions #--------------------------------------------------------------------------# subtest 'no filename for write()' => sub { my $obj = CPAN::Meta::YAML->new(); eval { $obj->write(); }; error_like( qr/You did not specify a file name/, "No filename provided to write()" ); }; #--------------------------------------------------------------------------# # Test that write uses correct encoding and can round-trip #--------------------------------------------------------------------------# my @cases = ( { label => "ascii", name => "Mengue" }, { label => "latin1", name => "Mengué" }, { label => "wide", name => "ã‚" }, ); my @warnings; local $SIG{__WARN__} = sub { push @warnings, $_[0] }; # CPAN::Meta::YAML doesn't preserve order in the file, so we can't actually check # file equivalence. We have to see if we can round-trip a data structure # from Perl to YAML and back. for my $c ( @cases ) { subtest "write $c->{label} characters" => sub { my $data; @warnings = (); # get a tempfile name to write to my $tempdir = File::Temp->newdir("YTXXXXXX", TMPDIR => 1 ); my $short_tempfile = 'output'; my $tempfile = catfile($tempdir, $short_tempfile); # CPAN::Meta::YAML->write ok( CPAN::Meta::YAML->new($c)->write($tempfile), "case $c->{label}: write $short_tempfile" ) or diag "ERROR: " . CPAN::Meta::YAML->errstr; # CPAN::Meta::YAML->read ok( $data = eval { CPAN::Meta::YAML->read( $tempfile ) }, "case $c->{label}: read $short_tempfile" ) or diag "ERROR: " . CPAN::Meta::YAML->errstr; is( $@, '', "no error caught" ); SKIP : { skip "no data read", 1 unless $data; cmp_deeply( $data, [ $c ], "case $c->{label}: Perl -> File -> Perl roundtrip" ); } # CPAN::Meta::YAML->read_string on UTF-8 decoded data ok( $data = eval { CPAN::Meta::YAML->read_string( slurp($tempfile, ":utf8") ) }, "case $c->{label}: read_string on UTF-8 decoded $short_tempfile" ); is( $@, '', "no error caught" ); SKIP : { skip "no data read", 1 unless $data; cmp_deeply( $data, [ $c ], "case $c->{label}: Perl -> File -> Decoded -> Perl roundtrip" ); } is( scalar @warnings, 0, "case $c->{label}: no warnings caught" ) or diag @warnings; } } done_testing; CPAN-Meta-YAML-0.020/t/32_world_tml.t000640 000766 000024 00000000272 14730103447 017072 0ustar00etherstaff000000 000000 use strict; use warnings; use lib 't/lib/'; use Test::More 0.88; use TestBridge; run_all_testml_files( "Real-world examples", 't/tml-world', \&test_yaml_roundtrip ); done_testing; CPAN-Meta-YAML-0.020/t/tml-local/000770 000766 000024 00000000000 14730103447 016262 5ustar00etherstaff000000 000000 CPAN-Meta-YAML-0.020/t/README.md000640 000766 000024 00000014404 14730103447 015657 0ustar00etherstaff000000 000000 # Guide to YAML::Tiny testing YAML::Tiny tests use several components: * .t files * Test libraries in t/lib * YAML data files in t/data * TestML data files in t/tml-* The use of each is described below. ## .t files The .t files are standard Perl test files. They may use one or more of the test libraries in t/lib. They may only use modules available in Perl 5.8.1 or later (and not subsequently deprecated), but they may use newer non-XS versions of those modules as necessary to avoid known bugs. Some .t files have complete inputs/outputs for their tests. Others iterate over .tml files in the t/tml-* directories. A .t file should load Test::More and use `done_testing` at the end to so that new tests may be added without needing to also update a test plan. Currently, the convention is to name .t files matching the pattern qr/^\d\d_\w+\.t$/ ## Test libraries There are currently three test libraries in t/lib. A .t file that uses one or more of them should put `use lib 't/lib';` at the top of the .t file. Test libraries can assume that if they were loaded, that 't/lib' is already in @INC. The test libraries are: * SubtestCompat * TestML::Tiny * TestBridge * TestUtils The "SubtestCompat" library provides a limited emulation of Test::More::subtest that is reasonably compatible back to 0.88. If using subtests, you must not set a plan in the subtest and you must use done_testing in the *.t file. The TestML::Tiny library contains functions for parsing and executing TestML tests with callbacks. TestML is a data-driven testing language; TestML::Tiny implements a small subset of its features. See the section on TestML, below, for an example. Generally, bugs should be patched upstream on CPAN and then a new Test::Tiny CPAN release can be copied here and pod-stripped. The TestBridge library contains testing functions for use in .t files or to be passed to TestML::Tiny functions as callbacks. Test functions should not include `done_testing`. They should use `subtest` for any repetitive testing that loops over test cases. Callback should check for the expected test points (see below) and skip a TML block if those points are not available. The TestUtils library contains utility functions. Testing functions should not be added here (i.e. nothing that uses Test::More). ## YAML data files in t/data Files in the t/data directory are intended to test how YAML files are loaded and decoded and typically need some custom test code to load the file and see if the result matches expectations (successful or not). If a real-world YAML file cannot be loaded due to character set encoding issues, it should be placed in this directory for testing. If a real-world YAML file is ASCII or UTF-8 encoded, can be decoded successfully, but has problems in parsing, it should be reduced to the smallest sample of YAML that demonstrates the parsing problem and added to a .tml file for testing. See below for more details. ## TestML quick intro TestML data files are UTF-8 encoded files with a .tml suffix that contain one or more test "blocks". Each block has a test label, and one or more 'test points', usually representing input and expected output, and possibly additional annotations or flags. Here is an example of a .tml file with a single block: # This is a TestML block: (this line is a comment) === This is the test label Lines until the first point are ignored # This is a "block" style point. All non-comment lines until next point # are the data for the 'yaml' point. The data ends with newline, and # trailing blank lines are trimmed. --- yaml --- foo: bar # a comment \# not a comment # This is the second point; "inline" style. The data after the colon goes # to end of line. Leading/trailing whitespace is trimmed. --- perl: [ { foo => 'bar' } ] # This is a point whose value is the empty string --- a_flag # This is the next block: === Another test case The test label is provided on a line beginning with qr/^===/. Test "points" are provided in sections beginning with qr/^--- +\w+/. All flush-left comment lines are stripped. Lines beginning with '\' are escaped. Different tests expect different test points in a .tml file, based on the specific test callback being used. Many .tml files have the points 'yaml' and 'perl' as in the example above. The 'yaml' point is a YAML document and the 'perl' point is a Data::Dumper Perl data structure. The test checks whether the YAML parses into a data structure identical to the Perl one. The 'a_flag' point is an annotation that the testing callback can use to affect the run of a given test. The semantics of points (including annotations) is specific to the callback functions used to process test blocks. # TestML data files in t/tml-* TestML data files are organized into three directories: * t/tml-spec — these test files are provided by the YAML spec maintainers and should not be modified except to skip testing features that YAML::Tiny does not support * t/tml-local — these test files are YAML::Tiny's own unit tests; generally new test cases for coverage or correctness should be added here; these are broken into subdirectories, described later * t/tml-world — these test files represent "real world" YAML and their corresponding expected Perl output Generally, if a "real world" problem can be isolated to a particular snippet of YAML, it's best to add it to a t/tml-local file (or create a new one). If the problem can only be seen in the context of the entire YAML document, include it in t/tml-world. If the problem relates to encoding, it should be put into t/data instead. # t/tml-local subdirectories The subdirectories in t/tml-local define four types of tests: * perl-to-yaml: test that perl data dump to an expected YAML string * yaml-roundtrip: test that a YAML string loads to an expected perl data structure; also tests that the perl data can be dumped and loaded back; * dump-error: test that certain perl data trigger expected errors * load-error: test that certain YAML strings trigger expected errors All .tml files in a t/tml-local directory must have the TestML test points required by the corresponding test functions defined in the TestBridge library. Generally, files should be grouped by data type or feature so that related tests are kept together. CPAN-Meta-YAML-0.020/t/01_api.t000640 000766 000024 00000003061 14730103447 015633 0ustar00etherstaff000000 000000 # Testing of some API methods; use strict; use warnings; use lib 't/lib/'; use Test::More 0.88; use SubtestCompat; use TestBridge; use CPAN::Meta::YAML; subtest "default exports" => sub { ok( defined(&Load), 'Found exported Load function' ); ok( defined(&Dump), 'Found exported Dump function' ); ok( \&main::Load == \&CPAN::Meta::YAML::Load, 'Load is CPAN::Meta::YAML' ); ok( \&main::Dump == \&CPAN::Meta::YAML::Dump, 'Dump is CPAN::Meta::YAML' ); ok( !defined(&LoadFile), 'LoadFile function not exported' ); ok( !defined(&DumpFile), 'DumpFile function not exported' ); ok( !defined(&freeze), 'freeze function not exported' ); ok( !defined(&thaw), 'thaw functiona not exported' ); }; subtest "all exports" => sub { package main::all_exports; use Test::More 0.88; use CPAN::Meta::YAML qw/Load Dump LoadFile DumpFile freeze thaw/; ok( defined(&Load), 'Found exported Load function' ); ok( defined(&Dump), 'Found exported Dump function' ); ok( defined(&LoadFile), 'Found exported LoadFile function' ); ok( defined(&DumpFile), 'Found exported DumpFile function' ); ok( defined(&freeze), 'Found exported freeze function' ); ok( defined(&thaw), 'Found exported thaw functiona' ); }; subtest "constructor and documents" => sub { my @docs = ( { one => 'two' }, { three => 'four' } ); ok( my $yaml = CPAN::Meta::YAML->new( @docs ), "constructor" ); cmp_deeply( [ @$yaml ], \@docs, "the object is an arrayref of documents" ); }; done_testing; CPAN-Meta-YAML-0.020/t/30_yaml_spec_tml.t000640 000766 000024 00000002066 14730103447 017720 0ustar00etherstaff000000 000000 # Run the appropriate tests from https://github.com/ingydotnet/yaml-spec-tml use strict; use warnings; use lib 't/lib'; use Test::More 0.88; use SubtestCompat; use TestBridge; use TestUtils; my $JSON = json_class() or Test::More::plan skip_all => 'no JSON backends available!?'; diag 'using JSON backend: ' . $JSON . ' ' . $JSON->VERSION if not $ENV{PERL_CORE}; # Each spec test will need a different bridge and arguments: my @spec_tests = ( ['t/tml-spec/basic-data.tml', 'test_yaml_json', $JSON], ['t/tml-spec/multiline.tml', 'test_yaml_json', $JSON], # This test is currently failing massively. We use LAST to only run what is # covered so far. ['t/tml-spec/unicode.tml', 'test_code_point'], # uses JSON::PP ); for my $test (@spec_tests) { my ($file, $bridge, @args) = @$test; my $code = sub { my ($file, $blocks) = @_; subtest "YAML Spec Test; file: $file" => sub { my $func = \&{$bridge}; $func->($_) for @$blocks; }; }; run_testml_file($file, $code, @args); } done_testing; CPAN-Meta-YAML-0.020/t/00-report-prereqs.t000644 000766 000024 00000013601 14730103447 017776 0ustar00etherstaff000000 000000 #!perl use strict; use warnings; # This test was generated by Dist::Zilla::Plugin::Test::ReportPrereqs 0.029 use Test::More tests => 1; use ExtUtils::MakeMaker; use File::Spec; # from $version::LAX my $lax_version_re = qr/(?: undef | (?: (?:[0-9]+) (?: \. | (?:\.[0-9]+) (?:_[0-9]+)? )? | (?:\.[0-9]+) (?:_[0-9]+)? ) | (?: v (?:[0-9]+) (?: (?:\.[0-9]+)+ (?:_[0-9]+)? )? | (?:[0-9]+)? (?:\.[0-9]+){2,} (?:_[0-9]+)? ) )/x; # hide optional CPAN::Meta modules from prereq scanner # and check if they are available my $cpan_meta = "CPAN::Meta"; my $cpan_meta_pre = "CPAN::Meta::Prereqs"; my $HAS_CPAN_META = eval "require $cpan_meta; $cpan_meta->VERSION('2.120900')" && eval "require $cpan_meta_pre"; ## no critic # Verify requirements? my $DO_VERIFY_PREREQS = 1; sub _max { my $max = shift; $max = ( $_ > $max ) ? $_ : $max for @_; return $max; } sub _merge_prereqs { my ($collector, $prereqs) = @_; # CPAN::Meta::Prereqs object if (ref $collector eq $cpan_meta_pre) { return $collector->with_merged_prereqs( CPAN::Meta::Prereqs->new( $prereqs ) ); } # Raw hashrefs for my $phase ( keys %$prereqs ) { for my $type ( keys %{ $prereqs->{$phase} } ) { for my $module ( keys %{ $prereqs->{$phase}{$type} } ) { $collector->{$phase}{$type}{$module} = $prereqs->{$phase}{$type}{$module}; } } } return $collector; } my @include = qw( ); my @exclude = qw( ); # Add static prereqs to the included modules list my $static_prereqs = do './t/00-report-prereqs.dd'; # Merge all prereqs (either with ::Prereqs or a hashref) my $full_prereqs = _merge_prereqs( ( $HAS_CPAN_META ? $cpan_meta_pre->new : {} ), $static_prereqs ); # Add dynamic prereqs to the included modules list (if we can) my ($source) = grep { -f } 'MYMETA.json', 'MYMETA.yml'; my $cpan_meta_error; if ( $source && $HAS_CPAN_META && (my $meta = eval { CPAN::Meta->load_file($source) } ) ) { $full_prereqs = _merge_prereqs($full_prereqs, $meta->prereqs); } else { $cpan_meta_error = $@; # capture error from CPAN::Meta->load_file($source) $source = 'static metadata'; } my @full_reports; my @dep_errors; my $req_hash = $HAS_CPAN_META ? $full_prereqs->as_string_hash : $full_prereqs; # Add static includes into a fake section for my $mod (@include) { $req_hash->{other}{modules}{$mod} = 0; } for my $phase ( qw(configure build test runtime develop other) ) { next unless $req_hash->{$phase}; next if ($phase eq 'develop' and not $ENV{AUTHOR_TESTING}); for my $type ( qw(requires recommends suggests conflicts modules) ) { next unless $req_hash->{$phase}{$type}; my $title = ucfirst($phase).' '.ucfirst($type); my @reports = [qw/Module Want Have/]; for my $mod ( sort keys %{ $req_hash->{$phase}{$type} } ) { next if grep { $_ eq $mod } @exclude; my $want = $req_hash->{$phase}{$type}{$mod}; $want = "undef" unless defined $want; $want = "any" if !$want && $want == 0; if ($mod eq 'perl') { push @reports, ['perl', $want, $]]; next; } my $req_string = $want eq 'any' ? 'any version required' : "version '$want' required"; my $file = $mod; $file =~ s{::}{/}g; $file .= ".pm"; my ($prefix) = grep { -e File::Spec->catfile($_, $file) } @INC; if ($prefix) { my $have = MM->parse_version( File::Spec->catfile($prefix, $file) ); $have = "undef" unless defined $have; push @reports, [$mod, $want, $have]; if ( $DO_VERIFY_PREREQS && $HAS_CPAN_META && $type eq 'requires' ) { if ( $have !~ /\A$lax_version_re\z/ ) { push @dep_errors, "$mod version '$have' cannot be parsed ($req_string)"; } elsif ( ! $full_prereqs->requirements_for( $phase, $type )->accepts_module( $mod => $have ) ) { push @dep_errors, "$mod version '$have' is not in required range '$want'"; } } } else { push @reports, [$mod, $want, "missing"]; if ( $DO_VERIFY_PREREQS && $type eq 'requires' ) { push @dep_errors, "$mod is not installed ($req_string)"; } } } if ( @reports ) { push @full_reports, "=== $title ===\n\n"; my $ml = _max( map { length $_->[0] } @reports ); my $wl = _max( map { length $_->[1] } @reports ); my $hl = _max( map { length $_->[2] } @reports ); if ($type eq 'modules') { splice @reports, 1, 0, ["-" x $ml, "", "-" x $hl]; push @full_reports, map { sprintf(" %*s %*s\n", -$ml, $_->[0], $hl, $_->[2]) } @reports; } else { splice @reports, 1, 0, ["-" x $ml, "-" x $wl, "-" x $hl]; push @full_reports, map { sprintf(" %*s %*s %*s\n", -$ml, $_->[0], $wl, $_->[1], $hl, $_->[2]) } @reports; } push @full_reports, "\n"; } } } if ( @full_reports ) { diag "\nVersions for all modules listed in $source (including optional ones):\n\n", @full_reports; } if ( $cpan_meta_error || @dep_errors ) { diag "\n*** WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING ***\n"; } if ( $cpan_meta_error ) { my ($orig_source) = grep { -f } 'MYMETA.json', 'MYMETA.yml'; diag "\nCPAN::Meta->load_file('$orig_source') failed with: $cpan_meta_error\n"; } if ( @dep_errors ) { diag join("\n", "\nThe following REQUIRED prerequisites were not satisfied:\n", @dep_errors, "\n" ); } pass('Reported prereqs'); # vim: ts=4 sts=4 sw=4 et: CPAN-Meta-YAML-0.020/t/10_read.t000640 000766 000024 00000006227 14730103447 016004 0ustar00etherstaff000000 000000 use strict; use warnings; use utf8; use lib 't/lib/'; use Test::More 0.88; use SubtestCompat; use TestUtils; use TestBridge; use CPAN::Meta::YAML; #--------------------------------------------------------------------------# # read() should read these files without error #--------------------------------------------------------------------------# my %passes = ( array => { file => 'ascii.yml', perl => [ [ 'foo' ] ], }, 'multibyte UTF-8' => { file => 'multibyte.yml', perl => [ { author => 'Ævar Arnfjörð Bjarmason ' } ], utf8 => 'author', }, 'UTF-8 BOM' => { file => 'utf_8_bom.yml', perl => [ { author => 'Ævar Arnfjörð Bjarmason ' } ], utf8 => 'author', }, ); for my $key ( sort keys %passes ) { subtest $key => sub { my $case = $passes{$key}; my $file = test_data_file( $case->{file} ); ok( -f $file, "Found $case->{file}" ); my $got = eval { CPAN::Meta::YAML->read( $file ) }; is( $@, '', "CPAN::Meta::YAML reads without exception" ); SKIP: { skip( "Shortcutting after failure", 2 ) if $@; isa_ok( $got, 'CPAN::Meta::YAML' ) or diag "ERROR: " . CPAN::Meta::YAML->errstr; cmp_deeply( $got, $case->{perl}, "CPAN::Meta::YAML parses correctly" ); } if ( $case->{utf8} ) { ok( utf8::is_utf8( $got->[0]->{$case->{utf8}} ), "utf8 decoded" ); } # test that read method on object is also a constructor ok( my $got2 = eval { $got->read( $file ) }, "read() object method"); isnt( $got, $got2, "objects are different" ); cmp_deeply( $got, $got2, "objects have same content" ); } } #--------------------------------------------------------------------------# # read() should fail to read these files and provide expected errors #--------------------------------------------------------------------------# my %errors = ( 'latin1.yml' => qr/latin1\.yml.*does not map to Unicode/, 'utf_16_le_bom.yml' => qr/utf_16_le_bom\.yml.*does not map to Unicode/, ); for my $key ( sort keys %errors ) { subtest $key => sub { my $file = test_data_file( $key ); ok( -f $file, "Found $key" ); my $result = eval { CPAN::Meta::YAML->read( $file ) }; ok( !$result, "returned false" ); error_like( $errors{$key}, "Got expected error" ); }; } # Additional errors without a file to read subtest "bad read arguments" => sub { eval { CPAN::Meta::YAML->read(); }; error_like(qr/You did not specify a file name/, "Got expected error: no filename provided to read()" ); eval { CPAN::Meta::YAML->read( test_data_file('nonexistent.yml') ); }; error_like(qr/File '.*?' does not exist/, "Got expected error: nonexistent filename provided to read()" ); eval { CPAN::Meta::YAML->read( test_data_directory() ); }; error_like(qr/'.*?' is a directory, not a file/, "Got expected error: directory provided to read()" ); }; done_testing; # COPYRIGHT # vim: ts=4 sts=4 sw=4 et: CPAN-Meta-YAML-0.020/t/lib/000770 000766 000024 00000000000 14730103447 015144 5ustar00etherstaff000000 000000 CPAN-Meta-YAML-0.020/t/11_read_string.t000640 000766 000024 00000003235 14730103447 017367 0ustar00etherstaff000000 000000 use strict; use warnings; use lib 't/lib/'; use Test::More 0.88; use SubtestCompat; use TestUtils; use TestBridge; use CPAN::Meta::YAML (); #--------------------------------------------------------------------------# # Generally, read_string can be tested with .tml files in t/tml-local/* # # This file is for error tests that can't be easily tested via .tml #--------------------------------------------------------------------------# subtest 'read_string without arg' => sub { eval { CPAN::Meta::YAML->read_string(); }; error_like(qr/Did not provide a string to load/, "Got expected error: no string provided to read_string()" ); }; subtest 'YAML without newline' => sub { my $str = join("\n" => ('---', '- foo', '---', '- bar', '---')); my $obj = eval { CPAN::Meta::YAML->read_string($str); }; is( $@, '', "YAML without newline is OK"); }; subtest 'read_string as object method' => sub { ok( my $obj = CPAN::Meta::YAML->new( { foo => 'bar' } ), "new YAML object" ); ok( my $obj2 = $obj->read_string( "---\nfoo: bar\n" ), "read_string object method" ); isnt( $obj, $obj2, "objects are different" ); cmp_deeply( $obj, $obj2, "objects have same content" ); }; subtest 'invalid UTF-8' => sub { # get invalid UTF-8 by reading Latin-1 with lax :utf8 layer my $string = do { local $SIG{__WARN__} = sub {}; slurp( test_data_file('latin1.yml'), ":utf8" ); }; my $obj = eval { CPAN::Meta::YAML->read_string($string); }; is( $obj, undef, "read_string should return undef" ); error_like( qr/invalid UTF-8 string/, "Got expected error about invalid UTF-8 string" ); }; done_testing; CPAN-Meta-YAML-0.020/t/00-report-prereqs.dd000644 000766 000024 00000014166 14730103447 020131 0ustar00etherstaff000000 000000 do { my $x = { 'configure' => { 'requires' => { 'ExtUtils::MakeMaker' => '6.17', 'perl' => '5.008001' } }, 'develop' => { 'requires' => { 'Dist::Zilla' => '5', 'Dist::Zilla::Plugin::AppendExternalData' => '0', 'Dist::Zilla::Plugin::Authority' => '0', 'Dist::Zilla::Plugin::AutoPrereqs' => '0', 'Dist::Zilla::Plugin::CheckChangesHasContent' => '0', 'Dist::Zilla::Plugin::CheckMetaResources' => '0', 'Dist::Zilla::Plugin::CheckPrereqsIndexed' => '0', 'Dist::Zilla::Plugin::ConfirmRelease' => '0', 'Dist::Zilla::Plugin::Doppelgaenger' => '0.007', 'Dist::Zilla::Plugin::Encoding' => '0', 'Dist::Zilla::Plugin::Git::Check' => '0', 'Dist::Zilla::Plugin::Git::CheckFor::CorrectBranch' => '0', 'Dist::Zilla::Plugin::Git::Commit' => '0', 'Dist::Zilla::Plugin::Git::Contributors' => '0', 'Dist::Zilla::Plugin::Git::GatherDir' => '0', 'Dist::Zilla::Plugin::Git::NextVersion' => '0', 'Dist::Zilla::Plugin::Git::Push' => '0', 'Dist::Zilla::Plugin::Git::Tag' => '0', 'Dist::Zilla::Plugin::GithubMeta' => '0', 'Dist::Zilla::Plugin::License' => '0', 'Dist::Zilla::Plugin::MakeMaker' => '0', 'Dist::Zilla::Plugin::MakeMaker::Highlander' => '0.003', 'Dist::Zilla::Plugin::Manifest' => '0', 'Dist::Zilla::Plugin::MetaJSON' => '0', 'Dist::Zilla::Plugin::MetaNoIndex' => '0', 'Dist::Zilla::Plugin::MetaProvides::Package' => '0', 'Dist::Zilla::Plugin::MetaResources' => '0', 'Dist::Zilla::Plugin::MetaTests' => '0', 'Dist::Zilla::Plugin::MetaYAML' => '0', 'Dist::Zilla::Plugin::MinimumPerl' => '0', 'Dist::Zilla::Plugin::NextRelease' => '5.033', 'Dist::Zilla::Plugin::PkgVersion' => '0', 'Dist::Zilla::Plugin::Pod2Readme' => '0', 'Dist::Zilla::Plugin::PodSyntaxTests' => '0', 'Dist::Zilla::Plugin::PodWeaver' => '0', 'Dist::Zilla::Plugin::Prereqs::AuthorDeps' => '0', 'Dist::Zilla::Plugin::PromptIfStale' => '0', 'Dist::Zilla::Plugin::RemovePrereqs' => '0', 'Dist::Zilla::Plugin::RunExtraTests' => '0', 'Dist::Zilla::Plugin::Test::Compile' => '0', 'Dist::Zilla::Plugin::Test::ReportPrereqs' => '0', 'Dist::Zilla::Plugin::Test::Version' => '0', 'Dist::Zilla::Plugin::TestRelease' => '0', 'Dist::Zilla::Plugin::UploadToCPAN' => '0', 'File::Spec' => '0', 'File::Temp' => '0', 'IO::Handle' => '0', 'IPC::Open3' => '0', 'Software::License::Perl_5' => '0', 'Test::CPAN::Meta' => '0', 'Test::More' => '0', 'Test::Pod' => '1.41', 'Test::Version' => '1' } }, 'runtime' => { 'requires' => { 'B' => '0', 'Carp' => '0', 'Exporter' => '0', 'Fcntl' => '0', 'Scalar::Util' => '0', 'perl' => '5.008001', 'strict' => '0', 'warnings' => '0' } }, 'test' => { 'recommends' => { 'CPAN::Meta' => '2.120900' }, 'requires' => { 'ExtUtils::MakeMaker' => '0', 'File::Basename' => '0', 'File::Find' => '0', 'File::Spec' => '0', 'File::Spec::Functions' => '0', 'File::Temp' => '0.19', 'IO::Dir' => '0', 'JSON::PP' => '0', 'Test::More' => '0.88', 'base' => '0', 'lib' => '0', 'open' => '0', 'perl' => '5.008001', 'utf8' => '0', 'vars' => '0' } } }; $x; }CPAN-Meta-YAML-0.020/t/tml-spec/000770 000766 000024 00000000000 14730103447 016122 5ustar00etherstaff000000 000000 CPAN-Meta-YAML-0.020/t/data/000770 000766 000024 00000000000 14730103447 015307 5ustar00etherstaff000000 000000 CPAN-Meta-YAML-0.020/t/tml000750 000766 000024 00000006544 14730103447 015127 0ustar00etherstaff000000 000000 #!/usr/bin/env perl use strict; use warnings; use lib 'lib', 't/lib/'; use Test::More 0.88; use SubtestCompat; use Getopt::Long qw/:config passthrough/; use List::Util qw/first/; use TestBridge; use TestUtils; #--------------------------------------------------------------------------# # Note: This program is both the proxy to select .tml files for 'prove' and the # test-runner that 'prove' executes. #--------------------------------------------------------------------------# # match path prefix under t/ my %BRIDGE_MAP = ( 'tml-local/dump-error' => \&test_dump_error, 'tml-local/load-error' => \&test_load_error, 'tml-local/load-warning' => \&test_load_warning, 'tml-local/perl-to-yaml' => \&test_perl_to_yaml, 'tml-local/yaml-roundtrip' => \&test_yaml_roundtrip, 'tml-spec/basic-data.tml' => \&test_yaml_json, 'tml-spec/unicode.tml' => \&test_code_point, 'tml-world' => \&test_yaml_roundtrip, ); sub main { my ($verbose, $run_tests); GetOptions( 'run_test' => \$run_tests, ); if ( $run_tests ) { my $file = shift @ARGV; exit 0 unless -f $file; my ($bridge) = first { $file =~ m{^t/\Q$_} } keys %BRIDGE_MAP; die "No bridge found for $file" unless $bridge; run_testml_file( $file, sub { my ($file, $blocks) = @_; subtest "TestML dev runner: $file" => sub { $BRIDGE_MAP{$bridge}->($_) for @$blocks; }; done_testing; }, ); } else { my (@opts, @files, @patterns); for (@ARGV) { if ( /^-/ ) { push @opts, $_; } elsif ( -f ) { push @files, $_; } else { push @patterns, $_; } } # if we got no files or patterns, treat that as taking anything @patterns = "." if !@patterns && !@files; if (@patterns) { FILE: for my $file ( find_tml_files('t') ) { if ( first { $file =~ /$_/ } @patterns ) { push @files, $file; } } } exec( 'prove', @opts, '--exec', "$0 --run_test", @files ) if @files; } } main; __END__ =head1 NAME =for stopwords tml t/tml - run .tml files matching a pattern =head1 SYNOPSIS t/tml [prove options] [patterns] =head1 USAGE This program runs F against a set of F<.tml> files using their corresponding test bridge functions. Any arguments beginning with C<-> will be passed through to F. All other arguments will be used as patterns to select F<.tml> files found anywhere under the F directory. You can use shell globbing syntax, and let the shell expand the patterns, or you can quote/escape the patterns and let them be treated as Perl regular expressions. For example: t/tml unicode # paths matching qr/unicode/ t/tml basic uni # paths matching qr/basic/ or qr/uni/ t/tml 'local.*re' # paths matching qr/local.*re/ t/tml '\d+' # paths matching qr/\d+/ Examples of options for prove: t/tml -v quoting # verbose run of paths matching qr/quoting/ t/tml -j9 world # parallel run of paths matching qr/world/ t/tml -j9 # parallel run of all .tml files =cut CPAN-Meta-YAML-0.020/t/86_fail.t000640 000766 000024 00000001300 14730103447 016004 0ustar00etherstaff000000 000000 =pod This is an example of a serious design flaw in CPAN::Meta::YAML. It is generally a bad idea to fake out a parsing process. In this case, CPAN::Meta::YAML strips off all lines that look like comments. It should be easy to find dozens of bugs by looking at the assumptions the code makes and then finding a counter case like this. That's why I'm working on Tiny::YAML and YAML::Pegex, which are driven by a grammar. =cut use Test::More tests => 1; use CPAN::Meta::YAML; TODO: { local $TODO = "Failing tests for things CPAN::Meta::YAML does wrong"; my $yaml = <<'...'; - | # Perl sub: sub foo {} ... is Load($yaml)->[0], "# Perl sub:\nsub foo{}\n", "Comments in literal scalars"; } CPAN-Meta-YAML-0.020/t/01_compile.t000640 000766 000024 00000000553 14730103447 016515 0ustar00etherstaff000000 000000 # Load testing for CPAN::Meta::YAML use strict; use warnings; use lib 't/lib'; BEGIN { $| = 1; } use Test::More 0.88; # Check their perl version ok( "$]" >= 5.008001, "Your perl is new enough" ); # Does the module load require_ok( 'CPAN::Meta::YAML' ); require_ok( 'TestUtils' ); require_ok( 'TestBridge' ); require_ok( 'TestML::Tiny' ); done_testing; CPAN-Meta-YAML-0.020/t/data/latin1.yml000640 000766 000024 00000001114 14730103447 017216 0ustar00etherstaff000000 000000 --- invoice: 34843 date : 2001-01-23 bill-to: given : Chris family : Dumàrs address: lines: | 458 Walkman Dr. Suite #292 city : Royal Oak state : MI postal : 48046 product: - sku : BL394D quantity : 4 description : Basketball price : 450.00 - sku : BL4438H quantity : 1 description : Super Hoop price : 2392.00 tax : 251.42 total: 4443.52 comments: > Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338. CPAN-Meta-YAML-0.020/t/data/ascii.yml000640 000766 000024 00000000012 14730103447 017112 0ustar00etherstaff000000 000000 --- - foo CPAN-Meta-YAML-0.020/t/data/utf_8_bom.yml000640 000766 000024 00000000075 14730103447 017715 0ustar00etherstaff000000 000000 --- author: "Ævar Arnfjörð Bjarmason " CPAN-Meta-YAML-0.020/t/data/multibyte.yml000640 000766 000024 00000000072 14730103447 020046 0ustar00etherstaff000000 000000 --- author: "Ævar Arnfjörð Bjarmason " CPAN-Meta-YAML-0.020/t/data/utf_16_le_bom.yml000640 000766 000024 00000000026 14730103447 020450 0ustar00etherstaff000000 000000 ÿþ--- - foo CPAN-Meta-YAML-0.020/t/tml-spec/basic-data.tml000640 000766 000024 00000000466 14730103447 020635 0ustar00etherstaff000000 000000 === basic hash # This is just a simple one key hash. --- yaml a: b --- json {"a":"b"} === double quoted keys # Hash with quoted key with embedded newline --- yaml "a\nb": c --- json {"a\nb":"c"} # --- dump # "a\nb": c === basic array # This is just a simple one key hash. --- yaml - a -b --- json ["a","b"] CPAN-Meta-YAML-0.020/t/tml-spec/multiline.tml000640 000766 000024 00000001014 14730103447 020635 0ustar00etherstaff000000 000000 === basic multiline # This is just a simple one key hash. --- yaml a: | ciao a tutti --- json {"a":"ciao\na tutti\n"} === multiline with inner indentation # This is just a simple one key hash. --- yaml a: | ciao a tutti --- json {"a":"ciao\n a\ntutti\n"} === two multilines with variable inner indentation # This is just a simple one key hash. --- yaml - | ciao a tutti - | quanti voi amici --- json ["ciao\n a\n tutti\n","quanti\n voi\namici\n"] CPAN-Meta-YAML-0.020/t/tml-spec/unicode.tml000640 000766 000024 00000015774 14730103447 020303 0ustar00etherstaff000000 000000 # Test unicode strings in key and value contexts %TestML 0.1.0 ### # These tests target unicode characters that are handled special or known to be # problematic. Test YNY (YAML→Native→YAML) and NYN roundtripping. # # YAML scalar emission does quoting based on first character, presence of # escape characters, and special ambiguous cases like ': '. These ones # character strings go a long way towards making sure an implementation is # correct. ### # Make a mapping { "$code" : "$code" } where code is a unicode code point: # Dump mapping matches *yaml *code.dump_code_key_value == *yaml # Load *yaml then dump matches *yaml *yaml.load_yaml.dump_yaml == *yaml # Dump mapping the load memory-matches mapping *code.code_key_value.dump_yaml.load_yaml === *code.code_key_value # 0 → \0 "null" # # \z is the other YAML "null" encoding. Most implementations (including # libyaml), seem to go with \0 when emitting. === Code point 0 --- code: 0 --- yaml "\0": "\0" # 1-6,14-27,29-31 → \x## === Code point 1 --- code: 1 --- yaml "\x01": "\x01" # 7 → \a "bell" (alarm) === Code point 7 --- code: 7 --- yaml "\a": "\a" # 8 → \b "backspace" === Code point 8 --- code: 8 --- yaml "\b": "\b" # 9 → \t "horizontal tab" === Code point 9 --- code: 9 --- yaml "\t": "\t" # 10 → \n "linefeed" (newline) === Code point 10 --- code: 10 --- yaml "\n": "\n" # 11 → \v "vertical tab" === Code point 11 --- code: 11 --- yaml "\v": "\v" # 11 → \f "form feed" === Code point 12 --- code: 12 --- yaml "\f": "\f" # 11 → \f "carriage return" === Code point 13 --- code: 13 --- yaml "\r": "\r" # 27 → \e "escape" === Code point 27 --- code: 27 --- yaml "\e": "\e" # Space character needs quotes. === Code point 32 --- code: 32 --- yaml ' ': ' ' # ! is a tag indicator. Needs quotes. === Code point 33 --- code: 33 --- yaml '!': '!' # Quote single quotes with double quotes. === Code point 34 --- code: 34 --- yaml '"': '"' # '#' is comment character. Needs quotes. === Code point 35 --- code: 35 --- yaml '#': '#' # $ has no special meaning. No quotes. === Code point 36 --- code: 36 --- yaml $: $ # % is directive indicator. Needs quotees. === Code point 37 --- code: 37 --- yaml '%': '%' # & is anchor indicator. Needs quotes. === Code point 38 --- code: 38 --- yaml '&': '&' # Quote double quotes with single quotes. === Code point 39 --- code: 39 --- yaml "'": "'" # ( has no special meaning. No quotes. === Code point 40 --- code: 40 --- yaml (: ( # ) has no special meaning. No quotes. === Code point 41 --- code: 41 --- yaml ): ) # * is an alias indicator. Needs quotes. === Code point 42 --- code: 42 --- yaml '*': '*' # + has no special meaning. No quotes. === Code point 43 --- code: 43 --- yaml +: + # , is a list separator. Needs quotes. === Code point 44 --- code: 44 --- yaml ',': ',' # - is a sequence element marker. In many contexts it is not ambiguous when # unquoted, but in others it is ambiguous. libyaml always quotes it so going # with that for now. === Code point 45 --- code: 45 --- yaml '-': '-' # . has no special meaning. No quotes. === Code point 46 --- code: 46 --- yaml .: . # / has no special meaning. No quotes. === Code point 47 --- code: 47 --- yaml /: / # 48-57 → 0-9 "digitss" # These values are strings, so must quote them. === Code point 48 --- code: 48 --- yaml '0': '0' # : is a key/value separator. It is not always ambigous when not quoted, but # libyaml always quotes it at start of a string. Probably wise. Going with that # for now. === Code point 58 --- code: 58 --- yaml ':': ':' # ; has no special meaning. No quotes. === Code point 59 --- code: 59 --- yaml ;: ; # < has no special meaning. No quotes. === Code point 60 --- code: 60 --- yaml <: < # = has no special meaning. No quotes. === Code point 61 --- code: 61 --- yaml =: = # > is a folded scalar indicator. Needs quotes. === Code point 62 --- code: 62 --- yaml '>': '>' # ? is a mapping key indicator. Needs quotes. === Code point 63 --- code: 63 --- yaml '?': '?' # @ is a reserved character. Needs quotes. # TODO Check spec on this. === Code point 64 --- code: 64 --- yaml '@': '@' # 65-90 → A-Z "upper case letters". No quotes. === Code point 65 --- code: 65 --- yaml A: A # Some implementations think N means false. This should not be the case in a # default schema. No quotes. # # NOTE: # http://yaml.org/type/bool.html suggests that many simple strings should be # loaded as boolean, but this is an outdated concept. Currently, only the # words true/false/null (lower case) should be loaded specially (not as # strings). This may become even more restrictive in the future. ie Only # true/false/null in a flow context. === Code point 78 --- code: 78 --- yaml N: N # Some implementations think Y means true. This should not be the case in a # default schema. No quotes. === Code point 89 --- code: 89 --- yaml Y: Y # [ is a flow sequence start indicator. Needs quotes. === Code point 91 --- code: 91 --- yaml '[': '[' # \ is an escape indicator in double quoted strings. Used on its own it has no # special meaning. No quotes. === Code point 92 --- SKIP --- code: 92 --- yaml \: \ # ] is a flow sequence end indicator. Needs quotes. === Code point 93 --- code: 93 --- yaml ']': ']' # ^ has no special meaning. No quotes. === Code point 94 --- code: 94 --- yaml ^: ^ # _ has no special meaning. No quotes. === Code point 95 --- code: 95 --- yaml _: _ # ` is a reserved character. Needs quotes. === Code point 96 --- code: 96 --- yaml '`': '`' # 65-90 → a-z "lower case letters". No quotes. === Code point 97 --- code: 97 --- yaml a: a # Some implementations think n means false. This should not be the case in a # default schema. No quotes. === Code point 110 --- code: 110 --- yaml n: n # Some implementations think y means true. This should not be the case in a # default schema. No quotes. === Code point 121 --- code: 121 --- yaml y: y # { is a flow mapping start indicator. Needs quotes. === Code point 123 --- code: 123 --- yaml '{': '{' # | is a literal scalar indicator. Needs quotes. === Code point 124 --- code: 124 --- yaml '|': '|' # } is a flow mapping end indicator. Needs quotes. === Code point 125 --- code: 125 --- yaml '}': '}' # A single ~ has long been used as a plain scalar representation of null. This # should be deprecated, but may take a while. === Code point 126 --- code: 126 --- yaml '~': '~' --- unquoted ~: ~ # 127 → "escape" # YAML does not have a special character. YAML2 should consider \?. === Code point 127 --- code: 127 --- yaml "\x7F": "\x7F" # 80-84,86-159 → \x## === Code point 128 --- code: 128 --- yaml "\x80": "\x80" # 133 (\x85) → "next line" (NEL) === Code point 133 --- code: 133 --- yaml "\N": "\N" # 160 (\xA0) → "non-breaking space" # It seems extremely odd that YAML does not escape this. # Investigate further. === Code point 160 --- SKIP --- code: 160 --- yaml  :   # 161-… → From here on up use printable unicode chars. # XXX Need to look into other special code blocks. Especially those known to # libyaml. === Code point 161 --- code: 161 --- yaml ¡: ¡ CPAN-Meta-YAML-0.020/t/lib/TestUtils.pm000640 000766 000024 00000002064 14730103447 017443 0ustar00etherstaff000000 000000 package TestUtils; use strict; use warnings; use Exporter (); use File::Spec (); use File::Find (); our @ISA = qw{ Exporter }; our @EXPORT = qw{ find_tml_files json_class slurp test_data_directory test_data_file }; sub find_tml_files { my $dir = shift; my @files; File::Find::find( sub { push @files, $File::Find::name if -f and /\.tml$/ }, $dir ); return @files; } sub json_class { return eval { require JSON::MaybeXS; JSON::MaybeXS->VERSION('1.001000'); $JSON::MaybeXS::JSON_Class } || do { require JSON::PP; 'JSON::PP' }; } sub test_data_directory { return File::Spec->catdir( 't', 'data' ); } sub test_data_file { return File::Spec->catfile( test_data_directory(), shift ); } sub slurp { my $file = shift; local $/ = undef; open( FILE, " $file" ) or die "open($file) failed: $!"; binmode( FILE, $_[0] ) if @_ > 0; # binmode(FILE); # disable perl's BOM interpretation my $source = ; close( FILE ) or die "close($file) failed: $!"; $source; } 1; CPAN-Meta-YAML-0.020/t/lib/TestBridge.pm000640 000766 000024 00000027403 14730103447 017543 0ustar00etherstaff000000 000000 package TestBridge; use strict; use warnings; use lib 't/lib'; use open ':std', ':encoding(UTF-8)'; # force stdin, stdout, stderr into utf8 use Test::More 0.88; use SubtestCompat; use TestUtils; use TestML::Tiny; use CPAN::Meta::YAML; use Exporter (); our @ISA = qw{ Exporter }; our @EXPORT = qw{ run_all_testml_files run_testml_file test_yaml_roundtrip test_perl_to_yaml test_dump_error test_load_error test_load_warning test_yaml_json test_code_point error_like cmp_deeply _testml_has_points }; # regular expressions for checking error messages; incomplete, but more # can be added as more error messages get test coverage my %ERROR = ( E_CIRCULAR => qr{\QCPAN::Meta::YAML does not support circular references}, E_FEATURE => qr{\QCPAN::Meta::YAML does not support a feature}, E_PLAIN => qr{\QCPAN::Meta::YAML found illegal characters in plain scalar}, E_CLASSIFY => qr{\QCPAN::Meta::YAML failed to classify the line}, ); my %WARN = ( E_DUPKEY => qr{\QCPAN::Meta::YAML found a duplicate key}, ); # use XXX -with => 'YAML::XS'; #--------------------------------------------------------------------------# # run_all_testml_files # # Iterate over all .tml files in a directory using a particular test bridge # code # reference. Each file is wrapped in a subtest. #--------------------------------------------------------------------------# sub run_all_testml_files { my ($label, $dir, $bridge, @args) = @_; my $code = sub { my ($file, $blocks) = @_; subtest "$label: $file" => sub { $bridge->($_, @args) for @$blocks; }; }; my @files = find_tml_files($dir); run_testml_file($_, $code) for sort @files; } sub run_testml_file { my ($file, $code) = @_; my $blocks = TestML::Tiny->new( testml => $file, version => '0.1.0', )->{function}{data}; $code->($file, $blocks); } # retrieves all the keys in @point from the $block hash, returning them in # order, along with $block->{Label}. # returns false if any keys cannot be found sub _testml_has_points { my ($block, @points) = @_; my @values; for my $point (@points) { defined $block->{$point} or return; push @values, $block->{$point}; } push @values, $block->{Label}; return @values; } #--------------------------------------------------------------------------# # test_yaml_roundtrip # # two blocks: perl, yaml # # Tests that a YAML string loads to the expected perl data. Also, tests # roundtripping from perl->YAML->perl. # # We can't compare the YAML for roundtripping because CPAN::Meta::YAML doesn't # preserve order and comments. Therefore, all we can test is that given input # YAML we can produce output YAML that produces the same Perl data as the # input. # # The perl must be an array reference of data to serialize: # # [ $thing1, $thing2, ... ] # # However, if a test point called 'serializes' exists, the output YAML is # expected to match the input YAML and will be checked for equality. #--------------------------------------------------------------------------# sub test_yaml_roundtrip { my ($block) = @_; my ($yaml, $perl, $label) = _testml_has_points($block, qw(yaml perl)) or return; my %options = (); for (qw(serializes)) { if (defined($block->{$_})) { $options{$_} = 1; } } my $expected = eval $perl; die $@ if $@; bless $expected, 'CPAN::Meta::YAML'; subtest $label, sub { # Does the string parse to the structure my $yaml_copy = $yaml; my $got = eval { CPAN::Meta::YAML->read_string( $yaml_copy ); }; is( $@, '', "CPAN::Meta::YAML parses without error" ); is( $yaml_copy, $yaml, "CPAN::Meta::YAML does not modify the input string" ); SKIP: { skip( "Shortcutting after failure", 2 ) if $@; isa_ok( $got, 'CPAN::Meta::YAML' ); cmp_deeply( $got, $expected, "CPAN::Meta::YAML parses correctly" ) or diag "ERROR: $CPAN::Meta::YAML::errstr\n\nYAML:$yaml"; } # Does the structure serialize to the string. # We can't test this by direct comparison, because any # whitespace or comments would be lost. # So instead we parse back in. my $output = eval { $expected->write_string }; is( $@, '', "CPAN::Meta::YAML serializes without error" ); SKIP: { skip( "Shortcutting after failure", 5 ) if $@; ok( !!(defined $output and ! ref $output), "CPAN::Meta::YAML serializes to scalar", ); my $roundtrip = eval { CPAN::Meta::YAML->read_string( $output ) }; is( $@, '', "CPAN::Meta::YAML round-trips without error" ); skip( "Shortcutting after failure", 2 ) if $@; isa_ok( $roundtrip, 'CPAN::Meta::YAML' ); cmp_deeply( $roundtrip, $expected, "CPAN::Meta::YAML round-trips correctly" ); # Testing the serialization skip( "Shortcutting perfect serialization tests", 1 ) unless $options{serializes}; is( $output, $yaml, 'Serializes ok' ); } }; } #--------------------------------------------------------------------------# # test_perl_to_yaml # # two blocks: perl, yaml # # Tests that perl references serialize correctly to a specific YAML output # # The perl must be an array reference of data to serialize: # # [ $thing1, $thing2, ... ] #--------------------------------------------------------------------------# sub test_perl_to_yaml { my ($block) = @_; my ($perl, $yaml, $label) = _testml_has_points($block, qw(perl yaml)) or return; my $input = eval "no strict; $perl"; die $@ if $@; subtest $label, sub { my $result = eval { CPAN::Meta::YAML->new( @$input )->write_string }; is( $@, '', "write_string lives" ); is( $result, $yaml, "dumped YAML correct" ); }; } #--------------------------------------------------------------------------# # test_dump_error # # two blocks: perl, error # # Tests that perl references result in an error when dumped # # The perl must be an array reference of data to serialize: # # [ $thing1, $thing2, ... ] # # The error must be a key in the %ERROR hash in this file #--------------------------------------------------------------------------# sub test_dump_error { my ($block) = @_; my ($perl, $error, $label) = _testml_has_points($block, qw(perl error)) or return; my $input = eval "no strict; $perl"; die $@ if $@; chomp $error; my $expected = $ERROR{$error}; subtest $label, sub { my $result = eval { CPAN::Meta::YAML->new( @$input )->write_string }; ok( !$result, "returned false" ); error_like( $expected, "Got expected error" ); }; } #--------------------------------------------------------------------------# # test_load_error # # two blocks: yaml, error # # Tests that a YAML string results in an error when loaded # # The error must be a key in the %ERROR hash in this file #--------------------------------------------------------------------------# sub test_load_error { my ($block) = @_; my ($yaml, $error, $label) = _testml_has_points($block, qw(yaml error)) or return; chomp $error; my $expected = $ERROR{$error}; subtest $label, sub { my $result = eval { CPAN::Meta::YAML->read_string( $yaml ) }; is( $result, undef, 'read_string returns undef' ); error_like( $expected, "Got expected error" ) or diag "YAML:\n$yaml"; }; } #--------------------------------------------------------------------------# # test_load_warning # # two blocks: yaml, warning # # Tests that a YAML string results in warning when loaded # # The warning must be a key in the %WARN hash in this file #--------------------------------------------------------------------------# sub test_load_warning { my ($block) = @_; my ($yaml, $warning, $label) = _testml_has_points($block, qw(yaml warning)) or return; chomp $warning; my $expected = $WARN{$warning}; subtest $label, sub { # this is not in a sub like warning_like because of the danger of # matching the regex parameter against something earlier in the stack my @warnings; local $SIG{__WARN__} = sub { push @warnings, shift; }; my $result = eval { CPAN::Meta::YAML->read_string( $yaml ) }; is(scalar(@warnings), 1, 'got exactly one warning'); like( $warnings[0], $expected, 'Got expected warning', ) or diag "YAML:\n$yaml\n", 'warning: ', explain(\@warnings); }; } #--------------------------------------------------------------------------# # test_yaml_json # # two blocks: yaml, json # # Tests that a YAML string can be loaded to Perl and dumped to JSON and # match an expected JSON output. The expected JSON is loaded and dumped # to ensure similar JSON dump options. #--------------------------------------------------------------------------# sub test_yaml_json { my ($block, $json_lib) = @_; $json_lib ||= do { require JSON::PP; 'JSON::PP' }; my ($yaml, $json, $label) = _testml_has_points($block, qw(yaml json)) or return; subtest "$label", sub { # test YAML Load my $object = eval { CPAN::Meta::YAML::Load($yaml); }; my $err = $@; ok !$err, "YAML loads"; return if $err; # test YAML->Perl->JSON # N.B. round-trip JSON to decode any \uNNNN escapes and get to # characters my $want = $json_lib->new->encode( $json_lib->new->decode($json) ); my $got = $json_lib->new->encode($object); is $got, $want, "Load is accurate"; }; } #--------------------------------------------------------------------------# # test_code_point # # two blocks: code, yaml # # Tests that a Unicode codepoint is correctly dumped to YAML as both # key and value. # # The code test point must be a non-negative integer # # The yaml code point is the expected output of { $key => $value } where # both key and value are the character represented by the codepoint. #--------------------------------------------------------------------------# sub test_code_point { my ($block) = @_; my ($code, $yaml, $label) = _testml_has_points($block, qw(code yaml)) or return; subtest "$label - Unicode map key/value test" => sub { my $data = { chr($code) => chr($code) }; my $dump = CPAN::Meta::YAML::Dump($data); $dump =~ s/^---\n//; is $dump, $yaml, "Dump key and value of code point char $code"; my $yny = CPAN::Meta::YAML::Dump(CPAN::Meta::YAML::Load($yaml)); $yny =~ s/^---\n//; is $yny, $yaml, "YAML for code point $code YNY roundtrips"; my $nyn = CPAN::Meta::YAML::Load(CPAN::Meta::YAML::Dump($data)); cmp_deeply( $nyn, $data, "YAML for code point $code NYN roundtrips" ); } } #--------------------------------------------------------------------------# # error_like # # Test CPAN::Meta::YAML->errstr against a regular expression and clear the # errstr afterwards #--------------------------------------------------------------------------# sub error_like { my ($regex, $label) = @_; $label = "Got expected error" unless defined $label; local $Test::Builder::Level = $Test::Builder::Level + 1; my $ok = like( $@, $regex, $label ); return $ok; } #--------------------------------------------------------------------------# # cmp_deeply # # is_deeply with some better diagnostics #--------------------------------------------------------------------------# sub cmp_deeply { my ($got, $want, $label) = @_; local $Test::Builder::Level = $Test::Builder::Level + 1; is_deeply( $got, $want, $label ) or diag "GOT:\n", explain($got), "\nWANTED:\n", explain($want); } 1; CPAN-Meta-YAML-0.020/t/lib/TestML/000770 000766 000024 00000000000 14730103447 016314 5ustar00etherstaff000000 000000 CPAN-Meta-YAML-0.020/t/lib/SubtestCompat.pm000640 000766 000024 00000004066 14730103447 020304 0ustar00etherstaff000000 000000 use 5.008001; use strict; use warnings; package SubtestCompat; # XXX must be used with no_plan or done_testing use Test::More 0.88; use base 'Exporter'; our @EXPORT; our $INDENT = -2; # intercept 'skip_all' in subtest and turn into a regular skip sub _fake_plan { my ( $self, $cmd, $arg ) = @_; return unless $cmd; if ( $cmd eq 'skip_all' ) { die bless { reason => $arg }, "Subtest::SKIP"; } else { goto &Test::Builder::plan; } } unless ( Test::More->can("subtest") ) { *subtest = sub { my ( $label, $code ) = @_; local $Test::Builder::Level = $Test::Builder::Level + 1; local $INDENT = $INDENT + 2; $label = "TEST: $label"; my $sep_len = 60 - length($label); note( " " x $INDENT . "$label { " . ( " " x ($sep_len-$INDENT-2) ) ); eval { no warnings 'redefine'; local *Test::Builder::plan = \&_fake_plan; # only want subtest error reporting to look up to the code ref # for where test was called, not further up to *our* callers, # so we *reset* the Level, rather than increment it local $Test::Builder::Level = 1; $code->(); }; if ( my $err = $@ ) { if ( ref($err) eq 'Subtest::SKIP' ) { SKIP: { skip $err->{reason}, 1; } } else { fail("SUBTEST: $label"); diag("Caught exception: $err"); die "$err\n"; } } note( " " x $INDENT . "}" ); }; push @EXPORT, 'subtest'; } elsif ( !eval { Test::More->VERSION(0.95_01) } ) { my $subtest = \&Test::Builder::subtest; no warnings 'redefine'; *Test::Builder::subtest = sub { my ($self, $name, $subtests, @args) = @_; my $sub = sub { $subtests->(@_); $self->done_testing unless $self->{Have_Plan} || $self->{No_Plan} || $self->{Skip_All}; }; return $self->$subtest($name, $sub, @args); }; } 1; CPAN-Meta-YAML-0.020/t/lib/TestML/Tiny.pm000640 000766 000024 00000020623 14730103447 017577 0ustar00etherstaff000000 000000 use 5.008001; use strict; use warnings; package TestML::Tiny; ; # original $VERSION removed by Doppelgaenger use Carp(); use Test::More 0.88 (); # use XXX; sub import { strict->import; warnings->import; } sub new { my $self = bless { @_[1..$#_] }, $_[0]; my $testml = $self->_get_testml; my $bridge = $self->_get_bridge; $self->{runtime} ||= TestML::Tiny::Runtime->new( bridge => $bridge, ); my $compiler = TestML::Tiny::Compiler->new( $self->{version} ? (version => $self->{version}) : (), ); $self->{function} = $compiler->compile($testml); return $self; } sub run { my ($self) = @_; my $runtime = $self->{runtime} || ''; Carp::croak "Missing or invalid runtime object for TestML::Tiny::run()" unless defined($runtime) and ref($runtime) eq 'TestML::Tiny::Runtime'; $runtime->run; } sub _get_testml { my ($self) = @_; my $testml = $self->{testml} or Carp::croak "TestML object requires a testml attribute"; $testml = $self->_slurp($testml) if $testml !~ /\n/; return $testml; } sub _get_bridge { my ($self) = @_; my $bridge = $self->{bridge} || 'main'; return $bridge if ref $bridge; eval "require $bridge"; Carp::croak $@ if $@ and $@ !~ /^Can't locate /; return ( defined(&{"${bridge}::new"}) ? $bridge->new : bless {}, $bridge ); } sub _slurp { open my $fh, "<:raw:encoding(UTF-8)", $_[1] or die "Can't open $_[1] for input"; local $/; <$fh>; } #------------------------------------------------------------------------------ package TestML::Tiny::Runtime; # use XXX; sub new { my $self = $TestML::Tiny::Runtime::Singleton = bless { @_[1..$#_] }, $_[0]; }; sub run { Test::More::fail 'not done yet!'; Test::More::done_testing; } #------------------------------------------------------------------------------ package TestML::Tiny::Compiler; # use XXX; my $ID = qr/\w+/; my $SP = qr/[\ \t]/; my $LINE = qr/.*$/m; my $DIRECTIVE = qr/^%($ID)$SP+($LINE)/m; sub new { my $self = bless { @_[1..$#_] }, $_[0]; } sub runtime { $TestML::Tiny::Runtime::Singleton; } sub compile { my ($self, $testml) = @_; my $function = $self->{function} = TestML::Tiny::Function->new; $self->{testml} = $testml; $self->preprocess; my $version = $self->check_version; my ($code_syntax, $data_syntax) = @{$self}{qw(code_syntax data_syntax)}; my $code_method = "compile_code_${code_syntax}_$version"; Carp::croak "Don't know how to compile TestML '$code_syntax' code" unless $self->can($code_method); my $data_method = "compile_data_${data_syntax}_$version"; Carp::croak "Don't know how to compile TestML '$data_syntax' data" unless $self->can($data_method); $function->{statements} = $self->$code_method; $function->{data} = $self->$data_method; return $function; } my %directives = ( code_syntax => 'tiny', data_syntax => 'testml', data_marker => '===', block_marker => '===', point_marker => '---', ); sub preprocess { my ($self) = @_; my $version = $self->{version} || undef; my $testml = $self->{testml}; my $directives = [ $testml =~ /$DIRECTIVE/gm ]; $testml =~ s/($DIRECTIVE)/#$1/g; while (@$directives) { my ($key, $value) = splice(@$directives, 0, 2); if ($key eq "TestML") { $self->check_not_set_and_set($key, $value, 'version'); } elsif ($key eq "BlockMarker") { $self->check_not_set_and_set( 'BlockMarker', $value, 'block_marker' ); ($self->{block_marker} = $value) =~ s/([\*\^\$\+\?\(\)\.])/\\$1/g; } elsif ($key eq "PointMarker") { $self->check_not_set_and_set( 'PointMarker', $value, 'point_marker' ); ($self->{point_marker} = $value) =~ s/([\*\^\$\+\?\(\)\.])/\\$1/g; } elsif ($key eq "CodeSyntax") { die "Untested"; $self->check_not_set_and_set( 'CodeSyntax', $value, 'code_syntax' ); $self->{code_syntax} = $value; } elsif ($key eq "DataSyntax") { die "Untested"; $self->check_not_set_and_set( 'DataSyntax', $value, 'data_syntax' ); $self->{data_syntax} = $value; } else { Carp::croak "Unknown TestML directive: '%$key'"; } } $self->{data_marker} = $self->{block_marker} if not($self->{data_marker}) and $self->{block_marker}; for my $directive (keys %directives) { $self->{$directive} ||= $directives{$directive}; } ($self->{code}, $self->{data}) = ($testml =~ /(.*?)(^$self->{data_marker}.*)/msg); $self->{code} ||= ''; $self->{data} ||= ''; } sub check_not_set_and_set { my ($self, $key, $value, $attr) = @_; if (defined $self->{$attr} and $self->{$attr} ne $value) { Carp::croak "Can't set TestML '$key' directive to '$value'. " . "Already set to '$self->{$attr}'"; } $self->{$attr} = $value; } sub check_version { my ($self) = @_; my $version = $self->{version} || undef; Carp::croak "TestML syntax version not defined. Cannot continue" unless defined $version; Carp::croak "Invalid value for TestML version '$version'. Must be 0.1.0" unless $version eq '0.1.0'; $version =~ s/\./_/g; return $version; } sub compile_code_tiny_0_1_0 { my ($self) = @_; my $num = 1; [ grep { not /(^#|^\s*$)/ } split /\n/, $self->{code} ]; } sub compile_data_testml_0_1_0 { my ($self) = @_; my $lines = [ grep { ! /^#/ } split /\n/, $self->{data} ]; my $blocks = []; my $parse = []; push @$lines, undef; # sentinel while (@$lines) { push @$parse, shift @$lines; if (!defined($lines->[0]) or $lines->[0] =~ /^$self->{block_marker}/ ) { my $block = $self->_parse_testml_block($parse); push @$blocks, $block unless exists $block->{SKIP}; last if exists $block->{LAST}; $parse = []; # clear for next parse } last if !defined($lines->[0]); } my $only = [ grep { exists $_->{ONLY} } @$blocks ]; return @$only ? $only : $blocks; } sub _parse_testml_block { my ($self, $lines) = @_; my ($label) = $lines->[0] =~ /^$self->{block_marker}(?:\s+(.*))?$/; shift @$lines until not(@$lines) or $lines->[0] =~ /^$self->{point_marker} +\w+/; my $block = $self->_parse_testml_points($lines); $block->{Label} = $label || ''; return $block; } sub _parse_testml_points { my ($self, $lines) = @_; my $block = {}; while (@$lines) { my $line = shift @$lines; $line =~ /^$self->{point_marker} +(\w+)/ or die "Invalid TestML line:\n'$line'"; my $point_name = $1; die "$block repeats $point_name" if exists $block->{$point_name}; $block->{$point_name} = ''; if ($line =~ /^$self->{point_marker} +(\w+): +(.*?) *$/) { ($block->{$1} = $2) =~ s/^ *(.*?) *$/$1/; shift @$lines while @$lines and $lines->[0] !~ /^$self->{point_marker} +(\w)/; } elsif ($line =~ /^$self->{point_marker} +(\w+)$/) { $point_name = $1; while ( @$lines ) { $line = shift @$lines; if ($line =~ /^$self->{point_marker} \w+/) { unshift @$lines, $line; last; } $block->{$point_name} .= "$line\n"; } $block->{$point_name} =~ s/\n\s*\z/\n/; $block->{$point_name} =~ s/^\\//gm; } else { die "Invalid TestML line:\n'$line'"; } } return $block; } #------------------------------------------------------------------------------ package TestML::Tiny::Function; sub new { my $self = bless { statements => [], data => [], namespace => {}, }, $_[0]; } #------------------------------------------------------------------------------ package TestML::Tiny::Bridge; sub new { my $self = bless { @_[1..$#_] }, $_[0]; } #------------------------------------------------------------------------------ package TestML::Tiny::Library::Standard; sub new { my $self = bless { @_[1..$#_] }, $_[0]; } 1; CPAN-Meta-YAML-0.020/t/tml-local/load-error/000770 000766 000024 00000000000 14730103447 020330 5ustar00etherstaff000000 000000 CPAN-Meta-YAML-0.020/t/tml-local/perl-to-yaml/000770 000766 000024 00000000000 14730103447 020604 5ustar00etherstaff000000 000000 CPAN-Meta-YAML-0.020/t/tml-local/load-warning/000770 000766 000024 00000000000 14730103447 020644 5ustar00etherstaff000000 000000 CPAN-Meta-YAML-0.020/t/tml-local/yaml-roundtrip/000770 000766 000024 00000000000 14730103447 021250 5ustar00etherstaff000000 000000 CPAN-Meta-YAML-0.020/t/tml-local/dump-error/000770 000766 000024 00000000000 14730103447 020356 5ustar00etherstaff000000 000000 CPAN-Meta-YAML-0.020/t/tml-local/dump-error/circular.tml000640 000766 000024 00000000560 14730103447 022700 0ustar00etherstaff000000 000000 === Circular Reference Protection # When we try to serialize, it should NOT infinite loop --- perl $VAR1 = [ { 'a' => 'b', 'c' => [ {}, 2 ] }, [] ]; $VAR1->[0]{'c'}[0] = $VAR1->[0]; $VAR1->[1] = $VAR1->[0]{'c'}; [ $VAR1 ] --- error: E_CIRCULAR CPAN-Meta-YAML-0.020/t/tml-local/yaml-roundtrip/scalar.tml000640 000766 000024 00000003520 14730103447 023232 0ustar00etherstaff000000 000000 %PointMarker +++ # Just a scalar === one_scalar +++ yaml --- foo +++ perl [ 'foo' ] === one_scalar2 +++ yaml --- foo +++ perl [ 'foo' ] === two_scalar +++ yaml --- foo --- bar +++ perl [ 'foo', 'bar' ] ##################################################################### # Support for literal multi-line scalars # Declarative multi-line scalar === simple_multiline +++ yaml --- foo: > bar baz +++ perl [ { foo => "bar baz\n" } ] # Piped multi-line scalar === indented +++ yaml --- - | foo bar - 1 +++ perl [ [ "foo\nbar\n", 1 ] ] # ... with a pointless hyphen === indented +++ yaml --- - |- foo bar - 1 +++ perl [ [ "foo\nbar", 1 ] ] ##################################################################### # Hitchhiker Scalar === hitchhiker scalar +++ yaml --- 42 +++ perl [ 42 ] +++ serializes ##################################################################### # Newlines and tabs === special characters +++ yaml foo: "foo\\\n\tbar" +++ perl [ { foo => "foo\\\n\tbar" } ] ##################################################################### # Unprintable Characters === unprintable +++ yaml --- "foo\n\x00" +++ perl [ "foo\n\0" ] ##################################################################### # Ticker #32402 # Tests a particular pathological case === Pathological >< case +++ yaml --- - value - '><' +++ perl [ [ 'value', '><' ] ] ##################################################################### # Special Characters === Special Characters +++ SKIP # Encoding failure +++ yaml --- - "Ingy d\xC3\xB6t Net" +++ perl [ [ "Ingy d\xC3\xB6t Net" ] ] ###################################################################### # Check illegal characters that are in legal places === Bang in a quote +++ yaml --- 'Wow!' +++ perl [ "Wow!" ] === Ampersand in a quote +++ yaml --- 'This&that' +++ perl [ "This&that" ] CPAN-Meta-YAML-0.020/t/tml-local/yaml-roundtrip/mapping.tml000640 000766 000024 00000004550 14730103447 023424 0ustar00etherstaff000000 000000 === Empty mapping --- yaml \--- {} --- perl [ {} ] # Simple hashs === one_hash1 --- yaml --- foo: bar --- perl [ { foo => 'bar' } ] === one_hash2 --- yaml --- foo: bar this: ~ --- perl [ { this => undef, foo => 'bar' } ] === one_hash3 --- yaml --- -foo: bar --- perl [ { '-foo' => 'bar' } ] # Implicit document start === implicit_hash --- yaml foo: bar --- perl [ { foo => 'bar' } ] # Make sure we support x-foo keys === x-foo key --- yaml --- x-foo: 1 --- perl [ { 'x-foo' => 1 } ] # Hash key legally containing a colon === module_hash_key --- yaml --- Foo::Bar: 1 --- perl [ { 'Foo::Bar' => 1 } ] # Hash indented === hash_indented --- yaml --- foo: bar --- perl [ { foo => "bar" } ] ##################################################################### # Empty Values and Premature EOF === empty hash keys --- yaml --- foo: 0 requires: build_requires: --- perl [ { foo => 0, requires => undef, build_requires => undef } ] --- noyamlpm ##################################################################### # Confirm we can read the synopsis === synopsis --- yaml --- rootproperty: blah section: one: two three: four Foo: Bar empty: ~ --- perl [ { rootproperty => 'blah', section => { one => 'two', three => 'four', Foo => 'Bar', empty => undef, }, } ] ##################################################################### # Indentation after empty hash value === Indentation after empty hash value --- yaml --- Test: optmods: Bad: 0 Foo: 1 Long: 0 version: 5 Test_IncludeA: optmods: Test_IncludeB: optmods: _meta: name: 'test profile' note: 'note this test profile' --- perl [ { Test => { optmods => { Bad => 0, Foo => 1, Long => 0, }, version => 5, }, Test_IncludeA => { optmods => undef, }, Test_IncludeB => { optmods => undef, }, _meta => { name => 'test profile', note => 'note this test profile', }, } ] ##################################################################### # Spaces in the Key === spaces in the key --- yaml --- the key: the value --- perl [ { 'the key' => 'the value' } ] # Complex keys === key_with_whitespace --- yaml --- a b: c d --- perl [ { 'a b' => 'c d' } ] === quoted_empty_key --- yaml --- '': foo --- perl [ { '' => 'foo' } ] CPAN-Meta-YAML-0.020/t/tml-local/yaml-roundtrip/comment.tml000640 000766 000024 00000004313 14730103447 023430 0ustar00etherstaff000000 000000 ##################################################################### # Main Tests === Properly ignore comments --- yaml --- a: b#content c: d #comment e: - f #comment - g# content h: 'single' # comment h2: 'single # content' # comment i: "double" # comment i2: "double # content" # comment j: | # comment literal # content block # content k: {} # comment l: [] # comment m: # comment n: o --- perl [ { a => 'b#content', c => 'd', e => [ 'f', 'g# content', ], h => 'single', h2 => 'single # content', i => 'double', i2 => 'double # content', j => "literal # content\nblock # content\n", k => {}, l => [], m => { n => 'o', }, }, ] --- noyamlpm # Repeat, with otherwise illegal characters in the comments === Properly ignore comments (with otherwise illegal characters) --- yaml --- a: b#content c: d #comment '"!&@%` e: - f #comment '"!&@%` - g# content h: 'single' # comment '"!&@%` h2: 'single # content' # comment '"!&@%` i: "double" # comment '"!&@%` i2: "double # content" # comment '"!&@%` j: | # comment '"!&@%` literal # content block # content k: {} # comment '"!&@%` l: [] # comment '"!&@%` m: # comment '"!&@%` n: o --- perl [ { a => 'b#content', c => 'd', e => [ 'f', 'g# content', ], h => 'single', h2 => 'single # content', i => 'double', i2 => 'double # content', j => "literal # content\nblock # content\n", k => {}, l => [], m => { n => 'o', }, }, ] --- noyamlpm #################################################################### # Comment on the Document Line === comment header --- yaml --- # Comment foo: bar --- perl [ { foo => 'bar' } ] --- noyamlpm # Empty comments === empty_comment_in_list --- yaml --- - foo \# - bar --- perl [ [ 'foo', 'bar' ] ] === empty_comment_in_hash --- yaml --- foo: bar \# foo one: two --- perl [ { foo => 'bar', one => 'two' } ] CPAN-Meta-YAML-0.020/t/tml-local/yaml-roundtrip/collection.tml000640 000766 000024 00000003530 14730103447 024121 0ustar00etherstaff000000 000000 #--------------------------------------------------------------------------# # This file is for testing combinations of sequences and mappings #--------------------------------------------------------------------------# ##################################################################### # Null HASH/ARRAY === null hash in array --- yaml --- - foo - {} - bar --- perl [ [ 'foo', {}, 'bar' ] ] === null array in array --- yaml --- - foo - [] - bar --- perl [ [ 'foo', [], 'bar' ] ] === null hash in hash --- yaml --- foo: {} bar: 1 --- perl [ { foo => {}, bar => 1 } ] === null array in hash --- yaml --- foo: [] bar: 1 --- perl [ { foo => [], bar => 1 } ] # Simple array inside a hash with an undef === array_in_hash --- yaml --- foo: - bar - ~ - baz --- perl [ { foo => [ 'bar', undef, 'baz' ] } ] # Simple hash inside a hash with an undef === hash_in_hash --- yaml --- foo: ~ bar: foo: bar --- perl [ { foo => undef, bar => { foo => 'bar' } } ] # Mixed hash and scalars inside an array === hash_in_array --- yaml --- - foo: ~ this: that - foo - ~ - foo: bar this: that --- perl [ [ { foo => undef, this => 'that' }, 'foo', undef, { foo => 'bar', this => 'that' }, ] ] ###################################################################### # Non-Indenting Sub-List === Non-indenting sub-list --- yaml --- foo: - list bar: value --- perl [ { foo => [ 'list' ], bar => 'value' } ] --- noyamlpm # Inline nested hash === inline_nested_hash --- yaml --- - ~ - foo: bar this: that - baz --- perl [ [ undef, { foo => 'bar', this => 'that' }, 'baz' ] ] # RT 51491 === space after hypen --- yaml \--- FOO: - bar: baz --- perl [ { 'FOO' => [ { bar => 'baz' } ] } ] # RT 92916 (a Test::Database ticket) === colon at end of key --- yaml \--- dbi:SQLite:: foo: bar --- perl [ { 'dbi:SQLite:' => { 'foo' => 'bar' } } ] CPAN-Meta-YAML-0.020/t/tml-local/yaml-roundtrip/quoting.tml000640 000766 000024 00000003571 14730103447 023461 0ustar00etherstaff000000 000000 === Empty double-quote --- yaml \--- - "" --- perl [ [ "" ] ] # Simple single quote === single_quote1 --- yaml --- - 'foo' --- perl [ [ 'foo' ] ] === single_spaces --- yaml --- - ' ' --- perl [ [ ' ' ] ] === single_null --- yaml --- - '' --- perl [ [ '' ] ] # Double quotes === only_spaces --- noyamlpm --- yaml --- " " --- perl [ ' ' ] === leading_trailing_spaces --- noyamlpm --- yaml --- " foo" --- "bar " --- perl [ " foo", "bar " ] === single quotes in double quotes --- yaml \--- "'foo'" --- perl [ "'foo'" ] === double quotes in single quotes --- yaml \--- '"foo"' --- perl [ '"foo"' ] ##################################################################### # Quote vs Hash === hash-like quote --- yaml --- author: - 'mst: Matt S. Trout ' --- perl [ { author => [ 'mst: Matt S. Trout ' ] } ] ##################################################################### # Quote and Escaping Idiosyncracies === single quote subtleties --- yaml --- name1: 'O''Reilly' name2: 'O''Reilly O''Tool' name3: 'Double '''' Quote' --- perl [ { name1 => "O'Reilly", name2 => "O'Reilly O'Tool", name3 => "Double '' Quote", } ] === single quote subtleties --- yaml --- slash1: '\\' slash2: '\\foo' slash3: '\\foo\\\\' --- perl [ { slash1 => "\\\\", slash2 => "\\\\foo", slash3 => "\\\\foo\\\\\\\\", } ] ##################################################################### # Check Multiple-Escaping # RT #42119: write of two single quotes === Multiple escaping of quote ok --- yaml --- "A'B'C" --- perl [ "A'B'C" ] # Escapes without whitespace === Multiple escaping of escape ok --- yaml \--- A\B\C --- perl [ "A\\B\\C" ] # Escapes with whitespace === Multiple escaping of escape with whitespace ok --- yaml --- 'A\B \C' --- perl [ "A\\B \\C" ] === Single Dash --- yaml --- foo: '-' --- perl [ { foo => '-' } ] CPAN-Meta-YAML-0.020/t/tml-local/yaml-roundtrip/document.tml000640 000766 000024 00000004632 14730103447 023610 0ustar00etherstaff000000 000000 ##################################################################### # Support for YAML version directives # Simple inline case (comment variant) === simple_doctype_comment --- yaml --- #YAML:1.0 foo: bar --- perl [ { foo => 'bar' } ] --- nosyck # Simple inline case (percent variant) === simple_doctype_percent --- yaml --- %YAML:1.0 foo: bar --- perl [ { foo => 'bar' } ] --- noyamlpm --- noxs # Simple header (comment variant) === predocument_1_0 --- yaml \%YAML:1.0 --- foo: bar --- perl [ { foo => 'bar' } ] --- noyamlpm --- nosyck --- noxs # Simple inline case (comment variant) === predocument_1_1 --- yaml \%YAML 1.1 --- foo: bar --- perl [ { foo => 'bar' } ] --- noyamlpm --- nosyck # Multiple inline documents (comment variant) === multi_doctype_comment --- yaml --- #YAML:1.0 foo: bar --- #YAML:1.0 - 1 --- #YAML:1.0 foo: bar --- perl [ { foo => 'bar' }, [ 1 ], { foo => 'bar' } ] # Simple pre-document case (comment variant) === predocument_percent --- yaml \%YAML 1.1 --- foo: bar --- perl [ { foo => 'bar' } ] --- noyamlpm --- nosyck # Simple pre-document case (comment variant) === predocument_comment --- yaml \#YAML 1.1 --- foo: bar --- perl [ { foo => 'bar' } ] === two documents --- yaml \--- - foo \--- - bar --- perl [ [ 'foo' ], [ 'bar' ] ] # Document ending (hash) === document_end_hash --- yaml --- foo: bar ... --- perl [ { foo => "bar" } ] --- noyamlpm --- nosyck # Document ending (array) === document_end_array --- yaml --- - foo ... --- perl [ [ 'foo' ] ] --- noyamlpm # Multiple documents (simple) === multi_document_simple --- yaml --- - foo ... --- - foo ... --- perl [ [ 'foo' ], [ 'foo' ] ] --- noyamlpm # Multiple documents (whitespace-separated) === multi_document_space --- yaml --- - foo ... --- - foo ... --- perl [ [ 'foo' ], [ 'foo' ] ] --- noyamlpm ##################################################################### # Sample Testing # Test a completely empty document === empty --- yaml --- perl [ ] # Just a newline ### YAML.pm has a bug where it dies on a single newline === only_newlines --- yaml \ \ --- perl [ ] # Just a comment === only_comment --- yaml \# comment --- perl [ ] # Empty documents === only_header --- yaml --- --- perl [ undef ] === two_header --- yaml --- --- --- perl [ undef, undef ] === one_undef --- yaml --- ~ --- perl [ undef ] === one_undef2 --- yaml --- ~ --- perl [ undef ] === two_undef --- yaml --- ~ --- --- perl [ undef, undef ] CPAN-Meta-YAML-0.020/t/tml-local/yaml-roundtrip/sequence.tml000640 000766 000024 00000002301 14730103447 023571 0ustar00etherstaff000000 000000 === Empty sequence --- yaml \--- [] --- perl [ [] ] # Simple lists === one_list1 --- yaml --- - foo --- perl [ [ 'foo' ] ] # Implicit document start === implicit_array --- yaml - foo --- perl [ [ 'foo' ] ] === one_list2 --- yaml --- - foo - bar --- perl [ [ 'foo', 'bar' ] ] === one_listundef --- yaml --- - ~ - bar --- perl [ [ undef, 'bar' ] ] === one_listundefs --- noyamlpm --- yaml --- - ~ - - --- perl [ [ undef, undef, undef ] ] ##################################################################### # Empty Values and Premature EOF === empty array keys --- yaml --- - foo - - --- perl [ [ 'foo', undef, undef ] ] --- noyamlpm ##################################################################### # Empty Quote Line === empty quote line --- yaml --- - foo \# - bar --- perl [ [ "foo", "bar" ] ] ##################################################################### # Trailing Whitespace # === trailing whitespace --- yaml --- abstract: Generate fractal curves foo: ~ arr: # THESE LINES HAVE INTENTIONAL TRAILING WHITESPACE - foo - ~ - 'bar' --- perl [ { abstract => 'Generate fractal curves', foo => undef, arr => [ 'foo', undef, 'bar' ], } ] CPAN-Meta-YAML-0.020/t/tml-local/load-warning/document.tml000640 000766 000024 00000000111 14730103447 023170 0ustar00etherstaff000000 000000 === mapping with double key --- yaml foo: 1 foo: 2 --- warning: E_DUPKEY CPAN-Meta-YAML-0.020/t/tml-local/perl-to-yaml/quoting.tml000640 000766 000024 00000000531 14730103447 023006 0ustar00etherstaff000000 000000 === Quote boolean-like string (scalar) # Strings that could be confused with booleans should be quoted --- perl [ 'true' ] --- yaml \--- 'true' === Quote boolean-like string (list) --- perl [ [ qw{ null true false } ] ] --- yaml \--- - 'null' - 'true' - 'false' === Quote scalars ending in colon --- perl [ [ 'A:' ] ] --- yaml \--- - 'A:' CPAN-Meta-YAML-0.020/t/tml-local/load-error/scalar.tml000640 000766 000024 00000001136 14730103447 022313 0ustar00etherstaff000000 000000 === multiline quote --- yaml - 'Multiline quote' --- error: E_FEATURE === dash dash 2 --- yaml - - 2 --- error: E_PLAIN === dash --- yaml foo: - --- error: E_PLAIN === leading ampersand --- yaml foo: @INC --- error: E_PLAIN === leading percent --- yaml foo: %INC --- error: E_PLAIN === trailing colon --- yaml foo: bar: --- error: E_PLAIN === key key value --- yaml foo: bar: baz --- error: E_PLAIN === backticks --- yaml foo: `perl -V` --- error: E_PLAIN === double-dash --- yaml -- --- error: E_PLAIN === multi-line scalar document starting on header --- yaml \--- foo bar --- error: E_CLASSIFY CPAN-Meta-YAML-0.020/t/tml-local/load-error/document.tml000640 000766 000024 00000000125 14730103447 022661 0ustar00etherstaff000000 000000 === scalar document followed by mapping --- yaml \--- foo a: 1 --- error: E_CLASSIFY CPAN-Meta-YAML-0.020/t/tml-local/load-error/tag.tml000640 000766 000024 00000000221 14730103447 021613 0ustar00etherstaff000000 000000 === version object --- yaml \--- version: !!perl/hash:version original: v2.0.2 qv: 1 version: - 2 - 0 - 2 --- error: E_FEATURE CPAN-Meta-YAML-0.020/t/tml-world/ITS-SIN-FIDS-Content-XML.tml000640 000766 000024 00000001701 14730103447 022712 0ustar00etherstaff000000 000000 === ITS-SIN-FIDS-Content-XML # Testing a META.yml from a commercial project that crashed --- yaml \# http://module-build.sourceforge.net/META-spec.html \#XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX# name: ITS-SIN-FIDS-Content-XML version: 0.01 version_from: lib/ITS/SIN/FIDS/Content/XML.pm installdirs: site requires: Test::More: 0.45 XML::Simple: 2 distribution_type: module generated_by: ExtUtils::MakeMaker version 6.30 --- perl [ { name => 'ITS-SIN-FIDS-Content-XML', version => "0.01", # this kludge is to prevent floating point comparison errors version_from => 'lib/ITS/SIN/FIDS/Content/XML.pm', installdirs => 'site', requires => { 'Test::More' => 0.45, 'XML::Simple' => 2, }, distribution_type => 'module', generated_by => 'ExtUtils::MakeMaker version 6.30', } ] CPAN-Meta-YAML-0.020/t/tml-world/Template-Provider-Unicode-Japanese.tml000640 000766 000024 00000002221 14730103447 025504 0ustar00etherstaff000000 000000 === Template-Provider-Unicode-Japanese --- yaml --- abstract: Decode all templates by Unicode::Japanese author: Hironori Yoshida C<< >> distribution_type: module generated_by: Module::Install version 0.65 license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.3.html version: 1.3 name: Template-Provider-Unicode-Japanese no_index: directory: - inc - t requires: Template::Config: 0 Unicode::Japanese: 0 perl: 5.6.0 version: 0 version: 1.2.1 --- perl [ { abstract => 'Decode all templates by Unicode::Japanese', author => 'Hironori Yoshida C<< >>', distribution_type => 'module', generated_by => 'Module::Install version 0.65', license => 'perl', 'meta-spec' => { url => 'http://module-build.sourceforge.net/META-spec-v1.3.html', version => '1.3', }, name => 'Template-Provider-Unicode-Japanese', no_index => { directory => [ qw{ inc t } ], }, requires => { 'Template::Config' => 0, 'Unicode::Japanese' => 0, perl => '5.6.0', version => '0', }, version => '1.2.1', } ] CPAN-Meta-YAML-0.020/t/tml-world/Spreadsheet-Read.tml000640 000766 000024 00000010657 14730103447 022165 0ustar00etherstaff000000 000000 === Spreadsheet-Read --- yaml \--- #YAML:1.1 name: Read version: VERSION abstract: Meta-Wrapper for reading spreadsheet data license: perl author: - H.Merijn Brand generated_by: Author distribution_type: module provides: Spreadsheet::Read: file: Read.pm version: VERSION requires: perl: 5.006 Exporter: 0 Carp: 0 Data::Dumper: 0 recommends: perl: 5.008005 File::Temp: 0.14 IO::Scalar: 0 build_requires: perl: 5.006 Test::Harness: 0 Test::More: 0 optional_features: - opt_csv: description: Provides parsing of CSV streams requires: Text::CSV_XS: 0.23 recommends: Text::CSV: 1.10 Text::CSV_PP: 1.10 Text::CSV_XS: 0.58 - opt_excel: description: Provides parsing of Microsoft Excel files requires: Spreadsheet::ParseExcel: 0.26 Spreadsheet::ParseExcel::FmtDefault: 0 recommends: Spreadsheet::ParseExcel: 0.42 - opt_excelx: description: Provides parsing of Microsoft Excel 2007 files requires: Spreadsheet::XLSX: 0.07 - opt_oo: description: Provides parsing of OpenOffice spreadsheets requires: Spreadsheet::ReadSXC: 0.2 - opt_tools: description: Spreadsheet tools recommends: Tk: 0 Tk::NoteBook: 0 Tk::TableMatrix::Spreadsheet: 0 resources: license: http://dev.perl.org/licenses/ meta-spec: version: 1.4 url: http://module-build.sourceforge.net/META-spec-v1.4.html --- perl [ { 'resources' => { 'license' => 'http://dev.perl.org/licenses/' }, 'meta-spec' => { 'version' => '1.4', 'url' => 'http://module-build.sourceforge.net/META-spec-v1.4.html' }, 'distribution_type' => 'module', 'generated_by' => 'Author', 'version' => 'VERSION', 'name' => 'Read', 'author' => [ 'H.Merijn Brand ' ], 'license' => 'perl', 'build_requires' => { 'Test::More' => '0', 'Test::Harness' => '0', 'perl' => '5.006' }, 'provides' => { 'Spreadsheet::Read' => { 'version' => 'VERSION', 'file' => 'Read.pm' } }, 'optional_features' => [ { 'opt_csv' => { 'requires' => { 'Text::CSV_XS' => '0.23' }, 'recommends' => { 'Text::CSV_PP' => '1.10', 'Text::CSV_XS' => '0.58', 'Text::CSV' => '1.10' }, 'description' => 'Provides parsing of CSV streams' } }, { 'opt_excel' => { 'requires' => { 'Spreadsheet::ParseExcel' => '0.26', 'Spreadsheet::ParseExcel::FmtDefault' => '0' }, 'recommends' => { 'Spreadsheet::ParseExcel' => '0.42' }, 'description' => 'Provides parsing of Microsoft Excel files' } }, { 'opt_excelx' => { 'requires' => { 'Spreadsheet::XLSX' => '0.07' }, 'description' => 'Provides parsing of Microsoft Excel 2007 files' } }, { 'opt_oo' => { 'requires' => { 'Spreadsheet::ReadSXC' => '0.2' }, 'description' => 'Provides parsing of OpenOffice spreadsheets' } }, { 'opt_tools' => { 'recommends' => { 'Tk::TableMatrix::Spreadsheet' => '0', 'Tk::NoteBook' => '0', 'Tk' => '0' }, 'description' => 'Spreadsheet tools' } } ], 'requires' => { 'perl' => '5.006', 'Data::Dumper' => '0', 'Exporter' => '0', 'Carp' => '0' }, 'recommends' => { 'perl' => '5.008005', 'IO::Scalar' => '0', 'File::Temp' => '0.14' }, 'abstract' => 'Meta-Wrapper for reading spreadsheet data' } ] --- noyamlpm CPAN-Meta-YAML-0.020/t/tml-world/Plagger.tml000640 000766 000024 00000004215 14730103447 020417 0ustar00etherstaff000000 000000 ##################################################################### # Example Plagger Configuration 1 === Plagger --- yaml plugins: - module: Subscription::Bloglines config: username: you@example.pl password: foobar mark_read: 1 - module: Publish::Gmail config: mailto: example@gmail.com mailfrom: miyagawa@example.com mailroute: via: smtp host: smtp.example.com --- perl [ { plugins => [ { module => 'Subscription::Bloglines', config => { username => 'you@example.pl', password => 'foobar', mark_read => 1, }, }, { module => 'Publish::Gmail', config => { mailto => 'example@gmail.com', mailfrom => 'miyagawa@example.com', mailroute => { via => 'smtp', host => 'smtp.example.com', }, }, }, ] } ] ##################################################################### # Example Plagger Configuration 2 === plagger2 --- yaml plugins: - module: Subscription::Config config: feed: # Trac's feed for changesets - http://plagger.org/.../rss # I don't like to be notified of the same items # more than once - module: Filter::Rule rule: module: Fresh mtime: path: /tmp/rssbot.time autoupdate: 1 - module: Notify::IRC config: daemon_port: 9999 nickname: plaggerbot server_host: chat.freenode.net server_channels: - '#plagger-ja' - '#plagger' --- perl [ { plugins => [ { module => 'Subscription::Config', config => { feed => [ 'http://plagger.org/.../rss' ], }, }, { module => 'Filter::Rule', rule => { module => 'Fresh', mtime => { path => '/tmp/rssbot.time', autoupdate => 1, }, }, }, { module => 'Notify::IRC', config => { daemon_port => 9999, nickname => 'plaggerbot', server_host => 'chat.freenode.net', server_channels => [ '#plagger-ja', '#plagger', ], }, } ] } ] CPAN-Meta-YAML-0.020/t/tml-world/HTML-WebDAO.tml000640 000766 000024 00000000762 14730103447 020644 0ustar00etherstaff000000 000000 === HTML-WebDAO --- yaml \--- #YAML:1.0 name: HTML-WebDAO version: 0.04 author: - |- Zahatski Aliaksandr, Ezagap@users.sourceforge.netE abstract: Perl extension for create complex web application license: perl --- perl [ { abstract => 'Perl extension for create complex web application', author => [ 'Zahatski Aliaksandr, Ezagap@users.sourceforge.netE', ], license => 'perl', name => 'HTML-WebDAO', version => '0.04', } ] --- nosyck CPAN-Meta-YAML-0.020/t/tml-world/Acme-Time-Baby.tml000640 000766 000024 00000001151 14730103447 021446 0ustar00etherstaff000000 000000 === Acme-Time-Baby --- yaml \# http://module-build.sourceforge.net/META-spec.html \#XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX# name: Acme-Time-Baby version: 2.106 version_from: Baby.pm installdirs: site requires: warnings: distribution_type: module generated_by: ExtUtils::MakeMaker version 6.17 --- perl [ { name => 'Acme-Time-Baby', version => '2.106', version_from => 'Baby.pm', installdirs => 'site', requires => { warnings => undef, }, distribution_type => 'module', generated_by => 'ExtUtils::MakeMaker version 6.17', } ] CPAN-Meta-YAML-0.020/t/tml-world/Vanilla-Perl.tml000640 000766 000024 00000016146 14730103447 021332 0ustar00etherstaff000000 000000 === vanilla_perl # VanillaPerl YAML config file --- yaml # package info package_name: VanillaPerl package_version: 5 # directories download_dir: c:\temp\vp_sources build_dir: c:\temp\vp_build image_dir: c:\vanilla-perl # Binary components binary: - name: dmake url: http://search.cpan.org/CPAN/authors/id/S/SH/SHAY/dmake-4.5-20060619-SHAY.zip license: dmake/COPYING : dmake/COPYING dmake/readme/license.txt: dmake/license.txt install_to: dmake/dmake.exe: dmake/bin/dmake.exe dmake/startup: dmake/bin/startup - name: gcc-core url: http://umn.dl.sourceforge.net/mingw/gcc-core-3.4.5-20060117-1.tar.gz license: COPYING: gcc/COPYING COPYING.lib: gcc/COPYING.lib install_to: mingw - name: gcc-g++ url: http://umn.dl.sourceforge.net/mingw/gcc-g++-3.4.5-20060117-1.tar.gz license: install_to: mingw - name: binutils url: http://umn.dl.sourceforge.net/mingw/binutils-2.16.91-20060119-1.tar.gz license: Copying: binutils/Copying Copying.lib: binutils/Copying.lib install_to: mingw - name: mingw-runtime url: http://umn.dl.sourceforge.net/mingw/mingw-runtime-3.10.tar.gz license: doc/mingw-runtime/Contributors: mingw/Contributors doc/mingw-runtime/Disclaimer: mingw/Disclaimer install_to: mingw - name: w32api url: http://umn.dl.sourceforge.net/mingw/w32api-3.6.tar.gz license: install_to: mingw extra: extra\README.w32api: licenses\win32api\README.w32api # Source components source: - name: perl url: http://mirrors.kernel.org/CPAN/src/perl-5.8.8.tar.gz license: perl-5.8.8/Readme: perl/Readme perl-5.8.8/Artistic: perl/Artistic perl-5.8.8/Copying: perl/Copying unpack_to: perl install_to: perl after: extra\Config.pm: lib\CPAN\Config.pm # Additional modules to bundle in site\lib modules: # i.e. not used, but gets us the libwin32 dist - name: Win32::Job unpack_to: APIFile: Win32API-File - name: IO force: 1 - name: Compress::Zlib - name: IO::Zlib - name: Archive::Tar - name: Net::FTP extra: extra\libnet.cfg: libnet.cfg # Extra files to be placed # Signature.pm: perl\site\lib\Module\Signature.pm extra: README: README.txt LICENSE.txt: LICENSE.txt Changes: Release-Notes.txt extra\Config.pm: perl\lib\CPAN\Config.pm # reset this again extra\links\Perl-Documentation.url: links\Perl Documentation.url extra\links\Perl-Homepage.url: links\Perl Homepage.url extra\links\Perl-Mailing-Lists.url: links\Perl Mailing Lists.url extra\links\Perlmonks-Community-Forum.url: links\Perlmonks Community Forum.url extra\links\Search-CPAN-Modules.url: links\Search CPAN Modules.url extra\links\Vanilla-Perl-Homepage.url: links\Vanilla Perl Homepage.url --- perl [ { package_name => 'VanillaPerl', package_version => 5, download_dir => 'c:\temp\vp_sources', build_dir => 'c:\temp\vp_build', image_dir => 'c:\vanilla-perl', binary => [ { name => 'dmake', url => 'http://search.cpan.org/CPAN/authors/id/S/SH/SHAY/dmake-4.5-20060619-SHAY.zip', license => { 'dmake/COPYING' => 'dmake/COPYING', 'dmake/readme/license.txt' => 'dmake/license.txt', }, install_to => { 'dmake/dmake.exe' => 'dmake/bin/dmake.exe', 'dmake/startup' => 'dmake/bin/startup', }, }, { name => 'gcc-core', url => 'http://umn.dl.sourceforge.net/mingw/gcc-core-3.4.5-20060117-1.tar.gz', license => { 'COPYING' => 'gcc/COPYING', 'COPYING.lib' => 'gcc/COPYING.lib', }, install_to => 'mingw', }, { name => 'gcc-g++', url => 'http://umn.dl.sourceforge.net/mingw/gcc-g++-3.4.5-20060117-1.tar.gz', license => undef, install_to => 'mingw', }, { name => 'binutils', url => 'http://umn.dl.sourceforge.net/mingw/binutils-2.16.91-20060119-1.tar.gz', license => { 'Copying' => 'binutils/Copying', 'Copying.lib' => 'binutils/Copying.lib', }, install_to => 'mingw', }, { name => 'mingw-runtime', url => 'http://umn.dl.sourceforge.net/mingw/mingw-runtime-3.10.tar.gz', license => { 'doc/mingw-runtime/Contributors' => 'mingw/Contributors', 'doc/mingw-runtime/Disclaimer' => 'mingw/Disclaimer', }, install_to => 'mingw', }, { name => 'w32api', url => 'http://umn.dl.sourceforge.net/mingw/w32api-3.6.tar.gz', license => undef, install_to => 'mingw', extra => { 'extra\README.w32api' => 'licenses\win32api\README.w32api', }, } ], source => [ { name => 'perl', url => 'http://mirrors.kernel.org/CPAN/src/perl-5.8.8.tar.gz', license => { 'perl-5.8.8/Readme' => 'perl/Readme', 'perl-5.8.8/Artistic' => 'perl/Artistic', 'perl-5.8.8/Copying' => 'perl/Copying', }, unpack_to => 'perl', install_to => 'perl', after => { 'extra\Config.pm' => 'lib\CPAN\Config.pm', }, } ], modules => [ { name => 'Win32::Job', unpack_to => { APIFile => 'Win32API-File', }, }, { name => 'IO', force => 1, }, { name => 'Compress::Zlib', }, { name => 'IO::Zlib', }, { name => 'Archive::Tar', }, { name => 'Net::FTP', extra => { 'extra\libnet.cfg' => 'libnet.cfg', }, }, ], extra => { 'README' => 'README.txt', 'LICENSE.txt' => 'LICENSE.txt', 'Changes' => 'Release-Notes.txt', 'extra\Config.pm' => 'perl\lib\CPAN\Config.pm', 'extra\links\Perl-Documentation.url' => 'links\Perl Documentation.url', 'extra\links\Perl-Homepage.url' => 'links\Perl Homepage.url', 'extra\links\Perl-Mailing-Lists.url' => 'links\Perl Mailing Lists.url', 'extra\links\Perlmonks-Community-Forum.url' => 'links\Perlmonks Community Forum.url', 'extra\links\Search-CPAN-Modules.url' => 'links\Search CPAN Modules.url', 'extra\links\Vanilla-Perl-Homepage.url' => 'links\Vanilla Perl Homepage.url', }, } ] --- nosyck CPAN-Meta-YAML-0.020/t/tml-world/Data-Swap.tml000640 000766 000024 00000000615 14730103447 020617 0ustar00etherstaff000000 000000 === Data-Swap # File with a YAML header --- yaml \--- #YAML:1.0 name: Data-Swap version: 0.05 license: perl distribution_type: module requires: perl: 5.6.0 dynamic_config: 0 --- perl [ { name => 'Data-Swap', version => '0.05', license => 'perl', distribution_type => 'module', requires => { perl => '5.6.0', }, dynamic_config => '0', } ] --- nosyck CPAN-Meta-YAML-0.020/t/tml-world/YAML-Tiny-META.tml000640 000766 000024 00000001774 14730103447 021254 0ustar00etherstaff000000 000000 === YAML::Tiny # Testing YAML::Tiny's own META.yml file -- at least as of some time ago --- yaml abstract: Read/Write YAML files with as little code as possible author: 'Adam Kennedy ' build_requires: File::Spec: 0.80 Test::More: 0.47 distribution_type: module generated_by: Module::Install version 0.63 license: perl name: YAML-Tiny no_index: directory: - inc - t requires: perl: 5.005 version: 0.03 --- perl [ { abstract => 'Read/Write YAML files with as little code as possible', author => 'Adam Kennedy ', build_requires => { 'File::Spec' => '0.80', 'Test::More' => '0.47', }, distribution_type => 'module', generated_by => 'Module::Install version 0.63', license => 'perl', name => 'YAML-Tiny', no_index => { directory => [ qw{inc t} ], }, requires => { perl => '5.005', }, version => '0.03', } ] CPAN-Meta-YAML-0.020/t/tml-world/Games-Nintendo-Wii-Mii.tml000640 000766 000024 00000002554 14730103447 023114 0ustar00etherstaff000000 000000 === Games-Nintendo-Wii-Mii # Testing various failing META.yml files from CPAN --- yaml --- abstract: Mii in Nintendo Wii data parser and builder author: Toru Yamaguchi distribution_type: module generated_by: Module::Install version 0.65 license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.3.html version: 1.3 name: Games-Nintendo-Wii-Mii no_index: directory: - inc - t requires: Carp: 1.03 Class::Accessor::Fast: 0.3 File::Slurp: 9999.12 IO::File: 1.1 Readonly: 0 Tie::IxHash: 1.21 URI: 1.35 XML::LibXML: 1.62 version: 0.02 --- perl [ { abstract => 'Mii in Nintendo Wii data parser and builder', author => 'Toru Yamaguchi ', distribution_type => 'module', generated_by => 'Module::Install version 0.65', license => 'perl', 'meta-spec' => { url => 'http://module-build.sourceforge.net/META-spec-v1.3.html', version => '1.3', }, name => 'Games-Nintendo-Wii-Mii', no_index => { directory => [ qw{ inc t } ], }, requires => { 'Carp' => '1.03', 'Class::Accessor::Fast' => '0.3', 'File::Slurp' => '9999.12', 'IO::File' => '1.1', 'Readonly' => '0', 'Tie::IxHash' => '1.21', 'URI' => '1.35', 'XML::LibXML' => '1.62', }, version => '0.02', } ] CPAN-Meta-YAML-0.020/t/tml-world/toolbar.tml000640 000766 000024 00000001446 14730103447 020503 0ustar00etherstaff000000 000000 === toolbar # Testing of a known-bad file from an editor --- yaml main_toolbar: - item file-new - item file-open - item file-print# - item file-close# - item file-save-all - item file-save - - item edit-changes-undo - item edit-changes-redo - - item edit-cut - item edit-copy - item edit-paste - item edit-replace - item edit-delete --- perl [ { main_toolbar => [ 'item file-new', 'item file-open', 'item file-print#', 'item file-close#', 'item file-save-all', 'item file-save', undef, 'item edit-changes-undo', 'item edit-changes-redo', undef, 'item edit-cut', 'item edit-copy', 'item edit-paste', 'item edit-replace', 'item edit-delete', ] } ] CPAN-Meta-YAML-0.020/t/tml-world/yaml_org.tml000640 000766 000024 00000002775 14730103447 020660 0ustar00etherstaff000000 000000 === yaml_org_example # Testing sample data structure from yaml.org --- yaml --- invoice: 34843 date : 2001-01-23 bill-to: given : Chris family : Dumars address: lines: | 458 Walkman Dr. Suite #292 city : Royal Oak state : MI postal : 48046 product: - sku : BL394D quantity : 4 description : Basketball price : 450.00 - sku : BL4438H quantity : 1 description : Super Hoop price : 2392.00 tax : 251.42 total: 4443.52 comments: > Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338. --- perl [ { invoice => 34843, date => '2001-01-23', 'bill-to' => { given => 'Chris', family => 'Dumars', address => { lines => "458 Walkman Dr.\nSuite #292\n", city => 'Royal Oak', state => 'MI', postal => 48046, }, }, product => [ { sku => 'BL394D', quantity => '4', description => 'Basketball', price => '450.00', }, { sku => 'BL4438H', quantity => '1', description => 'Super Hoop', price => '2392.00', }, ], tax => '251.42', total => '4443.52', comments => <<'END_TEXT', Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338. END_TEXT } ] --- nosyck