MooseX-Types-Structured-0.35/000700 000766 000024 00000000000 12637630671 016373 5ustar00etherstaff000000 000000 MooseX-Types-Structured-0.35/Build.PL000644 000766 000024 00000011040 12637630671 017675 0ustar00etherstaff000000 000000 # This Build.PL for MooseX-Types-Structured was generated by # Dist::Zilla::Plugin::ModuleBuildTiny::Fallback 0.022 use strict; use warnings; my %configure_requires = ( 'Module::Build::Tiny' => '0.034', ); my %errors = map { eval "require $_; $_->VERSION($configure_requires{$_}); 1"; $_ => $@, } keys %configure_requires; if (!grep { $_ } values %errors) { # This section for MooseX-Types-Structured was generated by Dist::Zilla::Plugin::ModuleBuildTiny 0.014. use strict; use warnings; use 5.008; # use Module::Build::Tiny 0.034; Module::Build::Tiny::Build_PL(); } else { if (not $ENV{PERL_MB_FALLBACK_SILENCE_WARNING}) { warn <<'EOW' *** WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING *** If you're seeing this warning, your toolchain is really, really old* and you'll almost certainly have problems installing CPAN modules from this century. But never fear, dear user, for we have the technology to fix this! If you're using CPAN.pm to install things, then you can upgrade it using: cpan CPAN If you're using CPANPLUS to install things, then you can upgrade it using: cpanp CPANPLUS If you're using cpanminus, you shouldn't be seeing this message in the first place, so please file an issue on github. This public service announcement was brought to you by the Perl Toolchain Gang, the irc.perl.org #toolchain IRC channel, and the number 42. ---- * Alternatively, you are running this file manually, in which case you need to learn to first fulfill all configure requires prerequisites listed in META.yml or META.json -- or use a cpan client to install this distribution. You can also silence this warning for future installations by setting the PERL_MB_FALLBACK_SILENCE_WARNING environment variable, but please don't do that until you fix your toolchain as described above. Errors from configure prereqs: EOW . do { require Data::Dumper; Data::Dumper->new([ \%errors ])->Indent(2)->Terse(1)->Sortkeys(1)->Dump; }; sleep 10 if -t STDIN && (-t STDOUT || !(-f STDOUT || -c STDOUT)); } # This section was automatically generated by Dist::Zilla::Plugin::ModuleBuild v5.042. use strict; use warnings; require Module::Build; Module::Build->VERSION(0.28); my %module_build_args = ( "configure_requires" => { "Module::Build::Tiny" => "0.034", "perl" => "5.008" }, "dist_abstract" => "Structured Type Constraints for Moose", "dist_author" => [ "John Napiorkowski ", "Florian Ragwitz ", "\x{5d9}\x{5d5}\x{5d1}\x{5dc} \x{5e7}\x{5d5}\x{5d2}'\x{5de}\x{5df} (Yuval Kogman) ", "Tomas (t0m) Doran ", "Robert Sedlacek " ], "dist_name" => "MooseX-Types-Structured", "dist_version" => "0.35", "license" => "perl", "module_name" => "MooseX::Types::Structured", "recursive_test_files" => 1, "requires" => { "Devel::PartialDump" => "0.13", "JSON::PP" => "2.27300", "Moose" => 0, "Moose::Meta::TypeCoercion" => 0, "Moose::Meta::TypeConstraint" => 0, "Moose::Meta::TypeConstraint::Parameterizable" => 0, "Moose::Util::TypeConstraints" => "1.06", "MooseX::Types" => "0.22", "Scalar::Util" => 0, "Sub::Exporter" => "0.982", "if" => 0, "namespace::clean" => "0.19", "overload" => 0, "perl" => "5.008" }, "test_requires" => { "Data::Dumper" => 0, "DateTime" => 0, "ExtUtils::MakeMaker" => 0, "File::Spec" => 0, "MooseX::Types::DateTime" => 0, "MooseX::Types::Moose" => 0, "Test::Fatal" => 0, "Test::More" => "0.88", "Test::Requires" => 0, "perl" => "5.008", "strict" => 0, "warnings" => 0 } ); my %fallback_build_requires = ( "Data::Dumper" => 0, "DateTime" => 0, "ExtUtils::MakeMaker" => 0, "File::Spec" => 0, "MooseX::Types::DateTime" => 0, "MooseX::Types::Moose" => 0, "Test::Fatal" => 0, "Test::More" => "0.88", "Test::Requires" => 0, "perl" => "5.008", "strict" => 0, "warnings" => 0 ); unless ( eval { Module::Build->VERSION(0.4004) } ) { delete $module_build_args{test_requires}; $module_build_args{build_requires} = \%fallback_build_requires; } my $build = Module::Build->new(%module_build_args); $build->create_build_script; } MooseX-Types-Structured-0.35/Changes000600 000766 000024 00000017263 12637630671 017701 0ustar00etherstaff000000 000000 Revision history for MooseX-Types-Structured 0.35 2015-12-27 00:32:49Z - avoid spaces in slurpy type constraint names (ilmari, PR#1) 0.34 2015-08-16 02:39:14Z - bump namespace::clean prereq 0.33 2015-04-01 17:10:23Z - avoid using a method installer in the main importer, to avoid removing subs' blessedness (RT#103247) 0.32 2015-03-28 21:39:38Z - fix namespace cleaning with older MooseX::Types 0.31 2015-03-28 21:08:14Z - various misc distribution and packaging cleanup 0.30 2013-12-19 22:51:17Z - remove pod from internal and unindexed modules, for a prettier metacpan release page 0.29 2013-11-20 23:36:48Z - fixed use of an interface that was deprecated in Moose-2.1100 (ether) - repository migrated from shadowcat to the github moose organization 0.28 2011-10-03 - Fixed regression where mixed type constraints (MX:Types style and 'classic' Stringy style) are used in a single structured type doesn't work. 0.27 2011-04-28 - test fixes for new Moose 0.26 2011-01-02 - removed version from Test::Fatal as asked by the debian folks - small documentation updates 0.25 2010-12-28 - fixed bug where ->is_subtype_of dies meaninglessly when the type we are trying to check is not a type we can find. This makes our handling consistent with core Moose. Also changed ->equals and ->is_a_type_of to be consistent. - Added test case for above - The test suite now uses Test::Fatal instead of Test::Exception (Karen Etheridge). 0.24 2010-11-16 - Added some performance enhancing caching code (phaeton) 0.23 2010-07-01 - Changes to the return value of ->validate that hopefully is both backwardly compatible as well as more detailed. Now if you have a deeply recursive of repeated type constraints inside other type constraints you will get a drill down report to show the actual type constraint that failed 0.22 2010-06-01 - Added tests to demonstrate type constraint equality problem introduced in Moose 1.05 0.21 2010-03-26 - Removed unneed module from test - additional contributed documentation fixes 0.20 2010-02-04 - Add a new Map type. (Ricardo SIGNES) - Properly handle Optional[] types within Tuples and Dicts. (Florian Ragwitz) 0.19 2009-11-06 - Require Devel::PartialDump 0.10 and change tests to expect the correct format of error. 0.18 2009-08-17 - Changed the Makefile.PL to reduce dependencies not needed by users that are not authors. Bumped the revision and released to clear an error with cpan permissions. 0.17 2009-08-12 - No new functionality. - Changed the way we specify dependencies in the Makefile.PL to reduce the depth of the dependency chain in cases where we don't need to be running the author quality tests. - Some documentation tweaks. 0.16 2009-05-28 - Fix failing tests and test warnings on MooseX::Types 0.11. 0.15 2009-05-27 - Change copy on license and added contributors section 0.14 2009-05-01 - Use a builder instead of wrapping new to set the default structured coercion (rafl). - Make overflow (slurpy) type constraints introspectable and the name of constraints using them reasonable (rafl). 0.13 2009-04-25 - Explicitly don't inline yet another constructor to avoid warnings (autarch). 0.12 2009-04-21 - Explicitly don't inline the constructor to avoid warnings (rafl). - Pathological test cases for API methods equals, is_a_type_of and is_subtype_of (rafl). - significant improvements to API methods is_a_type_of, is_subtype_of and equals (nothingmuch). 0.11 2009-04-06 - Fixed braindead bug in the way I override ->validate, which caused valiate to never correctly pass a constraint. 0.10 2009-04-02 - Minor documentation grammar fixes and one major example error fixed - Much improved error reporting. Now we return the 'internal' error that kicked a validation failure. It's still best to use this for debugging rather than for actual user error messages, since I think we are rapidly approaching a need for Moose constraints needing more in the error and message reporting. - Documentation for the above. 0.09 2009-03-07 - I guess we don't support the "subtype MyType, [TypeConstraint]" syntax anymore. Changed the recursion test to reflect that, which should fix my 100% fail rate :) 0.08 2009-03-06 - New Feature: slurpy method for when you want a structured type constraint that allows trailing arguments of indeterminate length. Please see the documentation and the '11-overflow.t' test for more. - Documentation for above as well as a bunch of POD cleanups, spell checks and improvements to formatting. - Stevan Little submitted a sweet update to the '10-recursion.t' test that blows my mind. Will probably form the core of a to be done set of cookbook style PODs. Worth looking at. - First step at improving the error message you get when validation fails. A full error stacktrace is not in this release, but you now at least get to see part of the offending value. 0.07 2008-12-09 - Fixed typo in previous changelog - documentation improvements and updates - increased version requirement for MooseX::Types so that we can take advantage of the recursion support added. - added test for recursion. 0.06 2008-12-06 - Added a 'helper' type constraint called Optional. See docs for more. - added lots of tests to cover the API better, coverage and fixes for the ->parameterize method in particular have been clarified. - changes so that the type contraints are more forgiving when null values appear in method calls. - used ->make_immutable which should speed up the constraints. - removed some unnecessary calls to use Moose when I wasn't using Moose. - lots of little code cleanup work and more internal documentation. - This version requires a newer Moose than previous versions. The Makefile.PL has been updated to reflect this. This is a required update. 0.05 2008-11-08 - Fixed some wackiness in the documentation. 0.04 2008-11-07 - Bumped minimum required versions of Moose and MooseX-Types to solve problem with overloading and type constraint names (issue resolved in Moose code.) - Changed the way the required Perl version string is used to increase compatibility and lowered minimum required Perl 0.03 2008-10-29 - Fixed incorrect Perl version string (rafl) - hide the meta classes from pause. This should clarify which POD is the right one to read and also I want to discourage people from subclassing that stuff since it will probably change - various documentation cleanup - new test 'example.t' with runable versions of the code in the example POD section. 0.02 2008-10-28 - cleared up some typos in the test suite - Fixed some POD formatting issues, mostly some dumb tabs I ended up with when I switched editors. Added a bit more documentation 0.01 2008-10-27 - Completed basic requirements, documentation and tests. MooseX-Types-Structured-0.35/CONTRIBUTING000644 000766 000024 00000007560 12637630671 020247 0ustar00etherstaff000000 000000 CONTRIBUTING Thank you for considering contributing to this distribution. This file contains instructions that will help you work with the source code. PLEASE NOTE that if you have any questions or difficulties, you can reach the maintainer(s) through the bug queue described later in this document (preferred), or by emailing the releaser directly. You are not required to follow any of the steps in this document to submit a patch or bug report; these are just recommendations, intended to help you (and help us help you faster). This distribution has a TODO file in the repository; you may want to check there to see if your issue or patch idea is mentioned. The distribution is managed with Dist::Zilla (https://metacpan.org/release/Dist-Zilla). This means than many of the usual files you might expect are not in the repository, but are generated at release time (e.g. Makefile.PL). However, you can run tests directly using the 'prove' tool: $ prove -l $ prove -lv t/some_test_file.t $ prove -lvr t/ In most cases, 'prove' is entirely sufficent for you to test any patches you have. You may need to satisfy some dependencies. The easiest way to satisfy dependencies is to install the last release -- this is available at https://metacpan.org/release/MooseX-Types-Structured If you use cpanminus, you can do it without downloading the tarball first: $ cpanm --reinstall --installdeps --with-recommends MooseX::Types::Structured Dist::Zilla is a very powerful authoring tool, but requires a number of author-specific plugins. If you would like to use it for contributing, install it from CPAN, then run one of the following commands, depending on your CPAN client: $ cpan `dzil authordeps --missing` or $ dzil authordeps --missing | cpanm You should then also install any additional requirements not needed by the dzil build but may be needed by tests or other development: $ cpan `dzil listdeps --author --missing` or $ dzil listdeps --author --missing | cpanm Or, you can use the 'dzil stale' command to install all requirements at once: $ cpan Dist::Zilla::App::Command::stale $ cpan `dzil stale --all` or $ cpanm Dist::Zilla::App::Command::stale $ dzil stale --all | cpanm You can also do this via cpanm directly: $ cpanm --reinstall --installdeps --with-develop --with-recommends MooseX::Types::Structured Once installed, here are some dzil commands you might try: $ dzil build $ dzil test $ dzil test --release $ dzil xtest $ dzil listdeps --json $ dzil build --notgz You can learn more about Dist::Zilla at http://dzil.org/. The code for this distribution is hosted at GitHub. The repository is: https://github.com/moose/MooseX-Types-Structured You can submit code changes by forking the repository, pushing your code changes to your clone, and then submitting a pull request. Detailed instructions for doing that is available here: https://help.github.com/articles/creating-a-pull-request If you have found a bug, but do not have an accompanying patch to fix it, you can submit an issue report here: https://rt.cpan.org/Public/Dist/Display.html?Name=MooseX-Types-Structured or via email: bug-MooseX-Types-Structured@rt.cpan.org There is also a mailing list available for users of this distribution, at http://lists.perl.org/list/moose.html There is also an irc channel available for users of this distribution, at irc://irc.perl.org/#moose If you send me a patch or pull request, your name and email address will be included in the documentation as a contributor (using the attribution on the commit or patch), unless you specifically request for it not to be. If you wish to be listed under a different name or address, you should submit a pull request to the .mailmap file to contain the correct mapping. This file was generated via Dist::Zilla::Plugin::GenerateFile::FromShareDir 0.009 from a template file originating in Dist-Zilla-PluginBundle-Author-ETHER-0.110. MooseX-Types-Structured-0.35/dist.ini000600 000766 000024 00000002077 12637630671 020047 0ustar00etherstaff000000 000000 name = MooseX-Types-Structured author = John Napiorkowski author = Florian Ragwitz author = יובל קוג'מן (Yuval Kogman) author = Tomas (t0m) Doran author = Robert Sedlacek license = Perl_5 copyright_holder = John Napiorkowski copyright_year = 2008 [@Author::ETHER] :version = 0.094 Authority.authority = cpan:JJNAPIORK -remove = PodCoverageTests changes_version_columns = 8 surgical_podweaver = 1 Test::MinimumVersion.max_target_perl = 5.008003 StaticInstall.dry_run = 0 ; we can safely set this here [Substitute] :version = 0.006 file = xt/author/clean-namespaces.t code = s/^(# this test was .*)$/$1\n# and altered by the local dist.ini/; code = s/^(use Test::CleanNamespaces.*)$/$1\nuse Test::Requires { 'MooseX::Types' => '0.44' };/; [Prereqs / DevelopRequires] Test::Requires = 0 [MetaResources] x_IRC = irc://irc.perl.org/#moose x_MailingList = http://lists.perl.org/list/moose.html [Test::Version] [Test::CheckBreaks] conflicts_module = Moose::Conflicts MooseX-Types-Structured-0.35/INSTALL000644 000766 000024 00000002023 12637630671 017433 0ustar00etherstaff000000 000000 This is the Perl distribution MooseX-Types-Structured. Installing MooseX-Types-Structured is straightforward. ## Installation with cpanm If you have cpanm, you only need one line: % cpanm MooseX::Types::Structured If you are installing into a system-wide directory, you may need to pass the "-S" flag to cpanm, which uses sudo to install the module: % cpanm -S MooseX::Types::Structured ## Installing with the CPAN shell Alternatively, if your CPAN shell is set up, you should just be able to do: % cpan MooseX::Types::Structured ## Manual installation As a last resort, you can manually install it. Download the tarball, untar it, then build it: % perl Build.PL % ./Build && ./Build test Then install it: % ./Build install If you are installing into a system-wide directory, you may need to run: % sudo ./Build install ## Documentation MooseX-Types-Structured documentation is available as POD. You can run perldoc from a shell to read the documentation: % perldoc MooseX::Types::Structured MooseX-Types-Structured-0.35/lib/000700 000766 000024 00000000000 12637630671 017141 5ustar00etherstaff000000 000000 MooseX-Types-Structured-0.35/LICENSE000644 000766 000024 00000043674 12637630671 017430 0ustar00etherstaff000000 000000 This software is copyright (c) 2008 by John Napiorkowski. 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) 2008 by John Napiorkowski. This is free software, licensed under: The GNU General Public License, Version 1, February 1989 GNU GENERAL PUBLIC LICENSE Version 1, February 1989 Copyright (C) 1989 Free Software Foundation, Inc. 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The license agreements of most software companies try to keep users at the mercy of those companies. By contrast, our General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. The General Public License applies to the Free Software Foundation's software and to any other program whose authors commit to using it. You can use it for your programs, too. When we speak of free software, we are referring to freedom, not price. Specifically, the General Public License is designed to make sure that you have the freedom to give away or sell copies of free software, that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of a such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must tell them their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any work containing the Program or a portion of it, either verbatim or with modifications. Each licensee is addressed as "you". 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this General Public License and to the absence of any warranty; and give any other recipients of the Program a copy of this General Public License along with the Program. You may charge a fee for the physical act of transferring a copy. 2. You may modify your copy or copies of the Program or any portion of it, and copy and distribute such modifications under the terms of Paragraph 1 above, provided that you also do the following: a) cause the modified files to carry prominent notices stating that you changed the files and the date of any change; and b) cause the whole of any work that you distribute or publish, that in whole or in part contains the Program or any part thereof, either with or without modifications, to be licensed at no charge to all third parties under the terms of this General Public License (except that you may choose to grant warranty protection to some or all third parties, at your option). c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the simplest and most usual way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this General Public License. d) You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. Mere aggregation of another independent work with the Program (or its derivative) on a volume of a storage or distribution medium does not bring the other work under the scope of these terms. 3. You may copy and distribute the Program (or a portion or derivative of it, under Paragraph 2) in object code or executable form under the terms of Paragraphs 1 and 2 above provided that you also do one of the following: a) accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Paragraphs 1 and 2 above; or, b) accompany it with a written offer, valid for at least three years, to give any third party free (except for a nominal charge for the cost of distribution) a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Paragraphs 1 and 2 above; or, c) accompany it with the information you received as to where the corresponding source code may be obtained. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form alone.) Source code for a work means the preferred form of the work for making modifications to it. For an executable file, complete source code means all the source code for all modules it contains; but, as a special exception, it need not include source code for modules which are standard libraries that accompany the operating system on which the executable file runs, or for standard header files or definitions files that accompany that operating system. 4. You may not copy, modify, sublicense, distribute or transfer the Program except as expressly provided under this General Public License. Any attempt otherwise to copy, modify, sublicense, distribute or transfer the Program is void, and will automatically terminate your rights to use the Program under this License. However, parties who have received copies, or rights to use copies, from you under this General Public License will not have their licenses terminated so long as such parties remain in full compliance. 5. By copying, distributing or modifying the Program (or any work based on the Program) you indicate your acceptance of this license to do so, and all its terms and conditions. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. 7. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of the license which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the license, you may choose any version ever published by the Free Software Foundation. 8. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to humanity, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19xx name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (a program to direct compilers to make passes at assemblers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice That's all there is to it! --- The Artistic License 1.0 --- This software is Copyright (c) 2008 by John Napiorkowski. This is free software, licensed under: The Artistic License 1.0 The Artistic License Preamble The intent of this document is to state the conditions under which a Package may be copied, such that the Copyright Holder maintains some semblance of artistic control over the development of the package, while giving the users of the package the right to use and distribute the Package in a more-or-less customary fashion, plus the right to make reasonable modifications. Definitions: - "Package" refers to the collection of files distributed by the Copyright Holder, and derivatives of that collection of files created through textual modification. - "Standard Version" refers to such a Package if it has not been modified, or has been modified in accordance with the wishes of the Copyright Holder. - "Copyright Holder" is whoever is named in the copyright or copyrights for the package. - "You" is you, if you're thinking about copying or distributing this Package. - "Reasonable copying fee" is whatever you can justify on the basis of media cost, duplication charges, time of people involved, and so on. (You will not be required to justify it to the Copyright Holder, but only to the computing community at large as a market that must bear the fee.) - "Freely Available" means that no fee is charged for the item itself, though there may be fees involved in handling the item. It also means that recipients of the item may redistribute it under the same conditions they received it. 1. You may make and give away verbatim copies of the source form of the Standard Version of this Package without restriction, provided that you duplicate all of the original copyright notices and associated disclaimers. 2. You may apply bug fixes, portability fixes and other modifications derived from the Public Domain or from the Copyright Holder. A Package modified in such a way shall still be considered the Standard Version. 3. You may otherwise modify your copy of this Package in any way, provided that you insert a prominent notice in each changed file stating how and when you changed that file, and provided that you do at least ONE of the following: a) place your modifications in the Public Domain or otherwise make them Freely Available, such as by posting said modifications to Usenet or an equivalent medium, or placing the modifications on a major archive site such as ftp.uu.net, or by allowing the Copyright Holder to include your modifications in the Standard Version of the Package. b) use the modified Package only within your corporation or organization. c) rename any non-standard executables so the names do not conflict with standard executables, which must also be provided, and provide a separate manual page for each non-standard executable that clearly documents how it differs from the Standard Version. d) make other distribution arrangements with the Copyright Holder. 4. You may distribute the programs of this Package in object code or executable form, provided that you do at least ONE of the following: a) distribute a Standard Version of the executables and library files, together with instructions (in the manual page or equivalent) on where to get the Standard Version. b) accompany the distribution with the machine-readable source of the Package with your modifications. c) accompany any non-standard executables with their corresponding Standard Version executables, giving the non-standard executables non-standard names, and clearly documenting the differences in manual pages (or equivalent), together with instructions on where to get the Standard Version. d) make other distribution arrangements with the Copyright Holder. 5. You may charge a reasonable copying fee for any distribution of this Package. You may charge any fee you choose for support of this Package. You may not charge a fee for this Package itself. However, you may distribute this Package in aggregate with other (possibly commercial) programs as part of a larger (possibly commercial) software distribution provided that you do not advertise this Package as a product of your own. 6. The scripts and library files supplied as input to or produced as output from the programs of this Package do not automatically fall under the copyright of this Package, but belong to whomever generated them, and may be sold commercially, and may be aggregated with this Package. 7. C or perl subroutines supplied by you and linked into this Package shall not be considered part of this Package. 8. The name of the Copyright Holder may not be used to endorse or promote products derived from this software without specific prior written permission. 9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. The End MooseX-Types-Structured-0.35/Makefile.PL000644 000766 000024 00000010365 12637630671 020364 0ustar00etherstaff000000 000000 # This Makefile.PL for MooseX-Types-Structured was generated by # Dist::Zilla::Plugin::MakeMaker::Fallback 0.021 # and Dist::Zilla::Plugin::MakeMaker::Awesome 0.35. # Don't edit it but the dist.ini and plugins used to construct it. use strict; use warnings; BEGIN { my %configure_requires = ( 'Module::Build::Tiny' => '0.034', ); my @missing = grep { ! eval "require $_; $_->VERSION($configure_requires{$_}); 1" } keys %configure_requires; if (@missing) { if (not $ENV{PERL_MM_FALLBACK_SILENCE_WARNING}) { warn <<'EOW'; *** WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING *** If you're seeing this warning, your toolchain is really, really old* and you'll almost certainly have problems installing CPAN modules from this century. But never fear, dear user, for we have the technology to fix this! If you're using CPAN.pm to install things, then you can upgrade it using: cpan CPAN If you're using CPANPLUS to install things, then you can upgrade it using: cpanp CPANPLUS If you're using cpanminus, you shouldn't be seeing this message in the first place, so please file an issue on github. If you're installing manually, please retrain your fingers to run Build.PL when present instead. This public service announcement was brought to you by the Perl Toolchain Gang, the irc.perl.org #toolchain IRC channel, and the number 42. ---- * Alternatively, you are doing something overly clever, in which case you should consider setting the 'prefer_installer' config option in CPAN.pm, or 'prefer_makefile' in CPANPLUS, to 'mb" and '0' respectively. You can also silence this warning for future installations by setting the PERL_MM_FALLBACK_SILENCE_WARNING environment variable. EOW sleep 10 if -t STDIN && (-t STDOUT || !(-f STDOUT || -c STDOUT)); } } } # end BEGIN use 5.008; use ExtUtils::MakeMaker; my %WriteMakefileArgs = ( "ABSTRACT" => "Structured Type Constraints for Moose", "AUTHOR" => "John Napiorkowski , Florian Ragwitz , \x{5d9}\x{5d5}\x{5d1}\x{5dc} \x{5e7}\x{5d5}\x{5d2}'\x{5de}\x{5df} (Yuval Kogman) , Tomas (t0m) Doran , Robert Sedlacek ", "CONFIGURE_REQUIRES" => { "Module::Build::Tiny" => "0.034" }, "DISTNAME" => "MooseX-Types-Structured", "LICENSE" => "perl", "MIN_PERL_VERSION" => "5.008", "NAME" => "MooseX::Types::Structured", "PL_FILES" => {}, "PREREQ_PM" => { "Devel::PartialDump" => "0.13", "JSON::PP" => "2.27300", "Moose" => 0, "Moose::Meta::TypeCoercion" => 0, "Moose::Meta::TypeConstraint" => 0, "Moose::Meta::TypeConstraint::Parameterizable" => 0, "Moose::Util::TypeConstraints" => "1.06", "MooseX::Types" => "0.22", "Scalar::Util" => 0, "Sub::Exporter" => "0.982", "if" => 0, "namespace::clean" => "0.19", "overload" => 0 }, "TEST_REQUIRES" => { "Data::Dumper" => 0, "DateTime" => 0, "ExtUtils::MakeMaker" => 0, "File::Spec" => 0, "MooseX::Types::DateTime" => 0, "MooseX::Types::Moose" => 0, "Test::Fatal" => 0, "Test::More" => "0.88", "Test::Requires" => 0, "strict" => 0, "warnings" => 0 }, "VERSION" => "0.35", "test" => { "TESTS" => "t/*.t t/regressions/*.t" } ); my %FallbackPrereqs = ( "Data::Dumper" => 0, "DateTime" => 0, "Devel::PartialDump" => "0.13", "ExtUtils::MakeMaker" => 0, "File::Spec" => 0, "JSON::PP" => "2.27300", "Moose" => 0, "Moose::Meta::TypeCoercion" => 0, "Moose::Meta::TypeConstraint" => 0, "Moose::Meta::TypeConstraint::Parameterizable" => 0, "Moose::Util::TypeConstraints" => "1.06", "MooseX::Types" => "0.22", "MooseX::Types::DateTime" => 0, "MooseX::Types::Moose" => 0, "Scalar::Util" => 0, "Sub::Exporter" => "0.982", "Test::Fatal" => 0, "Test::More" => "0.88", "Test::Requires" => 0, "if" => 0, "namespace::clean" => "0.19", "overload" => 0, "strict" => 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) }; WriteMakefile(%WriteMakefileArgs); MooseX-Types-Structured-0.35/MANIFEST000644 000766 000024 00000002375 12637630671 017545 0ustar00etherstaff000000 000000 # This file was automatically generated by Dist::Zilla::Plugin::Manifest v5.042. Build.PL CONTRIBUTING Changes INSTALL LICENSE MANIFEST META.json META.yml Makefile.PL README dist.ini lib/MooseX/Meta/TypeCoercion/Structured.pm lib/MooseX/Meta/TypeCoercion/Structured/Optional.pm lib/MooseX/Meta/TypeConstraint/Structured.pm lib/MooseX/Meta/TypeConstraint/Structured/Optional.pm lib/MooseX/Types/Structured.pm lib/MooseX/Types/Structured/MessageStack.pm lib/MooseX/Types/Structured/OverflowHandler.pm t/00-load.t t/00-report-prereqs.dd t/00-report-prereqs.t t/01-basic.t t/02-tuple.t t/03-dict.t t/04-combined.t t/04-map.t t/05-advanced.t t/06-api.t t/07-coerce.t t/08-examples.t t/09-optional.t t/10-recursion.t t/11-overflow.t t/12-error.t t/13-deeper_error.t t/14-fully-qualified.t t/bug-incorrect-message.t t/bug-is-subtype.t t/bug-mixed-stringy.t t/bug-optional.t t/regressions/01-is_type_of.t t/zzz-check-breaks.t xt/author/00-compile.t xt/author/clean-namespaces.t xt/author/eol.t xt/author/kwalitee.t xt/author/mojibake.t xt/author/no-tabs.t xt/author/pod-spell.t xt/author/pod-syntax.t xt/author/test-version.t xt/release/changes_has_content.t xt/release/cpan-changes.t xt/release/distmeta.t xt/release/minimum-version.t xt/release/pod-no404s.t xt/release/portability.t MooseX-Types-Structured-0.35/META.json000644 000766 000024 00000130273 12637630671 020034 0ustar00etherstaff000000 000000 { "abstract" : "Structured Type Constraints for Moose", "author" : [ "John Napiorkowski ", "Florian Ragwitz ", "יובל קוג'מן (Yuval Kogman) ", "Tomas (t0m) Doran ", "Robert Sedlacek " ], "dynamic_config" : 0, "generated_by" : "Dist::Zilla version 5.042, CPAN::Meta::Converter version 2.150005", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : 2 }, "name" : "MooseX-Types-Structured", "no_index" : { "directory" : [ "t", "xt" ] }, "prereqs" : { "configure" : { "requires" : { "Module::Build::Tiny" : "0.034", "perl" : "5.008" } }, "develop" : { "recommends" : { "Dist::Zilla::PluginBundle::Author::ETHER" : "0.110" }, "requires" : { "Dist::Zilla" : "5", "Dist::Zilla::Plugin::Authority" : "1.009", "Dist::Zilla::Plugin::AuthorityFromModule" : "0.002", "Dist::Zilla::Plugin::AutoMetaResources" : "0", "Dist::Zilla::Plugin::AutoPrereqs" : "5.038", "Dist::Zilla::Plugin::BumpVersionAfterRelease::Transitional" : "0.004", "Dist::Zilla::Plugin::CheckIssues" : "0", "Dist::Zilla::Plugin::CheckPrereqsIndexed" : "0", "Dist::Zilla::Plugin::CheckSelfDependency" : "0", "Dist::Zilla::Plugin::CheckStrictVersion" : "0", "Dist::Zilla::Plugin::ConfirmRelease" : "0", "Dist::Zilla::Plugin::CopyFilesFromRelease" : "0", "Dist::Zilla::Plugin::FileFinder::ByName" : "0", "Dist::Zilla::Plugin::GenerateFile::FromShareDir" : "0", "Dist::Zilla::Plugin::Git::Check" : "0", "Dist::Zilla::Plugin::Git::CheckFor::CorrectBranch" : "0.004", "Dist::Zilla::Plugin::Git::CheckFor::MergeConflicts" : "0", "Dist::Zilla::Plugin::Git::Commit" : "2.020", "Dist::Zilla::Plugin::Git::Contributors" : "0.004", "Dist::Zilla::Plugin::Git::Describe" : "0.004", "Dist::Zilla::Plugin::Git::GatherDir" : "2.016", "Dist::Zilla::Plugin::Git::Push" : "0", "Dist::Zilla::Plugin::Git::Remote::Check" : "0", "Dist::Zilla::Plugin::Git::Tag" : "0", "Dist::Zilla::Plugin::GitHub::Update" : "0.40", "Dist::Zilla::Plugin::GithubMeta" : "0.54", "Dist::Zilla::Plugin::InstallGuide" : "1.200005", "Dist::Zilla::Plugin::Keywords" : "0.004", "Dist::Zilla::Plugin::License" : "5.038", "Dist::Zilla::Plugin::MakeMaker::Fallback" : "0.012", "Dist::Zilla::Plugin::Manifest" : "0", "Dist::Zilla::Plugin::MetaConfig" : "0", "Dist::Zilla::Plugin::MetaJSON" : "0", "Dist::Zilla::Plugin::MetaNoIndex" : "0", "Dist::Zilla::Plugin::MetaProvides::Package" : "1.15000002", "Dist::Zilla::Plugin::MetaResources" : "0", "Dist::Zilla::Plugin::MetaTests" : "0", "Dist::Zilla::Plugin::MetaYAML" : "0", "Dist::Zilla::Plugin::MinimumPerl" : "1.006", "Dist::Zilla::Plugin::ModuleBuildTiny::Fallback" : "0.018", "Dist::Zilla::Plugin::MojibakeTests" : "0.8", "Dist::Zilla::Plugin::NextRelease" : "5.033", "Dist::Zilla::Plugin::PodSyntaxTests" : "5.040", "Dist::Zilla::Plugin::Prereqs" : "0", "Dist::Zilla::Plugin::Prereqs::AuthorDeps" : "0", "Dist::Zilla::Plugin::PromptIfStale" : "0", "Dist::Zilla::Plugin::Readme" : "0", "Dist::Zilla::Plugin::ReadmeAnyFromPod" : "0.142180", "Dist::Zilla::Plugin::RewriteVersion::Transitional" : "0.004", "Dist::Zilla::Plugin::Run::AfterBuild" : "0.038", "Dist::Zilla::Plugin::Run::AfterRelease" : "0.038", "Dist::Zilla::Plugin::RunExtraTests" : "0.024", "Dist::Zilla::Plugin::StaticInstall" : "0.005", "Dist::Zilla::Plugin::Substitute" : "0.006", "Dist::Zilla::Plugin::SurgicalPodWeaver" : "0", "Dist::Zilla::Plugin::Test::CPAN::Changes" : "0.008", "Dist::Zilla::Plugin::Test::ChangesHasContent" : "0", "Dist::Zilla::Plugin::Test::CheckBreaks" : "0", "Dist::Zilla::Plugin::Test::CleanNamespaces" : "0.006", "Dist::Zilla::Plugin::Test::Compile" : "2.039", "Dist::Zilla::Plugin::Test::EOL" : "0.17", "Dist::Zilla::Plugin::Test::Kwalitee" : "2.10", "Dist::Zilla::Plugin::Test::MinimumVersion" : "2.000003", "Dist::Zilla::Plugin::Test::NoTabs" : "0.08", "Dist::Zilla::Plugin::Test::Pod::No404s" : "1.002", "Dist::Zilla::Plugin::Test::PodSpelling" : "2.006003", "Dist::Zilla::Plugin::Test::Portability" : "0", "Dist::Zilla::Plugin::Test::ReportPrereqs" : "0.019", "Dist::Zilla::Plugin::Test::Version" : "0", "Dist::Zilla::Plugin::TestRelease" : "0", "Dist::Zilla::Plugin::UploadToCPAN" : "0", "Dist::Zilla::PluginBundle::Author::ETHER" : "0.094", "File::Spec" : "0", "IO::Handle" : "0", "IPC::Open3" : "0", "Pod::Wordlist" : "0", "Software::License::Perl_5" : "0", "Test::CPAN::Changes" : "0.19", "Test::CPAN::Meta" : "0", "Test::CleanNamespaces" : "0.15", "Test::EOL" : "0", "Test::Kwalitee" : "1.21", "Test::Mojibake" : "0", "Test::More" : "0.96", "Test::NoTabs" : "0", "Test::Pod" : "1.41", "Test::Pod::No404s" : "0", "Test::Requires" : "0", "Test::Spelling" : "0.12", "Test::Version" : "1", "blib" : "1.01", "strict" : "0", "warnings" : "0" } }, "runtime" : { "requires" : { "Devel::PartialDump" : "0.13", "JSON::PP" : "2.27300", "Moose" : "0", "Moose::Meta::TypeCoercion" : "0", "Moose::Meta::TypeConstraint" : "0", "Moose::Meta::TypeConstraint::Parameterizable" : "0", "Moose::Util::TypeConstraints" : "1.06", "MooseX::Types" : "0.22", "Scalar::Util" : "0", "Sub::Exporter" : "0.982", "if" : "0", "namespace::clean" : "0.19", "overload" : "0", "perl" : "5.008" } }, "test" : { "recommends" : { "CPAN::Meta" : "2.120900" }, "requires" : { "Data::Dumper" : "0", "DateTime" : "0", "ExtUtils::MakeMaker" : "0", "File::Spec" : "0", "MooseX::Types::DateTime" : "0", "MooseX::Types::Moose" : "0", "Test::Fatal" : "0", "Test::More" : "0.88", "Test::Requires" : "0", "perl" : "5.008", "strict" : "0", "warnings" : "0" } } }, "provides" : { "MooseX::Types::Structured" : { "file" : "lib/MooseX/Types/Structured.pm", "version" : "0.35" } }, "release_status" : "stable", "resources" : { "bugtracker" : { "mailto" : "bug-MooseX-Types-Structured@rt.cpan.org", "web" : "https://rt.cpan.org/Public/Dist/Display.html?Name=MooseX-Types-Structured" }, "homepage" : "https://github.com/moose/MooseX-Types-Structured", "repository" : { "type" : "git", "url" : "https://github.com/moose/MooseX-Types-Structured.git", "web" : "https://github.com/moose/MooseX-Types-Structured" }, "x_IRC" : "irc://irc.perl.org/#moose", "x_MailingList" : "http://lists.perl.org/list/moose.html" }, "version" : "0.35", "x_Dist_Zilla" : { "perl" : { "version" : "5.023006" }, "plugins" : [ { "class" : "Dist::Zilla::Plugin::Prereqs", "config" : { "Dist::Zilla::Plugin::Prereqs" : { "phase" : "develop", "type" : "requires" } }, "name" : "@Author::ETHER/bundle_plugins", "version" : "5.042" }, { "class" : "Dist::Zilla::Plugin::RewriteVersion::Transitional", "config" : { "Dist::Zilla::Plugin::PkgVersion" : {}, "Dist::Zilla::Plugin::RewriteVersion" : { "add_tarball_name" : 0, "finders" : [ ":ExecFiles", ":InstallModules" ], "global" : 1, "skip_version_provider" : 0 }, "Dist::Zilla::Plugin::RewriteVersion::Transitional" : {} }, "name" : "@Author::ETHER/RewriteVersion::Transitional", "version" : "0.007" }, { "class" : "Dist::Zilla::Plugin::PromptIfStale", "config" : { "Dist::Zilla::Plugin::PromptIfStale" : { "check_all_plugins" : 0, "check_all_prereqs" : 0, "modules" : [ "Dist::Zilla::PluginBundle::Author::ETHER" ], "phase" : "build", "skip" : [] } }, "name" : "@Author::ETHER/stale modules, build", "version" : "0.047" }, { "class" : "Dist::Zilla::Plugin::PromptIfStale", "config" : { "Dist::Zilla::Plugin::PromptIfStale" : { "check_all_plugins" : 1, "check_all_prereqs" : 1, "modules" : [], "phase" : "release", "skip" : [] } }, "name" : "@Author::ETHER/stale modules, release", "version" : "0.047" }, { "class" : "Dist::Zilla::Plugin::FileFinder::ByName", "name" : "@Author::ETHER/Examples", "version" : "5.042" }, { "class" : "Dist::Zilla::Plugin::Git::GatherDir", "config" : { "Dist::Zilla::Plugin::GatherDir" : { "exclude_filename" : [ "CONTRIBUTING", "INSTALL", "LICENSE", "README.pod", "TODO" ], "exclude_match" : [], "follow_symlinks" : 0, "include_dotfiles" : 0, "prefix" : "", "prune_directory" : [], "root" : "." }, "Dist::Zilla::Plugin::Git::GatherDir" : { "include_untracked" : 0 } }, "name" : "@Author::ETHER/Git::GatherDir", "version" : "2.036" }, { "class" : "Dist::Zilla::Plugin::MetaYAML", "name" : "@Author::ETHER/MetaYAML", "version" : "5.042" }, { "class" : "Dist::Zilla::Plugin::MetaJSON", "name" : "@Author::ETHER/MetaJSON", "version" : "5.042" }, { "class" : "Dist::Zilla::Plugin::Readme", "name" : "@Author::ETHER/Readme", "version" : "5.042" }, { "class" : "Dist::Zilla::Plugin::Manifest", "name" : "@Author::ETHER/Manifest", "version" : "5.042" }, { "class" : "Dist::Zilla::Plugin::License", "name" : "@Author::ETHER/License", "version" : "5.042" }, { "class" : "Dist::Zilla::Plugin::GenerateFile::FromShareDir", "config" : { "Dist::Zilla::Plugin::GenerateFile::FromShareDir" : { "destination_filename" : "CONTRIBUTING", "dist" : "Dist-Zilla-PluginBundle-Author-ETHER", "encoding" : "UTF-8", "has_xs" : 0, "location" : "build", "source_filename" : "CONTRIBUTING" }, "Dist::Zilla::Role::RepoFileInjector" : { "allow_overwrite" : 1, "repo_root" : ".", "version" : "0.005" } }, "name" : "@Author::ETHER/generate CONTRIBUTING", "version" : "0.009" }, { "class" : "Dist::Zilla::Plugin::InstallGuide", "name" : "@Author::ETHER/InstallGuide", "version" : "1.200006" }, { "class" : "Dist::Zilla::Plugin::Test::Compile", "config" : { "Dist::Zilla::Plugin::Test::Compile" : { "bail_out_on_fail" : "1", "fail_on_warning" : "author", "fake_home" : 0, "filename" : "xt/author/00-compile.t", "module_finder" : [ ":InstallModules" ], "needs_display" : 0, "phase" : "develop", "script_finder" : [ ":PerlExecFiles", "@Author::ETHER/Examples" ], "skips" : [] } }, "name" : "@Author::ETHER/Test::Compile", "version" : "2.054" }, { "class" : "Dist::Zilla::Plugin::Test::NoTabs", "config" : { "Dist::Zilla::Plugin::Test::NoTabs" : { "filename" : "xt/author/no-tabs.t", "finder" : [ ":InstallModules", ":ExecFiles", "@Author::ETHER/Examples", ":TestFiles", ":ExtraTestFiles" ] } }, "name" : "@Author::ETHER/Test::NoTabs", "version" : "0.15" }, { "class" : "Dist::Zilla::Plugin::Test::EOL", "config" : { "Dist::Zilla::Plugin::Test::EOL" : { "filename" : "xt/author/eol.t", "finder" : [ ":InstallModules", ":ExecFiles", "@Author::ETHER/Examples", ":TestFiles", ":ExtraTestFiles" ], "trailing_whitespace" : "1" } }, "name" : "@Author::ETHER/Test::EOL", "version" : "0.18" }, { "class" : "Dist::Zilla::Plugin::MetaTests", "name" : "@Author::ETHER/MetaTests", "version" : "5.042" }, { "class" : "Dist::Zilla::Plugin::Test::CPAN::Changes", "name" : "@Author::ETHER/Test::CPAN::Changes", "version" : "0.009" }, { "class" : "Dist::Zilla::Plugin::Test::ChangesHasContent", "name" : "@Author::ETHER/Test::ChangesHasContent", "version" : "0.008" }, { "class" : "Dist::Zilla::Plugin::Test::MinimumVersion", "name" : "@Author::ETHER/Test::MinimumVersion", "version" : "2.000006" }, { "class" : "Dist::Zilla::Plugin::PodSyntaxTests", "name" : "@Author::ETHER/PodSyntaxTests", "version" : "5.042" }, { "class" : "Dist::Zilla::Plugin::Test::PodSpelling", "config" : { "Dist::Zilla::Plugin::Test::PodSpelling" : { "directories" : [], "spell_cmd" : "", "stopwords" : [ "irc" ], "wordlist" : "Pod::Wordlist" } }, "name" : "@Author::ETHER/Test::PodSpelling", "version" : "2.007000" }, { "class" : "Dist::Zilla::Plugin::Test::Pod::No404s", "name" : "@Author::ETHER/Test::Pod::No404s", "version" : "1.002" }, { "class" : "Dist::Zilla::Plugin::Test::Kwalitee", "config" : { "Dist::Zilla::Plugin::Test::Kwalitee" : { "filename" : "xt/author/kwalitee.t", "skiptest" : [] } }, "name" : "@Author::ETHER/Test::Kwalitee", "version" : "2.12" }, { "class" : "Dist::Zilla::Plugin::MojibakeTests", "name" : "@Author::ETHER/MojibakeTests", "version" : "0.8" }, { "class" : "Dist::Zilla::Plugin::Test::ReportPrereqs", "name" : "@Author::ETHER/Test::ReportPrereqs", "version" : "0.021" }, { "class" : "Dist::Zilla::Plugin::Test::Portability", "name" : "@Author::ETHER/Test::Portability", "version" : "2.000006" }, { "class" : "Dist::Zilla::Plugin::Test::CleanNamespaces", "config" : { "Dist::Zilla::Plugin::Test::CleanNamespaces" : { "filename" : "xt/author/clean-namespaces.t", "skips" : [] } }, "name" : "@Author::ETHER/Test::CleanNamespaces", "version" : "0.006" }, { "class" : "Dist::Zilla::Plugin::Git::Describe", "name" : "@Author::ETHER/Git::Describe", "version" : "0.006" }, { "class" : "Dist::Zilla::Plugin::SurgicalPodWeaver", "config" : { "Dist::Zilla::Plugin::PodWeaver" : { "config_plugins" : [ "@Author::ETHER" ], "finder" : [ ":InstallModules", ":ExecFiles" ], "plugins" : [ { "class" : "Pod::Weaver::Plugin::EnsurePod5", "name" : "@CorePrep/EnsurePod5", "version" : "4.012" }, { "class" : "Pod::Weaver::Plugin::H1Nester", "name" : "@CorePrep/H1Nester", "version" : "4.012" }, { "class" : "Pod::Weaver::Plugin::SingleEncoding", "name" : "@Author::ETHER/SingleEncoding", "version" : "4.012" }, { "class" : "Pod::Weaver::Plugin::Transformer", "name" : "@Author::ETHER/List", "version" : "4.012" }, { "class" : "Pod::Weaver::Plugin::Transformer", "name" : "@Author::ETHER/Verbatim", "version" : "4.012" }, { "class" : "Pod::Weaver::Section::Region", "name" : "@Author::ETHER/header", "version" : "4.012" }, { "class" : "Pod::Weaver::Section::Name", "name" : "@Author::ETHER/Name", "version" : "4.012" }, { "class" : "Pod::Weaver::Section::Version", "name" : "@Author::ETHER/Version", "version" : "4.012" }, { "class" : "Pod::Weaver::Section::Region", "name" : "@Author::ETHER/prelude", "version" : "4.012" }, { "class" : "Pod::Weaver::Section::Generic", "name" : "SYNOPSIS", "version" : "4.012" }, { "class" : "Pod::Weaver::Section::Generic", "name" : "DESCRIPTION", "version" : "4.012" }, { "class" : "Pod::Weaver::Section::Generic", "name" : "OVERVIEW", "version" : "4.012" }, { "class" : "Pod::Weaver::Section::Collect", "name" : "ATTRIBUTES", "version" : "4.012" }, { "class" : "Pod::Weaver::Section::Collect", "name" : "METHODS", "version" : "4.012" }, { "class" : "Pod::Weaver::Section::Collect", "name" : "FUNCTIONS", "version" : "4.012" }, { "class" : "Pod::Weaver::Section::Collect", "name" : "TYPES", "version" : "4.012" }, { "class" : "Pod::Weaver::Section::Leftovers", "name" : "@Author::ETHER/Leftovers", "version" : "4.012" }, { "class" : "Pod::Weaver::Section::Region", "name" : "@Author::ETHER/postlude", "version" : "4.012" }, { "class" : "Pod::Weaver::Section::GenerateSection", "name" : "@Author::ETHER/generate SUPPORT", "version" : "1.01" }, { "class" : "Pod::Weaver::Section::AllowOverride", "name" : "@Author::ETHER/allow override SUPPORT", "version" : "0.05" }, { "class" : "Pod::Weaver::Section::Authors", "name" : "@Author::ETHER/Authors", "version" : "4.012" }, { "class" : "Pod::Weaver::Section::Contributors", "name" : "@Author::ETHER/Contributors", "version" : "0.009" }, { "class" : "Pod::Weaver::Section::Legal", "name" : "@Author::ETHER/Legal", "version" : "4.012" }, { "class" : "Pod::Weaver::Section::Region", "name" : "@Author::ETHER/footer", "version" : "4.012" } ] } }, "name" : "@Author::ETHER/SurgicalPodWeaver", "version" : "0.0023" }, { "class" : "Dist::Zilla::Plugin::GithubMeta", "name" : "@Author::ETHER/GithubMeta", "version" : "0.54" }, { "class" : "Dist::Zilla::Plugin::AutoMetaResources", "name" : "@Author::ETHER/AutoMetaResources", "version" : "1.21" }, { "class" : "Dist::Zilla::Plugin::AuthorityFromModule", "config" : { "Dist::Zilla::Plugin::AuthorityFromModule" : { "module" : "MooseX::Types::Structured" }, "Dist::Zilla::Role::ModuleMetadata" : { "Module::Metadata" : "1.000031", "version" : "0.003" } }, "name" : "@Author::ETHER/AuthorityFromModule", "version" : "0.006" }, { "class" : "Dist::Zilla::Plugin::Authority", "name" : "@Author::ETHER/Authority", "version" : "1.009" }, { "class" : "Dist::Zilla::Plugin::MetaNoIndex", "name" : "@Author::ETHER/MetaNoIndex", "version" : "5.042" }, { "class" : "Dist::Zilla::Plugin::MetaProvides::Package", "config" : { "Dist::Zilla::Plugin::MetaProvides::Package" : { "finder" : [ ":InstallModules" ], "finder_objects" : [ { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":InstallModules", "version" : "5.042" } ] }, "Dist::Zilla::Role::MetaProvider::Provider" : { "Dist::Zilla::Role::MetaProvider::Provider::VERSION" : "2.001010", "inherit_missing" : "0", "inherit_version" : "0", "meta_noindex" : "1" } }, "name" : "@Author::ETHER/MetaProvides::Package", "version" : "2.003001" }, { "class" : "Dist::Zilla::Plugin::MetaConfig", "name" : "@Author::ETHER/MetaConfig", "version" : "5.042" }, { "class" : "Dist::Zilla::Plugin::Keywords", "config" : { "Dist::Zilla::Plugin::Keywords" : { "keywords" : [] } }, "name" : "@Author::ETHER/Keywords", "version" : "0.006" }, { "class" : "Dist::Zilla::Plugin::AutoPrereqs", "name" : "@Author::ETHER/AutoPrereqs", "version" : "5.042" }, { "class" : "Dist::Zilla::Plugin::Prereqs::AuthorDeps", "name" : "@Author::ETHER/Prereqs::AuthorDeps", "version" : "0.005" }, { "class" : "Dist::Zilla::Plugin::MinimumPerl", "name" : "@Author::ETHER/MinimumPerl", "version" : "1.006" }, { "class" : "Dist::Zilla::Plugin::Prereqs", "config" : { "Dist::Zilla::Plugin::Prereqs" : { "phase" : "develop", "type" : "recommends" } }, "name" : "@Author::ETHER/pluginbundle_version", "version" : "5.042" }, { "class" : "Dist::Zilla::Plugin::Prereqs", "config" : { "Dist::Zilla::Plugin::Prereqs" : { "phase" : "develop", "type" : "requires" } }, "name" : "@Author::ETHER/pod_weaving", "version" : "5.042" }, { "class" : "Dist::Zilla::Plugin::MakeMaker::Fallback", "config" : { "Dist::Zilla::Plugin::MakeMaker::Awesome" : { "version" : "0.35" }, "Dist::Zilla::Role::TestRunner" : { "default_jobs" : 9 } }, "name" : "@Author::ETHER/MakeMaker::Fallback", "version" : "0.021" }, { "class" : "Dist::Zilla::Plugin::ModuleBuildTiny::Fallback", "config" : { "Dist::Zilla::Plugin::ModuleBuildTiny::Fallback" : { "mb_version" : "0.28", "plugins" : [ { "class" : "Dist::Zilla::Plugin::ModuleBuild", "config" : { "Dist::Zilla::Role::TestRunner" : { "default_jobs" : 9 } }, "name" : "ModuleBuild, via ModuleBuildTiny::Fallback", "version" : "5.042" }, { "class" : "Dist::Zilla::Plugin::ModuleBuildTiny", "config" : { "Dist::Zilla::Role::TestRunner" : { "default_jobs" : 9 } }, "name" : "ModuleBuildTiny, via ModuleBuildTiny::Fallback", "version" : "0.014" } ] }, "Dist::Zilla::Role::TestRunner" : { "default_jobs" : 9 } }, "name" : "@Author::ETHER/ModuleBuildTiny::Fallback", "version" : "0.022" }, { "class" : "Dist::Zilla::Plugin::Git::Contributors", "config" : { "Dist::Zilla::Plugin::Git::Contributors" : { "include_authors" : 0, "include_releaser" : 1, "order_by" : "commits", "paths" : [ "." ] } }, "name" : "@Author::ETHER/Git::Contributors", "version" : "0.016" }, { "class" : "Dist::Zilla::Plugin::StaticInstall", "config" : { "Dist::Zilla::Plugin::StaticInstall" : { "dry_run" : 0, "mode" : "auto" } }, "name" : "@Author::ETHER/StaticInstall", "version" : "0.009" }, { "class" : "Dist::Zilla::Plugin::RunExtraTests", "config" : { "Dist::Zilla::Role::TestRunner" : { "default_jobs" : 9 } }, "name" : "@Author::ETHER/RunExtraTests", "version" : "0.028" }, { "class" : "Dist::Zilla::Plugin::CheckSelfDependency", "config" : { "Dist::Zilla::Plugin::CheckSelfDependency" : { "finder" : [ ":InstallModules" ] }, "Dist::Zilla::Role::ModuleMetadata" : { "Module::Metadata" : "1.000031", "version" : "0.003" } }, "name" : "@Author::ETHER/CheckSelfDependency", "version" : "0.011" }, { "class" : "Dist::Zilla::Plugin::Run::AfterBuild", "config" : { "Dist::Zilla::Plugin::Run::Role::Runner" : { "fatal_errors" : 1, "quiet" : 1, "run" : [ "bash -c \"test -e .ackrc && grep -q -- '--ignore-dir=.latest' .ackrc || echo '--ignore-dir=.latest' >> .ackrc; if [[ `dirname '%d'` != .build ]]; then test -e .ackrc && grep -q -- '--ignore-dir=%d' .ackrc || echo '--ignore-dir=%d' >> .ackrc; fi\"" ] } }, "name" : "@Author::ETHER/.ackrc", "version" : "0.042" }, { "class" : "Dist::Zilla::Plugin::Run::AfterBuild", "config" : { "Dist::Zilla::Plugin::Run::Role::Runner" : { "eval" : [ "if ('%d' =~ /^%n-[.[:xdigit:]]+$/) { unlink '.latest'; symlink '%d', '.latest'; }" ], "fatal_errors" : 1, "quiet" : 1 } }, "name" : "@Author::ETHER/.latest", "version" : "0.042" }, { "class" : "Dist::Zilla::Plugin::CheckStrictVersion", "name" : "@Author::ETHER/CheckStrictVersion", "version" : "0.001" }, { "class" : "Dist::Zilla::Plugin::Git::Check", "config" : { "Dist::Zilla::Plugin::Git::Check" : { "untracked_files" : "die" }, "Dist::Zilla::Role::Git::DirtyFiles" : { "allow_dirty" : [], "allow_dirty_match" : [], "changelog" : "Changes" }, "Dist::Zilla::Role::Git::Repo" : { "repo_root" : "." } }, "name" : "@Author::ETHER/initial check", "version" : "2.036" }, { "class" : "Dist::Zilla::Plugin::Git::CheckFor::MergeConflicts", "config" : { "Dist::Zilla::Role::Git::Repo" : { "repo_root" : "." } }, "name" : "@Author::ETHER/Git::CheckFor::MergeConflicts", "version" : "0.013" }, { "class" : "Dist::Zilla::Plugin::Git::CheckFor::CorrectBranch", "config" : { "Dist::Zilla::Role::Git::Repo" : { "repo_root" : "." } }, "name" : "@Author::ETHER/Git::CheckFor::CorrectBranch", "version" : "0.013" }, { "class" : "Dist::Zilla::Plugin::Git::Remote::Check", "name" : "@Author::ETHER/Git::Remote::Check", "version" : "0.2.0" }, { "class" : "Dist::Zilla::Plugin::CheckPrereqsIndexed", "name" : "@Author::ETHER/CheckPrereqsIndexed", "version" : "0.017" }, { "class" : "Dist::Zilla::Plugin::TestRelease", "name" : "@Author::ETHER/TestRelease", "version" : "5.042" }, { "class" : "Dist::Zilla::Plugin::Git::Check", "config" : { "Dist::Zilla::Plugin::Git::Check" : { "untracked_files" : "die" }, "Dist::Zilla::Role::Git::DirtyFiles" : { "allow_dirty" : [], "allow_dirty_match" : [], "changelog" : "Changes" }, "Dist::Zilla::Role::Git::Repo" : { "repo_root" : "." } }, "name" : "@Author::ETHER/after tests", "version" : "2.036" }, { "class" : "Dist::Zilla::Plugin::CheckIssues", "name" : "@Author::ETHER/CheckIssues", "version" : "0.009" }, { "class" : "Dist::Zilla::Plugin::UploadToCPAN", "name" : "@Author::ETHER/UploadToCPAN", "version" : "5.042" }, { "class" : "Dist::Zilla::Plugin::CopyFilesFromRelease", "config" : { "Dist::Zilla::Plugin::CopyFilesFromRelease" : { "filename" : [ "CONTRIBUTING", "Changes", "INSTALL", "LICENCE", "LICENSE", "ppport.h" ], "match" : [] } }, "name" : "@Author::ETHER/CopyFilesFromRelease", "version" : "0.006" }, { "class" : "Dist::Zilla::Plugin::ReadmeAnyFromPod", "config" : { "Dist::Zilla::Role::FileWatcher" : { "version" : "0.006" } }, "name" : "@Author::ETHER/ReadmeAnyFromPod", "version" : "0.150250" }, { "class" : "Dist::Zilla::Plugin::Git::Commit", "config" : { "Dist::Zilla::Plugin::Git::Commit" : { "add_files_in" : [ "." ], "commit_msg" : "%N-%v%t%n%n%c" }, "Dist::Zilla::Role::Git::DirtyFiles" : { "allow_dirty" : [ "CONTRIBUTING", "Changes", "INSTALL", "LICENSE", "README.pod" ], "allow_dirty_match" : [], "changelog" : "Changes" }, "Dist::Zilla::Role::Git::Repo" : { "repo_root" : "." }, "Dist::Zilla::Role::Git::StringFormatter" : { "time_zone" : "local" } }, "name" : "@Author::ETHER/release snapshot", "version" : "2.036" }, { "class" : "Dist::Zilla::Plugin::Git::Tag", "config" : { "Dist::Zilla::Plugin::Git::Tag" : { "branch" : null, "changelog" : "Changes", "signed" : 0, "tag" : "v0.35", "tag_format" : "v%v", "tag_message" : "v%v%t" }, "Dist::Zilla::Role::Git::Repo" : { "repo_root" : "." }, "Dist::Zilla::Role::Git::StringFormatter" : { "time_zone" : "local" } }, "name" : "@Author::ETHER/Git::Tag", "version" : "2.036" }, { "class" : "Dist::Zilla::Plugin::GitHub::Update", "config" : { "Dist::Zilla::Plugin::GitHub::Update" : { "metacpan" : 1 } }, "name" : "@Author::ETHER/GitHub::Update", "version" : "0.41" }, { "class" : "Dist::Zilla::Plugin::BumpVersionAfterRelease::Transitional", "config" : { "Dist::Zilla::Plugin::BumpVersionAfterRelease" : { "finders" : [ ":ExecFiles", ":InstallModules" ], "global" : 1, "munge_makefile_pl" : 1 }, "Dist::Zilla::Plugin::BumpVersionAfterRelease::Transitional" : {} }, "name" : "@Author::ETHER/BumpVersionAfterRelease::Transitional", "version" : "0.007" }, { "class" : "Dist::Zilla::Plugin::NextRelease", "name" : "@Author::ETHER/NextRelease", "version" : "5.042" }, { "class" : "Dist::Zilla::Plugin::Git::Commit", "config" : { "Dist::Zilla::Plugin::Git::Commit" : { "add_files_in" : [], "commit_msg" : "increment $VERSION after %v release" }, "Dist::Zilla::Role::Git::DirtyFiles" : { "allow_dirty" : [ "Changes" ], "allow_dirty_match" : [ "(?^:^lib/.*\\.pm$)" ], "changelog" : "Changes" }, "Dist::Zilla::Role::Git::Repo" : { "repo_root" : "." }, "Dist::Zilla::Role::Git::StringFormatter" : { "time_zone" : "local" } }, "name" : "@Author::ETHER/post-release commit", "version" : "2.036" }, { "class" : "Dist::Zilla::Plugin::Git::Push", "config" : { "Dist::Zilla::Plugin::Git::Push" : { "push_to" : [ "origin" ], "remotes_must_exist" : 1 }, "Dist::Zilla::Role::Git::Repo" : { "repo_root" : "." } }, "name" : "@Author::ETHER/Git::Push", "version" : "2.036" }, { "class" : "Dist::Zilla::Plugin::Run::AfterRelease", "config" : { "Dist::Zilla::Plugin::Run::Role::Runner" : { "fatal_errors" : 0, "quiet" : 0, "run" : [ "REDACTED" ] } }, "name" : "@Author::ETHER/install release", "version" : "0.042" }, { "class" : "Dist::Zilla::Plugin::Run::AfterRelease", "config" : { "Dist::Zilla::Plugin::Run::Role::Runner" : { "eval" : [ "print \"release complete!\\xa\"" ], "fatal_errors" : 1, "quiet" : 1 } }, "name" : "@Author::ETHER/release complete", "version" : "0.042" }, { "class" : "Dist::Zilla::Plugin::ConfirmRelease", "name" : "@Author::ETHER/ConfirmRelease", "version" : "5.042" }, { "class" : "Dist::Zilla::Plugin::Substitute", "name" : "Substitute", "version" : "0.006" }, { "class" : "Dist::Zilla::Plugin::Prereqs", "config" : { "Dist::Zilla::Plugin::Prereqs" : { "phase" : "develop", "type" : "requires" } }, "name" : "DevelopRequires", "version" : "5.042" }, { "class" : "Dist::Zilla::Plugin::MetaResources", "name" : "MetaResources", "version" : "5.042" }, { "class" : "Dist::Zilla::Plugin::Test::Version", "name" : "Test::Version", "version" : "1.05" }, { "class" : "Dist::Zilla::Plugin::Test::CheckBreaks", "config" : { "Dist::Zilla::Plugin::Test::CheckBreaks" : { "conflicts_module" : "Moose::Conflicts", "no_forced_deps" : 0 }, "Dist::Zilla::Role::ModuleMetadata" : { "Module::Metadata" : "1.000031", "version" : "0.003" } }, "name" : "Test::CheckBreaks", "version" : "0.014" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":InstallModules", "version" : "5.042" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":IncModules", "version" : "5.042" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":TestFiles", "version" : "5.042" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":ExtraTestFiles", "version" : "5.042" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":ExecFiles", "version" : "5.042" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":PerlExecFiles", "version" : "5.042" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":ShareFiles", "version" : "5.042" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":MainModule", "version" : "5.042" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":AllFiles", "version" : "5.042" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":NoFiles", "version" : "5.042" }, { "class" : "Dist::Zilla::Plugin::VerifyPhases", "name" : "@Author::ETHER/PHASE VERIFICATION", "version" : "0.013" } ], "zilla" : { "class" : "Dist::Zilla::Dist::Builder", "config" : { "is_trial" : "0" }, "version" : "5.042" } }, "x_authority" : "cpan:JJNAPIORK", "x_authority_from_module" : "MooseX::Types::Structured", "x_contributors" : [ "Karen Etheridge ", "Ricardo Signes ", "Dave Rolsky ", "Ansgar Burchardt ", "Stevan Little ", "arcanez ", "Jesse Luehrs ", "D. Ilmari Mannsåker " ], "x_permissions_from_module" : "MooseX::Types::Structured", "x_static_install" : 1 } MooseX-Types-Structured-0.35/META.yml000644 000766 000024 00000063271 12637630671 017667 0ustar00etherstaff000000 000000 --- abstract: 'Structured Type Constraints for Moose' author: - 'John Napiorkowski ' - 'Florian Ragwitz ' - "יובל קוג'מן (Yuval Kogman) " - 'Tomas (t0m) Doran ' - 'Robert Sedlacek ' build_requires: Data::Dumper: '0' DateTime: '0' ExtUtils::MakeMaker: '0' File::Spec: '0' MooseX::Types::DateTime: '0' MooseX::Types::Moose: '0' Test::Fatal: '0' Test::More: '0.88' Test::Requires: '0' perl: '5.008' strict: '0' warnings: '0' configure_requires: Module::Build::Tiny: '0.034' perl: '5.008' dynamic_config: 0 generated_by: 'Dist::Zilla version 5.042, CPAN::Meta::Converter version 2.150005' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: MooseX-Types-Structured no_index: directory: - t - xt provides: MooseX::Types::Structured: file: lib/MooseX/Types/Structured.pm version: '0.35' requires: Devel::PartialDump: '0.13' JSON::PP: '2.27300' Moose: '0' Moose::Meta::TypeCoercion: '0' Moose::Meta::TypeConstraint: '0' Moose::Meta::TypeConstraint::Parameterizable: '0' Moose::Util::TypeConstraints: '1.06' MooseX::Types: '0.22' Scalar::Util: '0' Sub::Exporter: '0.982' if: '0' namespace::clean: '0.19' overload: '0' perl: '5.008' resources: IRC: irc://irc.perl.org/#moose MailingList: http://lists.perl.org/list/moose.html bugtracker: https://rt.cpan.org/Public/Dist/Display.html?Name=MooseX-Types-Structured homepage: https://github.com/moose/MooseX-Types-Structured repository: https://github.com/moose/MooseX-Types-Structured.git version: '0.35' x_Dist_Zilla: perl: version: '5.023006' plugins: - class: Dist::Zilla::Plugin::Prereqs config: Dist::Zilla::Plugin::Prereqs: phase: develop type: requires name: '@Author::ETHER/bundle_plugins' version: '5.042' - class: Dist::Zilla::Plugin::RewriteVersion::Transitional config: Dist::Zilla::Plugin::PkgVersion: {} Dist::Zilla::Plugin::RewriteVersion: add_tarball_name: 0 finders: - ':ExecFiles' - ':InstallModules' global: 1 skip_version_provider: 0 Dist::Zilla::Plugin::RewriteVersion::Transitional: {} name: '@Author::ETHER/RewriteVersion::Transitional' version: '0.007' - class: Dist::Zilla::Plugin::PromptIfStale config: Dist::Zilla::Plugin::PromptIfStale: check_all_plugins: 0 check_all_prereqs: 0 modules: - Dist::Zilla::PluginBundle::Author::ETHER phase: build skip: [] name: '@Author::ETHER/stale modules, build' version: '0.047' - class: Dist::Zilla::Plugin::PromptIfStale config: Dist::Zilla::Plugin::PromptIfStale: check_all_plugins: 1 check_all_prereqs: 1 modules: [] phase: release skip: [] name: '@Author::ETHER/stale modules, release' version: '0.047' - class: Dist::Zilla::Plugin::FileFinder::ByName name: '@Author::ETHER/Examples' version: '5.042' - class: Dist::Zilla::Plugin::Git::GatherDir config: Dist::Zilla::Plugin::GatherDir: exclude_filename: - CONTRIBUTING - INSTALL - LICENSE - README.pod - TODO exclude_match: [] follow_symlinks: 0 include_dotfiles: 0 prefix: '' prune_directory: [] root: . Dist::Zilla::Plugin::Git::GatherDir: include_untracked: 0 name: '@Author::ETHER/Git::GatherDir' version: '2.036' - class: Dist::Zilla::Plugin::MetaYAML name: '@Author::ETHER/MetaYAML' version: '5.042' - class: Dist::Zilla::Plugin::MetaJSON name: '@Author::ETHER/MetaJSON' version: '5.042' - class: Dist::Zilla::Plugin::Readme name: '@Author::ETHER/Readme' version: '5.042' - class: Dist::Zilla::Plugin::Manifest name: '@Author::ETHER/Manifest' version: '5.042' - class: Dist::Zilla::Plugin::License name: '@Author::ETHER/License' version: '5.042' - class: Dist::Zilla::Plugin::GenerateFile::FromShareDir config: Dist::Zilla::Plugin::GenerateFile::FromShareDir: destination_filename: CONTRIBUTING dist: Dist-Zilla-PluginBundle-Author-ETHER encoding: UTF-8 has_xs: 0 location: build source_filename: CONTRIBUTING Dist::Zilla::Role::RepoFileInjector: allow_overwrite: 1 repo_root: . version: '0.005' name: '@Author::ETHER/generate CONTRIBUTING' version: '0.009' - class: Dist::Zilla::Plugin::InstallGuide name: '@Author::ETHER/InstallGuide' version: '1.200006' - class: Dist::Zilla::Plugin::Test::Compile config: Dist::Zilla::Plugin::Test::Compile: bail_out_on_fail: '1' fail_on_warning: author fake_home: 0 filename: xt/author/00-compile.t module_finder: - ':InstallModules' needs_display: 0 phase: develop script_finder: - ':PerlExecFiles' - '@Author::ETHER/Examples' skips: [] name: '@Author::ETHER/Test::Compile' version: '2.054' - class: Dist::Zilla::Plugin::Test::NoTabs config: Dist::Zilla::Plugin::Test::NoTabs: filename: xt/author/no-tabs.t finder: - ':InstallModules' - ':ExecFiles' - '@Author::ETHER/Examples' - ':TestFiles' - ':ExtraTestFiles' name: '@Author::ETHER/Test::NoTabs' version: '0.15' - class: Dist::Zilla::Plugin::Test::EOL config: Dist::Zilla::Plugin::Test::EOL: filename: xt/author/eol.t finder: - ':InstallModules' - ':ExecFiles' - '@Author::ETHER/Examples' - ':TestFiles' - ':ExtraTestFiles' trailing_whitespace: '1' name: '@Author::ETHER/Test::EOL' version: '0.18' - class: Dist::Zilla::Plugin::MetaTests name: '@Author::ETHER/MetaTests' version: '5.042' - class: Dist::Zilla::Plugin::Test::CPAN::Changes name: '@Author::ETHER/Test::CPAN::Changes' version: '0.009' - class: Dist::Zilla::Plugin::Test::ChangesHasContent name: '@Author::ETHER/Test::ChangesHasContent' version: '0.008' - class: Dist::Zilla::Plugin::Test::MinimumVersion name: '@Author::ETHER/Test::MinimumVersion' version: '2.000006' - class: Dist::Zilla::Plugin::PodSyntaxTests name: '@Author::ETHER/PodSyntaxTests' version: '5.042' - class: Dist::Zilla::Plugin::Test::PodSpelling config: Dist::Zilla::Plugin::Test::PodSpelling: directories: [] spell_cmd: '' stopwords: - irc wordlist: Pod::Wordlist name: '@Author::ETHER/Test::PodSpelling' version: '2.007000' - class: Dist::Zilla::Plugin::Test::Pod::No404s name: '@Author::ETHER/Test::Pod::No404s' version: '1.002' - class: Dist::Zilla::Plugin::Test::Kwalitee config: Dist::Zilla::Plugin::Test::Kwalitee: filename: xt/author/kwalitee.t skiptest: [] name: '@Author::ETHER/Test::Kwalitee' version: '2.12' - class: Dist::Zilla::Plugin::MojibakeTests name: '@Author::ETHER/MojibakeTests' version: '0.8' - class: Dist::Zilla::Plugin::Test::ReportPrereqs name: '@Author::ETHER/Test::ReportPrereqs' version: '0.021' - class: Dist::Zilla::Plugin::Test::Portability name: '@Author::ETHER/Test::Portability' version: '2.000006' - class: Dist::Zilla::Plugin::Test::CleanNamespaces config: Dist::Zilla::Plugin::Test::CleanNamespaces: filename: xt/author/clean-namespaces.t skips: [] name: '@Author::ETHER/Test::CleanNamespaces' version: '0.006' - class: Dist::Zilla::Plugin::Git::Describe name: '@Author::ETHER/Git::Describe' version: '0.006' - class: Dist::Zilla::Plugin::SurgicalPodWeaver config: Dist::Zilla::Plugin::PodWeaver: config_plugins: - '@Author::ETHER' finder: - ':InstallModules' - ':ExecFiles' plugins: - class: Pod::Weaver::Plugin::EnsurePod5 name: '@CorePrep/EnsurePod5' version: '4.012' - class: Pod::Weaver::Plugin::H1Nester name: '@CorePrep/H1Nester' version: '4.012' - class: Pod::Weaver::Plugin::SingleEncoding name: '@Author::ETHER/SingleEncoding' version: '4.012' - class: Pod::Weaver::Plugin::Transformer name: '@Author::ETHER/List' version: '4.012' - class: Pod::Weaver::Plugin::Transformer name: '@Author::ETHER/Verbatim' version: '4.012' - class: Pod::Weaver::Section::Region name: '@Author::ETHER/header' version: '4.012' - class: Pod::Weaver::Section::Name name: '@Author::ETHER/Name' version: '4.012' - class: Pod::Weaver::Section::Version name: '@Author::ETHER/Version' version: '4.012' - class: Pod::Weaver::Section::Region name: '@Author::ETHER/prelude' version: '4.012' - class: Pod::Weaver::Section::Generic name: SYNOPSIS version: '4.012' - class: Pod::Weaver::Section::Generic name: DESCRIPTION version: '4.012' - class: Pod::Weaver::Section::Generic name: OVERVIEW version: '4.012' - class: Pod::Weaver::Section::Collect name: ATTRIBUTES version: '4.012' - class: Pod::Weaver::Section::Collect name: METHODS version: '4.012' - class: Pod::Weaver::Section::Collect name: FUNCTIONS version: '4.012' - class: Pod::Weaver::Section::Collect name: TYPES version: '4.012' - class: Pod::Weaver::Section::Leftovers name: '@Author::ETHER/Leftovers' version: '4.012' - class: Pod::Weaver::Section::Region name: '@Author::ETHER/postlude' version: '4.012' - class: Pod::Weaver::Section::GenerateSection name: '@Author::ETHER/generate SUPPORT' version: '1.01' - class: Pod::Weaver::Section::AllowOverride name: '@Author::ETHER/allow override SUPPORT' version: '0.05' - class: Pod::Weaver::Section::Authors name: '@Author::ETHER/Authors' version: '4.012' - class: Pod::Weaver::Section::Contributors name: '@Author::ETHER/Contributors' version: '0.009' - class: Pod::Weaver::Section::Legal name: '@Author::ETHER/Legal' version: '4.012' - class: Pod::Weaver::Section::Region name: '@Author::ETHER/footer' version: '4.012' name: '@Author::ETHER/SurgicalPodWeaver' version: '0.0023' - class: Dist::Zilla::Plugin::GithubMeta name: '@Author::ETHER/GithubMeta' version: '0.54' - class: Dist::Zilla::Plugin::AutoMetaResources name: '@Author::ETHER/AutoMetaResources' version: '1.21' - class: Dist::Zilla::Plugin::AuthorityFromModule config: Dist::Zilla::Plugin::AuthorityFromModule: module: MooseX::Types::Structured Dist::Zilla::Role::ModuleMetadata: Module::Metadata: '1.000031' version: '0.003' name: '@Author::ETHER/AuthorityFromModule' version: '0.006' - class: Dist::Zilla::Plugin::Authority name: '@Author::ETHER/Authority' version: '1.009' - class: Dist::Zilla::Plugin::MetaNoIndex name: '@Author::ETHER/MetaNoIndex' version: '5.042' - class: Dist::Zilla::Plugin::MetaProvides::Package config: Dist::Zilla::Plugin::MetaProvides::Package: finder: - ':InstallModules' finder_objects: - class: Dist::Zilla::Plugin::FinderCode name: ':InstallModules' version: '5.042' Dist::Zilla::Role::MetaProvider::Provider: Dist::Zilla::Role::MetaProvider::Provider::VERSION: '2.001010' inherit_missing: '0' inherit_version: '0' meta_noindex: '1' name: '@Author::ETHER/MetaProvides::Package' version: '2.003001' - class: Dist::Zilla::Plugin::MetaConfig name: '@Author::ETHER/MetaConfig' version: '5.042' - class: Dist::Zilla::Plugin::Keywords config: Dist::Zilla::Plugin::Keywords: keywords: [] name: '@Author::ETHER/Keywords' version: '0.006' - class: Dist::Zilla::Plugin::AutoPrereqs name: '@Author::ETHER/AutoPrereqs' version: '5.042' - class: Dist::Zilla::Plugin::Prereqs::AuthorDeps name: '@Author::ETHER/Prereqs::AuthorDeps' version: '0.005' - class: Dist::Zilla::Plugin::MinimumPerl name: '@Author::ETHER/MinimumPerl' version: '1.006' - class: Dist::Zilla::Plugin::Prereqs config: Dist::Zilla::Plugin::Prereqs: phase: develop type: recommends name: '@Author::ETHER/pluginbundle_version' version: '5.042' - class: Dist::Zilla::Plugin::Prereqs config: Dist::Zilla::Plugin::Prereqs: phase: develop type: requires name: '@Author::ETHER/pod_weaving' version: '5.042' - class: Dist::Zilla::Plugin::MakeMaker::Fallback config: Dist::Zilla::Plugin::MakeMaker::Awesome: version: '0.35' Dist::Zilla::Role::TestRunner: default_jobs: 9 name: '@Author::ETHER/MakeMaker::Fallback' version: '0.021' - class: Dist::Zilla::Plugin::ModuleBuildTiny::Fallback config: Dist::Zilla::Plugin::ModuleBuildTiny::Fallback: mb_version: '0.28' plugins: - class: Dist::Zilla::Plugin::ModuleBuild config: Dist::Zilla::Role::TestRunner: default_jobs: 9 name: 'ModuleBuild, via ModuleBuildTiny::Fallback' version: '5.042' - class: Dist::Zilla::Plugin::ModuleBuildTiny config: Dist::Zilla::Role::TestRunner: default_jobs: 9 name: 'ModuleBuildTiny, via ModuleBuildTiny::Fallback' version: '0.014' Dist::Zilla::Role::TestRunner: default_jobs: 9 name: '@Author::ETHER/ModuleBuildTiny::Fallback' version: '0.022' - class: Dist::Zilla::Plugin::Git::Contributors config: Dist::Zilla::Plugin::Git::Contributors: include_authors: 0 include_releaser: 1 order_by: commits paths: - . name: '@Author::ETHER/Git::Contributors' version: '0.016' - class: Dist::Zilla::Plugin::StaticInstall config: Dist::Zilla::Plugin::StaticInstall: dry_run: 0 mode: auto name: '@Author::ETHER/StaticInstall' version: '0.009' - class: Dist::Zilla::Plugin::RunExtraTests config: Dist::Zilla::Role::TestRunner: default_jobs: 9 name: '@Author::ETHER/RunExtraTests' version: '0.028' - class: Dist::Zilla::Plugin::CheckSelfDependency config: Dist::Zilla::Plugin::CheckSelfDependency: finder: - ':InstallModules' Dist::Zilla::Role::ModuleMetadata: Module::Metadata: '1.000031' version: '0.003' name: '@Author::ETHER/CheckSelfDependency' version: '0.011' - class: Dist::Zilla::Plugin::Run::AfterBuild config: Dist::Zilla::Plugin::Run::Role::Runner: fatal_errors: 1 quiet: 1 run: - "bash -c \"test -e .ackrc && grep -q -- '--ignore-dir=.latest' .ackrc || echo '--ignore-dir=.latest' >> .ackrc; if [[ `dirname '%d'` != .build ]]; then test -e .ackrc && grep -q -- '--ignore-dir=%d' .ackrc || echo '--ignore-dir=%d' >> .ackrc; fi\"" name: '@Author::ETHER/.ackrc' version: '0.042' - class: Dist::Zilla::Plugin::Run::AfterBuild config: Dist::Zilla::Plugin::Run::Role::Runner: eval: - "if ('%d' =~ /^%n-[.[:xdigit:]]+$/) { unlink '.latest'; symlink '%d', '.latest'; }" fatal_errors: 1 quiet: 1 name: '@Author::ETHER/.latest' version: '0.042' - class: Dist::Zilla::Plugin::CheckStrictVersion name: '@Author::ETHER/CheckStrictVersion' version: '0.001' - class: Dist::Zilla::Plugin::Git::Check config: Dist::Zilla::Plugin::Git::Check: untracked_files: die Dist::Zilla::Role::Git::DirtyFiles: allow_dirty: [] allow_dirty_match: [] changelog: Changes Dist::Zilla::Role::Git::Repo: repo_root: . name: '@Author::ETHER/initial check' version: '2.036' - class: Dist::Zilla::Plugin::Git::CheckFor::MergeConflicts config: Dist::Zilla::Role::Git::Repo: repo_root: . name: '@Author::ETHER/Git::CheckFor::MergeConflicts' version: '0.013' - class: Dist::Zilla::Plugin::Git::CheckFor::CorrectBranch config: Dist::Zilla::Role::Git::Repo: repo_root: . name: '@Author::ETHER/Git::CheckFor::CorrectBranch' version: '0.013' - class: Dist::Zilla::Plugin::Git::Remote::Check name: '@Author::ETHER/Git::Remote::Check' version: 0.2.0 - class: Dist::Zilla::Plugin::CheckPrereqsIndexed name: '@Author::ETHER/CheckPrereqsIndexed' version: '0.017' - class: Dist::Zilla::Plugin::TestRelease name: '@Author::ETHER/TestRelease' version: '5.042' - class: Dist::Zilla::Plugin::Git::Check config: Dist::Zilla::Plugin::Git::Check: untracked_files: die Dist::Zilla::Role::Git::DirtyFiles: allow_dirty: [] allow_dirty_match: [] changelog: Changes Dist::Zilla::Role::Git::Repo: repo_root: . name: '@Author::ETHER/after tests' version: '2.036' - class: Dist::Zilla::Plugin::CheckIssues name: '@Author::ETHER/CheckIssues' version: '0.009' - class: Dist::Zilla::Plugin::UploadToCPAN name: '@Author::ETHER/UploadToCPAN' version: '5.042' - class: Dist::Zilla::Plugin::CopyFilesFromRelease config: Dist::Zilla::Plugin::CopyFilesFromRelease: filename: - CONTRIBUTING - Changes - INSTALL - LICENCE - LICENSE - ppport.h match: [] name: '@Author::ETHER/CopyFilesFromRelease' version: '0.006' - class: Dist::Zilla::Plugin::ReadmeAnyFromPod config: Dist::Zilla::Role::FileWatcher: version: '0.006' name: '@Author::ETHER/ReadmeAnyFromPod' version: '0.150250' - class: Dist::Zilla::Plugin::Git::Commit config: Dist::Zilla::Plugin::Git::Commit: add_files_in: - . commit_msg: '%N-%v%t%n%n%c' Dist::Zilla::Role::Git::DirtyFiles: allow_dirty: - CONTRIBUTING - Changes - INSTALL - LICENSE - README.pod allow_dirty_match: [] changelog: Changes Dist::Zilla::Role::Git::Repo: repo_root: . Dist::Zilla::Role::Git::StringFormatter: time_zone: local name: '@Author::ETHER/release snapshot' version: '2.036' - class: Dist::Zilla::Plugin::Git::Tag config: Dist::Zilla::Plugin::Git::Tag: branch: ~ changelog: Changes signed: 0 tag: v0.35 tag_format: v%v tag_message: v%v%t Dist::Zilla::Role::Git::Repo: repo_root: . Dist::Zilla::Role::Git::StringFormatter: time_zone: local name: '@Author::ETHER/Git::Tag' version: '2.036' - class: Dist::Zilla::Plugin::GitHub::Update config: Dist::Zilla::Plugin::GitHub::Update: metacpan: 1 name: '@Author::ETHER/GitHub::Update' version: '0.41' - class: Dist::Zilla::Plugin::BumpVersionAfterRelease::Transitional config: Dist::Zilla::Plugin::BumpVersionAfterRelease: finders: - ':ExecFiles' - ':InstallModules' global: 1 munge_makefile_pl: 1 Dist::Zilla::Plugin::BumpVersionAfterRelease::Transitional: {} name: '@Author::ETHER/BumpVersionAfterRelease::Transitional' version: '0.007' - class: Dist::Zilla::Plugin::NextRelease name: '@Author::ETHER/NextRelease' version: '5.042' - class: Dist::Zilla::Plugin::Git::Commit config: Dist::Zilla::Plugin::Git::Commit: add_files_in: [] commit_msg: 'increment $VERSION after %v release' Dist::Zilla::Role::Git::DirtyFiles: allow_dirty: - Changes allow_dirty_match: - (?^:^lib/.*\.pm$) changelog: Changes Dist::Zilla::Role::Git::Repo: repo_root: . Dist::Zilla::Role::Git::StringFormatter: time_zone: local name: '@Author::ETHER/post-release commit' version: '2.036' - class: Dist::Zilla::Plugin::Git::Push config: Dist::Zilla::Plugin::Git::Push: push_to: - origin remotes_must_exist: 1 Dist::Zilla::Role::Git::Repo: repo_root: . name: '@Author::ETHER/Git::Push' version: '2.036' - class: Dist::Zilla::Plugin::Run::AfterRelease config: Dist::Zilla::Plugin::Run::Role::Runner: fatal_errors: 0 quiet: 0 run: - REDACTED name: '@Author::ETHER/install release' version: '0.042' - class: Dist::Zilla::Plugin::Run::AfterRelease config: Dist::Zilla::Plugin::Run::Role::Runner: eval: - 'print "release complete!\xa"' fatal_errors: 1 quiet: 1 name: '@Author::ETHER/release complete' version: '0.042' - class: Dist::Zilla::Plugin::ConfirmRelease name: '@Author::ETHER/ConfirmRelease' version: '5.042' - class: Dist::Zilla::Plugin::Substitute name: Substitute version: '0.006' - class: Dist::Zilla::Plugin::Prereqs config: Dist::Zilla::Plugin::Prereqs: phase: develop type: requires name: DevelopRequires version: '5.042' - class: Dist::Zilla::Plugin::MetaResources name: MetaResources version: '5.042' - class: Dist::Zilla::Plugin::Test::Version name: Test::Version version: '1.05' - class: Dist::Zilla::Plugin::Test::CheckBreaks config: Dist::Zilla::Plugin::Test::CheckBreaks: conflicts_module: Moose::Conflicts no_forced_deps: 0 Dist::Zilla::Role::ModuleMetadata: Module::Metadata: '1.000031' version: '0.003' name: Test::CheckBreaks version: '0.014' - class: Dist::Zilla::Plugin::FinderCode name: ':InstallModules' version: '5.042' - class: Dist::Zilla::Plugin::FinderCode name: ':IncModules' version: '5.042' - class: Dist::Zilla::Plugin::FinderCode name: ':TestFiles' version: '5.042' - class: Dist::Zilla::Plugin::FinderCode name: ':ExtraTestFiles' version: '5.042' - class: Dist::Zilla::Plugin::FinderCode name: ':ExecFiles' version: '5.042' - class: Dist::Zilla::Plugin::FinderCode name: ':PerlExecFiles' version: '5.042' - class: Dist::Zilla::Plugin::FinderCode name: ':ShareFiles' version: '5.042' - class: Dist::Zilla::Plugin::FinderCode name: ':MainModule' version: '5.042' - class: Dist::Zilla::Plugin::FinderCode name: ':AllFiles' version: '5.042' - class: Dist::Zilla::Plugin::FinderCode name: ':NoFiles' version: '5.042' - class: Dist::Zilla::Plugin::VerifyPhases name: '@Author::ETHER/PHASE VERIFICATION' version: '0.013' zilla: class: Dist::Zilla::Dist::Builder config: is_trial: '0' version: '5.042' x_authority: cpan:JJNAPIORK x_authority_from_module: MooseX::Types::Structured x_contributors: - 'Karen Etheridge ' - 'Ricardo Signes ' - 'Dave Rolsky ' - 'Ansgar Burchardt ' - 'Stevan Little ' - 'arcanez ' - 'Jesse Luehrs ' - 'D. Ilmari Mannsåker ' x_permissions_from_module: MooseX::Types::Structured x_static_install: 1 MooseX-Types-Structured-0.35/README000644 000766 000024 00000000605 12637630671 017266 0ustar00etherstaff000000 000000 This archive contains the distribution MooseX-Types-Structured, version 0.35: Structured Type Constraints for Moose This software is copyright (c) 2008 by John Napiorkowski. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. This README file was generated by Dist::Zilla::Plugin::Readme v5.042. MooseX-Types-Structured-0.35/t/000700 000766 000024 00000000000 12637630671 016636 5ustar00etherstaff000000 000000 MooseX-Types-Structured-0.35/xt/000700 000766 000024 00000000000 12637630671 017026 5ustar00etherstaff000000 000000 MooseX-Types-Structured-0.35/xt/author/000700 000766 000024 00000000000 12637630671 020330 5ustar00etherstaff000000 000000 MooseX-Types-Structured-0.35/xt/release/000700 000766 000024 00000000000 12637630671 020446 5ustar00etherstaff000000 000000 MooseX-Types-Structured-0.35/xt/release/changes_has_content.t000644 000766 000024 00000002010 12637630671 024633 0ustar00etherstaff000000 000000 #!perl use Test::More tests => 2; note 'Checking Changes'; my $changes_file = 'Changes'; my $newver = '0.35'; my $trial_token = '-TRIAL'; SKIP: { ok(-e $changes_file, "$changes_file file exists") or skip 'Changes is missing', 1; ok(_get_changes($newver), "$changes_file has content for $newver"); } done_testing; # _get_changes copied and adapted from Dist::Zilla::Plugin::Git::Commit # by Jerome Quelin sub _get_changes { my $newver = shift; # parse changelog to find commit message open(my $fh, '<', $changes_file) or die "cannot open $changes_file: $!"; my $changelog = join('', <$fh>); close $fh; my @content = grep { /^$newver(?:$trial_token)?(?:\s+|$)/ ... /^\S/ } # from newver to un-indented split /\n/, $changelog; shift @content; # drop the version line # drop unindented last line and trailing blank lines pop @content while ( @content && $content[-1] =~ /^(?:\S|\s*$)/ ); # return number of non-blank lines return scalar @content; } MooseX-Types-Structured-0.35/xt/release/cpan-changes.t000644 000766 000024 00000000263 12637630671 023175 0ustar00etherstaff000000 000000 #!perl use strict; use warnings; use Test::More 0.96 tests => 2; use_ok('Test::CPAN::Changes'); subtest 'changes_ok' => sub { changes_file_ok('Changes'); }; done_testing(); MooseX-Types-Structured-0.35/xt/release/distmeta.t000644 000766 000024 00000000172 12637630671 022457 0ustar00etherstaff000000 000000 #!perl # This file was automatically generated by Dist::Zilla::Plugin::MetaTests. use Test::CPAN::Meta; meta_yaml_ok(); MooseX-Types-Structured-0.35/xt/release/minimum-version.t000644 000766 000024 00000000271 12637630671 024003 0ustar00etherstaff000000 000000 #!perl use Test::More; eval "use Test::MinimumVersion"; plan skip_all => "Test::MinimumVersion required for testing minimum versions" if $@; all_minimum_version_ok( qq{5.008003} ); MooseX-Types-Structured-0.35/xt/release/pod-no404s.t000644 000766 000024 00000000527 12637630671 022460 0ustar00etherstaff000000 000000 #!perl use strict; use warnings; use Test::More; foreach my $env_skip ( qw( SKIP_POD_NO404S AUTOMATED_TESTING ) ){ plan skip_all => "\$ENV{$env_skip} is set, skipping" if $ENV{$env_skip}; } eval "use Test::Pod::No404s"; if ( $@ ) { plan skip_all => 'Test::Pod::No404s required for testing POD'; } else { all_pod_files_ok(); } MooseX-Types-Structured-0.35/xt/release/portability.t000644 000766 000024 00000000277 12637630671 023215 0ustar00etherstaff000000 000000 #!perl use strict; use warnings; use Test::More; eval 'use Test::Portability::Files'; plan skip_all => 'Test::Portability::Files required for testing portability' if $@; run_tests(); MooseX-Types-Structured-0.35/xt/author/00-compile.t000644 000766 000024 00000002733 12637630671 022401 0ustar00etherstaff000000 000000 use 5.006; use strict; use warnings; # this test was generated with Dist::Zilla::Plugin::Test::Compile 2.054 use Test::More 0.94; plan tests => 8; my @module_files = ( 'MooseX/Meta/TypeCoercion/Structured.pm', 'MooseX/Meta/TypeCoercion/Structured/Optional.pm', 'MooseX/Meta/TypeConstraint/Structured.pm', 'MooseX/Meta/TypeConstraint/Structured/Optional.pm', 'MooseX/Types/Structured.pm', 'MooseX/Types/Structured/MessageStack.pm', 'MooseX/Types/Structured/OverflowHandler.pm' ); # no fake home requested my $inc_switch = -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; my $pid = open3($stdin, '>&STDERR', $stderr, $^X, $inc_switch, '-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: ', explain(\@warnings); BAIL_OUT("Compilation problems") if !Test::More->builder->is_passing; MooseX-Types-Structured-0.35/xt/author/clean-namespaces.t000644 000766 000024 00000000507 12637630671 023730 0ustar00etherstaff000000 000000 use strict; use warnings; # this test was generated with Dist::Zilla::Plugin::Test::CleanNamespaces 0.006 # and altered by the local dist.ini use Test::More 0.94; use Test::CleanNamespaces 0.15; use Test::Requires { 'MooseX::Types' => '0.44' }; subtest all_namespaces_clean => sub { all_namespaces_clean() }; done_testing; MooseX-Types-Structured-0.35/xt/author/eol.t000644 000766 000024 00000003151 12637630671 021306 0ustar00etherstaff000000 000000 use strict; use warnings; # this test was generated with Dist::Zilla::Plugin::Test::EOL 0.18 use Test::More 0.88; use Test::EOL; my @files = ( 'lib/MooseX/Meta/TypeCoercion/Structured.pm', 'lib/MooseX/Meta/TypeCoercion/Structured/Optional.pm', 'lib/MooseX/Meta/TypeConstraint/Structured.pm', 'lib/MooseX/Meta/TypeConstraint/Structured/Optional.pm', 'lib/MooseX/Types/Structured.pm', 'lib/MooseX/Types/Structured/MessageStack.pm', 'lib/MooseX/Types/Structured/OverflowHandler.pm', 't/00-load.t', 't/00-report-prereqs.dd', 't/00-report-prereqs.t', 't/01-basic.t', 't/02-tuple.t', 't/03-dict.t', 't/04-combined.t', 't/04-map.t', 't/05-advanced.t', 't/06-api.t', 't/07-coerce.t', 't/08-examples.t', 't/09-optional.t', 't/10-recursion.t', 't/11-overflow.t', 't/12-error.t', 't/13-deeper_error.t', 't/14-fully-qualified.t', 't/bug-incorrect-message.t', 't/bug-is-subtype.t', 't/bug-mixed-stringy.t', 't/bug-optional.t', 't/regressions/01-is_type_of.t', 't/zzz-check-breaks.t', 'xt/author/00-compile.t', 'xt/author/clean-namespaces.t', 'xt/author/eol.t', 'xt/author/kwalitee.t', 'xt/author/mojibake.t', 'xt/author/no-tabs.t', 'xt/author/pod-spell.t', 'xt/author/pod-syntax.t', 'xt/author/test-version.t', 'xt/release/changes_has_content.t', 'xt/release/cpan-changes.t', 'xt/release/distmeta.t', 'xt/release/minimum-version.t', 'xt/release/pod-no404s.t', 'xt/release/portability.t' ); eol_unix_ok($_, { trailing_whitespace => 1 }) foreach @files; done_testing; MooseX-Types-Structured-0.35/xt/author/kwalitee.t000644 000766 000024 00000000275 12637630671 022340 0ustar00etherstaff000000 000000 # this test was generated with Dist::Zilla::Plugin::Test::Kwalitee 2.12 use strict; use warnings; use Test::More 0.88; use Test::Kwalitee 1.21 'kwalitee_ok'; kwalitee_ok(); done_testing; MooseX-Types-Structured-0.35/xt/author/mojibake.t000644 000766 000024 00000000151 12637630671 022305 0ustar00etherstaff000000 000000 #!perl use strict; use warnings qw(all); use Test::More; use Test::Mojibake; all_files_encoding_ok(); MooseX-Types-Structured-0.35/xt/author/no-tabs.t000644 000766 000024 00000003117 12637630671 022074 0ustar00etherstaff000000 000000 use strict; use warnings; # this test was generated with Dist::Zilla::Plugin::Test::NoTabs 0.15 use Test::More 0.88; use Test::NoTabs; my @files = ( 'lib/MooseX/Meta/TypeCoercion/Structured.pm', 'lib/MooseX/Meta/TypeCoercion/Structured/Optional.pm', 'lib/MooseX/Meta/TypeConstraint/Structured.pm', 'lib/MooseX/Meta/TypeConstraint/Structured/Optional.pm', 'lib/MooseX/Types/Structured.pm', 'lib/MooseX/Types/Structured/MessageStack.pm', 'lib/MooseX/Types/Structured/OverflowHandler.pm', 't/00-load.t', 't/00-report-prereqs.dd', 't/00-report-prereqs.t', 't/01-basic.t', 't/02-tuple.t', 't/03-dict.t', 't/04-combined.t', 't/04-map.t', 't/05-advanced.t', 't/06-api.t', 't/07-coerce.t', 't/08-examples.t', 't/09-optional.t', 't/10-recursion.t', 't/11-overflow.t', 't/12-error.t', 't/13-deeper_error.t', 't/14-fully-qualified.t', 't/bug-incorrect-message.t', 't/bug-is-subtype.t', 't/bug-mixed-stringy.t', 't/bug-optional.t', 't/regressions/01-is_type_of.t', 't/zzz-check-breaks.t', 'xt/author/00-compile.t', 'xt/author/clean-namespaces.t', 'xt/author/eol.t', 'xt/author/kwalitee.t', 'xt/author/mojibake.t', 'xt/author/no-tabs.t', 'xt/author/pod-spell.t', 'xt/author/pod-syntax.t', 'xt/author/test-version.t', 'xt/release/changes_has_content.t', 'xt/release/cpan-changes.t', 'xt/release/distmeta.t', 'xt/release/minimum-version.t', 'xt/release/pod-no404s.t', 'xt/release/portability.t' ); notabs_ok($_) foreach @files; done_testing; MooseX-Types-Structured-0.35/xt/author/pod-spell.t000644 000766 000024 00000001166 12637630671 022432 0ustar00etherstaff000000 000000 use strict; use warnings; use Test::More; # generated by Dist::Zilla::Plugin::Test::PodSpelling 2.007000 use Test::Spelling 0.12; use Pod::Wordlist; add_stopwords(); all_pod_files_spelling_ok( qw( bin lib ) ); __DATA__ irc John Napiorkowski jjnapiork Florian Ragwitz rafl יובל קוג Yuval Kogman nothingmuch Tomas t0m Doran bobtfish Robert Sedlacek rs Karen Etheridge ether Ricardo Signes rjbs Dave Rolsky autarch Ansgar Burchardt ansgar Stevan Little stevan arcanez justin Jesse Luehrs doy Ilmari Mannsåker ilmari lib MooseX Meta TypeCoercion Structured Optional TypeConstraint Types MessageStack OverflowHandler MooseX-Types-Structured-0.35/xt/author/pod-syntax.t000644 000766 000024 00000000252 12637630671 022634 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(); MooseX-Types-Structured-0.35/xt/author/test-version.t000644 000766 000024 00000000640 12637630671 023171 0ustar00etherstaff000000 000000 use strict; use warnings; use Test::More; # generated by Dist::Zilla::Plugin::Test::Version 1.05 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; MooseX-Types-Structured-0.35/t/00-load.t000644 000766 000024 00000000461 12637630671 020172 0ustar00etherstaff000000 000000 use strict; use warnings; use Test::More tests=>4; ## List all the modules we want to make sure can at least compile use_ok 'MooseX::Meta::TypeConstraint::Structured'; use_ok 'MooseX::Meta::TypeCoercion::Structured'; use_ok 'MooseX::Types::Structured::MessageStack'; use_ok 'MooseX::Types::Structured'; MooseX-Types-Structured-0.35/t/00-report-prereqs.dd000644 000766 000024 00000023704 12637630671 022376 0ustar00etherstaff000000 000000 do { my $x = { 'configure' => { 'requires' => { 'Module::Build::Tiny' => '0.034', 'perl' => '5.008' } }, 'develop' => { 'recommends' => { 'Dist::Zilla::PluginBundle::Author::ETHER' => '0.110' }, 'requires' => { 'Dist::Zilla' => '5', 'Dist::Zilla::Plugin::Authority' => '1.009', 'Dist::Zilla::Plugin::AuthorityFromModule' => '0.002', 'Dist::Zilla::Plugin::AutoMetaResources' => '0', 'Dist::Zilla::Plugin::AutoPrereqs' => '5.038', 'Dist::Zilla::Plugin::BumpVersionAfterRelease::Transitional' => '0.004', 'Dist::Zilla::Plugin::CheckIssues' => '0', 'Dist::Zilla::Plugin::CheckPrereqsIndexed' => '0', 'Dist::Zilla::Plugin::CheckSelfDependency' => '0', 'Dist::Zilla::Plugin::CheckStrictVersion' => '0', 'Dist::Zilla::Plugin::ConfirmRelease' => '0', 'Dist::Zilla::Plugin::CopyFilesFromRelease' => '0', 'Dist::Zilla::Plugin::FileFinder::ByName' => '0', 'Dist::Zilla::Plugin::GenerateFile::FromShareDir' => '0', 'Dist::Zilla::Plugin::Git::Check' => '0', 'Dist::Zilla::Plugin::Git::CheckFor::CorrectBranch' => '0.004', 'Dist::Zilla::Plugin::Git::CheckFor::MergeConflicts' => '0', 'Dist::Zilla::Plugin::Git::Commit' => '2.020', 'Dist::Zilla::Plugin::Git::Contributors' => '0.004', 'Dist::Zilla::Plugin::Git::Describe' => '0.004', 'Dist::Zilla::Plugin::Git::GatherDir' => '2.016', 'Dist::Zilla::Plugin::Git::Push' => '0', 'Dist::Zilla::Plugin::Git::Remote::Check' => '0', 'Dist::Zilla::Plugin::Git::Tag' => '0', 'Dist::Zilla::Plugin::GitHub::Update' => '0.40', 'Dist::Zilla::Plugin::GithubMeta' => '0.54', 'Dist::Zilla::Plugin::InstallGuide' => '1.200005', 'Dist::Zilla::Plugin::Keywords' => '0.004', 'Dist::Zilla::Plugin::License' => '5.038', 'Dist::Zilla::Plugin::MakeMaker::Fallback' => '0.012', 'Dist::Zilla::Plugin::Manifest' => '0', 'Dist::Zilla::Plugin::MetaConfig' => '0', 'Dist::Zilla::Plugin::MetaJSON' => '0', 'Dist::Zilla::Plugin::MetaNoIndex' => '0', 'Dist::Zilla::Plugin::MetaProvides::Package' => '1.15000002', 'Dist::Zilla::Plugin::MetaResources' => '0', 'Dist::Zilla::Plugin::MetaTests' => '0', 'Dist::Zilla::Plugin::MetaYAML' => '0', 'Dist::Zilla::Plugin::MinimumPerl' => '1.006', 'Dist::Zilla::Plugin::ModuleBuildTiny::Fallback' => '0.018', 'Dist::Zilla::Plugin::MojibakeTests' => '0.8', 'Dist::Zilla::Plugin::NextRelease' => '5.033', 'Dist::Zilla::Plugin::PodSyntaxTests' => '5.040', 'Dist::Zilla::Plugin::Prereqs' => '0', 'Dist::Zilla::Plugin::Prereqs::AuthorDeps' => '0', 'Dist::Zilla::Plugin::PromptIfStale' => '0', 'Dist::Zilla::Plugin::Readme' => '0', 'Dist::Zilla::Plugin::ReadmeAnyFromPod' => '0.142180', 'Dist::Zilla::Plugin::RewriteVersion::Transitional' => '0.004', 'Dist::Zilla::Plugin::Run::AfterBuild' => '0.038', 'Dist::Zilla::Plugin::Run::AfterRelease' => '0.038', 'Dist::Zilla::Plugin::RunExtraTests' => '0.024', 'Dist::Zilla::Plugin::StaticInstall' => '0.005', 'Dist::Zilla::Plugin::Substitute' => '0.006', 'Dist::Zilla::Plugin::SurgicalPodWeaver' => '0', 'Dist::Zilla::Plugin::Test::CPAN::Changes' => '0.008', 'Dist::Zilla::Plugin::Test::ChangesHasContent' => '0', 'Dist::Zilla::Plugin::Test::CheckBreaks' => '0', 'Dist::Zilla::Plugin::Test::CleanNamespaces' => '0.006', 'Dist::Zilla::Plugin::Test::Compile' => '2.039', 'Dist::Zilla::Plugin::Test::EOL' => '0.17', 'Dist::Zilla::Plugin::Test::Kwalitee' => '2.10', 'Dist::Zilla::Plugin::Test::MinimumVersion' => '2.000003', 'Dist::Zilla::Plugin::Test::NoTabs' => '0.08', 'Dist::Zilla::Plugin::Test::Pod::No404s' => '1.002', 'Dist::Zilla::Plugin::Test::PodSpelling' => '2.006003', 'Dist::Zilla::Plugin::Test::Portability' => '0', 'Dist::Zilla::Plugin::Test::ReportPrereqs' => '0.019', 'Dist::Zilla::Plugin::Test::Version' => '0', 'Dist::Zilla::Plugin::TestRelease' => '0', 'Dist::Zilla::Plugin::UploadToCPAN' => '0', 'Dist::Zilla::PluginBundle::Author::ETHER' => '0.094', 'File::Spec' => '0', 'IO::Handle' => '0', 'IPC::Open3' => '0', 'Pod::Wordlist' => '0', 'Software::License::Perl_5' => '0', 'Test::CPAN::Changes' => '0.19', 'Test::CPAN::Meta' => '0', 'Test::CleanNamespaces' => '0.15', 'Test::EOL' => '0', 'Test::Kwalitee' => '1.21', 'Test::Mojibake' => '0', 'Test::More' => '0.96', 'Test::NoTabs' => '0', 'Test::Pod' => '1.41', 'Test::Pod::No404s' => '0', 'Test::Requires' => '0', 'Test::Spelling' => '0.12', 'Test::Version' => '1', 'blib' => '1.01', 'strict' => '0', 'warnings' => '0' } }, 'runtime' => { 'requires' => { 'Devel::PartialDump' => '0.13', 'JSON::PP' => '2.27300', 'Moose' => '0', 'Moose::Meta::TypeCoercion' => '0', 'Moose::Meta::TypeConstraint' => '0', 'Moose::Meta::TypeConstraint::Parameterizable' => '0', 'Moose::Util::TypeConstraints' => '1.06', 'MooseX::Types' => '0.22', 'Scalar::Util' => '0', 'Sub::Exporter' => '0.982', 'if' => '0', 'namespace::clean' => '0.19', 'overload' => '0', 'perl' => '5.008' } }, 'test' => { 'recommends' => { 'CPAN::Meta' => '2.120900' }, 'requires' => { 'Data::Dumper' => '0', 'DateTime' => '0', 'ExtUtils::MakeMaker' => '0', 'File::Spec' => '0', 'MooseX::Types::DateTime' => '0', 'MooseX::Types::Moose' => '0', 'Test::Fatal' => '0', 'Test::More' => '0.88', 'Test::Requires' => '0', 'perl' => '5.008', 'strict' => '0', 'warnings' => '0' } } }; $x; }MooseX-Types-Structured-0.35/t/00-report-prereqs.t000644 000766 000024 00000012731 12637630671 022250 0ustar00etherstaff000000 000000 #!perl use strict; use warnings; # This test was generated by Dist::Zilla::Plugin::Test::ReportPrereqs 0.021 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'; if ( $source && $HAS_CPAN_META ) { if ( my $meta = eval { CPAN::Meta->load_file($source) } ) { $full_prereqs = _merge_prereqs($full_prereqs, $meta->prereqs); } } else { $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 $mod eq 'perl'; next if grep { $_ eq $mod } @exclude; my $file = $mod; $file =~ s{::}{/}g; $file .= ".pm"; my ($prefix) = grep { -e File::Spec->catfile($_, $file) } @INC; my $want = $req_hash->{$phase}{$type}{$mod}; $want = "undef" unless defined $want; $want = "any" if !$want && $want == 0; my $req_string = $want eq 'any' ? 'any version required' : "version '$want' required"; 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 ( @dep_errors ) { diag join("\n", "\n*** WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING ***\n", "The following REQUIRED prerequisites were not satisfied:\n", @dep_errors, "\n" ); } pass; # vim: ts=4 sts=4 sw=4 et: MooseX-Types-Structured-0.35/t/01-basic.t000600 000766 000024 00000002632 12637630671 020327 0ustar00etherstaff000000 000000 use strict; use warnings; use Test::More tests=>12; use MooseX::Meta::TypeConstraint::Structured; use Moose::Util::TypeConstraints 'find_type_constraint'; ok my $int = find_type_constraint('Int') => 'Got Int'; ok my $str = find_type_constraint('Str') => 'Got Str'; ok my $arrayref = find_type_constraint('ArrayRef') => 'Got ArrayRef'; my $list_tc = MooseX::Meta::TypeConstraint::Structured->new( name => 'list_tc', parent => $arrayref, type_constraints => [$int, $str], constraint_generator=> sub { my ($self) = @_; my @type_constraints = @{ $self->type_constraints }; return sub { my ($values, $err) = @_; my @values = @$values; for my $type_constraint (@type_constraints) { my $value = shift @values || return; $type_constraint->check($value) || return; } if(@values) { return; } else { return 1; } } } ); isa_ok $list_tc, 'MooseX::Meta::TypeConstraint::Structured'; ok !$arrayref->check() => 'Parent undef fails'; ok !$list_tc->check() => 'undef fails'; ok !$list_tc->check(1) => '1 fails'; ok !$list_tc->check([]) => '[] fails'; ok !$list_tc->check([1]) => '[1] fails'; ok !$list_tc->check([1,2,3]) => '[1,2,3] fails'; ok !$list_tc->check(['a','b']) => '["a","b"] fails'; ok $list_tc->check([1,'a']) => '[1,"a"] passes'; MooseX-Types-Structured-0.35/t/02-tuple.t000600 000766 000024 00000015105 12637630671 020377 0ustar00etherstaff000000 000000 use strict; use warnings; use Test::More tests=>32; use Test::Fatal; { package Test::MooseX::Meta::TypeConstraint::Structured::Tuple; use Moose; use MooseX::Types::Structured qw(Tuple); use MooseX::Types::Moose qw(Int Str Object ArrayRef HashRef Maybe); use MooseX::Types -declare => [qw(MyString MoreThanFive FiveByFive MyArrayRefMoreThanTwoInt)]; subtype MyString, as Str, where { $_=~m/abc/}; subtype MoreThanFive, as Int, where { $_ > 5}; subtype MyArrayRefMoreThanTwoInt, as ArrayRef[MoreThanFive], where { scalar @$_ > 2 }; subtype FiveByFive, as Tuple[MoreThanFive, MyArrayRefMoreThanTwoInt]; #use Data::Dump qw/dump/; warn dump Tuple; has 'tuple' => (is=>'rw', isa=>Tuple[Int, Str, MyString]); has 'tuple_with_param' => (is=>'rw', isa=>Tuple[Int, Str, ArrayRef[Int]]); has 'tuple_with_maybe' => (is=>'rw', isa=>Tuple[Int, Str, Maybe[Int], Object]); has 'tuple_with_maybe2' => (is=>'rw', isa=>Tuple[Int, Str, Maybe[Int]]); has 'tuple_with_union' => (is=>'rw', isa=>Tuple[Int,Str,Int|Object,Int]); has 'tuple2' => (is=>'rw', isa=>Tuple[Int,Str,Int]); has 'tuple_with_parameterized' => (is=>'rw', isa=>Tuple[Int,Str,Int,ArrayRef[Int]]); has 'FiveByFiveAttr' => (is=>'rw', isa=>FiveByFive); } ## Instantiate a new test object ok my $record = Test::MooseX::Meta::TypeConstraint::Structured::Tuple->new => 'Instantiated new Record test class.'; isa_ok $record => 'Test::MooseX::Meta::TypeConstraint::Structured::Tuple' => 'Created correct object type.'; ## Test Tuple type constraint is( exception { $record->tuple([1,'hello', 'test.abc.test']); } => undef, 'Set tuple attribute without error'); is $record->tuple->[0], 1 => 'correct set the tuple attribute index 0'; is $record->tuple->[1], 'hello' => 'correct set the tuple attribute index 1'; is $record->tuple->[2], 'test.abc.test' => 'correct set the tuple attribute index 2'; like( exception { $record->tuple([1,'hello', 'test.xxx.test']); }, qr/Attribute \(tuple\) does not pass the type constraint/ => 'Properly failed for bad value in custom type constraint'); like( exception { $record->tuple(['asdasd',2, 'test.abc.test']); }, qr/Attribute \(tuple\) does not pass the type constraint/ => 'Got Expected Error for violating constraints'); ## Test tuple_with_maybe is( exception { $record->tuple_with_maybe([1,'hello', 1, $record]); } => undef, 'Set tuple attribute without error'); like( exception { $record->tuple_with_maybe([1,'hello', 'a', $record]); }, qr/Attribute \(tuple_with_maybe\) does not pass the type constraint/ => 'Properly failed for bad value parameterized constraint'); is( exception { $record->tuple_with_maybe([1,'hello',undef, $record]); } => undef, 'Set tuple attribute without error skipping optional parameter'); ## Test tuple_with_maybe2 is( exception { $record->tuple_with_maybe2([1,'hello', 1]); } => undef, 'Set tuple attribute without error'); like( exception { $record->tuple_with_maybe2([1,'hello', 'a']); }, qr/Attribute \(tuple_with_maybe2\) does not pass the type constraint/ => 'Properly failed for bad value parameterized constraint'); is( exception { $record->tuple_with_maybe2([1,'hello',undef]); } => undef, 'Set tuple attribute without error skipping optional parameter'); SKIP: { skip 'Core Maybe incorrectly allows null.', 1, 1; like( exception { $record->tuple_with_maybe2([1,'hello']); }, qr/Attribute \(tuple_with_maybe2\) does not pass the type constraint/ => 'Properly fails for missing maybe (needs to be at least undef)'); } ## Test Tuple with parameterized type is( exception { $record->tuple_with_param([1,'hello', [1,2,3]]); } => undef, 'Set tuple attribute without error'); like( exception { $record->tuple_with_param([1,'hello', [qw/a b c/]]); }, qr/Attribute \(tuple_with_param\) does not pass the type constraint/ => 'Properly failed for bad value parameterized constraint'); ## Test tuple2 (Tuple[Int,Str,Int]) ok $record->tuple2([1,'hello',3]) => "[1,'hello',3] properly suceeds"; like( exception { $record->tuple2([1,2,'world']); }, qr/Attribute \(tuple2\) does not pass the type constraint/ => "[1,2,'world'] properly fails"); like( exception { $record->tuple2(['hello1',2,3]); }, qr/Attribute \(tuple2\) does not pass the type constraint/ => "['hello',2,3] properly fails"); like( exception { $record->tuple2(['hello2',2,'world']); }, qr/Attribute \(tuple2\) does not pass the type constraint/ => "['hello',2,'world'] properly fails"); ## Test tuple_with_parameterized (Tuple[Int,Str,Int,ArrayRef[Int]]) ok $record->tuple_with_parameterized([1,'hello',3,[1,2,3]]) => "[1,'hello',3,[1,2,3]] properly suceeds"; like( exception { $record->tuple_with_parameterized([1,2,'world']); }, qr/Attribute \(tuple_with_parameterized\) does not pass the type constraint/ => "[1,2,'world'] properly fails"); like( exception { $record->tuple_with_parameterized(['hello1',2,3]); }, qr/Attribute \(tuple_with_parameterized\) does not pass the type constraint/ => "['hello',2,3] properly fails"); like( exception { $record->tuple_with_parameterized(['hello2',2,'world']); }, qr/Attribute \(tuple_with_parameterized\) does not pass the type constraint/ => "['hello',2,'world'] properly fails"); like( exception { $record->tuple_with_parameterized([1,'hello',3,[1,2,'world']]); }, qr/Attribute \(tuple_with_parameterized\) does not pass the type constraint/ => "[1,'hello',3,[1,2,'world']] properly fails"); ## Test FiveByFiveAttr is( exception { $record->FiveByFiveAttr([6,[7,8,9]]); } => undef, 'Set FiveByFiveAttr correctly'); like( exception { $record->FiveByFiveAttr([1,'hello', 'test']); }, qr/Attribute \(FiveByFiveAttr\) does not pass the type constraint/ => q{Properly failed for bad value in FiveByFiveAttr [1,'hello', 'test']}); like( exception { $record->FiveByFiveAttr([1,[8,9,10]]); }, qr/Attribute \(FiveByFiveAttr\) does not pass the type constraint/ => q{Properly failed for bad value in FiveByFiveAttr [1,[8,9,10]]}); like( exception { $record->FiveByFiveAttr([10,[11,12,0]]); }, qr/Attribute \(FiveByFiveAttr\) does not pass the type constraint/ => q{Properly failed for bad value in FiveByFiveAttr [10,[11,12,0]]}); like( exception { $record->FiveByFiveAttr([1,[1,1,0]]); }, qr/Attribute \(FiveByFiveAttr\) does not pass the type constraint/ => q{Properly failed for bad value in FiveByFiveAttr [1,[1,1,0]]}); like( exception { $record->FiveByFiveAttr([10,[11,12]]); }, qr/Attribute \(FiveByFiveAttr\) does not pass the type constraint/ => q{Properly failed for bad value in FiveByFiveAttr [10,[11,12]}); MooseX-Types-Structured-0.35/t/03-dict.t000600 000766 000024 00000006162 12637630671 020175 0ustar00etherstaff000000 000000 use strict; use warnings; use Test::More tests=>17; use Test::Fatal; { package Test::MooseX::Meta::TypeConstraint::Structured::Dict; use Moose; use MooseX::Types::Structured qw(Dict Tuple); use MooseX::Types::Moose qw(Int Str Object ArrayRef HashRef Maybe); use MooseX::Types -declare => [qw(MyString)]; subtype MyString, as Str, where { $_=~m/abc/}; has 'dict' => (is=>'rw', isa=>Dict[name=>Str, age=>Int]); has 'dict_with_maybe' => (is=>'rw', isa=>Dict[name=>Str, age=>Maybe[Int]]); has 'dict_with_tuple_with_union' => (is=>'rw', isa=>Dict[key1=>Str|Object, key2=>Tuple[Int,Str|Object]] ); } ## Instantiate a new test object ok my $record = Test::MooseX::Meta::TypeConstraint::Structured::Dict->new => 'Instantiated new Record test class.'; isa_ok $record => 'Test::MooseX::Meta::TypeConstraint::Structured::Dict' => 'Created correct object type.'; # Test dict Dict[name=>Str, age=>Int] is( exception { $record->dict({name=>'frith', age=>23}); } => undef, 'Set dict attribute without error'); is $record->dict->{name}, 'frith' => 'correct set the dict attribute name'; is $record->dict->{age}, 23 => 'correct set the dict attribute age'; like( exception { $record->dict({name=>[1,2,3], age=>'sdfsdfsd'}); }, qr/Attribute \(dict\) does not pass the type constraint/ => 'Got Expected Error for bad value in dict'); ## Test dict_with_maybe is( exception { $record->dict_with_maybe({name=>'frith', age=>23}); } => undef, 'Set dict attribute without error'); is $record->dict_with_maybe->{name}, 'frith' => 'correct set the dict attribute name'; is $record->dict_with_maybe->{age}, 23 => 'correct set the dict attribute age'; like( exception { $record->dict_with_maybe({name=>[1,2,3], age=>'sdfsdfsd'}); }, qr/Attribute \(dict_with_maybe\) does not pass the type constraint/ => 'Got Expected Error for bad value in dict'); like( exception { $record->dict_with_maybe({age=>30}); }, qr/Attribute \(dict_with_maybe\) does not pass the type constraint/ => 'Got Expected Error for missing named parameter'); is( exception { $record->dict_with_maybe({name=>'usal', age=>undef}); } => undef, 'Set dict attribute without error, skipping maybe'); ## Test dict_with_tuple_with_union: Dict[key1=>'Str|Object', key2=>Tuple['Int','Str|Object']] is( exception { $record->dict_with_tuple_with_union({key1=>'Hello', key2=>[1,'World']}); } => undef, 'Set tuple attribute without error'); like( exception { $record->dict_with_tuple_with_union({key1=>'Hello', key2=>['World',2]}); }, qr/Attribute \(dict_with_tuple_with_union\) does not pass the type constraint/ => 'Threw error on bad constraint'); is( exception { $record->dict_with_tuple_with_union({key1=>$record, key2=>[1,'World']}); } => undef, 'Set tuple attribute without error'); is( exception { $record->dict_with_tuple_with_union({key1=>'Hello', key2=>[1,$record]}); } => undef, 'Set tuple attribute without error'); like( exception { $record->dict_with_tuple_with_union({key1=>1, key2=>['World',2]}); }, qr/Attribute \(dict_with_tuple_with_union\) does not pass the type constraint/ => 'Threw error on bad constraint'); MooseX-Types-Structured-0.35/t/04-combined.t000600 000766 000024 00000004005 12637630671 021025 0ustar00etherstaff000000 000000 use strict; use warnings; use Test::More tests=>9; use Test::Fatal; { package Test::MooseX::Meta::TypeConstraint::Structured::Combined; use Moose; use MooseX::Types::Structured qw(Dict Tuple); use MooseX::Types::Moose qw(Int Str Object ArrayRef HashRef Maybe); has 'dict_with_tuple' => (is=>'rw', isa=>Dict[key1=>Str, key2=>Tuple[Int,Str]]); has 'dict_with_tuple_with_union' => (is=>'rw', isa=>Dict[key1=>Str|Object, key2=>Tuple[Int,Str|Object]] ); } ## Instantiate a new test object ok my $record = Test::MooseX::Meta::TypeConstraint::Structured::Combined->new => 'Instantiated new Record test class.'; isa_ok $record => 'Test::MooseX::Meta::TypeConstraint::Structured::Combined' => 'Created correct object type.'; ## Test dict_with_tuple is( exception { $record->dict_with_tuple({key1=>'Hello', key2=>[1,'World']}); } => undef, 'Set tuple attribute without error'); like( exception { $record->dict_with_tuple({key1=>'Hello', key2=>['World',2]}); }, qr/Attribute \(dict_with_tuple\) does not pass the type constraint/ => 'Threw error on bad constraint'); ## Test dict_with_tuple_with_union: Dict[key1=>'Str|Object', key2=>Tuple['Int','Str|Object']] is( exception { $record->dict_with_tuple_with_union({key1=>'Hello', key2=>[1,'World']}); } => undef, 'Set tuple attribute without error'); like( exception { $record->dict_with_tuple_with_union({key1=>'Hello', key2=>['World',2]}); }, qr/Attribute \(dict_with_tuple_with_union\) does not pass the type constraint/ => 'Threw error on bad constraint'); is( exception { $record->dict_with_tuple_with_union({key1=>$record, key2=>[1,'World']}); } => undef, 'Set tuple attribute without error'); is( exception { $record->dict_with_tuple_with_union({key1=>'Hello', key2=>[1,$record]}); } => undef, 'Set tuple attribute without error'); like( exception { $record->dict_with_tuple_with_union({key1=>1, key2=>['World',2]}); }, qr/Attribute \(dict_with_tuple_with_union\) does not pass the type constraint/ => 'Threw error on bad constraint'); MooseX-Types-Structured-0.35/t/04-map.t000600 000766 000024 00000001136 12637630671 020024 0ustar00etherstaff000000 000000 use strict; use warnings; use Test::More 0.88; use Test::Fatal; use MooseX::Types::Moose qw(Int Num); use MooseX::Types::Structured qw(Map); my $type = Map[ Int, Num ]; ok($type->assert_valid({ 10 => 10.5 }), "simple Int -> Num mapping"); like( exception { $type->assert_valid({ 10.5 => 10.5 }) }, qr{value .*10\.5.*}, "non-Int causes rejection on key"); like( exception { $type->assert_valid({ 10 => "ten and a half" }) }, qr{value .*ten and a half.*}, "non-Num value causes rejection on value"); ok($type->assert_valid({ }), "empty hashref is a valid mapping of any sort"); done_testing; MooseX-Types-Structured-0.35/t/05-advanced.t000600 000766 000024 00000011225 12637630671 021015 0ustar00etherstaff000000 000000 use strict; use warnings; use Test::More tests=>16; use Test::Fatal; { package Test::MooseX::Meta::TypeConstraint::Structured::Advanced; use Moose; use MooseX::Types::Structured qw(Dict Tuple); use MooseX::Types::Moose qw(Int Str Object ArrayRef HashRef Maybe); use MooseX::Types -declare => [qw( EqualLength MoreThanFive MoreLengthPlease PersonalInfo MorePersonalInfo MinFiveChars )]; subtype MoreThanFive, as Int, where { $_ > 5}; ## Tuple contains two equal length Arrays subtype EqualLength, as Tuple[ArrayRef[MoreThanFive],ArrayRef[MoreThanFive]], where { $#{$_->[0]} == $#{$_->[1]} }; ## subclass the complex tuple subtype MoreLengthPlease, as EqualLength, where { $#{$_->[0]} >= 4}; ## Complexe Dict subtype PersonalInfo, as Dict[name=>Str, stats=>MoreLengthPlease|Object]; ## Minimum 5 char string subtype MinFiveChars, as Str, where { length($_) > 5}; ## Dict key overloading subtype MorePersonalInfo, as PersonalInfo[name=>MinFiveChars, stats=>MoreLengthPlease|Object]; has 'EqualLengthAttr' => (is=>'rw', isa=>EqualLength); has 'MoreLengthPleaseAttr' => (is=>'rw', isa=>MoreLengthPlease); has 'PersonalInfoAttr' => (is=>'rw', isa=>PersonalInfo); has 'MorePersonalInfoAttr' => (is=>'rw', isa=>MorePersonalInfo); } ## Instantiate a new test object ok my $obj = Test::MooseX::Meta::TypeConstraint::Structured::Advanced->new => 'Instantiated new Record test class.'; isa_ok $obj => 'Test::MooseX::Meta::TypeConstraint::Structured::Advanced' => 'Created correct object type.'; ## Test EqualLengthAttr is( exception { $obj->EqualLengthAttr([[6,7,8],[9,10,11]]); } => undef, 'Set EqualLengthAttr attribute without error'); like( exception { $obj->EqualLengthAttr([1,'hello', 'test.xxx.test']); }, qr/Attribute \(EqualLengthAttr\) does not pass the type constraint/ => q{EqualLengthAttr correctly fails [1,'hello', 'test.xxx.test']}); like( exception { $obj->EqualLengthAttr([[6,7],[9,10,11]]); }, qr/Attribute \(EqualLengthAttr\) does not pass the type constraint/ => q{EqualLengthAttr correctly fails [[6,7],[9,10,11]]}); like( exception { $obj->EqualLengthAttr([[6,7,1],[9,10,11]]); }, qr/Attribute \(EqualLengthAttr\) does not pass the type constraint/ => q{EqualLengthAttr correctly fails [[6,7,1],[9,10,11]]}); ## Test MoreLengthPleaseAttr is( exception { $obj->MoreLengthPleaseAttr([[6,7,8,9,10],[11,12,13,14,15]]); } => undef, 'Set MoreLengthPleaseAttr attribute without error'); like( exception { $obj->MoreLengthPleaseAttr([[6,7,8,9],[11,12,13,14]]); }, qr/Attribute \(MoreLengthPleaseAttr\) does not pass the type constraint/ => q{MoreLengthPleaseAttr correctly fails [[6,7,8,9],[11,12,13,14]]}); ## Test PersonalInfoAttr is( exception { $obj->PersonalInfoAttr({name=>'John', stats=>[[6,7,8,9,10],[11,12,13,14,15]]}); } => undef, 'Set PersonalInfoAttr attribute without error 1'); is( exception { $obj->PersonalInfoAttr({name=>'John', stats=>$obj}); } => undef, 'Set PersonalInfoAttr attribute without error 2'); like( exception { $obj->PersonalInfoAttr({name=>'John', stats=>[[6,7,8,9],[11,12,13,14]]}); }, qr/Attribute \(PersonalInfoAttr\) does not pass the type constraint/ => q{PersonalInfoAttr correctly fails name=>'John', stats=>[[6,7,8,9],[11,12,13,14]]}); like( exception { $obj->PersonalInfoAttr({name=>'John', extra=>1, stats=>[[6,7,8,9,10],[11,12,13,14,15]]}); }, qr/Attribute \(PersonalInfoAttr\) does not pass the type constraint/ => q{PersonalInfoAttr correctly fails name=>'John', extra=>1, stats=>[[6,7,8,9,10],[11,12,13,14,15]]}); ## Test MorePersonalInfoAttr is( exception { $obj->MorePersonalInfoAttr({name=>'Johnnap', stats=>[[6,7,8,9,10],[11,12,13,14,15]]}); } => undef, 'Set MorePersonalInfoAttr attribute without error 1'); like( exception { $obj->MorePersonalInfoAttr({name=>'Johnnap', stats=>[[6,7,8,9],[11,12,13,14]]}); }, qr/Attribute \(MorePersonalInfoAttr\) does not pass the type constraint/ => q{MorePersonalInfoAttr correctly fails name=>'Johnnap', stats=>[[6,7,8,9],[11,12,13,14]]}); like( exception { $obj->MorePersonalInfoAttr({name=>'Johnnap', extra=>1, stats=>[[6,7,8,9,10],[11,12,13,14,15]]}); }, qr/Attribute \(MorePersonalInfoAttr\) does not pass the type constraint/ => q{MorePersonalInfoAttr correctly fails name=>'Johnnap', extra=>1, stats=>[[6,7,8,9,10],[11,12,13,14,15]]}); like( exception { $obj->MorePersonalInfoAttr({name=>'.bc', stats=>[[6,7,8,9,10],[11,12,13,14,15]]}); }, qr/Attribute \(MorePersonalInfoAttr\) does not pass the type constraint/ => q{MorePersonalInfoAttr correctly fails name=>'.bc', stats=>[[6,7,8,9,10],[11,12,13,14,15]]}); MooseX-Types-Structured-0.35/t/06-api.t000600 000766 000024 00000016754 12637630671 020036 0ustar00etherstaff000000 000000 use strict; use warnings; use Test::More tests=>88; { package TypeLib; use MooseX::Types::Structured qw(Dict Tuple); use MooseX::Types::Moose qw(Int Str Item Object ArrayRef HashRef); use MooseX::Types -declare => [qw( MyDict1 MyDict2 MyDict3 MyDict4 subMyDict3 subMyDict1 MyTuple1 MyTuple2 MyTuple3 subMyTuple3 )]; ## Create some sample Dicts subtype MyDict1, as Dict[name=>Str, age=>Int]; subtype subMyDict1, as MyDict1; subtype MyDict2, as Dict[name=>Str, age=>Int]; subtype MyDict3, as Dict[key=>Int, anotherkey=>Str]; subtype subMyDict3, as MyDict3; subtype MyDict4, as Dict[name=>Str, age=>Item]; ## Create some sample Tuples subtype MyTuple1, as Tuple[Int,Int,Str]; subtype MyTuple2, as Tuple[Int,Int,Str]; subtype MyTuple3, as Tuple[Object, HashRef]; subtype subMyTuple3, as MyTuple3; } use Moose::Util::TypeConstraints; use MooseX::Types::Structured qw(Dict Tuple); use MooseX::Types::Moose qw(Int Str Item Object ArrayRef HashRef); BEGIN { TypeLib->import(':all'); } ## Test equals ok ( MyDict1->equals(MyDict2), 'MyDict1 == MyDict2'); ok ( MyDict2->equals(MyDict1), 'MyDict2 == MyDict1'); ok (!MyDict1->equals(MyDict3), 'MyDict1 == MyDict3'); ok (!MyDict2->equals(MyDict3), 'MyDict2 == MyDict3'); ok (!MyDict3->equals(MyDict2), 'MyDict3 == MyDict2'); ok (!MyDict3->equals(MyDict1), 'MyDict3 == MyDict1'); ok ( MyTuple1->equals(MyTuple2), 'MyTuple1 == MyTuple2'); ok ( MyTuple2->equals(MyTuple1), 'MyTuple2 == MyTuple1'); ok (!MyTuple1->equals(MyTuple3), 'MyTuple1 == MyTuple3'); ok (!MyTuple2->equals(MyTuple3), 'MyTuple2 == MyTuple3'); ok (!MyTuple3->equals(MyTuple2), 'MyTuple3 == MyTuple2'); ok (!MyTuple3->equals(MyTuple1), 'MyTuple3 == MyTuple1'); ok ( MyDict1->equals(MyDict2), 'MyDict1 == MyDict2'); ok ( MyDict2->equals(MyDict1), 'MyDict2 == MyDict1'); ok (!MyDict1->equals(MyDict3), 'MyDict1 == MyDict3'); ok (!MyDict1->equals(MyDict4), 'MyDict1 == MyDict3'); ok (!MyDict2->equals(MyDict3), 'MyDict2 == MyDict3'); ok (!MyDict2->equals(MyDict4), 'MyDict2 == MyDict3'); ok (!MyDict3->equals(MyDict2), 'MyDict3 == MyDict2'); ok (!MyDict3->equals(MyDict4), 'MyDict3 == MyDict2'); ok (!MyDict3->equals(MyDict1), 'MyDict3 == MyDict1'); ok (!MyDict4->equals(MyDict1), 'MyDict3 == MyDict1'); ok (!MyDict4->equals(MyDict2), 'MyDict3 == MyDict1'); ok (!MyDict4->equals(MyDict3), 'MyDict3 == MyDict1'); ok ( MyTuple1->equals(MyTuple2), 'MyTuple1 == MyTuple2'); ok ( MyTuple2->equals(MyTuple1), 'MyTuple2 == MyTuple1'); ok (!MyTuple1->equals(MyTuple3), 'MyTuple1 == MyTuple3'); ok (!MyTuple2->equals(MyTuple3), 'MyTuple2 == MyTuple3'); ok (!MyTuple3->equals(MyTuple2), 'MyTuple3 == MyTuple2'); ok (!MyTuple3->equals(MyTuple1), 'MyTuple3 == MyTuple1'); ## Test is_a_type_of ok ( MyDict1->is_a_type_of(HashRef), 'MyDict1 is_a_type_of HashRef'); ok ( MyDict1->is_a_type_of(Dict), 'MyDict1 is_a_type_of Dict'); ok (!MyDict1->is_a_type_of(Tuple), 'MyDict1 NOT is_a_type_of Tuple'); ok ( MyDict1->is_a_type_of(MyDict2), 'MyDict1 is_a_type_of MyDict2'); ok ( MyDict2->is_a_type_of(MyDict1), 'MyDict2 is_a_type_of MyDict1'); ok (!MyDict1->is_a_type_of(MyDict3), 'MyDict1 NOT is_a_type_of MyDict3'); ok (!MyDict2->is_a_type_of(MyDict3), 'MyDict2 NOT is_a_type_of MyDict3'); ok ( subMyDict1->is_a_type_of(Dict), 'subMyDict1 type of Dict'); ok ( subMyDict1->is_a_type_of(MyDict1), 'subMyDict1 type of MyDict1'); ok ( subMyDict1->is_a_type_of(subMyDict1), 'subMyDict1 type of subMyDict1'); ok ( subMyDict1->is_a_type_of(MyDict2), 'subMyDict1 type of MyDict2'); ok ( MyDict4->is_a_type_of(HashRef), 'MyDict4 is_a_type_of HashRef'); ok ( MyDict4->is_a_type_of(Dict), 'MyDict4 is_a_type_of Dict'); ok (!MyDict4->is_a_type_of(Tuple), 'MyDict4 NOT is_a_type_of Tuple'); ok (!MyDict4->is_a_type_of(MyDict2), 'MyDict4 NOT is_a_type_of MyDict2'); ok ( MyDict2->is_a_type_of(MyDict4), 'MyDict2 is_a_type_of MyDict4'); ok (!MyDict4->is_a_type_of(MyDict3), 'MyDict4 NOT is_a_type_of MyDict3'); ok ( MyTuple1->is_a_type_of(Tuple), 'MyTuple1 is_a_type_of Tuple'); ok (!MyTuple1->is_a_type_of(Dict), 'MyTuple1 NOT is_a_type_of Dict'); ok ( MyTuple1->is_a_type_of(MyTuple2), 'MyTuple1 is_a_type_of MyTuple2'); ok ( MyTuple2->is_a_type_of(MyTuple1), 'MyTuple2 is_a_type_of MyTuple1'); ok (!MyTuple1->is_a_type_of(MyTuple3), 'MyTuple1 NOT is_a_type_of MyTuple3'); ok (!MyTuple2->is_a_type_of(MyTuple3), 'MyTuple2 NOT is_a_type_of MyTuple3'); ## is_subtype_of ok ( not((Tuple[Tuple[ class_type('Paper'), class_type('Stone') ], Dict[]])->equals( Tuple[Tuple[ Item, Item ], Dict[]] )), "tuple of tuple" ); ok ( (Tuple[Tuple[ class_type('Paper'), class_type('Stone') ], Dict[]])->equals( Tuple[Tuple[ class_type('Paper'), class_type('Stone') ], Dict[]] ), "tuple of tuple" ); ok ( (Tuple[Tuple[ class_type('Paper'), class_type('Stone') ], Dict[]])->is_a_type_of( Tuple[Tuple[ Item, Item ], Dict[]] ), "tuple of tuple" ); ok ( (Tuple[Tuple[ class_type('Paper'), class_type('Stone') ], Dict[]])->is_a_type_of( Tuple[Tuple[ Item, Item ], Dict[]] ), "tuple of tuple" ); ok ( (Tuple[Tuple[ class_type('Paper'), class_type('Stone') ], Dict[]])->is_subtype_of( Tuple[Tuple[ Item, Item ], Dict[]] ), "tuple of tuple" ); ok ( MyDict1->is_subtype_of(HashRef), 'MyDict1 is_subtype_of HashRef'); ok ( MyDict1->is_subtype_of(Dict), 'MyDict1 is_subtype_of Dict'); ok ( MyDict1->is_subtype_of(MyDict4), 'MyDict1 is_subtype_of MyDict4'); ok (!MyDict1->is_subtype_of(Tuple), 'MyDict1 NOT is_subtype_of Tuple'); ok (!MyDict1->is_subtype_of(MyDict2), 'MyDict1 NOT is_subtype_of MyDict2'); ok (!MyDict2->is_subtype_of(MyDict1), 'MyDict2 NOT is_subtype_of MyDict1'); ok (!MyDict1->is_subtype_of(MyDict3), 'MyDict1 NOT is_subtype_of MyDict3'); ok (!MyDict2->is_subtype_of(MyDict3), 'MyDict2 NOT is_subtype_of MyDict3'); ok ( subMyDict1->is_subtype_of(Dict), 'subMyDict1 is_subtype_of Dict'); ok ( subMyDict1->is_subtype_of(MyDict1), 'subMyDict1 is_subtype_of MyDict1'); ok (!subMyDict1->is_subtype_of(subMyDict1), 'subMyDict1 NOT is_subtype_of subMyDict1'); ok ( subMyDict1->is_subtype_of(MyDict2), 'subMyDict1 is_subtype_of MyDict2'); ok ( MyTuple1->is_subtype_of(Tuple), 'MyTuple1 is_subtype_of Tuple'); ok (!MyTuple1->is_subtype_of(Dict), 'MyTuple1 NOT is_subtype_of Dict'); ok (!MyTuple1->is_subtype_of(MyTuple2), 'MyTuple1 is_subtype_of MyTuple2'); ok (!MyTuple2->is_subtype_of(MyTuple1), 'MyTuple2 is_subtype_of MyTuple1'); ok (!MyTuple1->is_subtype_of(MyTuple3), 'MyTuple1 NOT is_subtype_of MyTuple3'); ok (!MyTuple2->is_subtype_of(MyTuple3), 'MyTuple2 NOT is_subtype_of MyTuple3'); ## Test manual parameterizing PARAMETERIZE: { ok (my $int = Moose::Util::TypeConstraints::find_or_parse_type_constraint('Int'), 'Got Int'); ok (my $str = Moose::Util::TypeConstraints::find_or_parse_type_constraint('Str'), 'Got Str'); ok (my $hashref = Moose::Util::TypeConstraints::find_or_parse_type_constraint('HashRef[Int]'), 'Got HashRef'); ## Test Dict->parameterize ok (my $test_dict = Dict(), 'Created Test Dict'); ok (my $person = $test_dict->parameterize(name=>$str, age=>$int), 'Parameterized It'); ok ($person->check({name=>'John', age=>21}), 'Passed'); ok ($person->check({age=>25, name=>'User'}), 'Passed'); ## Test Tuple->parameterize ok (my $test_tuple = Tuple(), 'Created Test Tuple'); ok (my $int_and_hashref = $test_tuple->parameterize($int, $hashref), 'Parameterized It'); ok ($int_and_hashref->check([1, {key=>2, key2=>3}]), "Passed"); ok (!$int_and_hashref->check(['a', {key=>2, key2=>3}]), "Not Passed"); ok (!$int_and_hashref->check([1, {key=>'a', key2=>3}]), "Not Passed"); } MooseX-Types-Structured-0.35/t/07-coerce.t000600 000766 000024 00000005542 12637630671 020517 0ustar00etherstaff000000 000000 use strict; use warnings; use Test::More tests=>16; { package Test::MooseX::Meta::TypeConstraint::Structured::Coerce; use Moose; use MooseX::Types::Structured qw(Dict Tuple); use MooseX::Types::Moose qw(Int Str Object ArrayRef HashRef); use MooseX::Types -declare => [qw( myDict myTuple Fullname )]; subtype myDict, as Dict[name=>Str, age=>Int]; subtype Fullname, as Dict[first=>Str, last=>Str]; coerce Fullname, from ArrayRef, via { +{first=>$_->[0], last=>$_->[1]} }; subtype myTuple, as Tuple[Str, Int]; ## Create some coercions. Note the dob_epoch could be a more useful convert ## from a dob datetime object, I'm just lazy. coerce myDict, from Int, via { +{name=>'JohnDoe', age=>$_} }, from Dict[aname=>HashRef, dob_in_years=>Int], via { +{ name=> $_->{aname}->{first} .' '. $_->{aname}->{last}, age=>$_->{dob_in_years}, } }, from Dict[bname=>HashRef, dob_in_years=>Int], via { +{ name=> $_->{bname}->{first} .' '. $_->{bname}->{last}, age=>$_->{dob_in_years}, } }, from Dict[fullname=>Fullname, dob_epoch=>Int], via { +{ name=> $_->{fullname}->{first} .' '. $_->{fullname}->{last}, age=>$_->{dob_epoch}} }, from myTuple, via { +{name=>$_->[0], age=>$_->[1]} }; has 'stuff' => (is=>'rw', isa=>myDict, coerce=>1); } ## Create an object to test ok my $person = Test::MooseX::Meta::TypeConstraint::Structured::Coerce->new(); isa_ok $person, 'Test::MooseX::Meta::TypeConstraint::Structured::Coerce';## Try out the coercions ok $person->stuff({name=>"John",age=>25}), 'Set Stuff {name=>"John",age=>25}'; is_deeply $person->stuff, {name=>"John",age=>25}, 'Correct set'; ok $person->stuff(30), 'Set Stuff 30'; is_deeply $person->stuff, {name=>"JohnDoe",age=>30}, 'Correct set'; ok $person->stuff({aname=>{first=>"frank", last=>"herbert"},dob_in_years=>80}), '{{first=>"frank", last=>"herbert"},80}'; is_deeply $person->stuff, {name=>"frank herbert",age=>80}, 'Correct set'; ok $person->stuff({bname=>{first=>"frankbbb", last=>"herbert"},dob_in_years=>84}), '{{first=>"frankbbb", last=>"herbert"},84}'; is_deeply $person->stuff, {name=>"frankbbb herbert",age=>84}, 'Correct set'; ok $person->stuff(["mary",40]), 'Set Stuff ["mary",40]'; is_deeply $person->stuff, {name=>"mary",age=>40}, 'Correct set'; ok $person->stuff({fullname=>{first=>"frank", last=>"herbert1"},dob_epoch=>85}), '{{first=>"frank", last=>"herbert1"},85}'; is_deeply $person->stuff, {name=>"frank herbert1",age=>85}, 'Correct set'; SKIP: { skip 'deep coercions not yet supported', 2, 1; ok $person->stuff({fullname=>["frank", "herbert2"],dob_epoch=>86}), '{fullname=>["frank", "herbert2"],dob_epoch=>86}'; is_deeply $person->stuff, {name=>"frank herbert2",age=>86}, 'Correct set'; } MooseX-Types-Structured-0.35/t/08-examples.t000600 000766 000024 00000004073 12637630671 021074 0ustar00etherstaff000000 000000 use strict; use warnings; use Test::More; use Test::Requires 'MooseX::Types::DateTime'; plan tests => 10; { ## Normalize a HashRef package Test::MooseX::Meta::TypeConstraint::Structured::Examples::Normalize; use Moose; use DateTime; use MooseX::Types::Structured qw(Dict Tuple); use MooseX::Types::DateTime qw(DateTime); use MooseX::Types::Moose qw(Int Str Object ArrayRef HashRef); use MooseX::Types -declare => [qw( Name Age Person FullName )]; ## So that our test works, we'll set Now to 2008. sub Now { return 'DateTime'->new(year=>2008); } subtype FullName, as Dict[last=>Str, first=>Str]; subtype Person, as Dict[name=>Str, age=>Int]; coerce Person, from Dict[first=>Str, last=>Str, years=>Int], via { +{ name => "$_->{first} $_->{last}", age=>$_->{years}, }}, from Dict[fullname=>FullName, dob=>DateTime], via { +{ name => "$_->{fullname}{first} $_->{fullname}{last}", age => ($_->{dob} - Now)->years, }}; has person => (is=>'rw', isa=>Person, coerce=>1); } NORMALIZE: { ok my $normalize = Test::MooseX::Meta::TypeConstraint::Structured::Examples::Normalize->new(); isa_ok $normalize, 'Test::MooseX::Meta::TypeConstraint::Structured::Examples::Normalize'; ok $normalize->person({name=>'John', age=>25}) => 'Set value'; is_deeply $normalize->person, {name=>'John', age=>25} => 'Value is correct'; ok $normalize->person({first=>'John', last=>'Napiorkowski', years=>35}) => 'Set value'; is_deeply $normalize->person, {name=>'John Napiorkowski', age=>35} => 'Value is correct'; ok $normalize->person({years=>36, last=>'Napiorkowski', first=>'John'}) => 'Set value'; is_deeply $normalize->person, {name=>'John Napiorkowski', age=>36} => 'Value is correct'; ok $normalize->person({fullname=>{first=>'Vanessa', last=>'Li'}, dob=>DateTime->new(year=>1974)}) => 'Set value'; is_deeply $normalize->person, {name=>'Vanessa Li', age=>34} => 'Value is correct'; } MooseX-Types-Structured-0.35/t/09-optional.t000600 000766 000024 00000016140 12637630671 021102 0ustar00etherstaff000000 000000 use strict; use warnings; use Test::More tests=>46; use Test::Fatal; use Moose::Util::TypeConstraints (); use MooseX::Types::Structured qw(Optional); APITEST: { ok my $Optional = Moose::Util::TypeConstraints::find_or_parse_type_constraint('MooseX::Types::Structured::Optional') => 'Got Optional'; isa_ok $Optional => 'Moose::Meta::TypeConstraint::Parameterizable'; ok my $int = Moose::Util::TypeConstraints::find_or_parse_type_constraint('Int') => 'Got Int'; ok my $arrayref = Moose::Util::TypeConstraints::find_or_parse_type_constraint('ArrayRef[Int]') => 'Got ArrayRef[Int]'; BASIC: { ok my $Optional_Int = $Optional->parameterize($int), 'Parameterized Int'; ok my $Optional_ArrayRef = $Optional->parameterize($arrayref), 'Parameterized ArrayRef'; ok $Optional_Int->check() => 'Optional is allowed to not exist'; ok !$Optional_Int->check(undef) => 'Optional is NOT allowed to be undef'; ok $Optional_Int->check(199) => 'Correctly validates 199'; ok !$Optional_Int->check("a") => 'Correctly fails "a"'; ok $Optional_ArrayRef->check() => 'Optional is allowed to not exist'; ok !$Optional_ArrayRef->check(undef) => 'Optional is NOT allowed to be undef'; ok $Optional_ArrayRef->check([1,2,3]) => 'Correctly validates [1,2,3]'; ok !$Optional_ArrayRef->check("a") => 'Correctly fails "a"'; ok !$Optional_ArrayRef->check(["a","b"]) => 'Correctly fails ["a","b"]'; } SUBREF: { ok my $Optional_Int = Optional->parameterize($int),'Parameterized Int'; ok my $Optional_ArrayRef = Optional->parameterize($arrayref), 'Parameterized ArrayRef'; ok $Optional_Int->check() => 'Optional is allowed to not exist'; ok !$Optional_Int->check(undef) => 'Optional is NOT allowed to be undef'; ok $Optional_Int->check(199) => 'Correctly validates 199'; ok !$Optional_Int->check("a") => 'Correctly fails "a"'; ok $Optional_ArrayRef->check() => 'Optional is allowed to not exist'; ok !$Optional_ArrayRef->check(undef) => 'Optional is NOT allowed to be undef'; ok $Optional_ArrayRef->check([1,2,3]) => 'Correctly validates [1,2,3]'; ok !$Optional_ArrayRef->check("a") => 'Correctly fails "a"'; ok !$Optional_ArrayRef->check(["a","b"]) => 'Correctly fails ["a","b"]'; } } OBJECTTEST: { package Test::MooseX::Meta::TypeConstraint::Structured::Optional; use Moose; use MooseX::Types::Structured qw(Dict Tuple Optional); use MooseX::Types::Moose qw(Int Str Object ArrayRef HashRef Maybe); use MooseX::Types -declare => [qw( MoreThanFive TupleOptional1 TupleOptional2 Gender DictOptional1 Insane )]; subtype MoreThanFive, as Int, where { $_ > 5}; enum Gender, [ qw/male female transgendered/ ]; subtype TupleOptional1() => as Tuple[Int, MoreThanFive, Optional[Str|Object]]; subtype TupleOptional2, as Tuple[Int, MoreThanFive, Optional[HashRef[Int|Object]]]; subtype DictOptional1, as Dict[name=>Str, age=>Int, gender=>Optional[Gender]]; subtype Insane, as Tuple[ Int, Optional[Str|Object], DictOptional1, Optional[ArrayRef[Int]] ]; has 'TupleOptional1Attr' => (is=>'rw', isa=>TupleOptional1); has 'TupleOptional2Attr' => (is=>'rw', isa=>TupleOptional2); has 'DictOptional1Attr' => (is=>'rw', isa=>DictOptional1); has 'InsaneAttr' => (is=>'rw', isa=>Insane); } ok my $obj = Test::MooseX::Meta::TypeConstraint::Structured::Optional->new => 'Instantiated new test class.'; isa_ok $obj => 'Test::MooseX::Meta::TypeConstraint::Structured::Optional' => 'Created correct object type.'; # Test Insane is( exception { $obj->InsaneAttr([1,"hello",{name=>"John",age=>39,gender=>"male"},[1,2,3]]); } => undef, 'Set InsaneAttr attribute without error [1,"hello",{name=>"John",age=>39,gender=>"male"},[1,2,3]]'); is( exception { $obj->InsaneAttr([1,$obj,{name=>"John",age=>39},[1,2,3]]); } => undef, 'Set InsaneAttr attribute without error [1,$obj,{name=>"John",age=>39},[1,2,3]]'); is( exception { $obj->InsaneAttr([1,$obj,{name=>"John",age=>39}]); } => undef, 'Set InsaneAttr attribute without error [1,$obj,{name=>"John",age=>39}]'); like( exception { $obj->InsaneAttr([1,$obj,{name=>"John",age=>39},[qw/a b c/]]); }, qr/Attribute \(InsaneAttr\) does not pass the type constraint/ => q{InsaneAttr correctly fails [1,$obj,{name=>"John",age=>39},[qw/a b c/]]}); like( exception { $obj->InsaneAttr([1,"hello",{name=>"John",age=>39,gender=>undef},[1,2,3]]); }, qr/Attribute \(InsaneAttr\) does not pass the type constraint/ => q{InsaneAttr correctly fails [1,"hello",{name=>"John",age=>39,gender=>undef},[1,2,3]]}); # Test TupleOptional1Attr is( exception { $obj->TupleOptional1Attr([1,10,"hello"]); } => undef, 'Set TupleOptional1Attr attribute without error [1,10,"hello"]'); is( exception { $obj->TupleOptional1Attr([1,10,$obj]); } => undef, 'Set TupleOptional1Attr attribute without error [1,10,$obj]'); is( exception { $obj->TupleOptional1Attr([1,10]); } => undef, 'Set TupleOptional1Attr attribute without error [1,10]'); like( exception { $obj->TupleOptional1Attr([1,10,[1,2,3]]); }, qr/Attribute \(TupleOptional1Attr\) does not pass the type constraint/ => q{TupleOptional1Attr correctly fails [1,10,[1,2,3]]}); like( exception { $obj->TupleOptional1Attr([1,10,undef]); }, qr/Attribute \(TupleOptional1Attr\) does not pass the type constraint/ => q{TupleOptional1Attr correctly fails [1,10,undef]}); # Test TupleOptional2Attr is( exception { $obj->TupleOptional2Attr([1,10,{key1=>1,key2=>$obj}]); } => undef, 'Set TupleOptional2Attr attribute without error [1,10,{key1=>1,key2=>$obj}]'); is( exception { $obj->TupleOptional2Attr([1,10]); } => undef, 'Set TupleOptional2Attr attribute without error [1,10]'); like( exception { $obj->TupleOptional2Attr([1,10,[1,2,3]]); }, qr/Attribute \(TupleOptional2Attr\) does not pass the type constraint/ => q{TupleOptional2Attr correctly fails [1,10,[1,2,3]]}); like( exception { $obj->TupleOptional2Attr([1,10,undef]); }, qr/Attribute \(TupleOptional2Attr\) does not pass the type constraint/ => q{TupleOptional2Attr correctly fails [1,10,undef]}); # Test DictOptional1Attr: Dict[name=>Str, age=>Int, gender=>Optional[Gender]]; is( exception { $obj->DictOptional1Attr({name=>"John",age=>39,gender=>"male"}); } => undef, 'Set DictOptional1Attr attribute without error {name=>"John",age=>39,gender=>"male"}'); is( exception { $obj->DictOptional1Attr({name=>"Vanessa",age=>34}); } => undef, 'Set DictOptional1Attr attribute without error {name=>"Vanessa",age=>34}'); like( exception { $obj->DictOptional1Attr({name=>"John",age=>39,gender=>undef}); }, qr/Attribute \(DictOptional1Attr\) does not pass the type constraint/ => q{TupleOptional2Attr correctly fails {name=>"John",age=>39,gender=>undef}}); like( exception { $obj->DictOptional1Attr({name=>"John",age=>39,gender=>"aaa"}); }, qr/Attribute \(DictOptional1Attr\) does not pass the type constraint/ => q{TupleOptional2Attr correctly fails {name=>"John",age=>39,gender=>"aaa"}}); MooseX-Types-Structured-0.35/t/10-recursion.t000600 000766 000024 00000011722 12637630671 021257 0ustar00etherstaff000000 000000 ## Test case donated by Stevan Little use strict; use warnings; use Test::More tests => 25; use Data::Dumper; { package Interpreter; use Moose; use MooseX::Types::Structured qw(Dict Tuple); use MooseX::Types::Moose qw( Int Str ScalarRef ); use MooseX::Types -declare => [qw( Var Const Pair Op BinOp Lambda App Expr )]; use Data::Dumper 'Dumper'; subtype Var() => as ScalarRef; subtype Const() => as Int | Str; subtype Pair() => as Tuple[ Expr, Expr ]; enum Op() => [ qw[ + - ] ]; subtype BinOp() => as Tuple[ Expr, Op, Expr ]; subtype Lambda() => as Tuple[ Var, Expr ]; subtype App() => as Tuple[ Lambda, Expr ]; subtype Expr() => as Var | Const | Pair | BinOp | Lambda | App; sub match { my ($to_match, @cases) = @_; my $default; if (@cases % 2 != 0) { $default = pop @cases; } while (@cases) { my ($type, $action) = splice @cases, 0, 2; #warn "Got " . Dumper($to_match) . " in " . $type->name; if ($type->check($to_match)) { local $_ = $to_match; return $action->($to_match); } } { local $_ = $to_match; return $default->($to_match) if $default; } } sub run { my ($source, $e) = @_; $e ||= {}; #use Data::Dumper; warn "run(e) => " . Dumper $e; return match $source, Var() => sub { $e->{ ${$_} } }, Const() => sub { $_[0] }, BinOp() => sub { $_->[1] eq '+' ? ( run( $_->[0], $e ) + run( $_->[2], $e ) ) : ( run( $_->[0], $e ) - run( $_->[2], $e ) ) }, Lambda() => sub { $_ }, App() => sub { my ( $p, $body ) = @{ run( $_[0]->[0], $e ) }; $e->{ ${ $p } } = run( $_[0]->[1], $e ); run( $body, $e ); }, Pair() => sub { $_ }, Expr() => sub { run($_, $e) }, sub { confess "[run] Bad Source:" . Dumper $_ }; } sub pprint { my ($source) = @_; return match $source, Var() => sub { 'Var(' . ${$_} . ')' }, Op() => sub { 'Op(' . $_ . ')' }, Const() => sub { 'Const(' . $_ . ')' }, BinOp() => sub { 'BinOp( ' . ( join ' ' => map { pprint($_) } @{$_} ) . ' )' }, Lambda() => sub { "Lambda( " . pprint($_->[0]) . ' ' . pprint($_->[1]) . " )" }, App() => sub { "App( " . pprint($_->[0]) . ' ' . pprint($_->[1]) . " )" }, Pair() => sub { 'Pair(' . pprint($_->[0]) . ' => ' . pprint($_->[1]) . ')' }, Expr() => sub { pprint($_) }, sub { confess "[pprint] Bad Source:" . Dumper $_ }; } } { BEGIN { Interpreter->import(':all') }; ok is_Var(\'x'), q{passes is_Var('x')}; ok is_Const(1), q{passes is_Const(1)}; ok is_Const('Hello World'), q{passes is_Const}; ok is_Pair([ 'Hello', 'World' ]), q{passes is_Pair}; ok is_Pair([ \'Hello', 'World' ]), q{passes is_Pair}; ok is_Pair([ \'Hello', 100 ]), q{passes is_Pair}; ok is_Pair([ \'Hello', [ 1, '+', 1] ]), q{passes is_Pair}; ok is_Op('+'), q{passes is_Op('+')}; ok is_Op('-'), q{passes is_Op('-')}; ok is_BinOp([ 1, '+', 1]), q{passes is_BinOp([ 1, '+', 1])}; ok is_BinOp([ '+', '+', '+' ]), q{passes is_BinOp([ '+', '+', '+' ])}; ok is_BinOp([ 1, '+', [ 1, '+', 1 ]]), q{passes is_BinOp([ 1, '+', 1])}; ok is_Lambda([ \'x', [ \'x', '+', \'x' ]]), q{passes is_Lambda}; ok is_App([ [ \'x', [ \'x', '+', \'x' ]], 10 ]), q{passes is_App}; ok Expr->check([ 11, '+', 12]), '... check is supported'; ok is_Expr(\'x'), q{passes is_Expr(\'x')}; ok is_Expr(10), q{passes is_Expr(10)}; ok is_Expr([ 1, '+', 1]), q{passes is_Expr([ 1, '+', 1])}; ok is_Expr([ 1, '+', [ 1, '+', 1 ]]), q{passes is_Expr([ 1, '+', [ 1, '+', 1 ]])}; my $source = [ [ \'x', [ \'x', '+', \'x' ]], 10 ]; is Interpreter::pprint($source), 'App( Lambda( Var(x) BinOp( Var(x) Op(+) Var(x) ) ) Const(10) )', '... pretty printed correctly'; is Interpreter::run([ 1, '+', 1 ]), 2, '... eval-ed correctly'; is Interpreter::run([ 1, '+', [ 1, '+', 1 ] ]), 3, '... eval-ed correctly'; is_deeply Interpreter::run([ \'x', [ \'x', '+', \'x' ]]), [ \'x', [ \'x', '+', \'x' ]], '... eval-ed correctly'; is Interpreter::run($source), 20, '... eval-ed correctly'; is Interpreter::run( [ [ \'x', [ \'x', '+', \'x' ] ], [ 2, '+', 2 ] ] ), 8, '... eval-ed correctly'; } MooseX-Types-Structured-0.35/t/11-overflow.t000600 000766 000024 00000003174 12637630671 021114 0ustar00etherstaff000000 000000 use strict; use warnings; use Test::More tests=>14; use MooseX::Types::Structured qw(Dict Tuple slurpy); use MooseX::Types::Moose qw(Int Str ArrayRef HashRef Object); my $array_tailed_tuple = Tuple[ Int, Str, slurpy ArrayRef[Int], ]; is($array_tailed_tuple->name, 'MooseX::Types::Structured::Tuple[Int,Str,slurpy(ArrayRef[Int])]'); is Moose::Util::TypeConstraints::find_or_create_type_constraint($array_tailed_tuple), $array_tailed_tuple, 'find_or_create_type_constraint finds array with slurpy'; ok !$array_tailed_tuple->check(['ss',1]), 'correct fail'; ok $array_tailed_tuple->check([1,'ss']), 'correct pass'; ok !$array_tailed_tuple->check({}), 'correct fail'; ok $array_tailed_tuple->check([1,'hello',1,2,3,4]), 'correct pass with tail'; ok !$array_tailed_tuple->check([1,'hello',1,2,'bad',4]), 'correct fail with tail'; my $hash_tailed_dict = Dict[ name=>Str, age=>Int, slurpy HashRef[Int], ]; is($hash_tailed_dict->name, 'MooseX::Types::Structured::Dict[name,Str,age,Int,slurpy(HashRef[Int])]'); is Moose::Util::TypeConstraints::find_or_create_type_constraint($hash_tailed_dict), $hash_tailed_dict, 'find_or_create_type_constraint finds hash with slurpy'; ok !$hash_tailed_dict->check({name=>'john',age=>'napiorkowski'}), 'correct fail'; ok $hash_tailed_dict->check({name=>'Vanessa Li', age=>35}), 'correct pass'; ok !$hash_tailed_dict->check([]), 'correct fail'; ok $hash_tailed_dict->check({name=>'Vanessa Li', age=>35, more1=>1,more2=>2}), 'correct pass with tail'; ok !$hash_tailed_dict->check({name=>'Vanessa Li', age=>35, more1=>1,more2=>"aa"}), 'correct fail with tail'; MooseX-Types-Structured-0.35/t/12-error.t000600 000766 000024 00000010372 12637630671 020401 0ustar00etherstaff000000 000000 use strict; use warnings; use Test::More 0.88; use Moose::Util::TypeConstraints; use MooseX::Types::Structured qw(Dict Tuple Optional); use MooseX::Types::Moose qw(Int Str ArrayRef HashRef); # Create some TCs from which errors will be generated my $simple_tuple = subtype 'simple_tuple', as Tuple[Int,Str]; my $simple_dict = subtype 'simple_dict', as Dict[name=>Str,age=>Int]; # Make sure the constraints we made validate as expected ok $simple_tuple->check([1,'hello']), "simple_tuple validates: 1,'hello'"; ok !$simple_tuple->check(['hello',1]), "simple_tuple fails: 'hello',1"; ok $simple_dict->check({name=>'Vanessa',age=>34}), "simple_dict validates: {name=>'Vanessa',age=>34}"; ok !$simple_dict->check({name=>$simple_dict,age=>'hello'}), "simple_dict fails: {name=>Object, age=>String}"; ## Let's check all the expected validation errors for tuple like $simple_tuple->validate({a=>1,b=>2}), qr/Validation failed for 'simple_tuple' with value .*{ a: 1, b: 2 }/, 'Wrong basic type'; like $simple_tuple->validate(['a','b']), qr/failed for 'simple_tuple' with value .*\[ "a", "b" \]/, 'Correctly failed due to "a" not an Int'; like $simple_tuple->validate([1,$simple_tuple]), qr/Validation failed for 'simple_tuple' with value .*\[ 1, MooseX::Meta::TypeConstraint::Structured/, 'Correctly failed due to object not a Str'; like $simple_tuple->validate([1]), qr/Validation failed for 'Str' with value .*NULL/, 'Not enought values'; like $simple_tuple->validate([1,'hello','too many']), qr/More values than Type Constraints!/, 'Too Many values'; ## And the same thing for dicts [name=>Str,age=>Int] like $simple_dict->validate([1,2]), qr/ with value .*\[ 1, 2 \]/, 'Wrong basic type'; like $simple_dict->validate({name=>'John',age=>'foobar'}), qr/failed for 'Int' with value .*foobar/, 'Correctly failed due to age not an Int'; like $simple_dict->validate({name=>$simple_dict,age=>1}), qr/with value .*{ age: 1, name: MooseX:/, 'Correctly failed due to object not a Str'; like $simple_dict->validate({name=>'John'}), qr/failed for 'Int' with value .*NULL/, 'Not enought values'; like $simple_dict->validate({name=>'Vincent', age=>15,extra=>'morethanIneed'}), qr/More values than Type Constraints!/, 'Too Many values'; ## TODO some with Optional (or Maybe) and slurpy my $optional_tuple = subtype 'optional_tuple', as Tuple[Int,Optional[Str]]; my $optional_dict = subtype 'optional_dict', as Dict[name=>Str,age=>Optional[Int]]; like $optional_tuple->validate({a=>1,b=>2}), qr/Validation failed for 'optional_tuple' with value .*{ a: 1, b: 2 }/, 'Wrong basic type'; like $optional_tuple->validate(['baz','b']), qr/failed for 'Int' with value .*baz/, 'Correctly failed due to "baz" not an Int'; like $optional_tuple->validate([1,$simple_tuple]), qr/failed for 'Optional\[Str\]' with value .*MooseX/, 'Correctly failed due to object not a Str'; like $optional_tuple->validate([1,'hello','too many']), qr/More values than Type Constraints!/, 'Too Many values'; like $optional_dict->validate([1,2]), qr/ with value .*\[ 1, 2 \]/, 'Wrong basic type'; like $optional_dict->validate({name=>'John',age=>'quux'}), qr/Validation failed for 'Optional\[Int\]' with value .*quux/, 'Correctly failed due to age not an Int'; like $optional_dict->validate({name=>$simple_dict,age=>1}), qr/with value .*{ age: 1, name: MooseX:/, 'Correctly failed due to object not a Str'; like $optional_dict->validate({name=>'Vincent', age=>15,extra=>'morethanIneed'}), qr/More values than Type Constraints!/, 'Too Many values'; ## Deeper constraints my $deep_tuple = subtype 'deep_tuple', as Tuple[ Int, HashRef, Dict[ name=>Str, age=>Int, ], ]; ok $deep_tuple->check([1,{a=>2},{name=>'Vincent',age=>15}]), 'Good Constraint'; { my $message = $deep_tuple->validate([1,{a=>2},{name=>'Vincent',age=>'Hello'}]); like $message, qr/Validation failed for 'Dict\[name,Str,age,Int\]'/, 'Example deeper error'; } like $simple_tuple->validate(["aaa","bbb"]), qr/'Int' with value .*aaa/, 'correct deeper error'; like $deep_tuple->validate([1,{a=>2},{name=>'Vincent1',age=>'Hello1'}]), qr/'Int' with value .*Hello1/, 'correct deeper error'; ## Success Tests... ok !$deep_tuple->validate([1,{a=>2},{name=>'John',age=>40}]), 'Validates ok'; done_testing(); MooseX-Types-Structured-0.35/t/13-deeper_error.t000600 000766 000024 00000002030 12637630671 021716 0ustar00etherstaff000000 000000 use strict; use warnings; use Test::More 0.88; use Moose::Util::TypeConstraints; use MooseX::Types::Structured qw(Dict Tuple); use MooseX::Types::Moose qw(Int); my $deeper_tc = subtype as Dict[ a => Tuple[ Dict[ a1a => Tuple[Int], a1b => Tuple[Int], ], Dict[ a2a => Tuple[Int], a2b => Tuple[Int], ], ], b => Tuple[ Dict[ b1a => Tuple[Int], b1b => Tuple[Int], ], Dict[ b2a => Tuple[Int], b2b => Tuple[Int], ], ], ]; my $struc_to_validate = { a=>[ { a1a=>[1], a1b=>[2] }, { a2a=>['AA'], a2b=>[4] } ], b=>[ { b1a=>[5], b1b=>['BB'] }, { b2a=>[7], b2b=>[8] } ] }; ok my $message = $deeper_tc->validate($struc_to_validate), 'got error message of some sort'; done_testing(); ## warn $message; MooseX-Types-Structured-0.35/t/14-fully-qualified.t000600 000766 000024 00000000577 12637630671 022354 0ustar00etherstaff000000 000000 use strict; use warnings; use Test::More 0.88; use if $ENV{AUTHOR_TESTING}, 'Test::Warnings'; use MooseX::Types::Moose 'Str'; use MooseX::Types::Structured 'Dict'; ok(Dict->isa('Moose::Meta::TypeConstraint'), 'type is available as an import'); ok(MooseX::Types::Structured::Dict->isa('Moose::Meta::TypeConstraint'), 'type is available as a fully-qualified name'); done_testing; MooseX-Types-Structured-0.35/t/bug-incorrect-message.t000600 000766 000024 00000001344 12637630671 023214 0ustar00etherstaff000000 000000 use strict; use warnings; use Test::More 0.88; { package Test::MooseX::Types::Structured::IncorrectMessage; use Moose; use MooseX::Types::Moose qw(Str Int); use MooseX::Types::Structured qw(Tuple Dict); use MooseX::Types -declare => [qw(WrongMessage MyInt)]; subtype MyInt, as Int, message { 'Oh, my Int!' }; subtype WrongMessage, as Dict[name=>Str, age=>MyInt]; has 'person' => ( is => 'rw', required => 1, isa => WrongMessage, ); } my %init_args = ( person => { name => 'a', age => 'v', }, ); SKIP: { skip 'Deeper Error Messges not yet supported', 1,1; ok( Test::MooseX::Types::Structured::IncorrectMessage->new(%init_args), 'Made a class', ); } done_testing; MooseX-Types-Structured-0.35/t/bug-is-subtype.t000600 000766 000024 00000003572 12637630671 021713 0ustar00etherstaff000000 000000 use strict; use warnings; use Test::More 0.88; ## Bug report was that if calling ->is_subtype on crap (not a type, etc) you ## get a not very helpful error message. Fix was to make crap just return ## boolean false to make this like the rest of Moose type constraints. I am ## not convinced this is good, but at least is consistent. # # I also changed ->equals and ->is_a_type_of to be consistent { package moosex::types::structured::bug_is_subtype; use Moose; use MooseX::Types -declare => [qw/ ThingType /]; use MooseX::Types::Moose qw/ Int Str /; use MooseX::Types::Structured qw/ Dict /; subtype ThingType, as Dict [ id => Int, name => Str, ]; has thing => ( is => 'ro', isa => ThingType, ); } ok my $test = moosex::types::structured::bug_is_subtype->new, 'created class'; is( moosex::types::structured::bug_is_subtype::ThingType, 'moosex::types::structured::bug_is_subtype::ThingType', 'correct type', ); use MooseX::Types::Moose 'HashRef'; is( HashRef, 'HashRef', 'correct type', ); ok( moosex::types::structured::bug_is_subtype::ThingType->is_subtype_of(HashRef), 'is a subtype', ); ok( !moosex::types::structured::bug_is_subtype::ThingType ->is_subtype_of(moosex::types::structured::bug_is_subtype::ThingType), 'is not a subtype', ); ok( !moosex::types::structured::bug_is_subtype::ThingType ->is_subtype_of('SomeCrap'), 'is not a subtype', ); sub SomeCrap {} ok( !moosex::types::structured::bug_is_subtype::ThingType ->is_subtype_of(SomeCrap), 'is not a subtype', ); ok( !moosex::types::structured::bug_is_subtype::ThingType ->is_subtype_of(undef), 'is not a subtype', ); ok( !moosex::types::structured::bug_is_subtype::ThingType ->equals(undef), 'is not a subtype', ); ok( !moosex::types::structured::bug_is_subtype::ThingType ->is_a_type_of(undef), 'is not a subtype', ); done_testing; MooseX-Types-Structured-0.35/t/bug-mixed-stringy.t000600 000766 000024 00000001545 12637630671 022410 0ustar00etherstaff000000 000000 use strict; use warnings; use Test::More 0.88; { package Test::MooseX::Types::Structured::StringyBug; use Moose; use MooseX::Types::Moose qw(Str); use MooseX::Types::Structured qw(Tuple Dict); use Moose::Util::TypeConstraints; subtype "TestStringTypes::SubType", as Str, where { 1 }; has 'attr1' => ( is => 'ro', required => 1, isa => Dict[ foo1 => Str, foo2 => "Int", foo3 => "TestStringTypes::SubType", ], ); has 'attr2' => ( is => 'ro', required => 1, isa => Tuple[ Str, "Int", "TestStringTypes::SubType", ], ); } my %init_args = ( attr1 => { foo1 => 'a', foo2 => 2, foo3 => 'c', }, attr2 => ['a', 2, 'c'], ); ok( Test::MooseX::Types::Structured::StringyBug->new(%init_args), 'Made a class with mixed constraint types', ); done_testing; MooseX-Types-Structured-0.35/t/bug-optional.t000600 000766 000024 00000002132 12637630671 021423 0ustar00etherstaff000000 000000 use strict; use warnings; use Test::More 0.88; { package MyTypes; use MooseX::Types::Structured qw(Dict Tuple Optional); use MooseX::Types::Moose qw(Object Any); use MooseX::Types -declare => [qw( Signature MyDict MyTuple )]; subtype Signature, as Tuple[Tuple[Object], Dict[optional => Optional[Any], required => Any]]; subtype MyDict, as Dict[optional => Optional[Any], required => Any]; subtype MyTuple, as Tuple[Object, Any, Optional[Any]]; } BEGIN { MyTypes->import(':all'); } ok(!Signature->check([ [bless {}, 'Foo'], {} ])); ok(!MyDict->check({ })); ok(!MyDict->check({ optional => 42 })); ok(!MyDict->check({ optional => 42, unknown => 23 })); ok(!MyDict->check({ required => 42, unknown => 23 })); ok(MyDict->check({ optional => 42, required => 23 })); ok(MyDict->check({ required => 23 })); ok(!MyTuple->check([])); ok(!MyTuple->check([bless({}, 'Foo')])); ok(!MyTuple->check([bless({}, 'Foo'), 'bar', 'baz', 'moo'])); ok(MyTuple->check([bless({}, 'Foo'), 'bar'])); ok(MyTuple->check([bless({}, 'Foo'), 'bar', 'baz'])); done_testing; MooseX-Types-Structured-0.35/t/regressions/000700 000766 000024 00000000000 12637630671 021201 5ustar00etherstaff000000 000000 MooseX-Types-Structured-0.35/t/zzz-check-breaks.t000644 000766 000024 00000000623 12637630671 022213 0ustar00etherstaff000000 000000 use strict; use warnings; # this test was generated with Dist::Zilla::Plugin::Test::CheckBreaks 0.014 use Test::More tests => 2; SKIP: { eval 'require Moose::Conflicts; Moose::Conflicts->check_conflicts'; skip('no Moose::Conflicts module found', 1) if not $INC{'Moose/Conflicts.pm'}; diag $@ if $@; pass 'conflicts checked via Moose::Conflicts'; } pass 'no x_breaks data to check'; MooseX-Types-Structured-0.35/t/regressions/01-is_type_of.t000600 000766 000024 00000003155 12637630671 023752 0ustar00etherstaff000000 000000 use strict; use warnings; use Test::More tests=>11; { package TypeLib; use MooseX::Types::Structured qw(Dict Tuple); use MooseX::Types::Moose qw(Int Str Item); use MooseX::Types -declare => [qw( MyDict1 MyDict2 MyDict4 )]; subtype MyDict1, as Dict[name=>Str, age=>Int]; subtype MyDict2, as Dict[name=>Str, age=>Int]; subtype MyDict4, as Dict[name=>Str, age=>Item]; } BEGIN { TypeLib->import(':all'); } use Moose::Util::TypeConstraints; use MooseX::Types::Structured qw(Dict Tuple); use MooseX::Types::Moose qw(Item Any); ok ( MyDict2->is_a_type_of(MyDict4), 'MyDict2 is_a_type_of MyDict4'); ok ( MyDict1->is_subtype_of(MyDict4), 'MyDict1 is_subtype_of MyDict4'); ok ( (Tuple[Tuple[ class_type('Paper'), class_type('Stone') ], Dict[]])->is_a_type_of( Tuple[Tuple[ Item, Item ], Dict[]] ), "tuple of tuple" ); ok ( (Tuple[Tuple[ class_type('Paper'), class_type('Stone') ], Dict[]])->is_a_type_of( Tuple[Tuple[ Item, Item ], Dict[]] ), "tuple of tuple" ); ok ( (Tuple[Tuple[ class_type('Paper'), class_type('Stone') ], Dict[]])->is_subtype_of( Tuple[Tuple[ Item, Item ], Dict[]] ), "tuple of tuple" ); my $item = subtype as 'Item'; ok ( $item->is_subtype_of('Any'), q[$item is subtype of 'Any']); ok ( Item->is_subtype_of('Any'), q[Item is subtype of 'Any']); ok ( $item->is_subtype_of(Any), q[Item is subtype of Any]); ok ( Item->is_subtype_of(Any), q[Item is subtype of Any]); my $any = subtype as 'Any'; ok ( ! $item->is_subtype_of($any), q[$item is NOT a subtype of $any]); ok ( ! Item->is_subtype_of($any), q[Item is NOT a subtype of $any]); MooseX-Types-Structured-0.35/lib/MooseX/000700 000766 000024 00000000000 12637630671 020353 5ustar00etherstaff000000 000000 MooseX-Types-Structured-0.35/lib/MooseX/Meta/000700 000766 000024 00000000000 12637630671 021241 5ustar00etherstaff000000 000000 MooseX-Types-Structured-0.35/lib/MooseX/Types/000700 000766 000024 00000000000 12637630671 021457 5ustar00etherstaff000000 000000 MooseX-Types-Structured-0.35/lib/MooseX/Types/Structured/000700 000766 000024 00000000000 12637630671 023623 5ustar00etherstaff000000 000000 MooseX-Types-Structured-0.35/lib/MooseX/Types/Structured.pm000644 000766 000024 00000161661 12637630671 024206 0ustar00etherstaff000000 000000 package MooseX::Types::Structured; # git description: v0.34-6-g17def06 # ABSTRACT: Structured Type Constraints for Moose our $VERSION = '0.35'; use 5.008; use Moose::Util::TypeConstraints 1.06 'find_type_constraint'; use MooseX::Meta::TypeConstraint::Structured; use MooseX::Meta::TypeConstraint::Structured::Optional; use MooseX::Types::Structured::OverflowHandler; use MooseX::Types::Structured::MessageStack; use Devel::PartialDump 0.13; use Scalar::Util qw(blessed); use namespace::clean 0.19; use MooseX::Types 0.22 -declare => [qw(Dict Map Tuple Optional)]; use Sub::Exporter 0.982 -setup => { exports => [ qw(Dict Map Tuple Optional slurpy) ], }; use if MooseX::Types->VERSION >= 0.42, 'namespace::autoclean' => -except => 'import'; # TODO: https://github.com/rjbs/Sub-Exporter/issues/8 #pod =head1 SYNOPSIS #pod #pod The following is example usage for this module. #pod #pod package Person; #pod #pod use Moose; #pod use MooseX::Types::Moose qw(Str Int HashRef); #pod use MooseX::Types::Structured qw(Dict Tuple Optional); #pod #pod ## A name has a first and last part, but middle names are not required #pod has name => ( #pod isa=>Dict[ #pod first => Str, #pod last => Str, #pod middle => Optional[Str], #pod ], #pod ); #pod #pod ## description is a string field followed by a HashRef of tagged data. #pod has description => ( #pod isa=>Tuple[ #pod Str, #pod Optional[HashRef], #pod ], #pod ); #pod #pod ## Remainder of your class attributes and methods #pod #pod Then you can instantiate this class with something like: #pod #pod my $john = Person->new( #pod name => { #pod first => 'John', #pod middle => 'James' #pod last => 'Napiorkowski', #pod }, #pod description => [ #pod 'A cool guy who loves Perl and Moose.', { #pod married_to => 'Vanessa Li', #pod born_in => 'USA', #pod }; #pod ] #pod ); #pod #pod Or with: #pod #pod my $vanessa = Person->new( #pod name => { #pod first => 'Vanessa', #pod last => 'Li' #pod }, #pod description => ['A great student!'], #pod ); #pod #pod But all of these would cause a constraint error for the C attribute: #pod #pod ## Value for 'name' not a HashRef #pod Person->new( name => 'John' ); #pod #pod ## Value for 'name' has incorrect hash key and missing required keys #pod Person->new( name => { #pod first_name => 'John' #pod }); #pod #pod ## Also incorrect keys #pod Person->new( name => { #pod first_name => 'John', #pod age => 39, #pod }); #pod #pod ## key 'middle' incorrect type, should be a Str not a ArrayRef #pod Person->new( name => { #pod first => 'Vanessa', #pod middle => [1,2], #pod last => 'Li', #pod }); #pod #pod And these would cause a constraint error for the C attribute: #pod #pod ## Should be an ArrayRef #pod Person->new( description => 'Hello I am a String' ); #pod #pod ## First element must be a string not a HashRef. #pod Person->new (description => [{ #pod tag1 => 'value1', #pod tag2 => 'value2' #pod }]); #pod #pod Please see the test cases for more examples. #pod #pod =head1 DESCRIPTION #pod #pod A structured type constraint is a standard container L type constraint, #pod such as an C or C, which has been enhanced to allow you to #pod explicitly name all the allowed type constraints inside the structure. The #pod generalized form is: #pod #pod TypeConstraint[@TypeParameters or %TypeParameters] #pod #pod Where C is an array reference or hash references of #pod L objects. #pod #pod This type library enables structured type constraints. It is built on top of the #pod L library system, so you should review the documentation for that #pod if you are not familiar with it. #pod #pod =head2 Comparing Parameterized types to Structured types #pod #pod Parameterized constraints are built into core Moose and you are probably already #pod familiar with the type constraints C and C. Structured types #pod have similar functionality, so their syntax is likewise similar. For example, #pod you could define a parameterized constraint like: #pod #pod subtype ArrayOfInts, #pod as ArrayRef[Int]; #pod #pod which would constrain a value to something like [1,2,3,...] and so on. On the #pod other hand, a structured type constraint explicitly names all it's allowed #pod 'internal' type parameter constraints. For the example: #pod #pod subtype StringFollowedByInt, #pod as Tuple[Str,Int]; #pod #pod would constrain its value to things like C<< ['hello', 111] >> but C<< ['hello', 'world'] >> #pod would fail, as well as C<< ['hello', 111, 'world'] >> and so on. Here's another #pod example: #pod #pod package MyApp::Types; #pod #pod use MooseX::Types -declare [qw(StringIntOptionalHashRef)]; #pod use MooseX::Types::Moose qw(Str Int); #pod use MooseX::Types::Structured qw(Tuple Optional); #pod #pod subtype StringIntOptionalHashRef, #pod as Tuple[ #pod Str, Int, #pod Optional[HashRef] #pod ]; #pod #pod This defines a type constraint that validates values like: #pod #pod ['Hello', 100, {key1 => 'value1', key2 => 'value2'}]; #pod ['World', 200]; #pod #pod Notice that the last type constraint in the structure is optional. This is #pod enabled via the helper C type constraint, which is a variation of the #pod core Moose type constraint C. The main difference is that C type #pod constraints are required to validate if they exist, while C permits #pod undefined values. So the following example would not validate: #pod #pod StringIntOptionalHashRef->validate(['Hello Undefined', 1000, undef]); #pod #pod Please note the subtle difference between undefined and null. If you wish to #pod allow both null and undefined, you should use the core Moose C type #pod constraint instead: #pod #pod package MyApp::Types; #pod #pod use MooseX::Types -declare [qw(StringIntMaybeHashRef)]; #pod use MooseX::Types::Moose qw(Str Int Maybe); #pod use MooseX::Types::Structured qw(Tuple); #pod #pod subtype StringIntMaybeHashRef, #pod as Tuple[ #pod Str, Int, Maybe[HashRef] #pod ]; #pod #pod This would validate the following: #pod #pod ['Hello', 100, {key1 => 'value1', key2 => 'value2'}]; #pod ['World', 200, undef]; #pod ['World', 200]; #pod #pod Structured constraints are not limited to arrays. You can define a structure #pod against a C with the C type constraint as in this example: #pod #pod subtype FirstNameLastName, #pod as Dict[ #pod firstname => Str, #pod lastname => Str, #pod ]; #pod #pod This would constrain a C that validates something like: #pod #pod {firstname => 'Christopher', lastname => 'Parsons'}; #pod #pod but all the following would fail validation: #pod #pod ## Incorrect keys #pod {first => 'Christopher', last => 'Parsons'}; #pod #pod ## Too many keys #pod {firstname => 'Christopher', lastname => 'Parsons', middlename => 'Allen'}; #pod #pod ## Not a HashRef #pod ['Christopher', 'Parsons']; #pod #pod These structures can be as simple or elaborate as you wish. You can even #pod combine various structured, parameterized and simple constraints all together: #pod #pod subtype Crazy, #pod as Tuple[ #pod Int, #pod Dict[name=>Str, age=>Int], #pod ArrayRef[Int] #pod ]; #pod #pod Which would match: #pod #pod [1, {name=>'John', age=>25},[10,11,12]]; #pod #pod Please notice how the type parameters can be visually arranged to your liking #pod and to improve the clarity of your meaning. You don't need to run then #pod altogether onto a single line. Additionally, since the C type constraint #pod defines a hash constraint, the key order is not meaningful. For example: #pod #pod subtype AnyKeyOrder, #pod as Dict[ #pod key1=>Int, #pod key2=>Str, #pod key3=>Int, #pod ]; #pod #pod Would validate both: #pod #pod {key1 => 1, key2 => "Hi!", key3 => 2}; #pod {key2 => "Hi!", key1 => 100, key3 => 300}; #pod #pod As you would expect, since underneath it's just a plain old Perl hash at work. #pod #pod =head2 Alternatives #pod #pod You should exercise some care as to whether or not your complex structured #pod constraints would be better off contained by a real object as in the following #pod example: #pod #pod package MyApp::MyStruct; #pod use Moose; #pod #pod ## lazy way to make a bunch of attributes #pod has $_ for qw(full_name age_in_years); #pod #pod package MyApp::MyClass; #pod use Moose; #pod #pod has person => (isa => 'MyApp::MyStruct'); #pod #pod my $instance = MyApp::MyClass->new( #pod person=>MyApp::MyStruct->new( #pod full_name => 'John', #pod age_in_years => 39, #pod ), #pod ); #pod #pod This method may take some additional time to set up but will give you more #pod flexibility. However, structured constraints are highly compatible with this #pod method, granting some interesting possibilities for coercion. Try: #pod #pod package MyApp::MyClass; #pod #pod use Moose; #pod use MyApp::MyStruct; #pod #pod ## It's recommended your type declarations live in a separate class in order #pod ## to promote reusability and clarity. Inlined here for brevity. #pod #pod use MooseX::Types::DateTime qw(DateTime); #pod use MooseX::Types -declare [qw(MyStruct)]; #pod use MooseX::Types::Moose qw(Str Int); #pod use MooseX::Types::Structured qw(Dict); #pod #pod ## Use class_type to create an ISA type constraint if your object doesn't #pod ## inherit from Moose::Object. #pod class_type 'MyApp::MyStruct'; #pod #pod ## Just a shorter version really. #pod subtype MyStruct, #pod as 'MyApp::MyStruct'; #pod #pod ## Add the coercions. #pod coerce MyStruct, #pod from Dict[ #pod full_name=>Str, #pod age_in_years=>Int #pod ], via { #pod MyApp::MyStruct->new(%$_); #pod }, #pod from Dict[ #pod lastname=>Str, #pod firstname=>Str, #pod dob=>DateTime #pod ], via { #pod my $name = $_->{firstname} .' '. $_->{lastname}; #pod my $age = DateTime->now - $_->{dob}; #pod #pod MyApp::MyStruct->new( #pod full_name=>$name, #pod age_in_years=>$age->years, #pod ); #pod }; #pod #pod has person => (isa=>MyStruct); #pod #pod This would allow you to instantiate with something like: #pod #pod my $obj = MyApp::MyClass->new( person => { #pod full_name=>'John Napiorkowski', #pod age_in_years=>39, #pod }); #pod #pod Or even: #pod #pod my $obj = MyApp::MyClass->new( person => { #pod lastname=>'John', #pod firstname=>'Napiorkowski', #pod dob=>DateTime->new(year=>1969), #pod }); #pod #pod If you are not familiar with how coercions work, check out the L cookbook #pod entry L for an explanation. The section L #pod has additional examples and discussion. #pod #pod =for stopwords Subtyping #pod #pod =head2 Subtyping a Structured type constraint #pod #pod You need to exercise some care when you try to subtype a structured type as in #pod this example: #pod #pod subtype Person, #pod as Dict[name => Str]; #pod #pod subtype FriendlyPerson, #pod as Person[ #pod name => Str, #pod total_friends => Int, #pod ]; #pod #pod This will actually work BUT you have to take care that the subtype has a #pod structure that does not contradict the structure of it's parent. For now the #pod above works, but I will clarify the syntax for this at a future point, so #pod it's recommended to avoid (should not really be needed so much anyway). For #pod now this is supported in an EXPERIMENTAL way. Your thoughts, test cases and #pod patches are welcomed for discussion. If you find a good use for this, please #pod let me know. #pod #pod =head2 Coercions #pod #pod Coercions currently work for 'one level' deep. That is you can do: #pod #pod subtype Person, #pod as Dict[ #pod name => Str, #pod age => Int #pod ]; #pod #pod subtype Fullname, #pod as Dict[ #pod first => Str, #pod last => Str #pod ]; #pod #pod coerce Person, #pod ## Coerce an object of a particular class #pod from BlessedPersonObject, via { #pod +{ #pod name=>$_->name, #pod age=>$_->age, #pod }; #pod }, #pod #pod ## Coerce from [$name, $age] #pod from ArrayRef, via { #pod +{ #pod name=>$_->[0], #pod age=>$_->[1], #pod }, #pod }, #pod ## Coerce from {fullname=>{first=>...,last=>...}, dob=>$DateTimeObject} #pod from Dict[fullname=>Fullname, dob=>DateTime], via { #pod my $age = $_->dob - DateTime->now; #pod my $firstn = $_->{fullname}->{first}; #pod my $lastn = $_->{fullname}->{last} #pod +{ #pod name => $_->{fullname}->{first} .' '. , #pod age =>$age->years #pod } #pod }; #pod #pod And that should just work as expected. However, if there are any 'inner' #pod coercions, such as a coercion on C or on C, that coercion #pod won't currently get activated. #pod #pod Please see the test F<07-coerce.t> for a more detailed example. Discussion on #pod extending coercions to support this welcome on the Moose development channel or #pod mailing list. #pod #pod =head2 Recursion #pod #pod Newer versions of L support recursive type constraints. That is #pod you can include a type constraint as a contained type constraint of itself. For #pod example: #pod #pod subtype Person, #pod as Dict[ #pod name=>Str, #pod friends=>Optional[ #pod ArrayRef[Person] #pod ], #pod ]; #pod #pod This would declare a C subtype that contains a name and an optional #pod C of Cs who are friends as in: #pod #pod { #pod name => 'Mike', #pod friends => [ #pod { name => 'John' }, #pod { name => 'Vincent' }, #pod { #pod name => 'Tracey', #pod friends => [ #pod { name => 'Stephenie' }, #pod { name => 'Ilya' }, #pod ], #pod }, #pod ], #pod }; #pod #pod Please take care to make sure the recursion node is either C, or declare #pod a union with an non-recursive option such as: #pod #pod subtype Value #pod as Tuple[ #pod Str, #pod Str|Tuple, #pod ]; #pod #pod Which validates: #pod #pod [ #pod 'Hello', [ #pod 'World', [ #pod 'Is', [ #pod 'Getting', #pod 'Old', #pod ], #pod ], #pod ], #pod ]; #pod #pod Otherwise you will define a subtype that is impossible to validate since it is #pod infinitely recursive. For more information about defining recursive types, #pod please see the documentation in L and the test cases. #pod #pod =head1 TYPE CONSTRAINTS #pod #pod This type library defines the following constraints. #pod #pod =head2 Tuple[@constraints] #pod #pod This defines an ArrayRef based constraint which allows you to validate a specific #pod list of contained constraints. For example: #pod #pod Tuple[Int,Str]; ## Validates [1,'hello'] #pod Tuple[Str|Object, Int]; ## Validates ['hello', 1] or [$object, 2] #pod #pod The Values of @constraints should ideally be L declared type #pod constraints. We do support 'old style' L string based constraints to a #pod limited degree but these string type constraints are considered deprecated. #pod There will be limited support for bugs resulting from mixing string and #pod L in your structures. If you encounter such a bug and really #pod need it fixed, we will required a detailed test case at the minimum. #pod #pod =head2 Dict[%constraints] #pod #pod This defines a HashRef based constraint which allowed you to validate a specific #pod hashref. For example: #pod #pod Dict[name=>Str, age=>Int]; ## Validates {name=>'John', age=>39} #pod #pod The keys in C<%constraints> follow the same rules as C<@constraints> in the above #pod section. #pod #pod =head2 Map[ $key_constraint, $value_constraint ] #pod #pod This defines a C-based constraint in which both the keys and values are #pod required to meet certain constraints. For example, to map hostnames to IP #pod addresses, you might say: #pod #pod Map[ HostName, IPAddress ] #pod #pod The type constraint would only be met if every key was a valid C and #pod every value was a valid C. #pod #pod =head2 Optional[$constraint] #pod #pod This is primarily a helper constraint for C and C type constraints. What #pod this allows is for you to assert that a given type constraint is allowed to be #pod null (but NOT undefined). If the value is null, then the type constraint passes #pod but if the value is defined it must validate against the type constraint. This #pod makes it easy to make a Dict where one or more of the keys doesn't have to exist #pod or a tuple where some of the values are not required. For example: #pod #pod subtype Name() => as Dict[ #pod first=>Str, #pod last=>Str, #pod middle=>Optional[Str], #pod ]; #pod #pod ...creates a constraint that validates against a hashref with the keys 'first' and #pod 'last' being strings and required while an optional key 'middle' is must be a #pod string if it appears but doesn't have to appear. So in this case both the #pod following are valid: #pod #pod {first=>'John', middle=>'James', last=>'Napiorkowski'} #pod {first=>'Vanessa', last=>'Li'} #pod #pod If you use the C type constraint instead, your values will also validate #pod against C, which may be incorrect for you. #pod #pod =head1 EXPORTABLE SUBROUTINES #pod #pod This type library makes available for export the following subroutines #pod #pod =for stopwords slurpy #pod #pod =head2 slurpy #pod #pod Structured type constraints by their nature are closed; that is validation will #pod depend on an exact match between your structure definition and the arguments to #pod be checked. Sometimes you might wish for a slightly looser amount of validation. #pod For example, you may wish to validate the first 3 elements of an array reference #pod and allow for an arbitrary number of additional elements. At first thought you #pod might think you could do it this way: #pod #pod # I want to validate stuff like: [1,"hello", $obj, 2,3,4,5,6,...] #pod subtype AllowTailingArgs, #pod as Tuple[ #pod Int, #pod Str, #pod Object, #pod ArrayRef[Int], #pod ]; #pod #pod However what this will actually validate are structures like this: #pod #pod [10,"Hello", $obj, [11,12,13,...] ]; # Notice element 4 is an ArrayRef #pod #pod In order to allow structured validation of, "and then some", arguments, you can #pod use the L method against a type constraint. For example: #pod #pod use MooseX::Types::Structured qw(Tuple slurpy); #pod #pod subtype AllowTailingArgs, #pod as Tuple[ #pod Int, #pod Str, #pod Object, #pod slurpy ArrayRef[Int], #pod ]; #pod #pod This will now work as expected, validating ArrayRef structures such as: #pod #pod [1,"hello", $obj, 2,3,4,5,6,...] #pod #pod A few caveats apply. First, the slurpy type constraint must be the last one in #pod the list of type constraint parameters. Second, the parent type of the slurpy #pod type constraint must match that of the containing type constraint. That means #pod that a C can allow a slurpy C (or children of Cs, including #pod another C) and a C can allow a slurpy C (or children/subtypes of #pod HashRef, also including other C constraints). #pod #pod Please note the technical way this works 'under the hood' is that the #pod slurpy keyword transforms the target type constraint into a coderef. Please do #pod not try to create your own custom coderefs; always use the slurpy method. The #pod underlying technology may change in the future but the slurpy keyword will be #pod supported. #pod #pod =head1 ERROR MESSAGES #pod #pod Error reporting has been improved to return more useful debugging messages. Now #pod I will stringify the incoming check value with L so that you #pod can see the actual structure that is tripping up validation. Also, I report the #pod 'internal' validation error, so that if a particular element inside the #pod Structured Type is failing validation, you will see that. There's a limit to #pod how deep this internal reporting goes, but you shouldn't see any of the "failed #pod with ARRAY(XXXXXX)" that we got with earlier versions of this module. #pod #pod This support is continuing to expand, so it's best to use these messages for #pod debugging purposes and not for creating messages that 'escape into the wild' #pod such as error messages sent to the user. #pod #pod Please see the test '12-error.t' for a more lengthy example. Your thoughts and #pod preferable tests or code patches very welcome! #pod #pod =head1 EXAMPLES #pod #pod Here are some additional example usage for structured types. All examples can #pod be found also in the 't/examples.t' test. Your contributions are also welcomed. #pod #pod =head2 Normalize a HashRef #pod #pod You need a hashref to conform to a canonical structure but are required accept a #pod bunch of different incoming structures. You can normalize using the C type #pod constraint and coercions. This example also shows structured types mixed which #pod other L libraries. #pod #pod package Test::MooseX::Meta::TypeConstraint::Structured::Examples::Normalize; #pod #pod use Moose; #pod use DateTime; #pod #pod use MooseX::Types::Structured qw(Dict Tuple); #pod use MooseX::Types::DateTime qw(DateTime); #pod use MooseX::Types::Moose qw(Int Str Object); #pod use MooseX::Types -declare => [qw(Name Age Person)]; #pod #pod subtype Person, #pod as Dict[ #pod name=>Str, #pod age=>Int, #pod ]; #pod #pod coerce Person, #pod from Dict[ #pod first=>Str, #pod last=>Str, #pod years=>Int, #pod ], via { +{ #pod name => "$_->{first} $_->{last}", #pod age => $_->{years}, #pod }}, #pod from Dict[ #pod fullname=>Dict[ #pod last=>Str, #pod first=>Str, #pod ], #pod dob=>DateTime, #pod ], #pod ## DateTime needs to be inside of single quotes here to disambiguate the #pod ## class package from the DataTime type constraint imported via the #pod ## line "use MooseX::Types::DateTime qw(DateTime);" #pod via { +{ #pod name => "$_->{fullname}{first} $_->{fullname}{last}", #pod age => ($_->{dob} - 'DateTime'->now)->years, #pod }}; #pod #pod has person => (is=>'rw', isa=>Person, coerce=>1); #pod #pod And now you can instantiate with all the following: #pod #pod __PACKAGE__->new( #pod person=>{ #pod name=>'John Napiorkowski', #pod age=>39, #pod }, #pod ); #pod #pod __PACKAGE__->new( #pod person=>{ #pod first=>'John', #pod last=>'Napiorkowski', #pod years=>39, #pod }, #pod ); #pod #pod __PACKAGE__->new( #pod person=>{ #pod fullname => { #pod first=>'John', #pod last=>'Napiorkowski' #pod }, #pod dob => 'DateTime'->new( #pod year=>1969, #pod month=>2, #pod day=>13 #pod ), #pod }, #pod ); #pod #pod This technique is a way to support various ways to instantiate your class in a #pod clean and declarative way. #pod #pod =cut my $Optional = MooseX::Meta::TypeConstraint::Structured::Optional->new( name => 'MooseX::Types::Structured::Optional', package_defined_in => __PACKAGE__, parent => find_type_constraint('Item'), constraint => sub { 1 }, constraint_generator => sub { my ($type_parameter, @args) = @_; my $check = $type_parameter->_compiled_type_constraint(); return sub { my (@args) = @_; ## Does the arg exist? Something exists if it's a 'real' value ## or if it is set to undef. if(exists($args[0])) { ## If it exists, we need to validate it $check->($args[0]); } else { ## But it's is okay if the value doesn't exists return 1; } } } ); my $IsType = sub { my ($obj, $type) = @_; return $obj->can('equals') ? $obj->equals($type) : undef; }; my $CompiledTC = sub { my ($obj) = @_; my $method = '_compiled_type_constraint'; return( $obj->$IsType('Any') ? undef : $obj->can($method) ? $obj->$method : sub { $obj->check(shift) }, ); }; Moose::Util::TypeConstraints::register_type_constraint($Optional); Moose::Util::TypeConstraints::add_parameterizable_type($Optional); Moose::Util::TypeConstraints::get_type_constraint_registry->add_type_constraint( MooseX::Meta::TypeConstraint::Structured->new( name => "MooseX::Types::Structured::Tuple" , parent => find_type_constraint('ArrayRef'), constraint_generator=> sub { ## Get the constraints and values to check my ($self, $type_constraints) = @_; $type_constraints ||= $self->type_constraints; my @type_constraints = defined $type_constraints ? @$type_constraints : (); my $overflow_handler; if($type_constraints[-1] && blessed $type_constraints[-1] && $type_constraints[-1]->isa('MooseX::Types::Structured::OverflowHandler')) { $overflow_handler = pop @type_constraints; } my $length = $#type_constraints; foreach my $idx (0..$length) { unless(blessed $type_constraints[$idx]) { ($type_constraints[$idx] = find_type_constraint($type_constraints[$idx])) || die "$type_constraints[$idx] is not a registered type"; } } my (@checks, @optional, $o_check, $is_compiled); return sub { my ($values, $err) = @_; my @values = defined $values ? @$values : (); ## initialise on first time run unless ($is_compiled) { @checks = map { $_->$CompiledTC } @type_constraints; @optional = map { $_->is_subtype_of($Optional) } @type_constraints; $o_check = $overflow_handler->$CompiledTC if $overflow_handler; $is_compiled++; } ## Perform the checking VALUE: for my $type_index (0 .. $#checks) { my $type_constraint = $checks[ $type_index ]; if(@values) { my $value = shift @values; next VALUE unless $type_constraint; unless($type_constraint->($value)) { if($err) { my $message = $type_constraints[ $type_index ]->validate($value,$err); $err->add_message({message=>$message,level=>$err->level}); } return; } } else { ## Test if the TC supports null values unless ($optional[ $type_index ]) { if($err) { my $message = $type_constraints[ $type_index ]->get_message('NULL',$err); $err->add_message({message=>$message,level=>$err->level}); } return; } } } ## Make sure there are no leftovers. if(@values) { if($overflow_handler) { return $o_check->([@values], $err); } else { if($err) { my $message = "More values than Type Constraints!"; $err->add_message({message=>$message,level=>$err->level}); } return; } } else { return 1; } }; } ) ); Moose::Util::TypeConstraints::get_type_constraint_registry->add_type_constraint( MooseX::Meta::TypeConstraint::Structured->new( name => "MooseX::Types::Structured::Dict", parent => find_type_constraint('HashRef'), constraint_generator => sub { ## Get the constraints and values to check my ($self, $type_constraints) = @_; $type_constraints = $self->type_constraints; my @type_constraints = defined $type_constraints ? @$type_constraints : (); my $overflow_handler; if($type_constraints[-1] && blessed $type_constraints[-1] && $type_constraints[-1]->isa('MooseX::Types::Structured::OverflowHandler')) { $overflow_handler = pop @type_constraints; } my %type_constraints = @type_constraints; foreach my $key (keys %type_constraints) { unless(blessed $type_constraints{$key}) { ($type_constraints{$key} = find_type_constraint($type_constraints{$key})) || die "$type_constraints{$key} is not a registered type"; } } my (%check, %optional, $o_check, $is_compiled); return sub { my ($values, $err) = @_; my %values = defined $values ? %$values: (); unless ($is_compiled) { %check = map { ($_ => $type_constraints{ $_ }->$CompiledTC) } keys %type_constraints; %optional = map { ($_ => $type_constraints{ $_ }->is_subtype_of($Optional)) } keys %type_constraints; $o_check = $overflow_handler->$CompiledTC if $overflow_handler; $is_compiled++; } ## Perform the checking KEY: for my $key (keys %check) { my $type_constraint = $check{ $key }; if(exists $values{$key}) { my $value = $values{$key}; delete $values{$key}; next KEY unless $type_constraint; unless($type_constraint->($value)) { if($err) { my $message = $type_constraints{ $key }->validate($value,$err); $err->add_message({message=>$message,level=>$err->level}); } return; } } else { ## Test to see if the TC supports null values unless ($optional{ $key }) { if($err) { my $message = $type_constraints{ $key }->get_message('NULL',$err); $err->add_message({message=>$message,level=>$err->level}); } return; } } } ## Make sure there are no leftovers. if(%values) { if($overflow_handler) { return $o_check->(+{%values}); } else { if($err) { my $message = "More values than Type Constraints!"; $err->add_message({message=>$message,level=>$err->level}); } return; } } else { return 1; } } }, ) ); Moose::Util::TypeConstraints::get_type_constraint_registry->add_type_constraint( MooseX::Meta::TypeConstraint::Structured->new( name => "MooseX::Types::Structured::Map", parent => find_type_constraint('HashRef'), constraint_generator=> sub { ## Get the constraints and values to check my ($self, $type_constraints) = @_; $type_constraints = $self->type_constraints; my @constraints = defined $type_constraints ? @$type_constraints : (); Carp::confess( "too many args for Map type" ) if @constraints > 2; my ($key_type, $value_type) = @constraints == 2 ? @constraints : @constraints == 1 ? (undef, @constraints) : (); my ($key_check, $value_check, $is_compiled); return sub { my ($values, $err) = @_; my %values = defined $values ? %$values: (); unless ($is_compiled) { ($key_check, $value_check) = map { $_ ? $_->$CompiledTC : undef } $key_type, $value_type; $is_compiled++; } ## Perform the checking if ($value_check) { for my $value (values %$values) { unless ($value_check->($value)) { if($err) { my $message = $value_type->validate($value,$err); $err->add_message({message=>$message,level=>$err->level}); } return; } } } if ($key_check) { for my $key (keys %$values) { unless ($key_check->($key)) { if($err) { my $message = $key_type->validate($key,$err); $err->add_message({message=>$message,level=>$err->level}); } return; } } } return 1; }; }, ) ); sub slurpy ($) { my ($tc) = @_; return MooseX::Types::Structured::OverflowHandler->new( type_constraint => $tc, ); } #pod =head1 SEE ALSO #pod #pod The following modules or resources may be of interest. #pod #pod L, L, L, #pod L #pod #pod =cut 1; __END__ =pod =encoding UTF-8 =head1 NAME MooseX::Types::Structured - Structured Type Constraints for Moose =head1 VERSION version 0.35 =head1 SYNOPSIS The following is example usage for this module. package Person; use Moose; use MooseX::Types::Moose qw(Str Int HashRef); use MooseX::Types::Structured qw(Dict Tuple Optional); ## A name has a first and last part, but middle names are not required has name => ( isa=>Dict[ first => Str, last => Str, middle => Optional[Str], ], ); ## description is a string field followed by a HashRef of tagged data. has description => ( isa=>Tuple[ Str, Optional[HashRef], ], ); ## Remainder of your class attributes and methods Then you can instantiate this class with something like: my $john = Person->new( name => { first => 'John', middle => 'James' last => 'Napiorkowski', }, description => [ 'A cool guy who loves Perl and Moose.', { married_to => 'Vanessa Li', born_in => 'USA', }; ] ); Or with: my $vanessa = Person->new( name => { first => 'Vanessa', last => 'Li' }, description => ['A great student!'], ); But all of these would cause a constraint error for the C attribute: ## Value for 'name' not a HashRef Person->new( name => 'John' ); ## Value for 'name' has incorrect hash key and missing required keys Person->new( name => { first_name => 'John' }); ## Also incorrect keys Person->new( name => { first_name => 'John', age => 39, }); ## key 'middle' incorrect type, should be a Str not a ArrayRef Person->new( name => { first => 'Vanessa', middle => [1,2], last => 'Li', }); And these would cause a constraint error for the C attribute: ## Should be an ArrayRef Person->new( description => 'Hello I am a String' ); ## First element must be a string not a HashRef. Person->new (description => [{ tag1 => 'value1', tag2 => 'value2' }]); Please see the test cases for more examples. =head1 DESCRIPTION A structured type constraint is a standard container L type constraint, such as an C or C, which has been enhanced to allow you to explicitly name all the allowed type constraints inside the structure. The generalized form is: TypeConstraint[@TypeParameters or %TypeParameters] Where C is an array reference or hash references of L objects. This type library enables structured type constraints. It is built on top of the L library system, so you should review the documentation for that if you are not familiar with it. =head2 Comparing Parameterized types to Structured types Parameterized constraints are built into core Moose and you are probably already familiar with the type constraints C and C. Structured types have similar functionality, so their syntax is likewise similar. For example, you could define a parameterized constraint like: subtype ArrayOfInts, as ArrayRef[Int]; which would constrain a value to something like [1,2,3,...] and so on. On the other hand, a structured type constraint explicitly names all it's allowed 'internal' type parameter constraints. For the example: subtype StringFollowedByInt, as Tuple[Str,Int]; would constrain its value to things like C<< ['hello', 111] >> but C<< ['hello', 'world'] >> would fail, as well as C<< ['hello', 111, 'world'] >> and so on. Here's another example: package MyApp::Types; use MooseX::Types -declare [qw(StringIntOptionalHashRef)]; use MooseX::Types::Moose qw(Str Int); use MooseX::Types::Structured qw(Tuple Optional); subtype StringIntOptionalHashRef, as Tuple[ Str, Int, Optional[HashRef] ]; This defines a type constraint that validates values like: ['Hello', 100, {key1 => 'value1', key2 => 'value2'}]; ['World', 200]; Notice that the last type constraint in the structure is optional. This is enabled via the helper C type constraint, which is a variation of the core Moose type constraint C. The main difference is that C type constraints are required to validate if they exist, while C permits undefined values. So the following example would not validate: StringIntOptionalHashRef->validate(['Hello Undefined', 1000, undef]); Please note the subtle difference between undefined and null. If you wish to allow both null and undefined, you should use the core Moose C type constraint instead: package MyApp::Types; use MooseX::Types -declare [qw(StringIntMaybeHashRef)]; use MooseX::Types::Moose qw(Str Int Maybe); use MooseX::Types::Structured qw(Tuple); subtype StringIntMaybeHashRef, as Tuple[ Str, Int, Maybe[HashRef] ]; This would validate the following: ['Hello', 100, {key1 => 'value1', key2 => 'value2'}]; ['World', 200, undef]; ['World', 200]; Structured constraints are not limited to arrays. You can define a structure against a C with the C type constraint as in this example: subtype FirstNameLastName, as Dict[ firstname => Str, lastname => Str, ]; This would constrain a C that validates something like: {firstname => 'Christopher', lastname => 'Parsons'}; but all the following would fail validation: ## Incorrect keys {first => 'Christopher', last => 'Parsons'}; ## Too many keys {firstname => 'Christopher', lastname => 'Parsons', middlename => 'Allen'}; ## Not a HashRef ['Christopher', 'Parsons']; These structures can be as simple or elaborate as you wish. You can even combine various structured, parameterized and simple constraints all together: subtype Crazy, as Tuple[ Int, Dict[name=>Str, age=>Int], ArrayRef[Int] ]; Which would match: [1, {name=>'John', age=>25},[10,11,12]]; Please notice how the type parameters can be visually arranged to your liking and to improve the clarity of your meaning. You don't need to run then altogether onto a single line. Additionally, since the C type constraint defines a hash constraint, the key order is not meaningful. For example: subtype AnyKeyOrder, as Dict[ key1=>Int, key2=>Str, key3=>Int, ]; Would validate both: {key1 => 1, key2 => "Hi!", key3 => 2}; {key2 => "Hi!", key1 => 100, key3 => 300}; As you would expect, since underneath it's just a plain old Perl hash at work. =head2 Alternatives You should exercise some care as to whether or not your complex structured constraints would be better off contained by a real object as in the following example: package MyApp::MyStruct; use Moose; ## lazy way to make a bunch of attributes has $_ for qw(full_name age_in_years); package MyApp::MyClass; use Moose; has person => (isa => 'MyApp::MyStruct'); my $instance = MyApp::MyClass->new( person=>MyApp::MyStruct->new( full_name => 'John', age_in_years => 39, ), ); This method may take some additional time to set up but will give you more flexibility. However, structured constraints are highly compatible with this method, granting some interesting possibilities for coercion. Try: package MyApp::MyClass; use Moose; use MyApp::MyStruct; ## It's recommended your type declarations live in a separate class in order ## to promote reusability and clarity. Inlined here for brevity. use MooseX::Types::DateTime qw(DateTime); use MooseX::Types -declare [qw(MyStruct)]; use MooseX::Types::Moose qw(Str Int); use MooseX::Types::Structured qw(Dict); ## Use class_type to create an ISA type constraint if your object doesn't ## inherit from Moose::Object. class_type 'MyApp::MyStruct'; ## Just a shorter version really. subtype MyStruct, as 'MyApp::MyStruct'; ## Add the coercions. coerce MyStruct, from Dict[ full_name=>Str, age_in_years=>Int ], via { MyApp::MyStruct->new(%$_); }, from Dict[ lastname=>Str, firstname=>Str, dob=>DateTime ], via { my $name = $_->{firstname} .' '. $_->{lastname}; my $age = DateTime->now - $_->{dob}; MyApp::MyStruct->new( full_name=>$name, age_in_years=>$age->years, ); }; has person => (isa=>MyStruct); This would allow you to instantiate with something like: my $obj = MyApp::MyClass->new( person => { full_name=>'John Napiorkowski', age_in_years=>39, }); Or even: my $obj = MyApp::MyClass->new( person => { lastname=>'John', firstname=>'Napiorkowski', dob=>DateTime->new(year=>1969), }); If you are not familiar with how coercions work, check out the L cookbook entry L for an explanation. The section L has additional examples and discussion. =for stopwords Subtyping =head2 Subtyping a Structured type constraint You need to exercise some care when you try to subtype a structured type as in this example: subtype Person, as Dict[name => Str]; subtype FriendlyPerson, as Person[ name => Str, total_friends => Int, ]; This will actually work BUT you have to take care that the subtype has a structure that does not contradict the structure of it's parent. For now the above works, but I will clarify the syntax for this at a future point, so it's recommended to avoid (should not really be needed so much anyway). For now this is supported in an EXPERIMENTAL way. Your thoughts, test cases and patches are welcomed for discussion. If you find a good use for this, please let me know. =head2 Coercions Coercions currently work for 'one level' deep. That is you can do: subtype Person, as Dict[ name => Str, age => Int ]; subtype Fullname, as Dict[ first => Str, last => Str ]; coerce Person, ## Coerce an object of a particular class from BlessedPersonObject, via { +{ name=>$_->name, age=>$_->age, }; }, ## Coerce from [$name, $age] from ArrayRef, via { +{ name=>$_->[0], age=>$_->[1], }, }, ## Coerce from {fullname=>{first=>...,last=>...}, dob=>$DateTimeObject} from Dict[fullname=>Fullname, dob=>DateTime], via { my $age = $_->dob - DateTime->now; my $firstn = $_->{fullname}->{first}; my $lastn = $_->{fullname}->{last} +{ name => $_->{fullname}->{first} .' '. , age =>$age->years } }; And that should just work as expected. However, if there are any 'inner' coercions, such as a coercion on C or on C, that coercion won't currently get activated. Please see the test F<07-coerce.t> for a more detailed example. Discussion on extending coercions to support this welcome on the Moose development channel or mailing list. =head2 Recursion Newer versions of L support recursive type constraints. That is you can include a type constraint as a contained type constraint of itself. For example: subtype Person, as Dict[ name=>Str, friends=>Optional[ ArrayRef[Person] ], ]; This would declare a C subtype that contains a name and an optional C of Cs who are friends as in: { name => 'Mike', friends => [ { name => 'John' }, { name => 'Vincent' }, { name => 'Tracey', friends => [ { name => 'Stephenie' }, { name => 'Ilya' }, ], }, ], }; Please take care to make sure the recursion node is either C, or declare a union with an non-recursive option such as: subtype Value as Tuple[ Str, Str|Tuple, ]; Which validates: [ 'Hello', [ 'World', [ 'Is', [ 'Getting', 'Old', ], ], ], ]; Otherwise you will define a subtype that is impossible to validate since it is infinitely recursive. For more information about defining recursive types, please see the documentation in L and the test cases. =head1 TYPE CONSTRAINTS This type library defines the following constraints. =head2 Tuple[@constraints] This defines an ArrayRef based constraint which allows you to validate a specific list of contained constraints. For example: Tuple[Int,Str]; ## Validates [1,'hello'] Tuple[Str|Object, Int]; ## Validates ['hello', 1] or [$object, 2] The Values of @constraints should ideally be L declared type constraints. We do support 'old style' L string based constraints to a limited degree but these string type constraints are considered deprecated. There will be limited support for bugs resulting from mixing string and L in your structures. If you encounter such a bug and really need it fixed, we will required a detailed test case at the minimum. =head2 Dict[%constraints] This defines a HashRef based constraint which allowed you to validate a specific hashref. For example: Dict[name=>Str, age=>Int]; ## Validates {name=>'John', age=>39} The keys in C<%constraints> follow the same rules as C<@constraints> in the above section. =head2 Map[ $key_constraint, $value_constraint ] This defines a C-based constraint in which both the keys and values are required to meet certain constraints. For example, to map hostnames to IP addresses, you might say: Map[ HostName, IPAddress ] The type constraint would only be met if every key was a valid C and every value was a valid C. =head2 Optional[$constraint] This is primarily a helper constraint for C and C type constraints. What this allows is for you to assert that a given type constraint is allowed to be null (but NOT undefined). If the value is null, then the type constraint passes but if the value is defined it must validate against the type constraint. This makes it easy to make a Dict where one or more of the keys doesn't have to exist or a tuple where some of the values are not required. For example: subtype Name() => as Dict[ first=>Str, last=>Str, middle=>Optional[Str], ]; ...creates a constraint that validates against a hashref with the keys 'first' and 'last' being strings and required while an optional key 'middle' is must be a string if it appears but doesn't have to appear. So in this case both the following are valid: {first=>'John', middle=>'James', last=>'Napiorkowski'} {first=>'Vanessa', last=>'Li'} If you use the C type constraint instead, your values will also validate against C, which may be incorrect for you. =head1 EXPORTABLE SUBROUTINES This type library makes available for export the following subroutines =for stopwords slurpy =head2 slurpy Structured type constraints by their nature are closed; that is validation will depend on an exact match between your structure definition and the arguments to be checked. Sometimes you might wish for a slightly looser amount of validation. For example, you may wish to validate the first 3 elements of an array reference and allow for an arbitrary number of additional elements. At first thought you might think you could do it this way: # I want to validate stuff like: [1,"hello", $obj, 2,3,4,5,6,...] subtype AllowTailingArgs, as Tuple[ Int, Str, Object, ArrayRef[Int], ]; However what this will actually validate are structures like this: [10,"Hello", $obj, [11,12,13,...] ]; # Notice element 4 is an ArrayRef In order to allow structured validation of, "and then some", arguments, you can use the L method against a type constraint. For example: use MooseX::Types::Structured qw(Tuple slurpy); subtype AllowTailingArgs, as Tuple[ Int, Str, Object, slurpy ArrayRef[Int], ]; This will now work as expected, validating ArrayRef structures such as: [1,"hello", $obj, 2,3,4,5,6,...] A few caveats apply. First, the slurpy type constraint must be the last one in the list of type constraint parameters. Second, the parent type of the slurpy type constraint must match that of the containing type constraint. That means that a C can allow a slurpy C (or children of Cs, including another C) and a C can allow a slurpy C (or children/subtypes of HashRef, also including other C constraints). Please note the technical way this works 'under the hood' is that the slurpy keyword transforms the target type constraint into a coderef. Please do not try to create your own custom coderefs; always use the slurpy method. The underlying technology may change in the future but the slurpy keyword will be supported. =head1 ERROR MESSAGES Error reporting has been improved to return more useful debugging messages. Now I will stringify the incoming check value with L so that you can see the actual structure that is tripping up validation. Also, I report the 'internal' validation error, so that if a particular element inside the Structured Type is failing validation, you will see that. There's a limit to how deep this internal reporting goes, but you shouldn't see any of the "failed with ARRAY(XXXXXX)" that we got with earlier versions of this module. This support is continuing to expand, so it's best to use these messages for debugging purposes and not for creating messages that 'escape into the wild' such as error messages sent to the user. Please see the test '12-error.t' for a more lengthy example. Your thoughts and preferable tests or code patches very welcome! =head1 EXAMPLES Here are some additional example usage for structured types. All examples can be found also in the 't/examples.t' test. Your contributions are also welcomed. =head2 Normalize a HashRef You need a hashref to conform to a canonical structure but are required accept a bunch of different incoming structures. You can normalize using the C type constraint and coercions. This example also shows structured types mixed which other L libraries. package Test::MooseX::Meta::TypeConstraint::Structured::Examples::Normalize; use Moose; use DateTime; use MooseX::Types::Structured qw(Dict Tuple); use MooseX::Types::DateTime qw(DateTime); use MooseX::Types::Moose qw(Int Str Object); use MooseX::Types -declare => [qw(Name Age Person)]; subtype Person, as Dict[ name=>Str, age=>Int, ]; coerce Person, from Dict[ first=>Str, last=>Str, years=>Int, ], via { +{ name => "$_->{first} $_->{last}", age => $_->{years}, }}, from Dict[ fullname=>Dict[ last=>Str, first=>Str, ], dob=>DateTime, ], ## DateTime needs to be inside of single quotes here to disambiguate the ## class package from the DataTime type constraint imported via the ## line "use MooseX::Types::DateTime qw(DateTime);" via { +{ name => "$_->{fullname}{first} $_->{fullname}{last}", age => ($_->{dob} - 'DateTime'->now)->years, }}; has person => (is=>'rw', isa=>Person, coerce=>1); And now you can instantiate with all the following: __PACKAGE__->new( person=>{ name=>'John Napiorkowski', age=>39, }, ); __PACKAGE__->new( person=>{ first=>'John', last=>'Napiorkowski', years=>39, }, ); __PACKAGE__->new( person=>{ fullname => { first=>'John', last=>'Napiorkowski' }, dob => 'DateTime'->new( year=>1969, month=>2, day=>13 ), }, ); This technique is a way to support various ways to instantiate your class in a clean and declarative way. =head1 SEE ALSO The following modules or resources may be of interest. L, L, L, L =head1 SUPPORT Bugs may be submitted through L (or L). There is also a mailing list available for users of this distribution, at L. There is also an irc channel available for users of this distribution, at L. =head1 AUTHORS =over 4 =item * John Napiorkowski =item * Florian Ragwitz =item * יובל קוג'מן (Yuval Kogman) =item * Tomas (t0m) Doran =item * Robert Sedlacek =back =head1 CONTRIBUTORS =for stopwords Karen Etheridge Ricardo Signes Dave Rolsky Ansgar Burchardt Stevan Little arcanez Jesse Luehrs D. Ilmari Mannsåker =over 4 =item * Karen Etheridge =item * Ricardo Signes =item * Dave Rolsky =item * Ansgar Burchardt =item * Stevan Little =item * arcanez =item * Jesse Luehrs =item * D. Ilmari Mannsåker =back =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2008 by John Napiorkowski. 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 MooseX-Types-Structured-0.35/lib/MooseX/Types/Structured/MessageStack.pm000644 000766 000024 00000001456 12637630671 026553 0ustar00etherstaff000000 000000 package ## Hide from PAUSE MooseX::Types::Structured::MessageStack; use Moose; has 'level' => ( traits => ['Counter'], is => 'ro', isa => 'Num', required => 0, default => 0, handles => { inc_level => 'inc', dec_level => 'dec', }, ); has 'messages' => ( traits => ['Array'], is => 'ro', isa => 'ArrayRef[HashRef]', required => 1, default => sub { [] }, handles => { has_messages => 'count', add_message => 'push', all_messages => 'elements', }, ); sub as_string { my @messages = (shift)->all_messages; my @flattened_msgs = map { "\n". (" " x $_->{level}) ."[+] " . $_->{message}; } reverse @messages; return join("", @flattened_msgs); } no Moose; __PACKAGE__->meta->make_immutable; 1; MooseX-Types-Structured-0.35/lib/MooseX/Types/Structured/OverflowHandler.pm000600 000766 000024 00000000644 12637630671 027270 0ustar00etherstaff000000 000000 package ## Hide from PAUSE MooseX::Types::Structured::OverflowHandler; use Moose; use overload '""' => 'name', fallback => 1; has type_constraint => ( is => 'ro', isa => 'Moose::Meta::TypeConstraint', required => 1, handles => [qw/check/], ); sub name { my ($self) = @_; return 'slurpy(' . $self->type_constraint->name . ')'; } no Moose; __PACKAGE__->meta->make_immutable; 1; MooseX-Types-Structured-0.35/lib/MooseX/Meta/TypeCoercion/000700 000766 000024 00000000000 12637630671 023644 5ustar00etherstaff000000 000000 MooseX-Types-Structured-0.35/lib/MooseX/Meta/TypeConstraint/000700 000766 000024 00000000000 12637630671 024227 5ustar00etherstaff000000 000000 MooseX-Types-Structured-0.35/lib/MooseX/Meta/TypeConstraint/Structured/000700 000766 000024 00000000000 12637630671 026373 5ustar00etherstaff000000 000000 MooseX-Types-Structured-0.35/lib/MooseX/Meta/TypeConstraint/Structured.pm000600 000766 000024 00000032237 12637630671 026742 0ustar00etherstaff000000 000000 package ## Hide from PAUSE MooseX::Meta::TypeConstraint::Structured; # ABSTRACT: Structured type constraints use Moose; use Devel::PartialDump; use MooseX::Meta::TypeCoercion::Structured; extends 'Moose::Meta::TypeConstraint'; #pod =head1 DESCRIPTION #pod #pod A structure is a set of L that are 'aggregated' in #pod such a way as that they are all applied to an incoming list of arguments. The #pod idea here is that a Type Constraint could be something like, "An C followed by #pod an C and then a C" and that this could be done so with a declaration like: #pod #pod Tuple[Int,Int,Str]; ## Example syntax #pod #pod So a structure is a list of type constraints (the C in the above #pod example) which are intended to function together. #pod #pod =attr type_constraints #pod #pod A list of L objects. #pod #pod =cut has 'type_constraints' => ( is=>'ro', isa=>'Ref', predicate=>'has_type_constraints', ); #pod =attr constraint_generator #pod #pod =for stopwords subref #pod #pod A subref or closure that contains the way we validate incoming values against #pod a set of type constraints. #pod #pod =cut has 'constraint_generator' => ( is=>'ro', isa=>'CodeRef', predicate=>'has_constraint_generator', ); has coercion => ( is => 'ro', isa => 'Object', builder => '_build_coercion', ); sub _build_coercion { my ($self) = @_; return MooseX::Meta::TypeCoercion::Structured->new( type_constraint => $self, ); } #pod =method validate #pod #pod Messing with validate so that we can support nicer error messages. #pod #pod =cut sub _clean_message { my $message = shift @_; $message =~s/MooseX::Types::Structured:://g; return $message; } override 'validate' => sub { my ($self, $value, $message_stack) = @_; unless ($message_stack) { $message_stack = MooseX::Types::Structured::MessageStack->new(); } $message_stack->inc_level; if ($self->_compiled_type_constraint->($value, $message_stack)) { ## Everything is good, no error message to return return undef; } else { ## Whoops, need to figure out the right error message my $args = Devel::PartialDump::dump($value); $message_stack->dec_level; if($message_stack->has_messages) { if($message_stack->level) { ## we are inside a deeply structured constraint return $self->get_message($args); } else { my $message_str = $message_stack->as_string; return _clean_message($self->get_message("$args, Internal Validation Error is: $message_str")); } } else { return $self->get_message($args); } } }; #pod =method generate_constraint_for ($type_constraints) #pod #pod Given some type constraints, use them to generate validation rules for an ref #pod of values (to be passed at check time) #pod #pod =cut sub generate_constraint_for { my ($self, $type_constraints) = @_; return $self->constraint_generator->($self, $type_constraints); } #pod =for :prelude #pod =for stopwords parameterize #pod #pod =method parameterize (@type_constraints) #pod #pod Given a ref of type constraints, create a structured type. #pod #pod =cut sub parameterize { my ($self, @type_constraints) = @_; my $class = ref $self; my $name = $self->name .'['. join(',', map {"$_"} @type_constraints) .']'; my $constraint_generator = $self->__infer_constraint_generator; return $class->new( name => $name, parent => $self, type_constraints => \@type_constraints, constraint_generator => $constraint_generator, ); } #pod =method __infer_constraint_generator #pod #pod =for stopwords servicable #pod #pod This returns a CODEREF which generates a suitable constraint generator. Not #pod user servicable, you'll never call this directly. #pod #pod =cut sub __infer_constraint_generator { my ($self) = @_; if($self->has_constraint_generator) { return $self->constraint_generator; } else { return sub { ## I'm not sure about this stuff but everything seems to work my $tc = shift @_; my $merged_tc = [@$tc, @{$self->parent->type_constraints}]; $self->constraint->($merged_tc, @_); }; } } #pod =method compile_type_constraint #pod #pod hook into compile_type_constraint so we can set the correct validation rules. #pod #pod =cut around 'compile_type_constraint' => sub { my ($compile_type_constraint, $self, @args) = @_; if($self->has_type_constraints) { my $type_constraints = $self->type_constraints; my $constraint = $self->generate_constraint_for($type_constraints); $self->_set_constraint($constraint); } return $self->$compile_type_constraint(@args); }; #pod =method create_child_type #pod #pod modifier to make sure we get the constraint_generator #pod #pod =cut around 'create_child_type' => sub { my ($create_child_type, $self, %opts) = @_; return $self->$create_child_type( %opts, constraint_generator => $self->__infer_constraint_generator, ); }; #pod =method is_a_type_of #pod #pod =method is_subtype_of #pod #pod =method equals #pod #pod Override the base class behavior. #pod #pod =cut sub equals { my ( $self, $type_or_name ) = @_; my $other = Moose::Util::TypeConstraints::find_type_constraint($type_or_name) or return; return unless $other->isa(__PACKAGE__); return ( $self->parent->equals($other->parent) and $self->type_constraints_equals($other) ); } sub is_a_type_of { my ( $self, $type_or_name ) = @_; my $other = Moose::Util::TypeConstraints::find_type_constraint($type_or_name) or return; if ( $other->isa(__PACKAGE__) and @{ $other->type_constraints || [] }) { if ( $self->parent->is_a_type_of($other->parent) ) { return $self->_type_constraints_op_all($other, "is_a_type_of"); } elsif ( $self->parent->is_a_type_of($other) ) { return 1; # FIXME compare? } else { return 0; } } else { return $self->SUPER::is_a_type_of($other); } } sub is_subtype_of { my ( $self, $type_or_name ) = @_; my $other = Moose::Util::TypeConstraints::find_type_constraint($type_or_name) or return; if ( $other->isa(__PACKAGE__) ) { if ( $other->type_constraints and $self->type_constraints ) { if ( $self->parent->is_a_type_of($other->parent) ) { return ( $self->_type_constraints_op_all($other, "is_a_type_of") and $self->_type_constraints_op_any($other, "is_subtype_of") ); } elsif ( $self->parent->is_a_type_of($other) ) { return 1; # FIXME compare? } else { return 0; } } else { if ( $self->type_constraints ) { if ( $self->SUPER::is_subtype_of($other) ) { return 1; } else { return; } } else { return $self->parent->is_subtype_of($other->parent); } } } else { return $self->SUPER::is_subtype_of($other); } } #pod =method type_constraints_equals #pod #pod Checks to see if the internal type constraints are equal. #pod #pod =cut sub type_constraints_equals { my ( $self, $other ) = @_; $self->_type_constraints_op_all($other, "equals"); } sub _type_constraints_op_all { my ($self, $other, $op) = @_; return unless $other->isa(__PACKAGE__); my @self_type_constraints = @{$self->type_constraints||[]}; my @other_type_constraints = @{$other->type_constraints||[]}; return unless @self_type_constraints == @other_type_constraints; ## Incoming ay be either arrayref or hashref, need top compare both while(@self_type_constraints) { my $self_type_constraint = shift @self_type_constraints; my $other_type_constraint = shift @other_type_constraints; $_ = Moose::Util::TypeConstraints::find_or_create_isa_type_constraint($_) for $self_type_constraint, $other_type_constraint; my $result = $self_type_constraint->$op($other_type_constraint); return unless $result; } return 1; ##If we get this far, everything is good. } sub _type_constraints_op_any { my ($self, $other, $op) = @_; return unless $other->isa(__PACKAGE__); my @self_type_constraints = @{$self->type_constraints||[]}; my @other_type_constraints = @{$other->type_constraints||[]}; return unless @self_type_constraints == @other_type_constraints; ## Incoming ay be either arrayref or hashref, need top compare both while(@self_type_constraints) { my $self_type_constraint = shift @self_type_constraints; my $other_type_constraint = shift @other_type_constraints; $_ = Moose::Util::TypeConstraints::find_or_create_isa_type_constraint($_) for $self_type_constraint, $other_type_constraint; return 1 if $self_type_constraint->$op($other_type_constraint); } return 0; } #pod =method get_message #pod #pod Give you a better peek into what's causing the error. For now we stringify the #pod incoming deep value with L and pass that on to either your #pod custom error message or the default one. In the future we'll try to provide a #pod more complete stack trace of the actual offending elements #pod #pod =cut around 'get_message' => sub { my ($get_message, $self, $value) = @_; $value = Devel::PartialDump::dump($value) if ref $value; return $self->$get_message($value); }; #pod =head1 SEE ALSO #pod #pod The following modules or resources may be of interest. #pod #pod L, L #pod #pod =cut no Moose; __PACKAGE__->meta->make_immutable(inline_constructor => 0); __END__ =pod =encoding UTF-8 =head1 NAME MooseX::Meta::TypeConstraint::Structured - Structured type constraints =head1 VERSION version 0.35 =for stopwords parameterize =head1 DESCRIPTION A structure is a set of L that are 'aggregated' in such a way as that they are all applied to an incoming list of arguments. The idea here is that a Type Constraint could be something like, "An C followed by an C and then a C" and that this could be done so with a declaration like: Tuple[Int,Int,Str]; ## Example syntax So a structure is a list of type constraints (the C in the above example) which are intended to function together. =head1 ATTRIBUTES =head2 type_constraints A list of L objects. =head2 constraint_generator =head1 METHODS =head2 validate Messing with validate so that we can support nicer error messages. =head2 generate_constraint_for ($type_constraints) Given some type constraints, use them to generate validation rules for an ref of values (to be passed at check time) =head2 parameterize (@type_constraints) Given a ref of type constraints, create a structured type. =head2 __infer_constraint_generator =head2 compile_type_constraint hook into compile_type_constraint so we can set the correct validation rules. =head2 create_child_type modifier to make sure we get the constraint_generator =head2 is_a_type_of =head2 is_subtype_of =head2 equals Override the base class behavior. =head2 type_constraints_equals Checks to see if the internal type constraints are equal. =head2 get_message Give you a better peek into what's causing the error. For now we stringify the incoming deep value with L and pass that on to either your custom error message or the default one. In the future we'll try to provide a more complete stack trace of the actual offending elements =for stopwords subref A subref or closure that contains the way we validate incoming values against a set of type constraints. =for stopwords servicable This returns a CODEREF which generates a suitable constraint generator. Not user servicable, you'll never call this directly. =head1 SEE ALSO The following modules or resources may be of interest. L, L =head1 SUPPORT Bugs may be submitted through L (or L). There is also a mailing list available for users of this distribution, at L. There is also an irc channel available for users of this distribution, at L. =head1 AUTHORS =over 4 =item * John Napiorkowski =item * Florian Ragwitz =item * יובל קוג'מן (Yuval Kogman) =item * Tomas (t0m) Doran =item * Robert Sedlacek =back =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2008 by John Napiorkowski. 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 MooseX-Types-Structured-0.35/lib/MooseX/Meta/TypeConstraint/Structured/Optional.pm000600 000766 000024 00000000774 12637630671 030530 0ustar00etherstaff000000 000000 package ## Hide from PAUSE MooseX::Meta::TypeConstraint::Structured::Optional; use Moose; use MooseX::Meta::TypeCoercion::Structured::Optional; extends 'Moose::Meta::TypeConstraint::Parameterizable'; around parameterize => sub { my $orig = shift; my $self = shift; my $ret = $self->$orig(@_); $ret->coercion(MooseX::Meta::TypeCoercion::Structured::Optional->new(type_constraint => $ret)); return $ret; }; no Moose; __PACKAGE__->meta->make_immutable(inline_constructor => 0); 1; MooseX-Types-Structured-0.35/lib/MooseX/Meta/TypeCoercion/Structured/000700 000766 000024 00000000000 12637630671 026010 5ustar00etherstaff000000 000000 MooseX-Types-Structured-0.35/lib/MooseX/Meta/TypeCoercion/Structured.pm000600 000766 000024 00000000677 12637630671 026362 0ustar00etherstaff000000 000000 package ## Hide from PAUSE MooseX::Meta::TypeCoercion::Structured; use Moose; extends 'Moose::Meta::TypeCoercion'; # We need to make sure we can properly coerce the structure elements inside a # structured type constraint. However requirements for the best way to allow # this are still in flux. For now this class is a placeholder. # see also Moose::Meta::TypeCoercion. no Moose; __PACKAGE__->meta->make_immutable(inline_constructor => 0); MooseX-Types-Structured-0.35/lib/MooseX/Meta/TypeCoercion/Structured/Optional.pm000600 000766 000024 00000001164 12637630671 030137 0ustar00etherstaff000000 000000 package ## Hide from PAUSE MooseX::Meta::TypeCoercion::Structured::Optional; use Moose; extends 'Moose::Meta::TypeCoercion'; sub compile_type_coercion { my ($self) = @_; my $constraint = $self->type_constraint->type_parameter; $self->_compiled_type_coercion(sub { my ($value) = @_; return unless $constraint->has_coercion; return $constraint->coerce($value); }); } sub has_coercion_for_type { 0 } sub add_type_coercions { Moose->throw_error("Cannot add additional type coercions to Optional types"); } no Moose; __PACKAGE__->meta->make_immutable(inline_constructor => 0); 1;