CONTRIBUTING000664001750001750 614612403554216 15101 0ustar00taitai000000000000MooseX-MungeHas-0.007NAME CONTRIBUTING DESCRIPTION If you're reading this document, that means you might be thinking about helping me out with this project. Thanks! Here's some ways you could help out: * Bug reports Found a bug? Great! (Well, not so great I suppose.) The place to report them is . Don't e-mail me about it, as your e-mail is more than likely to get lost amongst the spam. An example script clearly demonstrating the bug (preferably written using Test::More) would be greatly appreciated. * Patches If you've found a bug and written a fix for it, even better! Generally speaking you should check out the latest copy of the code from the source repository rather than using the CPAN distribution. The file META.yml should contain a link to the source repository. If not, then try or submit a bug report. (As far as I'm concerned the lack of a link is a bug.) Many of my distributions are also mirrored at . To submit the patch, do a pull request on GitHub or Bitbucket, or attach a diff file to a bug report. Unless otherwise stated, I'll assume that your contributions are licensed under the same terms as the rest of the project. (If using git, feel free to work in a branch. For Mercurial, I'd prefer bookmarks within the default branch.) * Documentation If there's anything unclear in the documentation, please submit this as a bug report or patch as above. Non-toy example scripts that I can bundle would also be appreciated. * Translation Translations of documentation would be welcome. For translations of error messages and other strings embedded in the code, check with me first. Sometimes the English strings may not in a stable state, so it would be a waste of time translating them. Coding Style I tend to write using something approximating the Allman style, using tabs for indentation and Unix-style line breaks. * * I nominally encode all source files as UTF-8, though in practice most of them use a 7-bit-safe ASCII-compatible subset of UTF-8. AUTHOR Toby Inkster . COPYRIGHT AND LICENCE Copyright (c) 2012-2014 by Toby Inkster. CONTRIBUTING is available under three different licences permitting its redistribution: the CC-BY-SA_UK-2.0 licence, plus the same licences as Perl itself, which is distributed under the GNU General Public Licence version 1, and the Artistic Licence. This file is licensed under the Creative Commons Attribution-ShareAlike 2.0 UK: England & Wales License. To view a copy of this license, visit . This file is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. COPYRIGHT000664001750001750 256412403554216 14542 0ustar00taitai000000000000MooseX-MungeHas-0.007Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Upstream-Name: MooseX-MungeHas Upstream-Contact: Toby Inkster (TOBYINK) Source: https://metacpan.org/release/MooseX-MungeHas Files: examples/relax-type-constraints.pl t/01basic.t t/02moose.t t/03moo.t t/04mouse.t Copyright: This software is copyright (c) 2013 by Toby Inkster. License: GPL-1.0+ or Artistic-1.0 Files: CONTRIBUTING INSTALL LICENSE Makefile.PL Copyright: Unknown License: Unknown Files: Changes META.json META.yml doap.ttl Copyright: Copyright 2014 Toby Inkster. License: GPL-1.0+ or Artistic-1.0 Files: COPYRIGHT CREDITS SIGNATURE Copyright: None License: public-domain Files: README lib/MooseX/MungeHas.pm Copyright: This software is copyright (c) 2013-2014 by Toby Inkster. License: GPL-1.0+ or Artistic-1.0 Files: t/05multihas.t Copyright: This software is copyright (c) 2014 by Toby Inkster. License: GPL-1.0+ or Artistic-1.0 Files: dist.ini Copyright: Copyright 2013 Toby Inkster. License: GPL-1.0+ or Artistic-1.0 License: Artistic-1.0 This software is Copyright (c) 2014 by the copyright holder(s). This is free software, licensed under: The Artistic License 1.0 License: GPL-1.0 This software is Copyright (c) 2014 by the copyright holder(s). This is free software, licensed under: The GNU General Public License, Version 1, February 1989 CREDITS000664001750001750 24012403554213 14231 0ustar00taitai000000000000MooseX-MungeHas-0.007Maintainer: - Toby Inkster (TOBYINK) Contributor: - Andrew Rodland (ARODLAND) Thanks: - Luc J. Bourhis - Pierre Masci Changes000664001750001750 433312403554213 14533 0ustar00taitai000000000000MooseX-MungeHas-0.007MooseX-MungeHas =============== Created: 2013-05-27 Home page: Bug tracker: Maintainer: Toby Inkster (TOBYINK) 0.007 2014-09-09 - Allow exporting of more than one `has` function. - Better detection of OO framework. - Bugfix for interaction of `is_rw` and `has $name=>$builder`. 0.006 2014-09-09 tobyink ♥ builder - Allow Moo-style `builder=>$coderef` in Moose and Mouse. - Allow Object::Simple-style `has $name=>$coderef` in Moo, Moose, and Mouse. - Allow `has $name=>$type` in Moo, Moose, and Mouse. 0.005 2014-02-14 tobyink ♥ isa [ Bug Fixes ] - s/find_or_parse_type_constraint/find_or_create_isa_type_constraint/ Fixes RT#92557. Pierre Masci++ [ Documentation ] - Various documentation improvements. [ Test Suite ] - No longer depend on Types::Standard for tests; skip those tests if it's not installed. [ Packaging ] - No longer depend on Eval::TypeTiny. [ Other ] - Allow Moo-style isa=>sub{...} in Moose and Mouse. - Always enable the eq_1 feature; it's never useful for it to be disabled. - Remove the absolute dependency on Eval::TypeTiny; allow Eval::Closure to be used in its stead. 0.004 2013-08-29 [ Bug Fixes ] - Fix a stray `$.` that wasn't changed in 0.003. Andrew Rodland++ 0.003 2013-08-28 - Use the `$_` variable for the attribute name instead of `$.`. - Use the `%_` hash for the attribute spec instead of `%$_`. 0.002 2013-08-20 [ Bug Fixes ] - Fix syntax error compiling the eq_1 munger. 0.001 2013-06-12 [ Documentation ] - examples/relax-type-constraints.pl 0.000_04 2013-05-31 [ Bug Fixes ] - local @_ doesn't work with goto in Perl < 5.18. (Only affects Mouse.) Luc J. Bourhis++ 0.000_03 2013-05-31 [ Bug Fixes ] - Fix weird overloading-related bug in Perl < 5.17. 0.000_02 2013-05-31 [ Packaging ] - Depend on newer version of Eval::TypeTiny. - Much improved test suite. [ Other ] - Added: Make coerce => 0|1 work in Moo. - Removed: Drop the idea of shortcutting import with a single coderef; it doesn't work out so well. 0.000_01 2013-05-27 Preview release INSTALL000664001750001750 171112403554212 14265 0ustar00taitai000000000000MooseX-MungeHas-0.007 Installing MooseX-MungeHas should be straightforward. INSTALLATION WITH CPANMINUS If you have cpanm, you only need one line: % cpanm MooseX::MungeHas 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::MungeHas INSTALLATION WITH THE CPAN SHELL Alternatively, if your CPAN shell is set up, you should just be able to do: % cpan MooseX::MungeHas MANUAL INSTALLATION As a last resort, you can manually install it. Download the tarball and unpack it. Consult the file META.json for a list of pre-requisites. Install these first. To build MooseX-MungeHas: % perl Makefile.PL % make && make test Then install it: % make install If you are installing into a system-wide directory, you may need to run: % sudo make install LICENSE000664001750001750 4365512403554212 14276 0ustar00taitai000000000000MooseX-MungeHas-0.007This software is copyright (c) 2014 by Toby Inkster. 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) 2014 by Toby Inkster. 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) 2014 by Toby Inkster. 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 MANIFEST000664001750001750 37112403554216 14352 0ustar00taitai000000000000MooseX-MungeHas-0.007CONTRIBUTING COPYRIGHT CREDITS Changes INSTALL LICENSE MANIFEST META.json META.yml Makefile.PL README SIGNATURE dist.ini doap.ttl examples/relax-type-constraints.pl lib/MooseX/MungeHas.pm t/01basic.t t/02moose.t t/03moo.t t/04mouse.t t/05multihas.t META.json000664001750001750 447412403554216 14672 0ustar00taitai000000000000MooseX-MungeHas-0.007{ "abstract" : "munge your \"has\" (works with Moo, Moose and Mouse)", "author" : [ "Toby Inkster (TOBYINK) " ], "dynamic_config" : 1, "generated_by" : "Dist::Inkt::Profile::TOBYINK version 0.016, CPAN::Meta::Converter version 2.140640", "keywords" : [], "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : "2" }, "name" : "MooseX-MungeHas", "no_index" : { "directory" : [ "eg", "examples", "inc", "t", "xt" ] }, "optional_features" : {}, "prereqs" : { "configure" : { "requires" : { "ExtUtils::MakeMaker" : "6.17" } }, "develop" : { "recommends" : { "Dist::Inkt" : "0" } }, "runtime" : { "requires" : { "Sub::Util" : "1.40", "perl" : "5.008000" }, "suggests" : { "Class::Tiny::Antlers" : "0", "Moo" : "1.002000", "Moose" : "2.0000", "Mouse" : "1.00" } }, "test" : { "recommends" : { "Moo" : "1.002000", "Moose" : "2.0000", "Types::Standard" : "0.006" }, "requires" : { "Test::Fatal" : "0", "Test::More" : "0.96", "Test::Requires" : "0.06" }, "suggests" : { "Mouse" : "1.00" } } }, "provides" : { "MooseX::MungeHas" : { "file" : "lib/MooseX/MungeHas.pm", "version" : "0.007" } }, "release_status" : "stable", "resources" : { "X_identifier" : "http://purl.org/NET/cpan-uri/dist/MooseX-MungeHas/project", "bugtracker" : { "web" : "http://rt.cpan.org/Dist/Display.html?Queue=MooseX-MungeHas" }, "homepage" : "https://metacpan.org/release/MooseX-MungeHas", "license" : [ "http://dev.perl.org/licenses/" ], "repository" : { "type" : "git", "url" : "git://github.com/tobyink/p5-moosex-mungehas.git", "web" : "https://github.com/tobyink/p5-moosex-mungehas" } }, "version" : "0.007", "x_contributors" : [ "Andrew Rodland (ARODLAND) " ] } META.yml000664001750001750 216712403554216 14517 0ustar00taitai000000000000MooseX-MungeHas-0.007--- abstract: 'munge your "has" (works with Moo, Moose and Mouse)' author: - 'Toby Inkster (TOBYINK) ' build_requires: Test::Fatal: '0' Test::More: '0.96' Test::Requires: '0.06' configure_requires: ExtUtils::MakeMaker: '6.17' dynamic_config: 1 generated_by: 'Dist::Inkt::Profile::TOBYINK version 0.016, CPAN::Meta::Converter version 2.140640' keywords: [] license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: MooseX-MungeHas no_index: directory: - eg - examples - inc - t - xt optional_features: {} provides: MooseX::MungeHas: file: lib/MooseX/MungeHas.pm version: '0.007' requires: Sub::Util: '1.40' perl: '5.008000' resources: X_identifier: http://purl.org/NET/cpan-uri/dist/MooseX-MungeHas/project bugtracker: http://rt.cpan.org/Dist/Display.html?Queue=MooseX-MungeHas homepage: https://metacpan.org/release/MooseX-MungeHas license: http://dev.perl.org/licenses/ repository: git://github.com/tobyink/p5-moosex-mungehas.git version: '0.007' x_contributors: - 'Andrew Rodland (ARODLAND) ' Makefile.PL000664001750001750 1341612403554216 15237 0ustar00taitai000000000000MooseX-MungeHas-0.007use strict; use ExtUtils::MakeMaker 6.17; my $EUMM = eval( $ExtUtils::MakeMaker::VERSION ); my $meta = { "abstract" => "munge your \"has\" (works with Moo, Moose and Mouse)", "author" => ["Toby Inkster (TOBYINK) "], "dynamic_config" => 1, "generated_by" => "Dist::Inkt::Profile::TOBYINK version 0.016, CPAN::Meta::Converter version 2.140640", "keywords" => [], "license" => ["perl_5"], "meta-spec" => { url => "http://search.cpan.org/perldoc?CPAN::Meta::Spec", version => 2, }, "name" => "MooseX-MungeHas", "no_index" => { directory => ["eg", "examples", "inc", "t", "xt"] }, "prereqs" => { configure => { requires => { "ExtUtils::MakeMaker" => 6.17 } }, develop => { recommends => { "Dist::Inkt" => 0 } }, runtime => { requires => { "perl" => "5.008000", "Sub::Util" => "1.40" }, suggests => { "Class::Tiny::Antlers" => 0, "Moo" => "1.002000", "Moose" => "2.0000", "Mouse" => "1.00", }, }, test => { recommends => { "Moo" => "1.002000", "Moose" => "2.0000", "Types::Standard" => 0.006 }, requires => { "Test::Fatal" => 0, "Test::More" => 0.96, "Test::Requires" => 0.06 }, suggests => { Mouse => "1.00" }, }, }, "provides" => { "MooseX::MungeHas" => { file => "lib/MooseX/MungeHas.pm", version => 0.007 }, }, "release_status" => "stable", "resources" => { bugtracker => { web => "http://rt.cpan.org/Dist/Display.html?Queue=MooseX-MungeHas", }, homepage => "https://metacpan.org/release/MooseX-MungeHas", license => ["http://dev.perl.org/licenses/"], repository => { type => "git", url => "git://github.com/tobyink/p5-moosex-mungehas.git", web => "https://github.com/tobyink/p5-moosex-mungehas", }, X_identifier => "http://purl.org/NET/cpan-uri/dist/MooseX-MungeHas/project", }, "version" => 0.007, "x_contributors" => ["Andrew Rodland (ARODLAND) "], }; my %dynamic_config; do { $meta->{prereqs}{runtime}{requires}{'Eval::TypeTiny'} = '0.006' unless eval { require Eval::Closure }; }; my %WriteMakefileArgs = ( ABSTRACT => $meta->{abstract}, AUTHOR => ($EUMM >= 6.5702 ? $meta->{author} : $meta->{author}[0]), DISTNAME => $meta->{name}, VERSION => $meta->{version}, EXE_FILES => [ map $_->{file}, values %{ $meta->{x_provides_scripts} || {} } ], NAME => do { my $n = $meta->{name}; $n =~ s/-/::/g; $n }, test => { TESTS => "t/*.t" }, %dynamic_config, ); $WriteMakefileArgs{LICENSE} = $meta->{license}[0] if $EUMM >= 6.3001; sub deps { my %r; for my $stage (@_) { for my $dep (keys %{$meta->{prereqs}{$stage}{requires}}) { next if $dep eq 'perl'; my $ver = $meta->{prereqs}{$stage}{requires}{$dep}; $r{$dep} = $ver if !exists($r{$dep}) || $ver >= $r{$dep}; } } \%r; } my ($build_requires, $configure_requires, $runtime_requires, $test_requires); if ($EUMM >= 6.6303) { $WriteMakefileArgs{BUILD_REQUIRES} ||= deps('build'); $WriteMakefileArgs{CONFIGURE_REQUIRES} ||= deps('configure'); $WriteMakefileArgs{TEST_REQUIRES} ||= deps('test'); $WriteMakefileArgs{PREREQ_PM} ||= deps('runtime'); } elsif ($EUMM >= 6.5503) { $WriteMakefileArgs{BUILD_REQUIRES} ||= deps('build', 'test'); $WriteMakefileArgs{CONFIGURE_REQUIRES} ||= deps('configure'); $WriteMakefileArgs{PREREQ_PM} ||= deps('runtime'); } elsif ($EUMM >= 6.52) { $WriteMakefileArgs{CONFIGURE_REQUIRES} ||= deps('configure'); $WriteMakefileArgs{PREREQ_PM} ||= deps('runtime', 'build', 'test'); } else { $WriteMakefileArgs{PREREQ_PM} ||= deps('configure', 'build', 'test', 'runtime'); } { my ($minperl) = reverse sort( grep defined && /^[0-9]+(\.[0-9]+)?$/, map $meta->{prereqs}{$_}{requires}{perl}, qw( configure build runtime ) ); if (defined($minperl)) { die "Installing $meta->{name} requires Perl >= $minperl" unless $] >= $minperl; $WriteMakefileArgs{MIN_PERL_VERSION} ||= $minperl if $EUMM >= 6.48; } } sub FixMakefile { return unless -d 'inc'; my $file = shift; local *MAKEFILE; open MAKEFILE, "< $file" or die "FixMakefile: Couldn't open $file: $!; bailing out"; my $makefile = do { local $/; }; close MAKEFILE or die $!; $makefile =~ s/\b(test_harness\(\$\(TEST_VERBOSE\), )/$1'inc', /; $makefile =~ s/( -I\$\(INST_ARCHLIB\))/ -Iinc$1/g; $makefile =~ s/( "-I\$\(INST_LIB\)")/ "-Iinc"$1/g; $makefile =~ s/^(FULLPERL = .*)/$1 "-Iinc"/m; $makefile =~ s/^(PERL = .*)/$1 "-Iinc"/m; open MAKEFILE, "> $file" or die "FixMakefile: Couldn't open $file: $!; bailing out"; print MAKEFILE $makefile or die $!; close MAKEFILE or die $!; } my $mm = WriteMakefile(%WriteMakefileArgs); FixMakefile($mm->{FIRST_MAKEFILE} || 'Makefile'); exit(0); README000664001750001750 1165212403554212 14141 0ustar00taitai000000000000MooseX-MungeHas-0.007NAME MooseX::MungeHas - munge your "has" (works with Moo, Moose and Mouse) SYNOPSIS package Foo::Bar; use Moose; use MooseX::MungeHas "is_ro"; has foo => (); # read-only has bar => (is => "rw"); # read-write DESCRIPTION MooseX::MungeHas alters the behaviour of the attributes of your Moo, Moose or Mouse based class. It manages to support all three because it doesn't attempt to do anything smart with metathingies; it simply installs a wrapper for `has` that munges the attribute specification hash before passing it on to the original `has` function. The following munges are always applied (simply because I can see no sensible reason why you would not want them to be). * Implement `is => "rwp"` and `is => "lazy"` in Moose and Mouse. (These already work in Moo.) * Implement `builder => 1`, `clearer => 1`, `predicate => 1`, and `trigger => 1` in Moose and Mouse. (These already work in Moo.) * Implement `builder => sub { ... }` in Moose and Mouse. (This already works in Moo.) * Allow Moo to support `coerce => 0|1` for Type::Tiny type constraints. (Moo normally expects a coderef for the coercion.) (These already work in Moose and Mouse, and has actually been added to Moo as of version 1.006000.) * Makes `has $name => sub { ... }` into a shortcut for: has $name => (is => "lazy", builder => sub { ... }); * Makes `has $name => $type_constraint` into a shortcut for: has $name => (isa => $type_constraint); (Assuming that $type_constraint is a blessed type constraint object a la Type::Tiny, MooseX::Types, etc.) When you import this module (i.e. `use MooseX::MungeHas`) you can provide a list of additional mungers you want it to apply. These may be provided as coderefs, though for a few common, useful sets of behaviour, there are pre-defined shortcut strings. # "no_isa" is a pre-defined shortcut; # the other munger is a coderef. # use MooseX::MungeHas "no_isa", sub { # Make constructor ignore private attributes $_{init_arg} = undef if /^_/; }; Within coderefs, the name of the attribute being processed is available in the $_ variable, and the specification hash is available as %_. You may provide multiple coderefs. The following are the pre-defined shortcuts: `is_ro`, `is_rw`, `is_rwp`, `is_lazy` These mungers supply defaults for the `is` option. `always_coerce` Automatically provides `coerce => 1` if the type constraint provides coercions. (Unless you've explicitly specified `coerce => 0`.) `no_isa` Switches off `isa` checks for attributes, unless they coerce. `simple_isa` Loosens type constraints if they don't coerce, and if it's likely to make them significantly faster. (Loosening `Int` to `Num` won't speed it up.) Only works if you're using Type::Tiny constraints. Mungers provided as coderefs are executed *after* predefined ones, but are otherwise executed in the order specified. Multiple Wrappers Since version 0.007, it has been possible to use MooseX::MungeHas to export multiple wrappers with different names: package Foo; use Moose; use MooseX::MungeHas { has_ro => [ "is_ro", "always_coerce" ], has_rw => [ "is_rw", "always_coerce" ], }; has_ro "foo" => (required => 1); has_rw "bar"; Note in the example above, MooseX::MungeHas has installed two brand new wrapped `has` functions with different names, but it has left the standard `has` function unmolested. If you wanted to alter the standard function too, then you could use: package Foo; use Moose; use MooseX::MungeHas { has => [ "always_coerce" ], has_ro => [ "is_ro", "always_coerce" ], has_rw => [ "is_rw", "always_coerce" ], }; has_ro "foo" => (required => 1); has_rw "bar"; BUGS Please report any bugs to . SEE ALSO Moo, Mouse, Moose, MooseX::AttributeShortcuts, MooseX::InlineTypes, Type::Tiny::Manual. Similar: MooseX::HasDefaults, MooseX::Attributes::Curried, MooseX::Attribute::Prototype and MooseX::AttributeDefaults. AUTHOR Toby Inkster . COPYRIGHT AND LICENCE This software is copyright (c) 2013-2014 by Toby Inkster. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. DISCLAIMER OF WARRANTIES 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. SIGNATURE000664001750001750 352212403554216 14526 0ustar00taitai000000000000MooseX-MungeHas-0.007This file contains message digests of all files listed in MANIFEST, signed via the Module::Signature module, version 0.73. To verify the content in this distribution, first make sure you have Module::Signature installed, then type: % cpansign -v It will check each file's integrity, as well as the signature's validity. If "==> Signature verified OK! <==" is not displayed, the distribution may already have been compromised, and you should not run its Makefile.PL or Build.PL. -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 SHA1 33317486c4fa2cf7fec85bf92ed38ac0f64233a0 CONTRIBUTING SHA1 cdd1b8b556c2827c954a7da8d4cb67622bd9860b COPYRIGHT SHA1 9bdb808544968dd38baeb670866963bd29148b73 CREDITS SHA1 60577469e0934c3fca1a618b39f95a4836c8c87b Changes SHA1 0201316de11793b516748517282bc17326174d06 INSTALL SHA1 34f5e12514b91055de4b164a1f2327ef5c30ba53 LICENSE SHA1 a93c481ef4be5641011b6e58ccf2e900b473cba8 MANIFEST SHA1 fe6084bdfa2c6daa3b81f94975369dda69b1cacb META.json SHA1 5249f7624b3418b57cbe066082b053db5ed43da4 META.yml SHA1 00827f42bfa1be1a3bd5deaac2e345ce1847cac4 Makefile.PL SHA1 07d98136b5e27808f9c8bd7d57cce37ae3f26d93 README SHA1 84df85d3af53361fcc3e9a67d4de00db41c51a0e dist.ini SHA1 8f2d517d6741cb76ecee81b005c3a6a9730d015c doap.ttl SHA1 402909c5eb5f1bfe84d8f59867e7524bd09261a4 examples/relax-type-constraints.pl SHA1 40fb3261cff00bfb0129dacf23618fa3a794c4b2 lib/MooseX/MungeHas.pm SHA1 ab48d4d2abb7400eaecd8846e06e117b3a0ed217 t/01basic.t SHA1 a064f828a0dbc400d88f4654a1c3e89f788e7a02 t/02moose.t SHA1 16524a381e2a294bc2871c942e32d06899109aa6 t/03moo.t SHA1 a910c52e0650e001d699cbfaae983e725e3b3ba4 t/04mouse.t SHA1 cc154d13f53fe4d0f9218bd896dad5ec53e097d2 t/05multihas.t -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iEYEARECAAYFAlQO2I4ACgkQzr+BKGoqfTn9XgCgsaEShl4IDMz7PI/F6D3E3KzD eHIAoKxUXFaXprN7nlqzRdXp22l1sPet =CP7u -----END PGP SIGNATURE----- dist.ini000664001750001750 15412403554212 14660 0ustar00taitai000000000000MooseX-MungeHas-0.007; Configuration file for Dist::Inkt ; ;; class = 'Dist::Inkt::Profile::TOBYINK' ;; name = 'MooseX-MungeHas' doap.ttl000664001750001750 3042312403554216 14732 0ustar00taitai000000000000MooseX-MungeHas-0.007@prefix cpan-uri: . @prefix dc: . @prefix doap: . @prefix doap-bugs: . @prefix doap-changeset: . @prefix doap-deps: . @prefix foaf: . @prefix rdfs: . @prefix xsd: . dc:title "the same terms as the perl 5 programming language system itself". a doap:Project; dc:contributor ; doap-deps:develop-recommendation [ doap-deps:on "Dist::Inkt"^^doap-deps:CpanId ]; doap-deps:runtime-requirement [ doap-deps:on "perl 5.008000"^^doap-deps:CpanId ], [ doap-deps:on "Sub::Util 1.40"^^doap-deps:CpanId ]; doap-deps:runtime-suggestion [ doap-deps:on "Moo 1.002000"^^doap-deps:CpanId ], [ doap-deps:on "Moose 2.0000"^^doap-deps:CpanId ], [ doap-deps:on "Mouse 1.00"^^doap-deps:CpanId ], [ doap-deps:on "Class::Tiny::Antlers"^^doap-deps:CpanId; ]; doap-deps:test-recommendation [ doap-deps:on "Moose 2.0000"^^doap-deps:CpanId ], [ doap-deps:on "Moo 1.002000"^^doap-deps:CpanId ], [ doap-deps:on "Types::Standard 0.006"^^doap-deps:CpanId; ]; doap-deps:test-requirement [ doap-deps:on "Test::More 0.96"^^doap-deps:CpanId ], [ doap-deps:on "Test::Requires 0.06"^^doap-deps:CpanId; ], [ doap-deps:on "Test::Fatal"^^doap-deps:CpanId ]; doap-deps:test-suggestion [ doap-deps:on "Mouse 1.00"^^doap-deps:CpanId ]; doap:bug-database ; doap:created "2013-05-27"^^xsd:date; doap:developer ; doap:download-page ; doap:homepage ; doap:license ; doap:maintainer ; doap:name "MooseX-MungeHas"; doap:programming-language "Perl"; doap:release , , , , , , , , , , ; doap:repository [ a doap:GitRepository; doap:browse ; ]; doap:shortdesc "munge your \"has\" (works with Moo, Moose and Mouse)". a cpan-uri:DeveloperRelease, doap:Version; rdfs:label "Preview release"; dc:identifier "MooseX-MungeHas-0.000_01"^^xsd:string; dc:issued "2013-05-27"^^xsd:date; doap-changeset:released-by ; doap:file-release ; doap:revision "0.000_01"^^xsd:string. a cpan-uri:DeveloperRelease, doap:Version; dc:identifier "MooseX-MungeHas-0.000_02"^^xsd:string; dc:issued "2013-05-31"^^xsd:date; doap-changeset:changeset [ doap-changeset:item [ a doap-changeset:Packaging; rdfs:label "Depend on newer version of Eval::TypeTiny."; ], [ a doap-changeset:Addition; rdfs:label "Make coerce => 0|1 work in Moo."; ], [ a doap-changeset:Removal; rdfs:label "Drop the idea of shortcutting import with a single coderef; it doesn't work out so well."; ], [ a doap-changeset:Packaging; rdfs:label "Much improved test suite."; ]; ]; doap-changeset:released-by ; doap:file-release ; doap:revision "0.000_02"^^xsd:string. a cpan-uri:DeveloperRelease, doap:Version; dc:identifier "MooseX-MungeHas-0.000_03"^^xsd:string; dc:issued "2013-05-31"^^xsd:date; doap-changeset:changeset [ doap-changeset:item [ a doap-changeset:Bugfix; rdfs:label "Fix weird overloading-related bug in Perl < 5.17."; ]; ]; doap-changeset:released-by ; doap:file-release ; doap:revision "0.000_03"^^xsd:string. a cpan-uri:DeveloperRelease, doap:Version; dc:identifier "MooseX-MungeHas-0.000_04"^^xsd:string; dc:issued "2013-05-31"^^xsd:date; doap-changeset:changeset [ doap-changeset:item [ a doap-changeset:Bugfix; rdfs:label "local @_ doesn't work with goto in Perl < 5.18. (Only affects Mouse.)"; doap-changeset:thanks ; ]; ]; doap-changeset:released-by ; doap:file-release ; doap:revision "0.000_04"^^xsd:string. a doap:Version; dc:identifier "MooseX-MungeHas-0.001"^^xsd:string; dc:issued "2013-06-12"^^xsd:date; doap-changeset:changeset [ doap-changeset:item [ a doap-changeset:Addition, doap-changeset:Documentation; rdfs:label "examples/relax-type-constraints.pl"; ]; ]; doap-changeset:released-by ; doap:file-release ; doap:revision "0.001"^^xsd:string. a doap:Version; dc:identifier "MooseX-MungeHas-0.002"^^xsd:string; dc:issued "2013-08-20"^^xsd:date; doap-changeset:changeset [ doap-changeset:item [ a doap-changeset:Bugfix; rdfs:label "Fix syntax error compiling the eq_1 munger."; ]; ]; doap-changeset:released-by ; doap:file-release ; doap:revision "0.002"^^xsd:string. a doap:Version; dc:identifier "MooseX-MungeHas-0.003"^^xsd:string; dc:issued "2013-08-28"^^xsd:date; doap-changeset:changeset [ doap-changeset:item [ a doap-changeset:Change; rdfs:label "Use the `$_` variable for the attribute name instead of `$.`."; ], [ a doap-changeset:Change; rdfs:label "Use the `%_` hash for the attribute spec instead of `%$_`."; ]; ]; doap-changeset:released-by ; doap:file-release ; doap:revision "0.003"^^xsd:string. a doap:Version; dc:identifier "MooseX-MungeHas-0.004"^^xsd:string; dc:issued "2013-08-29"^^xsd:date; doap-changeset:changeset [ doap-changeset:item [ a doap-changeset:Bugfix; rdfs:label "Fix a stray `$.` that wasn't changed in 0.003."; doap-changeset:blame ; ]; ]; doap-changeset:released-by ; doap:file-release ; doap:revision "0.004"^^xsd:string. a doap:Version; rdfs:label "tobyink ♥ isa"; dc:identifier "MooseX-MungeHas-0.005"^^xsd:string; dc:issued "2014-02-14"^^xsd:date; doap-changeset:changeset [ doap-changeset:item [ a doap-changeset:Change; rdfs:label "Allow Moo-style isa=>sub{...} in Moose and Mouse."; ], [ a doap-changeset:Change; rdfs:label "Remove the absolute dependency on Eval::TypeTiny; allow Eval::Closure to be used in its stead."; ], [ a doap-changeset:Change; rdfs:label "Always enable the eq_1 feature; it's never useful for it to be disabled."; ], [ a doap-changeset:Documentation; rdfs:label "Various documentation improvements."; ], [ a doap-changeset:Bugfix; rdfs:label "s/find_or_parse_type_constraint/find_or_create_isa_type_constraint/"; doap-changeset:fixes ; doap-changeset:thanks ; ], [ a doap-changeset:Packaging; rdfs:label "No longer depend on Eval::TypeTiny."; ], [ a doap-changeset:Packaging, doap-changeset:Tests; rdfs:label "No longer depend on Types::Standard for tests; skip those tests if it's not installed."; ]; ]; doap-changeset:released-by ; doap:file-release ; doap:revision "0.005"^^xsd:string. a doap:Version; rdfs:label "tobyink ♥ builder"; dc:identifier "MooseX-MungeHas-0.006"^^xsd:string; dc:issued "2014-09-09"^^xsd:date; doap-changeset:changeset [ doap-changeset:item [ a doap-changeset:Change; rdfs:label "Allow Object::Simple-style `has $name=>$coderef` in Moo, Moose, and Mouse."; ], [ a doap-changeset:Change; rdfs:label "Allow `has $name=>$type` in Moo, Moose, and Mouse."; ], [ a doap-changeset:Change; rdfs:label "Allow Moo-style `builder=>$coderef` in Moose and Mouse."; ]; ]; doap-changeset:released-by ; doap:file-release ; doap:revision "0.006"^^xsd:string. a doap:Version; dc:identifier "MooseX-MungeHas-0.007"^^xsd:string; dc:issued "2014-09-09"^^xsd:date; doap-changeset:changeset [ doap-changeset:item [ a doap-changeset:Change; rdfs:label "Better detection of OO framework."; ], [ a doap-changeset:Change; rdfs:label "Allow exporting of more than one `has` function."; ], [ a doap-changeset:Change; rdfs:label "Bugfix for interaction of `is_rw` and `has $name=>$builder`."; ]; ]; doap-changeset:released-by ; doap:file-release ; doap:revision "0.007"^^xsd:string. a foaf:Person; foaf:name "Andrew Rodland"; foaf:nick "ARODLAND"; foaf:page . a foaf:Person; foaf:mbox ; foaf:name "Toby Inkster"; foaf:nick "TOBYINK"; foaf:page . a doap-bugs:Issue; doap-bugs:id "92557"^^xsd:string; doap-bugs:page . foaf:name "Pierre Masci"; foaf:page . a foaf:Person; foaf:name "Luc J. Bourhis"; foaf:page . relax-type-constraints.pl000664001750001750 401112403554212 22042 0ustar00taitai000000000000MooseX-MungeHas-0.007/examplesuse strict; use warnings; use Time::HiRes qw(time); { package Person; use Moose; use Types::Standard qw(Int Str); use MooseX::MungeHas $ENV{PERL_FASTER} ? qw(is_ro no_isa) : qw(is_ro); my $Natural = Int->create_child_type( name => "NaturalNumber", constraint => sub { $_ >= 0 }, ); has name => (isa => Str, required => 1); has age => (isa => $Natural); __PACKAGE__->meta->make_immutable; } my $start = time; while () { /^(.+)\|(.+)$/ and Person->new(name => $1, age => $2); } my $finish = time; printf("Completed run in: %0.6f s.\n", $finish - $start); =pod =encoding utf-8 =head1 PURPOSE Here's a simple use case for MooseX::MungeHas. View this files's source code for the full script. We use an environment variable to toggle type constraint checks: use MooseX::MungeHas $ENV{PERL_FASTER} ? qw(is_ro no_isa) : qw(is_ro); When the code is run normally (e.g. on a development machine), the C munger is not in effect. When run on a machine with the C environment variable set to true (e.g. on the production machine), the C munger strings into action, and type constraints cease to be checked. (Because any type errors would have cropped up on the development machines, right??) =head1 OUTPUT Your machine is probably faster than mine, but a typical output with C false is: Completed run in: 0.002362 s. And with C true: Completed run in: 0.001246 s. =head1 DEPENDENCIES Example requires L and L. =head1 AUTHOR Toby Inkster Etobyink@cpan.orgE. =head1 COPYRIGHT AND LICENCE This software is copyright (c) 2013 by Toby Inkster. 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 __DATA__ Alice|10 Bob|11 Carol|12 Dave|10 Eve|11 Freddie|10 Greg|11 Hattie|9 Isabel|8 Jack|10 Kevin|11 Lisa|12 Maggie|9 Nils|10 Oliver|11 Peter|10 Quentin|9 Rachel|11 Simon|12 Tessa|8 Usma|9 Veronica|11 Wendy|10 Xavier|10 Yolande|11 Zachary|9 01basic.t000664001750001750 70512403554212 15070 0ustar00taitai000000000000MooseX-MungeHas-0.007/t=pod =encoding utf-8 =head1 PURPOSE Test that MooseX::MungeHas compiles. =head1 AUTHOR Toby Inkster Etobyink@cpan.orgE. =head1 COPYRIGHT AND LICENCE This software is copyright (c) 2013 by Toby Inkster. 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 use strict; use warnings; use Test::More; require MooseX::MungeHas; ok 1; done_testing; 02moose.t000664001750001750 460612403554212 15156 0ustar00taitai000000000000MooseX-MungeHas-0.007/t=pod =encoding utf-8 =head1 PURPOSE Test that MooseX::MungeHas features work with Moose. =head1 DEPENDENCIES Test requires Moose 2.0000 and Types::Standard 0.006 or is skipped. =head1 AUTHOR Toby Inkster Etobyink@cpan.orgE. =head1 COPYRIGHT AND LICENCE This software is copyright (c) 2013 by Toby Inkster. 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 use strict; use warnings; use Test::Requires { "Moose" => "2.0000" }; use Test::Requires { "Types::Standard" => "0.006" }; use Test::More; use Types::Standard -types; my $Even = Int->create_child_type( name => "Even", constraint => sub { $_ % 2 == 0 }, )->plus_coercions(Int, '2 * $_'); { package Local::Class1; use Moose; use MooseX::MungeHas qw( is_ro simple_isa always_coerce ); has attr1 => $Even; has attr2 => (isa => $Even, coerce => 0); # this should be simplified to Int has attr3 => (isa => $Even, is => "rwp"); has attr4 => (isa => $Even, is => "lazy", default => sub { 42 }); has attr5 => sub { 999 }; } ok( Local::Class1->meta->get_attribute("attr$_")->should_coerce, qq[Local::Class1->meta->get_attribute("attr$_")->should_coerce], ) for 1, 3, 4; ok( !Local::Class1->meta->get_attribute("attr2")->should_coerce, q[not Local::Class1->meta->get_attribute("attr2")->should_coerce], ); ok( Local::Class1->meta->get_attribute("attr$_")->type_constraint == $Even, qq[Local::Class1->meta->get_attribute("attr$_")->type_constraint == \$Even], ) || diag(Local::Class1->meta->get_attribute("attr1")->type_constraint) for 1, 3, 4; ok( Local::Class1->meta->get_attribute("attr2")->type_constraint == Int, q[Local::Class1->meta->get_attribute("attr2")->type_constraint == Int], ) or diag(Local::Class1->meta->get_attribute("attr2")->type_constraint); can_ok("Local::Class1", "_set_attr3"); my $o = Local::Class1->new; ok( !$o->meta->get_meta_instance->is_slot_initialized($o, "attr4"), '$o->attr4 is not initialized', ); is( $o->attr4, 42, 'default worked', ); ok( $o->meta->get_meta_instance->is_slot_initialized($o, "attr4"), '$o->attr4 is now initialized', ); ok( !$o->meta->get_meta_instance->is_slot_initialized($o, "attr5"), '$o->attr5 is not initialized', ); is( $o->attr5, 999, 'default worked', ); ok( $o->meta->get_meta_instance->is_slot_initialized($o, "attr5"), '$o->attr5 is now initialized', ); done_testing; 03moo.t000664001750001750 336712403554212 14632 0ustar00taitai000000000000MooseX-MungeHas-0.007/t=pod =encoding utf-8 =head1 PURPOSE Test that MooseX::MungeHas features work with Moo. =head1 DEPENDENCIES Test requires Moo 1.000000 and Types::Standard 0.006 or is skipped. =head1 AUTHOR Toby Inkster Etobyink@cpan.orgE. =head1 COPYRIGHT AND LICENCE This software is copyright (c) 2013 by Toby Inkster. 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 use strict; use warnings; use Test::Requires { "Moo" => "1.000000" }; use Test::Requires { "Types::Standard" => "0.006" }; use Test::More; use Test::Fatal; use Types::Standard -types; my $Even = Int->create_child_type( name => "Even", constraint => sub { $_ % 2 == 0 }, )->plus_coercions(Int, '2 * $_'); { package Local::Class1; use Moo; use MooseX::MungeHas qw( is_ro simple_isa always_coerce ); has attr1 => $Even; has attr2 => (isa => $Even, coerce => 0); # this should be simplified to Int has attr3 => (isa => $Even, is => "rwp"); has attr4 => (isa => $Even, is => "lazy", default => sub { 42 }); has attr5 => sub { 999 }; } is( Local::Class1->new("attr$_" => 333)->${\"attr$_"}, 666, qq[Local::Class1 attribute attr$_ coerces], ) for 1, 3, 4; is( Local::Class1->new("attr2" => 333)->attr2, 333, q[attr2 accepts an odd Int because its type check has been simplified], ); can_ok("Local::Class1", "_set_attr3"); my $o = Local::Class1->new; ok( !exists $o->{attr4}, '$o->attr4 is not initialized', ); is( $o->attr4, 42, 'default worked', ); ok( exists $o->{attr4}, '$o->attr4 is now initialized', ); ok( !exists $o->{attr5}, '$o->attr5 is not initialized', ); is( $o->attr5, 999, 'default worked', ); ok( exists $o->{attr5}, '$o->attr5 is now initialized', ); done_testing; 04mouse.t000664001750001750 432612403554212 15165 0ustar00taitai000000000000MooseX-MungeHas-0.007/t=pod =encoding utf-8 =head1 PURPOSE Test that MooseX::MungeHas features work with Mouse. =head1 DEPENDENCIES Test requires Mouse 1.00 and Types::Standard 0.006 or is skipped. =head1 AUTHOR Toby Inkster Etobyink@cpan.orgE. =head1 COPYRIGHT AND LICENCE This software is copyright (c) 2013 by Toby Inkster. 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 use strict; use warnings; use Test::Requires { "Mouse" => "1.00" }; use Test::Requires { "Types::Standard" => "0.006" }; use Test::More; use Types::Standard -types; my $Even = Int->create_child_type( name => "Even", constraint => sub { $_ % 2 == 0 }, )->plus_coercions(Int, '2 * $_'); { package Local::Class1; use Mouse; use MooseX::MungeHas qw( is_ro simple_isa always_coerce ); has attr1 => $Even; has attr2 => (isa => $Even, coerce => 0); # this should be simplified to Int has attr3 => (isa => $Even, is => "rwp"); has attr4 => (isa => $Even, is => "lazy", default => sub { 42 }); has attr5 => sub { 999 }; } ok( Local::Class1->meta->get_attribute("attr$_")->should_coerce, qq[Local::Class1->meta->get_attribute("attr$_")->should_coerce], ) for 1, 3, 4; ok( !Local::Class1->meta->get_attribute("attr2")->should_coerce, q[not Local::Class1->meta->get_attribute("attr2")->should_coerce], ); ok( Local::Class1->meta->get_attribute("attr$_")->type_constraint == $Even, qq[Local::Class1->meta->get_attribute("attr$_")->type_constraint == \$Even], ) || diag(Local::Class1->meta->get_attribute("attr1")->type_constraint) for 1, 3, 4; ok( Local::Class1->meta->get_attribute("attr2")->type_constraint == Int, q[Local::Class1->meta->get_attribute("attr2")->type_constraint == Int], ) or diag(Local::Class1->meta->get_attribute("attr2")->type_constraint); can_ok("Local::Class1", "_set_attr3"); my $o = Local::Class1->new; ok( !exists $o->{attr4}, '$o->attr4 is not initialized', ); is( $o->attr4, 42, 'default worked', ); ok( exists $o->{attr4}, '$o->attr4 is now initialized', ); ok( !exists $o->{attr5}, '$o->attr5 is not initialized', ); is( $o->attr5, 999, 'default worked', ); ok( exists $o->{attr5}, '$o->attr5 is now initialized', ); done_testing; 05multihas.t000664001750001750 222312403554212 15656 0ustar00taitai000000000000MooseX-MungeHas-0.007/t=pod =encoding utf-8 =head1 PURPOSE Test that it is possible to export multiple C mungers. =head1 DEPENDENCIES Test requires Moose 2.0000 or is skipped. =head1 AUTHOR Toby Inkster Etobyink@cpan.orgE. =head1 COPYRIGHT AND LICENCE This software is copyright (c) 2014 by Toby Inkster. 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 use strict; use warnings; use Test::Requires { "Moose" => "2.0000" }; use Test::More; { package Local::Class1; use Moose; use MooseX::MungeHas { has_ro => ['is_ro'], has_rw => ['is_rw'], }; has_ro "attr1"; has_ro "attr2", sub { 666 }; has_rw "attr3"; has_rw "attr4", sub { 999 }; } is( Local::Class1->meta->get_attribute("attr$_")->{is}, "ro", qq[Local::Class1->meta->get_attribute("attr$_")->{is} eq "ro"], ) for 1, 2; is( Local::Class1->meta->get_attribute("attr$_")->{is}, "rw", qq[Local::Class1->meta->get_attribute("attr$_")->{is} eq "rw"], ) for 3, 4; is( Local::Class1->new->attr2, 666, '$o->attr2 builder', ); is( Local::Class1->new->attr4, 999, '$o->attr4 builder', ); done_testing; MungeHas.pm000664001750001750 3055012403554212 17304 0ustar00taitai000000000000MooseX-MungeHas-0.007/lib/MooseXpackage MooseX::MungeHas; use 5.008; use strict; use warnings; BEGIN { $MooseX::MungeHas::AUTHORITY = 'cpan:TOBYINK'; $MooseX::MungeHas::VERSION = '0.007'; }; use Carp qw(croak); use Scalar::Util qw(blessed); BEGIN { for my $backend (qw/ Eval::TypeTiny Eval::Closure /) { last if eval( "require $backend; *eval_closure = \\&$backend\::eval_closure;" ); } exists(&eval_closure) or croak "Could not load Eval::TypeTiny"; }; sub import { no strict qw(refs); my $class = shift; my $caller = caller; my $orig = \&{"$caller\::has"} or croak "$caller does not have a 'has' function to munge"; my %export = (@_ == 1 and ref($_[0]) eq "HASH") ? %{ $_[0] } : ( has => [@_] ); for my $f (sort keys %export) { no warnings qw(redefine prototype); *{"$caller\::$f"} = $class->_make_has( $caller, $class->_make_munger($caller, @{$export{$f}}), $orig, ); } } { sub __detect_oo { my $package = $_[0]; if ($INC{'Moo.pm'}) { return "Moo" if $Moo::MAKERS{$package}; return "Moo" if $Moo::Role::INFO{$package}; } if ($INC{'Moose.pm'}) { require Moose::Util; return "Moose" if Moose::Util::find_meta($package); } if ($INC{'Mouse.pm'}) { require Mouse::Util; return "Mouse" if Mouse::Util::find_meta($package); } my $meta; eval { $meta = $package->meta } or return "?"; return "Moo" if ref($meta) eq "Moo::HandleMoose::FakeMetaClass"; return "Mouse" if $meta->isa("Mouse::Meta::Module"); return "Moose" if $meta->isa("Moose::Meta::Class"); return "Moose" if $meta->isa("Moose::Meta::Role"); return "?"; } my %_cache; sub _detect_oo { $_cache{$_[0]} ||= __detect_oo(@_) }; } sub _make_munger { my $class = shift; return $class->_compile_munger_code(@_); } sub _compile_munger_code { my $class = shift; my ($caller, @features) = @_; my %features = map +($_ => 1), grep !ref, @features; my @subs = grep ref, @features; my @code = "sub {"; if (_detect_oo($caller) =~ /^Mo[ou]se$/) { push @code, ' if (exists($_{isa}) && !ref($_{isa})) {'; push @code, ' $_{isa} = '._detect_oo($caller).'::Util::TypeConstraints::find_or_create_isa_type_constraint($_{isa});'; push @code, ' }'; } for my $is (qw/ro rw rwp lazy bare/) { if (delete $features{"is_$is"}) { push @code, ' $_{is} ||= "'.$is.'";'; } } push @code, ' if (exists($_{_is})) {'; push @code, ' my $_is = delete($_{_is});'; push @code, ' $_{is} ||= $_is;'; push @code, ' }'; push @code, ' if (ref($_{builder}) eq q(CODE)) {'; push @code, ' no strict qw(refs);'; push @code, ' require Sub::Util;'; push @code, ' my $name = "$_{__CALLER__}::_build_$_";'; push @code, ' *$name = Sub::Util::set_subname($name, $_{builder});'; push @code, ' $_{builder} = $name;'; push @code, ' }'; unless (_detect_oo($caller) eq "Moo") { push @code, ' if ($_{is} eq q(lazy)) {'; push @code, ' $_{is} = "ro";'; push @code, ' $_{lazy} = 1 unless exists($_{lazy});'; push @code, ' $_{builder} = "_build_$_" if $_{lazy} && !exists($_{builder}) && !exists($_{default});'; push @code, ' }'; push @code, ' if ($_{is} eq q(rwp)) {'; push @code, ' $_{is} = "ro";'; push @code, ' $_{writer} = "_set_$_" unless exists($_{writer});'; push @code, ' }'; push @code, ' if (ref($_{isa}) eq q(CODE)) {'; push @code, ' require Type::Tiny;'; push @code, ' my $code = $_{isa};'; push @code, ' my $safe = sub { !!eval { $code->($_); 1 } };'; push @code, ' $_{isa} = "Type::Tiny"->new(constraint => $safe);'; push @code, ' }'; } delete $features{"eq_1"}; push @code, ' my ($pfx, $name) = ($_ =~ /^(_*)(.+)$/);'; push @code, ' $_{builder} = "_build_$_" if exists($_{builder}) && $_{builder} eq q(1);'; push @code, ' $_{clearer} = "${pfx}clear_${name}" if exists($_{clearer}) && $_{clearer} eq q(1);'; push @code, ' $_{predicate} = "${pfx}has_${name}" if exists($_{predicate}) && $_{predicate} eq q(1);'; push @code, ' if (exists($_{trigger}) && $_{trigger} eq q(1)) {'; push @code, ' my $method = "_trigger_$_";'; push @code, ' $_{trigger} = sub { shift->$method(@_) };'; push @code, ' }'; if (delete $features{"always_coerce"}) { push @code, ' if (exists($_{isa}) and !exists($_{coerce}) and Scalar::Util::blessed($_{isa}) and $_{isa}->can("has_coercion") and $_{isa}->has_coercion) {'; push @code, ' $_{coerce} = 1;'; push @code, ' }'; } if (_detect_oo($caller) eq "Moo") { push @code, ' if (defined($_{coerce}) and !ref($_{coerce}) and $_{coerce} eq "1") {'; push @code, ' Scalar::Util::blessed($_{isa})'; push @code, ' and $_{isa}->isa("Type::Tiny")'; push @code, ' and ($_{coerce} = $_{isa}->coercion);'; push @code, ' }'; push @code, ' elsif (exists($_{coerce}) and not $_{coerce}) {'; push @code, ' delete($_{coerce});'; push @code, ' }'; } if (delete $features{"no_isa"}) { push @code, ' delete($_{isa}) if !exists($_{coerce});'; } if (delete $features{"simple_isa"}) { push @code, ' $_{isa} = "'.$class.'"->_simplify_isa($_{isa}) if Scalar::Util::blessed($_{isa}) && !$_{coerce};'; } push @code, sprintf(' $subs[%d]->(@_);', $_) for 0..$#subs; #push @code, ' ::diag(::explain($_, \%_));'; push @code, ' delete($_{__CALLER__});'; push @code, "}"; croak sprintf("Did not understand mungers: %s", join(q[, ], sort keys %features)) if keys %features; return eval_closure( source => \@code, environment => { '@subs' => \@subs }, ); } sub _simplify_isa { my $class = shift; my ($t) = @_; until ($t->can_be_inlined) { if ($t->has_parent) { $t = $t->parent; next; } if ($t->isa("Type::Tiny::Intersection")) { require Type::Tiny::Intersection; my (@can_be_inlined) = grep $_->can_be_inlined, @$t; $t = "Type::Tiny::Intersection"->new(type_constraints => \@can_be_inlined); next; } require Type::Tiny; return "Type::Tiny"->new; } return $t; } sub _make_has { my $class = shift; my ($caller, $coderef, $orig) = @_; return $class->_make_has_mouse(@_) if _detect_oo($caller) eq "Mouse"; return sub { my ($attr, %spec) = ( (@_ == 2 and ref($_[1]) eq "CODE") ? ($_[0], _is => "ro", lazy => 1, builder => $_[1]) : (@_ == 2 and ref($_[1]) eq "HASH") ? ($_[0], %{$_[1]}) : (@_ == 2 and blessed($_[1]) and $_[1]->can('check')) ? ($_[0], _is => "ro", isa => $_[1]) : @_ ); $spec{"__CALLER__"} = $caller; if (ref($attr) eq q(ARRAY)) { my @attrs = @$attr; for my $attr (@attrs) { local %_ = %spec; local $_ = $attr; $coderef->($attr, %_); return $orig->($attr, %_); } } else { local %_ = %spec; local $_ = $attr; $coderef->($attr, %_); return $orig->($attr, %_); } }; } sub _make_has_mouse { my $class = shift; my ($caller, $coderef, $orig) = @_; return sub { my ($attr, %spec) = ( (@_ == 2 and ref($_[1]) eq "CODE") ? ($_[0], _is => "ro", lazy => 1, builder => $_[1]) : (@_ == 2 and ref($_[1]) eq "HASH") ? ($_[0], %{$_[1]}) : (@_ == 2 and blessed($_[1]) and $_[1]->can('check')) ? ($_[0], _is => "ro", isa => $_[1]) : @_ ); $spec{"__CALLER__"} = $caller; if (ref($attr) eq q(ARRAY)) { croak "MooseX::MungeHas does not support has \\\@array for Mouse"; } else { local %_ = %spec; local $_ = $attr; $coderef->($attr, %_); @_ = ($attr, %_); goto $orig; } }; } 1; __END__ =pod =encoding utf-8 =for stopwords metathingies munges mungers =begin private =item eval_closure =end private =head1 NAME MooseX::MungeHas - munge your "has" (works with Moo, Moose and Mouse) =head1 SYNOPSIS package Foo::Bar; use Moose; use MooseX::MungeHas "is_ro"; has foo => (); # read-only has bar => (is => "rw"); # read-write =head1 DESCRIPTION MooseX::MungeHas alters the behaviour of the attributes of your L, L or L based class. It manages to support all three because it doesn't attempt to do anything smart with metathingies; it simply installs a wrapper for C<< has >> that munges the attribute specification hash before passing it on to the original C<< has >> function. The following munges are always applied (simply because I can see no sensible reason why you would not want them to be). =over =item * Implement C<< is => "rwp" >> and C<< is => "lazy" >> in L and L. (These already work in L.) =item * Implement C<< builder => 1 >>, C<< clearer => 1 >>, C<< predicate => 1 >>, and C<< trigger => 1 >> in L and L. (These already work in L.) =item * Implement C<< builder => sub { ... } >> in L and L. (This already works in L.) =item * Allow L to support C<< coerce => 0|1 >> for L type constraints. (Moo normally expects a coderef for the coercion.) (These already work in L and L, and has actually been added to L as of version 1.006000.) =item * Makes C<< has $name => sub { ... } >> into a shortcut for: has $name => (is => "lazy", builder => sub { ... }); =item * Makes C<< has $name => $type_constraint >> into a shortcut for: has $name => (isa => $type_constraint); (Assuming that C<< $type_constraint >> is a blessed type constraint object a la L, L, etc.) =back When you import this module (i.e. C<< use MooseX::MungeHas >>) you can provide a list of additional mungers you want it to apply. These may be provided as coderefs, though for a few common, useful sets of behaviour, there are pre-defined shortcut strings. # "no_isa" is a pre-defined shortcut; # the other munger is a coderef. # use MooseX::MungeHas "no_isa", sub { # Make constructor ignore private attributes $_{init_arg} = undef if /^_/; }; Within coderefs, the name of the attribute being processed is available in the C<< $_ >> variable, and the specification hash is available as C<< %_ >>. You may provide multiple coderefs. The following are the pre-defined shortcuts: =over =item C<< is_ro >>, C<< is_rw >>, C<< is_rwp >>, C<< is_lazy >> These mungers supply defaults for the C<< is >> option. =item C<< always_coerce >> Automatically provides C<< coerce => 1 >> if the type constraint provides coercions. (Unless you've explicitly specified C<< coerce => 0 >>.) =item C<< no_isa >> Switches off C<< isa >> checks for attributes, unless they coerce. =item C<< simple_isa >> Loosens type constraints if they don't coerce, and if it's likely to make them significantly faster. (Loosening C to C won't speed it up.) Only works if you're using L constraints. =back Mungers provided as coderefs are executed I predefined ones, but are otherwise executed in the order specified. =head2 Multiple Wrappers Since version 0.007, it has been possible to use MooseX::MungeHas to export multiple wrappers with different names: package Foo; use Moose; use MooseX::MungeHas { has_ro => [ "is_ro", "always_coerce" ], has_rw => [ "is_rw", "always_coerce" ], }; has_ro "foo" => (required => 1); has_rw "bar"; Note in the example above, MooseX::MungeHas has installed two brand new wrapped C functions with different names, but it has left the standard C function unmolested. If you wanted to alter the standard function too, then you could use: package Foo; use Moose; use MooseX::MungeHas { has => [ "always_coerce" ], has_ro => [ "is_ro", "always_coerce" ], has_rw => [ "is_rw", "always_coerce" ], }; has_ro "foo" => (required => 1); has_rw "bar"; =head1 BUGS Please report any bugs to L. =head1 SEE ALSO L, L, L, L, L, L. Similar: L, L, L and L. =head1 AUTHOR Toby Inkster Etobyink@cpan.orgE. =head1 COPYRIGHT AND LICENCE This software is copyright (c) 2013-2014 by Toby Inkster. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =head1 DISCLAIMER OF WARRANTIES 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.