MooseX-Storage-0.45/000755 000767 000024 00000000000 12255433343 014536 5ustar00etherstaff000000 000000 MooseX-Storage-0.45/Build.PL000644 000767 000024 00000000066 12255433343 016034 0ustar00etherstaff000000 000000 use 5.008; use Module::Build::Tiny 0.030; Build_PL(); MooseX-Storage-0.45/Changes000644 000767 000024 00000022242 12255433343 016033 0ustar00etherstaff000000 000000 Revision history for MooseX-Storage 0.45 2013-12-22 00:48:10Z - new 'Value' type handler added (thanks David Golden) 0.44 2013-11-30 20:09:54Z - re-release to fix compile test 0.43 2013-09-11 01:47:40Z - removed use of deprecated Class::MOP::load_class 0.42 2013-09-08 18:00:22Z - all features are now configured as x_default => 1 in metadata (not yet supported by any cpan clients), signalling to automatically add to prereqs when installing non-interactively - re-release with properly encoded META.yml 0.41 2013-09-03 01:05:15Z - re-release with updated Dist::Zilla plugins to clear the dynamic_config flag in metadata - repository has moved to the GitHub Moose organization 0.40 2013-08-29 01:57:00Z - replaced last use of Best (held over since 2010!) to YAML::Any - fixed another test making use of optional features 0.39 2013-07-27 00:02:26Z - re-release as stable (full working Dist::Zilla conversion) 0.38 2013-07-20 16:42:03Z (TRIAL RELEASE) - re-release with new compile test, which properly declares all its prerequisites 0.37 2013-07-20 00:41:17Z (TRIAL RELEASE) - fixed compile tests so that modules using optional features are skipped (from 0.36-TRIAL) 0.36 2013-07-17 04:41:39Z (TRIAL RELEASE) - convert to Dist::Zilla, with new optional prereq handling 0.35 2013-07-15 - properly skip optional tests when the required JSON backends aren't available 0.34 2013-06-20 - JSON storage works when Cpanel::JSON::XS is the only JSON backend installed 0.33 2013-03-29 - always JSONify data with sorted keys, to handle hash order randomization introduced in 5.17.* (RT#84287, Karen Etheridge) 0.32 2012-12-04 - Change to use core Digest and Digest::SHA dists, rather than Digest::SHA1. RT#69811 - Create a JSON::Any object, so setting $ENV{JSON_ANY_CONFIG} works. Adjust tests that were setting the wrong values and the default happened to work. - Don't rely on hash key order in tests (RT#81695) 0.31 2012-02-28 - Add example for add_custom_type_handler to the MooseX::Storage::Engine docs. (perigrin) - Incorrect documentation for ->unpack method's inject parameter fixed. - The test suite now uses Test::Fatal instead of Test::Exception (Karen Etheridge). 0.30 2011-04-29 - Make Makefile.PL features work again. RT#67170 0.29 2010-11-17 - Remove use of Test::TempDir in favor of File::Temp (gphat) 0.28 2010-10-03 - Make the engine_traits parameter be able to use a '+My::Trait::Name' prefix to specify a trait name which isn't in the MooseX::Storage::Engine::Trait namespace - Misc POD and test cleanups. 0.27 2010-04-15 - use of parameterized roles (first added in 0.22) now works in Deferred Example: $object->freeze({ format => [ $role_name => \%args ] }) 0.26 2010-03-25 - Fix URI for repository in metadata. - Fix infinite recursion when collapsing objects which overload stringify to freeze themselves. 0.25 2010-03-09 - Add support for Union types (bumps Moose dep to 0.99) 0.24 2010-01-11 - Add additional YAML implementation tests. - Switch from using Best to YAML::Any. - Remove Test::YAML::Valid. 0.23 2009-11-10 - Revert whitespace change in tests which breaks the tests if you have Test::YAML::Valid installed. 0.22 2009-11-05 - Fix warnings when types do not have a parent type. - allow the use of roles outside MooseX::Storage:: (rjbs) - allow the use of parameterized roles (rjbs) 0.21 2009-07-14 - Fix inconsistent dist versions with Perl::Version 0.20 2009-07-14 - Add support for Storage( traits => [...] ) with a MooseX::Storage::Traits::XX namespace to alter the behaviour of the storage engine. (Suggestions for how to make this less fugly appreciated) - Add feature to disable cycle checking, either via engine trait or option - add docs & tests (including 1 TODO test) - Add feature to only serialize attributes whose predicate returns 'true' - Implement the unpack( $data, inject => {...} ) feature. - add docs & tests - Move Base::WithChecksum to build upon Basic.pm, avoid code duplication - Add extra test to ensure restoring fails if required argument isn't provided - Fix a bug where if a required constructor argument was not serialized, it was impossible to ->unpack again. 0.19 2009-07-14 - Skip pod tests when not in author mode 0.18 2009-06-02 - Fix test failures without JSON::Any. Patch from RT#46343 (Nicholas Clarke) - Added support for Maybe[...] constraints fixing RT#43165 (plu) 0.17 2009-04-06 - Change MooseX::Storage::Engine to use get_all_attributes, rather than the deprecated compute_all_applicable_attributes (t0m) - Don't fail tests when Best is unavailable (t0m) 0.15 2008-09-29 - MooseX::Storage - Remove use of deprecated alias_method routine which was causing issues when you used multiple Roles which used MooseX::Storage (t0m). 0.14 2008-06-22 - MooseX::Storage::Engine - cycles are now tracked by refaddr instead of stringified object, which broke for any overloaded objects (Thanks to Jonathan Rockway) - Don't fail tests when YAML is unavailable - Use temporary files in test suite, instead of cwd 0.13 2008-05-24 - MooseX::Storage::Engine: - added find_type_handler_for($name) method to make finding type handlers easier - improved error messages - removed Build.PL since Module::Install no longer supports it 0.12 2008-03-14 - added build_requires for Test::Deep (awwaiid) - upped the Moose dependency to support the custom meta-attribute-traits - t/ - fixing all the tests to properly skip if optional features are not being used, this should help get rid of all our CPANtester failures - tested against 5.10 as well - MooseX::Storage::Engine MooseX::Storage::Meta::Attribute::DoNotSerialize MooseX::Storage::Meta::Attribute::Trait::DoNotSerialize - adding meta-attribute-trait support for DoNotSerialize - added tests for this 0.11 2008-01-10 - upped the Test::JSON dependency so that we use the version that supports JSON::Any - upped the JSON::Any requirement - minor test cleanups to handle optional dependencies better - MooseX::Storage::Engine - the numbers now have to numify (+0) in the expand/collapse so that certain JSON engines will not choke on them 0.10 2009-01-10 - updated copyright information - MooseX::Storage::Deferred - added this role, which allows you to wait until you actually call a method to determine what formatter and/or IO engine you want to use - added tests for this 0.09 2007-10-23 - MooseX::Storage::Util - added support to deal with utf8 strings correctly - MooseX::Storage::Engine::File MooseX::Storage::Engine::AtomicFile - fixed utf8 handling when storing string - added tests for this - t/ - added an extra test for the utf8 handling - Change build system to Module::Install 0.08 2007-10-10 - MooseX::Storage::Format::JSON - added support to deal with utf8 strings correctly 0.07 2007-09-27 - MooseX::Storage::Format::Storable - this will use Storable to freeze/thaw objects - added tests for this - MooseX::Storage::IO::StorableFile - this will use Storable to load/store objects - added tests for this - t/ - fixed tests in 030_with_checksum.t (thanks to sartak) 0.06 2007-08-07 - MooseX::Storage::Engine - added the Bool type and fixed a few bugs that it exposed (thanks to Sartak) - added tests for this 0.05 2007-07-15 - MooseX::Storage::Base::WithChecksum - Fixed minor issue where the WithChecksum would choke with a bad checksum due to odd Data::Dumper output. - t/ - forced JSON::Any in the basic JSON tests to use JSON.pm since this is what Test::JSON uses and subtle (and annoying) issues can arise. 0.04 2007-07-03 - MooseX::Storage::Util - made this more robust when it tries to use YAML and JSON loaders and fails to find one - fixed tests to reflect this 0.03 2007-06-27 - MooseX::Storage::Util - this is a collection of useful tools for working with MooseX::Storage data - added docs and test - t/ - added test for a custom type handler - fixed checksum test to skip if Digest::SHA1 (our default) is not available 0.02 2007-06-08 - MooseX::Storage::Base::WithChecksum - added a simple base role which makes a checksum of the data structure before packing, and checks the checksum before unpacking. - added tests for this - MooseX::Storage::Engine - better error reporting when cycles are found - class names are now stored as the full identifier (--) and are checked when they are expanded. - added docs and tests for this - MooseX::Storage::Engine::IO::(AtomicFile, File) - added checks to make sure the file gets opened correctly and dies if it does not. 0.01 2007-04-30 - This was Chris's idea originally (blame him), and we expanded on it to create what you see here :) MooseX-Storage-0.45/CONTRIBUTING000644 000767 000024 00000005317 12255433343 016376 0ustar00etherstaff000000 000000 CONTRIBUTING Thank you for considering contributing to this distribution. This file contains instructions that will help you work with the source code. The distribution is managed with 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-Storage. If you use cpanminus, you can do it without downloading the tarball first: $ cpanm --reinstall --installdeps --with-recommends MooseX::Storage 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` $ 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` $ dzil listdeps --author --missing | cpanm You can also do this via cpanm directly: $ cpanm --reinstall --installdeps --with-develop --with-recommends MooseX::Storage 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 main repository is: https://github.com/moose/MooseX-Storage. 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/ 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-Storage or via bug-MooseX-Storage@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. This file was generated via Dist::Zilla::Plugin::GenerateFile::ShareDir 0.003 from a template file originating in Dist-Zilla-PluginBundle-Author-ETHER-0.043. MooseX-Storage-0.45/dist.ini000644 000767 000024 00000005503 12255433343 016205 0ustar00etherstaff000000 000000 name = MooseX-Storage author = Chris Prather author = Stevan Little author = יובל קוג'מן (Yuval Kogman) copyright_holder = Infinity Interactive, Inc. copyright_year = 2007 license = Perl_5 :version = 5 [@Author::ETHER] :version = 0.019 -remove = AutoPrereqs server = github Authority.authority = cpan:STEVAN Test::MinimumVersion.max_target_perl = 5.008003 ; these appear in every file, so it's easier to just put it here Test::PodSpelling.stopwords = cpan ; these are all the modules that use optional prereqs, and will cause ; cpantesters to barf in the compile tests Test::Compile.skip[] = ^MooseX::Storage::((Engine::)?IO::|Format::) [MetaResources] x_IRC = irc://irc.perl.org/#moose x_MailingList = http://lists.perl.org/list/moose.html ; authordep Pod::Weaver = 4 ; authordep Pod::Weaver::Section::Contributors [ContributorsFromGit] [Prereqs / RuntimeRequires] Moose = 0.99 String::RewritePrefix = 0 Digest = 0 Data::Dumper = 0 Scalar::Util = 0 Module::Runtime = 0 [Prereqs / TestRequires] Test::More = 0.88 Test::Deep = 0 Test::Fatal = 0 Test::Requires = 0.05 File::Spec::Functions = 0 [Prereqs / RuntimeRecommends] Digest::HMAC = 0 Digest::SHA = 0 [Prereqs / DevelopRequires] Digest = 0 Digest::HMAC = 0 Digest::HMAC_SHA1 = 0 Digest::SHA = 0 Encode = 0 [OptionalFeature / JSON-Runtime] :version = 0.006 ; for -default -description = Serialize to JSON. You should have at least one serialization format. -always_recommend = 1 -default = 1 JSON::Any = 1.15 [OptionalFeature / JSON-RuntimeRecommends] -description = Serialize to JSON. You should have at least one serialization format. -always_recommend = 1 -default = 1 MooseX::Storage::Format::JSONpm = 0 [OptionalFeature / JSON-Test] -description = Serialize to JSON. You should have at least one serialization format. -always_recommend = 1 -default = 1 Test::Deep::JSON = 0 [OptionalFeature / YAML-Runtime] -description = Serialize to YAML. You should have at least one serialization format. -always_recommend = 1 -default = 1 YAML::Any = 0 [OptionalFeature / YAML-RuntimeRecommends] -description = Serialize to YAML. You should have at least one serialization format. -always_recommend = 1 -default = 1 YAML = 0 YAML::Syck = 0 YAML::XS = 0 [OptionalFeature / YAML-Test] -description = Serialize to YAML. You should have at least one serialization format. -always_recommend = 1 -default = 1 Test::Without::Module = 0 [OptionalFeature / Storable] -description = Serialize to Storable. You should have at least one serialization format. -always_recommend = 1 -default = 1 Storable = 0 [OptionalFeature / File] -description = the ability to save the file to disk -always_recommend = 1 -default = 1 IO::File = 0 IO::AtomicFile = 0 MooseX-Storage-0.45/INSTALL000644 000767 000024 00000001721 12255433343 015570 0ustar00etherstaff000000 000000 This is the Perl distribution MooseX-Storage. Installing MooseX-Storage is straightforward. ## Installation with cpanm If you have cpanm, you only need one line: % cpanm MooseX::Storage 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::Storage ## Installing with the CPAN shell Alternatively, if your CPAN shell is set up, you should just be able to do: % cpan MooseX::Storage ## 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-Storage documentation is available as POD. You can run perldoc from a shell to read the documentation: % perldoc MooseX::Storage MooseX-Storage-0.45/lib/000755 000767 000024 00000000000 12255433343 015304 5ustar00etherstaff000000 000000 MooseX-Storage-0.45/LICENSE000644 000767 000024 00000043725 12255433343 015556 0ustar00etherstaff000000 000000 This software is copyright (c) 2007 by Infinity Interactive, Inc.. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Terms of the Perl programming language system itself a) the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version, or b) the "Artistic License" --- The GNU General Public License, Version 1, February 1989 --- This software is Copyright (c) 2007 by Infinity Interactive, Inc.. This is free software, licensed under: The GNU General Public License, Version 1, February 1989 GNU GENERAL PUBLIC LICENSE Version 1, February 1989 Copyright (C) 1989 Free Software Foundation, Inc. 51 Franklin St, Suite 500, Boston, MA 02110-1335 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The license agreements of most software companies try to keep users at the mercy of those companies. By contrast, our General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. The General Public License applies to the Free Software Foundation's software and to any other program whose authors commit to using it. You can use it for your programs, too. When we speak of free software, we are referring to freedom, not price. Specifically, the General Public License is designed to make sure that you have the freedom to give away or sell copies of free software, that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of a such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must tell them their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any work containing the Program or a portion of it, either verbatim or with modifications. Each licensee is addressed as "you". 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this General Public License and to the absence of any warranty; and give any other recipients of the Program a copy of this General Public License along with the Program. You may charge a fee for the physical act of transferring a copy. 2. You may modify your copy or copies of the Program or any portion of it, and copy and distribute such modifications under the terms of Paragraph 1 above, provided that you also do the following: a) cause the modified files to carry prominent notices stating that you changed the files and the date of any change; and b) cause the whole of any work that you distribute or publish, that in whole or in part contains the Program or any part thereof, either with or without modifications, to be licensed at no charge to all third parties under the terms of this General Public License (except that you may choose to grant warranty protection to some or all third parties, at your option). c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the simplest and most usual way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this General Public License. d) You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. Mere aggregation of another independent work with the Program (or its derivative) on a volume of a storage or distribution medium does not bring the other work under the scope of these terms. 3. You may copy and distribute the Program (or a portion or derivative of it, under Paragraph 2) in object code or executable form under the terms of Paragraphs 1 and 2 above provided that you also do one of the following: a) accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Paragraphs 1 and 2 above; or, b) accompany it with a written offer, valid for at least three years, to give any third party free (except for a nominal charge for the cost of distribution) a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Paragraphs 1 and 2 above; or, c) accompany it with the information you received as to where the corresponding source code may be obtained. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form alone.) Source code for a work means the preferred form of the work for making modifications to it. For an executable file, complete source code means all the source code for all modules it contains; but, as a special exception, it need not include source code for modules which are standard libraries that accompany the operating system on which the executable file runs, or for standard header files or definitions files that accompany that operating system. 4. You may not copy, modify, sublicense, distribute or transfer the Program except as expressly provided under this General Public License. Any attempt otherwise to copy, modify, sublicense, distribute or transfer the Program is void, and will automatically terminate your rights to use the Program under this License. However, parties who have received copies, or rights to use copies, from you under this General Public License will not have their licenses terminated so long as such parties remain in full compliance. 5. By copying, distributing or modifying the Program (or any work based on the Program) you indicate your acceptance of this license to do so, and all its terms and conditions. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. 7. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of the license which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the license, you may choose any version ever published by the Free Software Foundation. 8. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to humanity, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19xx name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (a program to direct compilers to make passes at assemblers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice That's all there is to it! --- The Artistic License 1.0 --- This software is Copyright (c) 2007 by Infinity Interactive, Inc.. 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-Storage-0.45/Makefile.PL000644 000767 000024 00000007161 12255433343 016515 0ustar00etherstaff000000 000000 # This Makefile.PL for MooseX-Storage was generated by # Dist::Zilla::Plugin::MakeMaker::Fallback 0.005. # Don't edit it but the dist.ini used to construct it. use strict; use warnings; BEGIN { my %configure_requires = ( 'ExtUtils::MakeMaker' => '6.30', 'Module::Build::Tiny' => '0.030', ); my @missing = grep { ! eval "require $_; $_->VERSION($configure_requires{$_}); 1" } keys %configure_requires; if (not @missing) { print "Congratulations, your toolchain understands 'configure_requires'!\n\n"; } else { $ENV{PERL_MM_FALLBACK_SILENCE_WARNING} or 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)); } } use 5.008; use ExtUtils::MakeMaker 6.30; my %WriteMakefileArgs = ( "ABSTRACT" => "A serialization framework for Moose classes", "AUTHOR" => "Chris Prather , Stevan Little , \x{5d9}\x{5d5}\x{5d1}\x{5dc} \x{5e7}\x{5d5}\x{5d2}'\x{5de}\x{5df} (Yuval Kogman) ", "BUILD_REQUIRES" => {}, "CONFIGURE_REQUIRES" => { "ExtUtils::MakeMaker" => "6.30", "Module::Build::Tiny" => "0.030" }, "DISTNAME" => "MooseX-Storage", "EXE_FILES" => [], "LICENSE" => "perl", "NAME" => "MooseX::Storage", "PREREQ_PM" => { "Data::Dumper" => 0, "Digest" => 0, "Module::Runtime" => 0, "Moose" => "0.99", "Scalar::Util" => 0, "String::RewritePrefix" => 0 }, "TEST_REQUIRES" => { "File::Spec::Functions" => 0, "Test::Deep" => 0, "Test::Fatal" => 0, "Test::More" => "0.88", "Test::Requires" => "0.05" }, "VERSION" => "0.45", "test" => { "TESTS" => "t/*.t" } ); unless ( eval { ExtUtils::MakeMaker->VERSION(6.63_03) } ) { my $tr = delete $WriteMakefileArgs{TEST_REQUIRES}; my $br = $WriteMakefileArgs{BUILD_REQUIRES}; for my $mod ( keys %$tr ) { if ( exists $br->{$mod} ) { $br->{$mod} = $tr->{$mod} if $tr->{$mod} > $br->{$mod}; } else { $br->{$mod} = $tr->{$mod}; } } } unless ( eval { ExtUtils::MakeMaker->VERSION(6.56) } ) { my $br = delete $WriteMakefileArgs{BUILD_REQUIRES}; my $pp = $WriteMakefileArgs{PREREQ_PM}; for my $mod ( keys %$br ) { if ( exists $pp->{$mod} ) { $pp->{$mod} = $br->{$mod} if $br->{$mod} > $pp->{$mod}; } else { $pp->{$mod} = $br->{$mod}; } } } delete $WriteMakefileArgs{CONFIGURE_REQUIRES} unless eval { ExtUtils::MakeMaker->VERSION(6.52) }; WriteMakefile(%WriteMakefileArgs); MooseX-Storage-0.45/MANIFEST000644 000767 000024 00000003733 12255433343 015675 0ustar00etherstaff000000 000000 Build.PL CONTRIBUTING Changes INSTALL LICENSE MANIFEST META.json META.yml Makefile.PL README README.md TODO dist.ini lib/MooseX/Storage.pm lib/MooseX/Storage/Base/WithChecksum.pm lib/MooseX/Storage/Basic.pm lib/MooseX/Storage/Deferred.pm lib/MooseX/Storage/Engine.pm lib/MooseX/Storage/Engine/IO/AtomicFile.pm lib/MooseX/Storage/Engine/IO/File.pm lib/MooseX/Storage/Engine/Trait/DisableCycleDetection.pm lib/MooseX/Storage/Engine/Trait/OnlyWhenBuilt.pm lib/MooseX/Storage/Format/JSON.pm lib/MooseX/Storage/Format/Storable.pm lib/MooseX/Storage/Format/YAML.pm lib/MooseX/Storage/IO/AtomicFile.pm lib/MooseX/Storage/IO/File.pm lib/MooseX/Storage/IO/StorableFile.pm lib/MooseX/Storage/Meta/Attribute/DoNotSerialize.pm lib/MooseX/Storage/Meta/Attribute/Trait/DoNotSerialize.pm lib/MooseX/Storage/Traits/DisableCycleDetection.pm lib/MooseX/Storage/Traits/OnlyWhenBuilt.pm lib/MooseX/Storage/Util.pm t/00-report-prereqs.t t/000_load.t t/001_basic.t t/002_basic_io.t t/002_basic_w_subtypes.t t/003_basic_w_embedded_objects.t t/004_w_cycles.t t/005_w_versions_and_authority_check.t t/006_w_custom_type_handlers.t t/007_false.t t/008_do_not_serialize.t t/009_do_not_serialize_lazy.t t/010_basic_json.t t/011_basic_json_w_utf8.t t/012_param_json.t t/020_basic_yaml.t t/020_basic_yaml_syck.t t/020_basic_yaml_xs.t t/030_with_checksum.t t/040_basic_utils.t t/050_basic_storable.t t/060_basic_deferred.t t/061_basic_deferred_w_io.t t/070_basic_maybe.t t/100_io.t t/101_io_atomic.t t/102_io_storable_file.t t/103_io_storable_file_custom.t t/104_io_w_utf8.t t/105_io_atomic_w_utf8.t t/200_combined_in_roles.t t/300_overloaded.t weaver.ini xt/author/00-compile.t xt/author/pod-spell.t xt/release/changes_has_content.t xt/release/cpan-changes.t xt/release/distmeta.t xt/release/eol.t xt/release/kwalitee.t xt/release/minimum-version.t xt/release/mojibake.t xt/release/no-tabs.t xt/release/pod-coverage.t xt/release/pod-no404s.t xt/release/pod-syntax.t xt/release/portability.t xt/release/test-version.t xt/release/unused-vars.t MooseX-Storage-0.45/META.json000644 000767 000024 00000100511 12255433343 016155 0ustar00etherstaff000000 000000 { "abstract" : "A serialization framework for Moose classes", "author" : [ "Chris Prather ", "Stevan Little ", "\u05d9\u05d5\u05d1\u05dc \u05e7\u05d5\u05d2'\u05de\u05df (Yuval Kogman) " ], "dynamic_config" : 0, "generated_by" : "Dist::Zilla version 5.006, CPAN::Meta::Converter version 2.133380", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : "2" }, "name" : "MooseX-Storage", "no_index" : { "directory" : [ "t", "xt", "examples" ] }, "optional_features" : { "File" : { "description" : "the ability to save the file to disk", "prereqs" : { "runtime" : { "requires" : { "IO::AtomicFile" : "0", "IO::File" : "0" } } }, "x_default" : "1" }, "JSON" : { "description" : "Serialize to JSON. You should have at least one serialization format.", "prereqs" : { "runtime" : { "recommends" : { "MooseX::Storage::Format::JSONpm" : "0" }, "requires" : { "JSON::Any" : "1.15" } }, "test" : { "requires" : { "Test::Deep::JSON" : "0" } } }, "x_default" : "1" }, "Storable" : { "description" : "Serialize to Storable. You should have at least one serialization format.", "prereqs" : { "runtime" : { "requires" : { "Storable" : "0" } } }, "x_default" : "1" }, "YAML" : { "description" : "Serialize to YAML. You should have at least one serialization format.", "prereqs" : { "runtime" : { "recommends" : { "YAML" : "0", "YAML::Syck" : "0", "YAML::XS" : "0" }, "requires" : { "YAML::Any" : "0" } }, "test" : { "requires" : { "Test::Without::Module" : "0" } } }, "x_default" : "1" } }, "prereqs" : { "configure" : { "requires" : { "ExtUtils::MakeMaker" : "6.30", "Module::Build::Tiny" : "0.030" } }, "develop" : { "recommends" : { "Dist::Zilla::PluginBundle::Author::ETHER" : "0.043" }, "requires" : { "Digest" : "0", "Digest::HMAC" : "0", "Digest::HMAC_SHA1" : "0", "Digest::SHA" : "0", "Dist::Zilla" : "5.006", "Dist::Zilla::Plugin::ContributorsFromGit" : "0", "Dist::Zilla::Plugin::GitHub::Update" : "0", "Dist::Zilla::Plugin::GithubMeta" : "0", "Dist::Zilla::Plugin::MakeMaker::Fallback" : "0", "Dist::Zilla::Plugin::MetaResources" : "0", "Dist::Zilla::Plugin::ModuleBuildTiny" : "0.004", "Dist::Zilla::Plugin::OptionalFeature" : "0", "Dist::Zilla::Plugin::Prereqs" : "0", "Dist::Zilla::PluginBundle::Author::ETHER" : "0.019", "Encode" : "0", "File::Spec" : "0", "IO::AtomicFile" : "0", "IO::File" : "0", "IO::Handle" : "0", "IPC::Open3" : "0", "JSON::Any" : "1.15", "MooseX::Storage::Format::JSONpm" : "0", "Pod::Coverage::TrustPod" : "0", "Pod::Weaver" : "4", "Pod::Weaver::Section::Contributors" : "0", "Storable" : "0", "Test::CPAN::Changes" : "0.19", "Test::CPAN::Meta" : "0", "Test::Deep::JSON" : "0", "Test::Kwalitee" : "1.12", "Test::More" : "0.94", "Test::NoTabs" : "0", "Test::Pod" : "1.41", "Test::Pod::Coverage" : "1.08", "Test::Without::Module" : "0", "YAML" : "0", "YAML::Any" : "0", "YAML::Syck" : "0", "YAML::XS" : "0" } }, "runtime" : { "recommends" : { "Digest::HMAC" : "0", "Digest::SHA" : "0", "IO::AtomicFile" : "0", "IO::File" : "0", "JSON::Any" : "1.15", "MooseX::Storage::Format::JSONpm" : "0", "Storable" : "0", "YAML" : "0", "YAML::Any" : "0", "YAML::Syck" : "0", "YAML::XS" : "0" }, "requires" : { "Data::Dumper" : "0", "Digest" : "0", "Module::Runtime" : "0", "Moose" : "0.99", "Scalar::Util" : "0", "String::RewritePrefix" : "0", "perl" : "5.008" } }, "test" : { "recommends" : { "CPAN::Meta" : "0", "CPAN::Meta::Requirements" : "0", "Test::Deep::JSON" : "0", "Test::Without::Module" : "0" }, "requires" : { "File::Spec::Functions" : "0", "Test::Deep" : "0", "Test::Fatal" : "0", "Test::More" : "0.88", "Test::Requires" : "0.05" } } }, "provides" : { "Moose::Meta::Attribute::Custom::DoNotSerialize" : { "file" : "lib/MooseX/Storage/Meta/Attribute/DoNotSerialize.pm", "version" : "0.45" }, "Moose::Meta::Attribute::Custom::Trait::DoNotSerialize" : { "file" : "lib/MooseX/Storage/Meta/Attribute/Trait/DoNotSerialize.pm", "version" : "0.45" }, "MooseX::Storage" : { "file" : "lib/MooseX/Storage.pm", "version" : "0.45" }, "MooseX::Storage::Base::WithChecksum" : { "file" : "lib/MooseX/Storage/Base/WithChecksum.pm", "version" : "0.45" }, "MooseX::Storage::Basic" : { "file" : "lib/MooseX/Storage/Basic.pm", "version" : "0.45" }, "MooseX::Storage::Deferred" : { "file" : "lib/MooseX/Storage/Deferred.pm", "version" : "0.45" }, "MooseX::Storage::Engine" : { "file" : "lib/MooseX/Storage/Engine.pm", "version" : "0.45" }, "MooseX::Storage::Engine::IO::AtomicFile" : { "file" : "lib/MooseX/Storage/Engine/IO/AtomicFile.pm", "version" : "0.45" }, "MooseX::Storage::Engine::IO::File" : { "file" : "lib/MooseX/Storage/Engine/IO/File.pm", "version" : "0.45" }, "MooseX::Storage::Engine::Trait::DisableCycleDetection" : { "file" : "lib/MooseX/Storage/Engine/Trait/DisableCycleDetection.pm", "version" : "0.45" }, "MooseX::Storage::Engine::Trait::OnlyWhenBuilt" : { "file" : "lib/MooseX/Storage/Engine/Trait/OnlyWhenBuilt.pm", "version" : "0.45" }, "MooseX::Storage::Format::JSON" : { "file" : "lib/MooseX/Storage/Format/JSON.pm", "version" : "0.45" }, "MooseX::Storage::Format::Storable" : { "file" : "lib/MooseX/Storage/Format/Storable.pm", "version" : "0.45" }, "MooseX::Storage::Format::YAML" : { "file" : "lib/MooseX/Storage/Format/YAML.pm", "version" : "0.45" }, "MooseX::Storage::IO::AtomicFile" : { "file" : "lib/MooseX/Storage/IO/AtomicFile.pm", "version" : "0.45" }, "MooseX::Storage::IO::File" : { "file" : "lib/MooseX/Storage/IO/File.pm", "version" : "0.45" }, "MooseX::Storage::IO::StorableFile" : { "file" : "lib/MooseX/Storage/IO/StorableFile.pm", "version" : "0.45" }, "MooseX::Storage::Meta::Attribute::DoNotSerialize" : { "file" : "lib/MooseX/Storage/Meta/Attribute/DoNotSerialize.pm", "version" : "0.45" }, "MooseX::Storage::Meta::Attribute::Trait::DoNotSerialize" : { "file" : "lib/MooseX/Storage/Meta/Attribute/Trait/DoNotSerialize.pm", "version" : "0.45" }, "MooseX::Storage::Traits::DisableCycleDetection" : { "file" : "lib/MooseX/Storage/Traits/DisableCycleDetection.pm", "version" : "0.45" }, "MooseX::Storage::Traits::OnlyWhenBuilt" : { "file" : "lib/MooseX/Storage/Traits/OnlyWhenBuilt.pm", "version" : "0.45" }, "MooseX::Storage::Util" : { "file" : "lib/MooseX/Storage/Util.pm", "version" : "0.45" } }, "release_status" : "stable", "resources" : { "bugtracker" : { "mailto" : "bug-MooseX-Storage@rt.cpan.org", "web" : "https://rt.cpan.org/Public/Dist/Display.html?Name=MooseX-Storage" }, "homepage" : "https://github.com/moose/MooseX-Storage", "repository" : { "type" : "git", "url" : "https://github.com/moose/MooseX-Storage.git", "web" : "https://github.com/moose/MooseX-Storage" }, "x_IRC" : "irc://irc.perl.org/#moose", "x_MailingList" : "http://lists.perl.org/list/moose.html" }, "version" : "0.45", "x_Dist_Zilla" : { "perl" : { "version" : "5.019006" }, "plugins" : [ { "class" : "Dist::Zilla::Plugin::Git::NextVersion", "name" : "@Author::ETHER/Git::NextVersion", "version" : "2.019" }, { "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/build", "version" : "0.015" }, { "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/release", "version" : "0.015" }, { "class" : "Dist::Zilla::Plugin::ExecDir", "name" : "@Author::ETHER/ExecDir", "version" : "5.006" }, { "class" : "Dist::Zilla::Plugin::ShareDir", "name" : "@Author::ETHER/ShareDir", "version" : "5.006" }, { "class" : "Dist::Zilla::Plugin::FileFinder::ByName", "name" : "@Author::ETHER/Examples", "version" : "5.006" }, { "class" : "Dist::Zilla::Plugin::Git::GatherDir", "name" : "@Author::ETHER/Git::GatherDir", "version" : "2.019" }, { "class" : "Dist::Zilla::Plugin::MetaYAML", "name" : "@Author::ETHER/MetaYAML", "version" : "5.006" }, { "class" : "Dist::Zilla::Plugin::MetaJSON", "name" : "@Author::ETHER/MetaJSON", "version" : "5.006" }, { "class" : "Dist::Zilla::Plugin::License", "name" : "@Author::ETHER/License", "version" : "5.006" }, { "class" : "Dist::Zilla::Plugin::Readme", "name" : "@Author::ETHER/Readme", "version" : "5.006" }, { "class" : "Dist::Zilla::Plugin::Manifest", "name" : "@Author::ETHER/Manifest", "version" : "5.006" }, { "class" : "Dist::Zilla::Plugin::GenerateFile::ShareDir", "config" : { "Dist::Zilla::Plugin::GenerateFile::ShareDir" : { "destination_filename" : "CONTRIBUTING", "dist" : "Dist-Zilla-PluginBundle-Author-ETHER", "encoding" : "UTF-8", "source_filename" : "CONTRIBUTING" } }, "name" : "@Author::ETHER/GenerateFile::ShareDir", "version" : "0.003" }, { "class" : "Dist::Zilla::Plugin::Test::Compile", "config" : { "Dist::Zilla::Plugin::Test::Compile" : { "filename" : "xt/author/00-compile.t", "module_finder" : [ ":InstallModules" ], "script_finder" : [ ":ExecFiles", "@Author::ETHER/Examples" ] } }, "name" : "@Author::ETHER/Test::Compile", "version" : "2.039" }, { "class" : "Dist::Zilla::Plugin::Test::NoTabs", "config" : { "Dist::Zilla::Plugin::Test::NoTabs" : { "module_finder" : [ ":InstallModules" ], "script_finder" : [ ":ExecFiles", "@Author::ETHER/Examples" ] } }, "name" : "@Author::ETHER/Test::NoTabs", "version" : "0.06" }, { "class" : "Dist::Zilla::Plugin::EOLTests", "name" : "@Author::ETHER/EOLTests", "version" : "0.02" }, { "class" : "Dist::Zilla::Plugin::MetaTests", "name" : "@Author::ETHER/MetaTests", "version" : "5.006" }, { "class" : "Dist::Zilla::Plugin::Test::Version", "name" : "@Author::ETHER/Test::Version", "version" : "0.002004" }, { "class" : "Dist::Zilla::Plugin::Test::CPAN::Changes", "name" : "@Author::ETHER/Test::CPAN::Changes", "version" : "0.008" }, { "class" : "Dist::Zilla::Plugin::Test::ChangesHasContent", "name" : "@Author::ETHER/Test::ChangesHasContent", "version" : "0.006" }, { "class" : "Dist::Zilla::Plugin::Test::UnusedVars", "name" : "@Author::ETHER/Test::UnusedVars", "version" : "2.000005" }, { "class" : "Dist::Zilla::Plugin::Test::MinimumVersion", "name" : "@Author::ETHER/Test::MinimumVersion", "version" : "2.000005" }, { "class" : "Dist::Zilla::Plugin::PodSyntaxTests", "name" : "@Author::ETHER/PodSyntaxTests", "version" : "5.006" }, { "class" : "Dist::Zilla::Plugin::PodCoverageTests", "name" : "@Author::ETHER/PodCoverageTests", "version" : "5.006" }, { "class" : "Dist::Zilla::Plugin::Test::PodSpelling", "name" : "@Author::ETHER/Test::PodSpelling", "version" : "2.006002" }, { "class" : "Dist::Zilla::Plugin::Test::Pod::No404s", "name" : "@Author::ETHER/Test::Pod::No404s", "version" : "1.001" }, { "class" : "Dist::Zilla::Plugin::Test::Kwalitee", "name" : "@Author::ETHER/Test::Kwalitee", "version" : "2.07" }, { "class" : "Dist::Zilla::Plugin::MojibakeTests", "name" : "@Author::ETHER/MojibakeTests", "version" : "0.5" }, { "class" : "Dist::Zilla::Plugin::Test::ReportPrereqs", "name" : "@Author::ETHER/Test::ReportPrereqs", "version" : "0.010" }, { "class" : "Dist::Zilla::Plugin::Test::Portability", "name" : "@Author::ETHER/Test::Portability", "version" : "2.000005" }, { "class" : "Dist::Zilla::Plugin::PruneCruft", "name" : "@Author::ETHER/PruneCruft", "version" : "5.006" }, { "class" : "Dist::Zilla::Plugin::ManifestSkip", "name" : "@Author::ETHER/ManifestSkip", "version" : "5.006" }, { "class" : "Dist::Zilla::Plugin::Authority", "name" : "@Author::ETHER/Authority", "version" : "1.006" }, { "class" : "Dist::Zilla::Plugin::Git::Describe", "name" : "@Author::ETHER/Git::Describe", "version" : "0.003" }, { "class" : "Dist::Zilla::Plugin::PkgVersion", "name" : "@Author::ETHER/PkgVersion", "version" : "5.006" }, { "class" : "Dist::Zilla::Plugin::PodWeaver", "config" : { "Dist::Zilla::Plugin::PodWeaver" : { "finder" : [ ":InstallModules", ":ExecFiles" ], "plugins" : [ { "class" : "Pod::Weaver::Plugin::EnsurePod5", "name" : "@CorePrep/EnsurePod5", "version" : "4.005" }, { "class" : "Pod::Weaver::Plugin::H1Nester", "name" : "@CorePrep/H1Nester", "version" : "4.005" }, { "class" : "Pod::Weaver::Plugin::SingleEncoding", "name" : "@Default/SingleEncoding", "version" : "4.005" }, { "class" : "Pod::Weaver::Section::Name", "name" : "@Default/Name", "version" : "4.005" }, { "class" : "Pod::Weaver::Section::Version", "name" : "@Default/Version", "version" : "4.005" }, { "class" : "Pod::Weaver::Section::Region", "name" : "@Default/prelude", "version" : "4.005" }, { "class" : "Pod::Weaver::Section::Generic", "name" : "SYNOPSIS", "version" : "4.005" }, { "class" : "Pod::Weaver::Section::Generic", "name" : "DESCRIPTION", "version" : "4.005" }, { "class" : "Pod::Weaver::Section::Generic", "name" : "OVERVIEW", "version" : "4.005" }, { "class" : "Pod::Weaver::Section::Collect", "name" : "ATTRIBUTES", "version" : "4.005" }, { "class" : "Pod::Weaver::Section::Collect", "name" : "METHODS", "version" : "4.005" }, { "class" : "Pod::Weaver::Section::Collect", "name" : "FUNCTIONS", "version" : "4.005" }, { "class" : "Pod::Weaver::Section::Leftovers", "name" : "@Default/Leftovers", "version" : "4.005" }, { "class" : "Pod::Weaver::Section::Region", "name" : "@Default/postlude", "version" : "4.005" }, { "class" : "Pod::Weaver::Section::Authors", "name" : "@Default/Authors", "version" : "4.005" }, { "class" : "Pod::Weaver::Section::Legal", "name" : "@Default/Legal", "version" : "4.005" }, { "class" : "Pod::Weaver::Plugin::Transformer", "name" : "-Transformer", "version" : "4.005" }, { "class" : "Pod::Weaver::Plugin::StopWords", "name" : "-StopWords", "version" : "1.008" }, { "class" : "Pod::Weaver::Section::Contributors", "name" : "Contributors", "version" : "0.007" } ] } }, "name" : "@Author::ETHER/PodWeaver", "version" : "4.002" }, { "class" : "Dist::Zilla::Plugin::NextRelease", "name" : "@Author::ETHER/NextRelease", "version" : "5.006" }, { "class" : "Dist::Zilla::Plugin::ReadmeAnyFromPod", "name" : "@Author::ETHER/ReadmeAnyFromPod", "version" : "0.133360" }, { "class" : "Dist::Zilla::Plugin::GithubMeta", "name" : "@Author::ETHER/GithubMeta", "version" : "0.42" }, { "class" : "Dist::Zilla::Plugin::AutoMetaResources", "name" : "@Author::ETHER/AutoMetaResources", "version" : "1.20" }, { "class" : "Dist::Zilla::Plugin::MetaNoIndex", "name" : "@Author::ETHER/MetaNoIndex", "version" : "5.006" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : "@Author::ETHER/MetaProvides::Package/AUTOVIV/:InstallModulesPM", "version" : "5.006" }, { "class" : "Dist::Zilla::Plugin::MetaProvides::Package", "config" : { "Dist::Zilla::Plugin::MetaProvides::Package" : {}, "Dist::Zilla::Role::MetaProvider::Provider" : { "inherit_missing" : "1", "inherit_version" : "1", "meta_noindex" : "1" } }, "name" : "@Author::ETHER/MetaProvides::Package", "version" : "1.15000001" }, { "class" : "Dist::Zilla::Plugin::MetaConfig", "name" : "@Author::ETHER/MetaConfig", "version" : "5.006" }, { "class" : "Dist::Zilla::Plugin::Prereqs::AuthorDeps", "name" : "@Author::ETHER/Prereqs::AuthorDeps", "version" : "0.002" }, { "class" : "Dist::Zilla::Plugin::MinimumPerl", "name" : "@Author::ETHER/MinimumPerl", "version" : "1.003" }, { "class" : "Dist::Zilla::Plugin::Prereqs", "config" : { "Dist::Zilla::Plugin::Prereqs" : { "phase" : "develop", "type" : "requires" } }, "name" : "@Author::ETHER/installer_requirements", "version" : "5.006" }, { "class" : "Dist::Zilla::Plugin::Prereqs", "config" : { "Dist::Zilla::Plugin::Prereqs" : { "phase" : "develop", "type" : "recommends" } }, "name" : "@Author::ETHER/pluginbundle_version", "version" : "5.006" }, { "class" : "Dist::Zilla::Plugin::RunExtraTests", "name" : "@Author::ETHER/RunExtraTests", "version" : "0.016" }, { "class" : "Dist::Zilla::Plugin::MakeMaker::Fallback", "name" : "@Author::ETHER/MakeMaker::Fallback", "version" : "0.005" }, { "class" : "Dist::Zilla::Plugin::ModuleBuildTiny", "name" : "@Author::ETHER/ModuleBuildTiny", "version" : "0.005" }, { "class" : "Dist::Zilla::Plugin::InstallGuide", "name" : "@Author::ETHER/InstallGuide", "version" : "1.200002" }, { "class" : "Dist::Zilla::Plugin::CheckSelfDependency", "name" : "@Author::ETHER/CheckSelfDependency", "version" : "0.006" }, { "class" : "Dist::Zilla::Plugin::Run::AfterBuild", "name" : "@Author::ETHER/Run::AfterBuild", "version" : "0.020" }, { "class" : "Dist::Zilla::Plugin::Git::Check", "name" : "@Author::ETHER/initial check", "version" : "2.019" }, { "class" : "Dist::Zilla::Plugin::Git::CheckFor::MergeConflicts", "name" : "@Author::ETHER/Git::CheckFor::MergeConflicts", "version" : "0.008" }, { "class" : "Dist::Zilla::Plugin::Git::CheckFor::CorrectBranch", "name" : "@Author::ETHER/Git::CheckFor::CorrectBranch", "version" : "0.008" }, { "class" : "Dist::Zilla::Plugin::Git::Remote::Check", "name" : "@Author::ETHER/Git::Remote::Check", "version" : "0.1.2" }, { "class" : "Dist::Zilla::Plugin::CheckPrereqsIndexed", "name" : "@Author::ETHER/CheckPrereqsIndexed", "version" : "0.009" }, { "class" : "Dist::Zilla::Plugin::TestRelease", "name" : "@Author::ETHER/TestRelease", "version" : "5.006" }, { "class" : "Dist::Zilla::Plugin::Git::Check", "name" : "@Author::ETHER/after tests", "version" : "2.019" }, { "class" : "Dist::Zilla::Plugin::UploadToCPAN", "name" : "@Author::ETHER/UploadToCPAN", "version" : "5.006" }, { "class" : "Dist::Zilla::Plugin::CopyFilesFromRelease", "name" : "@Author::ETHER/CopyFilesFromRelease", "version" : "0.001" }, { "class" : "Dist::Zilla::Plugin::Git::Commit", "name" : "@Author::ETHER/Git::Commit", "version" : "2.019" }, { "class" : "Dist::Zilla::Plugin::Git::Tag", "name" : "@Author::ETHER/Git::Tag", "version" : "2.019" }, { "class" : "Dist::Zilla::Plugin::GitHub::Update", "name" : "@Author::ETHER/GitHub::Update", "version" : "0.36" }, { "class" : "Dist::Zilla::Plugin::Git::Push", "name" : "@Author::ETHER/Git::Push", "version" : "2.019" }, { "class" : "Dist::Zilla::Plugin::InstallRelease", "name" : "@Author::ETHER/InstallRelease", "version" : "0.008" }, { "class" : "Dist::Zilla::Plugin::ConfirmRelease", "name" : "@Author::ETHER/ConfirmRelease", "version" : "5.006" }, { "class" : "Dist::Zilla::Plugin::Prereqs", "config" : { "Dist::Zilla::Plugin::Prereqs" : { "phase" : "develop", "type" : "requires" } }, "name" : "@Author::ETHER/via_options", "version" : "5.006" }, { "class" : "Dist::Zilla::Plugin::MetaResources", "name" : "MetaResources", "version" : "5.006" }, { "class" : "Dist::Zilla::Plugin::ContributorsFromGit", "name" : "ContributorsFromGit", "version" : "0.006" }, { "class" : "Dist::Zilla::Plugin::Prereqs", "config" : { "Dist::Zilla::Plugin::Prereqs" : { "phase" : "runtime", "type" : "requires" } }, "name" : "RuntimeRequires", "version" : "5.006" }, { "class" : "Dist::Zilla::Plugin::Prereqs", "config" : { "Dist::Zilla::Plugin::Prereqs" : { "phase" : "test", "type" : "requires" } }, "name" : "TestRequires", "version" : "5.006" }, { "class" : "Dist::Zilla::Plugin::Prereqs", "config" : { "Dist::Zilla::Plugin::Prereqs" : { "phase" : "runtime", "type" : "recommends" } }, "name" : "RuntimeRecommends", "version" : "5.006" }, { "class" : "Dist::Zilla::Plugin::Prereqs", "config" : { "Dist::Zilla::Plugin::Prereqs" : { "phase" : "develop", "type" : "requires" } }, "name" : "DevelopRequires", "version" : "5.006" }, { "class" : "Dist::Zilla::Plugin::OptionalFeature", "name" : "JSON-Runtime", "version" : "0.008" }, { "class" : "Dist::Zilla::Plugin::OptionalFeature", "name" : "JSON-RuntimeRecommends", "version" : "0.008" }, { "class" : "Dist::Zilla::Plugin::OptionalFeature", "name" : "JSON-Test", "version" : "0.008" }, { "class" : "Dist::Zilla::Plugin::OptionalFeature", "name" : "YAML-Runtime", "version" : "0.008" }, { "class" : "Dist::Zilla::Plugin::OptionalFeature", "name" : "YAML-RuntimeRecommends", "version" : "0.008" }, { "class" : "Dist::Zilla::Plugin::OptionalFeature", "name" : "YAML-Test", "version" : "0.008" }, { "class" : "Dist::Zilla::Plugin::OptionalFeature", "name" : "Storable", "version" : "0.008" }, { "class" : "Dist::Zilla::Plugin::OptionalFeature", "name" : "File", "version" : "0.008" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":InstallModules", "version" : "5.006" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":IncModules", "version" : "5.006" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":TestFiles", "version" : "5.006" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":ExecFiles", "version" : "5.006" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":ShareFiles", "version" : "5.006" }, { "class" : "Dist::Zilla::Plugin::FinderCode", "name" : ":MainModule", "version" : "5.006" } ], "zilla" : { "class" : "Dist::Zilla::Dist::Builder", "config" : { "is_trial" : "0" }, "version" : "5.006" } }, "x_authority" : "cpan:STEVAN", "x_contributors" : [ "Chris Prather ", "Cory Watson ", "Dagfinn Ilmari Manns\u00e5ker ", "David Golden ", "David Steinbrunner ", "Florian Ragwitz ", "Johannes Plunien ", "Jonathan Rockway ", "Jonathan Yu ", "Jos Boumans ", "Karen Etheridge ", "Ricardo Signes ", "Robert Boone ", "Shawn M Moore ", "Tomas Doran ", "Yuval Kogman " ] } MooseX-Storage-0.45/META.yml000644 000767 000024 00000047533 12255433343 016023 0ustar00etherstaff000000 000000 --- abstract: 'A serialization framework for Moose classes' author: - 'Chris Prather ' - 'Stevan Little ' - "יובל קוג'מן (Yuval Kogman) " build_requires: File::Spec::Functions: 0 Test::Deep: 0 Test::Fatal: 0 Test::More: 0.88 Test::Requires: 0.05 configure_requires: ExtUtils::MakeMaker: 6.30 Module::Build::Tiny: 0.030 dynamic_config: 0 generated_by: 'Dist::Zilla version 5.006, CPAN::Meta::Converter version 2.133380' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 name: MooseX-Storage no_index: directory: - t - xt - examples optional_features: File: description: 'the ability to save the file to disk' requires: IO::AtomicFile: 0 IO::File: 0 JSON: description: 'Serialize to JSON. You should have at least one serialization format.' recommends: MooseX::Storage::Format::JSONpm: 0 requires: JSON::Any: 1.15 Storable: description: 'Serialize to Storable. You should have at least one serialization format.' requires: Storable: 0 YAML: description: 'Serialize to YAML. You should have at least one serialization format.' recommends: YAML: 0 YAML::Syck: 0 YAML::XS: 0 requires: YAML::Any: 0 provides: Moose::Meta::Attribute::Custom::DoNotSerialize: file: lib/MooseX/Storage/Meta/Attribute/DoNotSerialize.pm version: 0.45 Moose::Meta::Attribute::Custom::Trait::DoNotSerialize: file: lib/MooseX/Storage/Meta/Attribute/Trait/DoNotSerialize.pm version: 0.45 MooseX::Storage: file: lib/MooseX/Storage.pm version: 0.45 MooseX::Storage::Base::WithChecksum: file: lib/MooseX/Storage/Base/WithChecksum.pm version: 0.45 MooseX::Storage::Basic: file: lib/MooseX/Storage/Basic.pm version: 0.45 MooseX::Storage::Deferred: file: lib/MooseX/Storage/Deferred.pm version: 0.45 MooseX::Storage::Engine: file: lib/MooseX/Storage/Engine.pm version: 0.45 MooseX::Storage::Engine::IO::AtomicFile: file: lib/MooseX/Storage/Engine/IO/AtomicFile.pm version: 0.45 MooseX::Storage::Engine::IO::File: file: lib/MooseX/Storage/Engine/IO/File.pm version: 0.45 MooseX::Storage::Engine::Trait::DisableCycleDetection: file: lib/MooseX/Storage/Engine/Trait/DisableCycleDetection.pm version: 0.45 MooseX::Storage::Engine::Trait::OnlyWhenBuilt: file: lib/MooseX/Storage/Engine/Trait/OnlyWhenBuilt.pm version: 0.45 MooseX::Storage::Format::JSON: file: lib/MooseX/Storage/Format/JSON.pm version: 0.45 MooseX::Storage::Format::Storable: file: lib/MooseX/Storage/Format/Storable.pm version: 0.45 MooseX::Storage::Format::YAML: file: lib/MooseX/Storage/Format/YAML.pm version: 0.45 MooseX::Storage::IO::AtomicFile: file: lib/MooseX/Storage/IO/AtomicFile.pm version: 0.45 MooseX::Storage::IO::File: file: lib/MooseX/Storage/IO/File.pm version: 0.45 MooseX::Storage::IO::StorableFile: file: lib/MooseX/Storage/IO/StorableFile.pm version: 0.45 MooseX::Storage::Meta::Attribute::DoNotSerialize: file: lib/MooseX/Storage/Meta/Attribute/DoNotSerialize.pm version: 0.45 MooseX::Storage::Meta::Attribute::Trait::DoNotSerialize: file: lib/MooseX/Storage/Meta/Attribute/Trait/DoNotSerialize.pm version: 0.45 MooseX::Storage::Traits::DisableCycleDetection: file: lib/MooseX/Storage/Traits/DisableCycleDetection.pm version: 0.45 MooseX::Storage::Traits::OnlyWhenBuilt: file: lib/MooseX/Storage/Traits/OnlyWhenBuilt.pm version: 0.45 MooseX::Storage::Util: file: lib/MooseX/Storage/Util.pm version: 0.45 recommends: Digest::HMAC: 0 Digest::SHA: 0 IO::AtomicFile: 0 IO::File: 0 JSON::Any: 1.15 MooseX::Storage::Format::JSONpm: 0 Storable: 0 YAML: 0 YAML::Any: 0 YAML::Syck: 0 YAML::XS: 0 requires: Data::Dumper: 0 Digest: 0 Module::Runtime: 0 Moose: 0.99 Scalar::Util: 0 String::RewritePrefix: 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-Storage homepage: https://github.com/moose/MooseX-Storage repository: https://github.com/moose/MooseX-Storage.git version: 0.45 x_Dist_Zilla: perl: version: 5.019006 plugins: - class: Dist::Zilla::Plugin::Git::NextVersion name: '@Author::ETHER/Git::NextVersion' version: 2.019 - 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/build' version: 0.015 - 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/release' version: 0.015 - class: Dist::Zilla::Plugin::ExecDir name: '@Author::ETHER/ExecDir' version: 5.006 - class: Dist::Zilla::Plugin::ShareDir name: '@Author::ETHER/ShareDir' version: 5.006 - class: Dist::Zilla::Plugin::FileFinder::ByName name: '@Author::ETHER/Examples' version: 5.006 - class: Dist::Zilla::Plugin::Git::GatherDir name: '@Author::ETHER/Git::GatherDir' version: 2.019 - class: Dist::Zilla::Plugin::MetaYAML name: '@Author::ETHER/MetaYAML' version: 5.006 - class: Dist::Zilla::Plugin::MetaJSON name: '@Author::ETHER/MetaJSON' version: 5.006 - class: Dist::Zilla::Plugin::License name: '@Author::ETHER/License' version: 5.006 - class: Dist::Zilla::Plugin::Readme name: '@Author::ETHER/Readme' version: 5.006 - class: Dist::Zilla::Plugin::Manifest name: '@Author::ETHER/Manifest' version: 5.006 - class: Dist::Zilla::Plugin::GenerateFile::ShareDir config: Dist::Zilla::Plugin::GenerateFile::ShareDir: destination_filename: CONTRIBUTING dist: Dist-Zilla-PluginBundle-Author-ETHER encoding: UTF-8 source_filename: CONTRIBUTING name: '@Author::ETHER/GenerateFile::ShareDir' version: 0.003 - class: Dist::Zilla::Plugin::Test::Compile config: Dist::Zilla::Plugin::Test::Compile: filename: xt/author/00-compile.t module_finder: - ':InstallModules' script_finder: - ':ExecFiles' - '@Author::ETHER/Examples' name: '@Author::ETHER/Test::Compile' version: 2.039 - class: Dist::Zilla::Plugin::Test::NoTabs config: Dist::Zilla::Plugin::Test::NoTabs: module_finder: - ':InstallModules' script_finder: - ':ExecFiles' - '@Author::ETHER/Examples' name: '@Author::ETHER/Test::NoTabs' version: 0.06 - class: Dist::Zilla::Plugin::EOLTests name: '@Author::ETHER/EOLTests' version: 0.02 - class: Dist::Zilla::Plugin::MetaTests name: '@Author::ETHER/MetaTests' version: 5.006 - class: Dist::Zilla::Plugin::Test::Version name: '@Author::ETHER/Test::Version' version: 0.002004 - class: Dist::Zilla::Plugin::Test::CPAN::Changes name: '@Author::ETHER/Test::CPAN::Changes' version: 0.008 - class: Dist::Zilla::Plugin::Test::ChangesHasContent name: '@Author::ETHER/Test::ChangesHasContent' version: 0.006 - class: Dist::Zilla::Plugin::Test::UnusedVars name: '@Author::ETHER/Test::UnusedVars' version: 2.000005 - class: Dist::Zilla::Plugin::Test::MinimumVersion name: '@Author::ETHER/Test::MinimumVersion' version: 2.000005 - class: Dist::Zilla::Plugin::PodSyntaxTests name: '@Author::ETHER/PodSyntaxTests' version: 5.006 - class: Dist::Zilla::Plugin::PodCoverageTests name: '@Author::ETHER/PodCoverageTests' version: 5.006 - class: Dist::Zilla::Plugin::Test::PodSpelling name: '@Author::ETHER/Test::PodSpelling' version: 2.006002 - class: Dist::Zilla::Plugin::Test::Pod::No404s name: '@Author::ETHER/Test::Pod::No404s' version: 1.001 - class: Dist::Zilla::Plugin::Test::Kwalitee name: '@Author::ETHER/Test::Kwalitee' version: 2.07 - class: Dist::Zilla::Plugin::MojibakeTests name: '@Author::ETHER/MojibakeTests' version: 0.5 - class: Dist::Zilla::Plugin::Test::ReportPrereqs name: '@Author::ETHER/Test::ReportPrereqs' version: 0.010 - class: Dist::Zilla::Plugin::Test::Portability name: '@Author::ETHER/Test::Portability' version: 2.000005 - class: Dist::Zilla::Plugin::PruneCruft name: '@Author::ETHER/PruneCruft' version: 5.006 - class: Dist::Zilla::Plugin::ManifestSkip name: '@Author::ETHER/ManifestSkip' version: 5.006 - class: Dist::Zilla::Plugin::Authority name: '@Author::ETHER/Authority' version: 1.006 - class: Dist::Zilla::Plugin::Git::Describe name: '@Author::ETHER/Git::Describe' version: 0.003 - class: Dist::Zilla::Plugin::PkgVersion name: '@Author::ETHER/PkgVersion' version: 5.006 - class: Dist::Zilla::Plugin::PodWeaver config: Dist::Zilla::Plugin::PodWeaver: finder: - ':InstallModules' - ':ExecFiles' plugins: - class: Pod::Weaver::Plugin::EnsurePod5 name: '@CorePrep/EnsurePod5' version: 4.005 - class: Pod::Weaver::Plugin::H1Nester name: '@CorePrep/H1Nester' version: 4.005 - class: Pod::Weaver::Plugin::SingleEncoding name: '@Default/SingleEncoding' version: 4.005 - class: Pod::Weaver::Section::Name name: '@Default/Name' version: 4.005 - class: Pod::Weaver::Section::Version name: '@Default/Version' version: 4.005 - class: Pod::Weaver::Section::Region name: '@Default/prelude' version: 4.005 - class: Pod::Weaver::Section::Generic name: SYNOPSIS version: 4.005 - class: Pod::Weaver::Section::Generic name: DESCRIPTION version: 4.005 - class: Pod::Weaver::Section::Generic name: OVERVIEW version: 4.005 - class: Pod::Weaver::Section::Collect name: ATTRIBUTES version: 4.005 - class: Pod::Weaver::Section::Collect name: METHODS version: 4.005 - class: Pod::Weaver::Section::Collect name: FUNCTIONS version: 4.005 - class: Pod::Weaver::Section::Leftovers name: '@Default/Leftovers' version: 4.005 - class: Pod::Weaver::Section::Region name: '@Default/postlude' version: 4.005 - class: Pod::Weaver::Section::Authors name: '@Default/Authors' version: 4.005 - class: Pod::Weaver::Section::Legal name: '@Default/Legal' version: 4.005 - class: Pod::Weaver::Plugin::Transformer name: '-Transformer' version: 4.005 - class: Pod::Weaver::Plugin::StopWords name: '-StopWords' version: 1.008 - class: Pod::Weaver::Section::Contributors name: Contributors version: 0.007 name: '@Author::ETHER/PodWeaver' version: 4.002 - class: Dist::Zilla::Plugin::NextRelease name: '@Author::ETHER/NextRelease' version: 5.006 - class: Dist::Zilla::Plugin::ReadmeAnyFromPod name: '@Author::ETHER/ReadmeAnyFromPod' version: 0.133360 - class: Dist::Zilla::Plugin::GithubMeta name: '@Author::ETHER/GithubMeta' version: 0.42 - class: Dist::Zilla::Plugin::AutoMetaResources name: '@Author::ETHER/AutoMetaResources' version: 1.20 - class: Dist::Zilla::Plugin::MetaNoIndex name: '@Author::ETHER/MetaNoIndex' version: 5.006 - class: Dist::Zilla::Plugin::FinderCode name: '@Author::ETHER/MetaProvides::Package/AUTOVIV/:InstallModulesPM' version: 5.006 - class: Dist::Zilla::Plugin::MetaProvides::Package config: Dist::Zilla::Plugin::MetaProvides::Package: {} Dist::Zilla::Role::MetaProvider::Provider: inherit_missing: 1 inherit_version: 1 meta_noindex: 1 name: '@Author::ETHER/MetaProvides::Package' version: 1.15000001 - class: Dist::Zilla::Plugin::MetaConfig name: '@Author::ETHER/MetaConfig' version: 5.006 - class: Dist::Zilla::Plugin::Prereqs::AuthorDeps name: '@Author::ETHER/Prereqs::AuthorDeps' version: 0.002 - class: Dist::Zilla::Plugin::MinimumPerl name: '@Author::ETHER/MinimumPerl' version: 1.003 - class: Dist::Zilla::Plugin::Prereqs config: Dist::Zilla::Plugin::Prereqs: phase: develop type: requires name: '@Author::ETHER/installer_requirements' version: 5.006 - class: Dist::Zilla::Plugin::Prereqs config: Dist::Zilla::Plugin::Prereqs: phase: develop type: recommends name: '@Author::ETHER/pluginbundle_version' version: 5.006 - class: Dist::Zilla::Plugin::RunExtraTests name: '@Author::ETHER/RunExtraTests' version: 0.016 - class: Dist::Zilla::Plugin::MakeMaker::Fallback name: '@Author::ETHER/MakeMaker::Fallback' version: 0.005 - class: Dist::Zilla::Plugin::ModuleBuildTiny name: '@Author::ETHER/ModuleBuildTiny' version: 0.005 - class: Dist::Zilla::Plugin::InstallGuide name: '@Author::ETHER/InstallGuide' version: 1.200002 - class: Dist::Zilla::Plugin::CheckSelfDependency name: '@Author::ETHER/CheckSelfDependency' version: 0.006 - class: Dist::Zilla::Plugin::Run::AfterBuild name: '@Author::ETHER/Run::AfterBuild' version: 0.020 - class: Dist::Zilla::Plugin::Git::Check name: '@Author::ETHER/initial check' version: 2.019 - class: Dist::Zilla::Plugin::Git::CheckFor::MergeConflicts name: '@Author::ETHER/Git::CheckFor::MergeConflicts' version: 0.008 - class: Dist::Zilla::Plugin::Git::CheckFor::CorrectBranch name: '@Author::ETHER/Git::CheckFor::CorrectBranch' version: 0.008 - class: Dist::Zilla::Plugin::Git::Remote::Check name: '@Author::ETHER/Git::Remote::Check' version: 0.1.2 - class: Dist::Zilla::Plugin::CheckPrereqsIndexed name: '@Author::ETHER/CheckPrereqsIndexed' version: 0.009 - class: Dist::Zilla::Plugin::TestRelease name: '@Author::ETHER/TestRelease' version: 5.006 - class: Dist::Zilla::Plugin::Git::Check name: '@Author::ETHER/after tests' version: 2.019 - class: Dist::Zilla::Plugin::UploadToCPAN name: '@Author::ETHER/UploadToCPAN' version: 5.006 - class: Dist::Zilla::Plugin::CopyFilesFromRelease name: '@Author::ETHER/CopyFilesFromRelease' version: 0.001 - class: Dist::Zilla::Plugin::Git::Commit name: '@Author::ETHER/Git::Commit' version: 2.019 - class: Dist::Zilla::Plugin::Git::Tag name: '@Author::ETHER/Git::Tag' version: 2.019 - class: Dist::Zilla::Plugin::GitHub::Update name: '@Author::ETHER/GitHub::Update' version: 0.36 - class: Dist::Zilla::Plugin::Git::Push name: '@Author::ETHER/Git::Push' version: 2.019 - class: Dist::Zilla::Plugin::InstallRelease name: '@Author::ETHER/InstallRelease' version: 0.008 - class: Dist::Zilla::Plugin::ConfirmRelease name: '@Author::ETHER/ConfirmRelease' version: 5.006 - class: Dist::Zilla::Plugin::Prereqs config: Dist::Zilla::Plugin::Prereqs: phase: develop type: requires name: '@Author::ETHER/via_options' version: 5.006 - class: Dist::Zilla::Plugin::MetaResources name: MetaResources version: 5.006 - class: Dist::Zilla::Plugin::ContributorsFromGit name: ContributorsFromGit version: 0.006 - class: Dist::Zilla::Plugin::Prereqs config: Dist::Zilla::Plugin::Prereqs: phase: runtime type: requires name: RuntimeRequires version: 5.006 - class: Dist::Zilla::Plugin::Prereqs config: Dist::Zilla::Plugin::Prereqs: phase: test type: requires name: TestRequires version: 5.006 - class: Dist::Zilla::Plugin::Prereqs config: Dist::Zilla::Plugin::Prereqs: phase: runtime type: recommends name: RuntimeRecommends version: 5.006 - class: Dist::Zilla::Plugin::Prereqs config: Dist::Zilla::Plugin::Prereqs: phase: develop type: requires name: DevelopRequires version: 5.006 - class: Dist::Zilla::Plugin::OptionalFeature name: JSON-Runtime version: 0.008 - class: Dist::Zilla::Plugin::OptionalFeature name: JSON-RuntimeRecommends version: 0.008 - class: Dist::Zilla::Plugin::OptionalFeature name: JSON-Test version: 0.008 - class: Dist::Zilla::Plugin::OptionalFeature name: YAML-Runtime version: 0.008 - class: Dist::Zilla::Plugin::OptionalFeature name: YAML-RuntimeRecommends version: 0.008 - class: Dist::Zilla::Plugin::OptionalFeature name: YAML-Test version: 0.008 - class: Dist::Zilla::Plugin::OptionalFeature name: Storable version: 0.008 - class: Dist::Zilla::Plugin::OptionalFeature name: File version: 0.008 - class: Dist::Zilla::Plugin::FinderCode name: ':InstallModules' version: 5.006 - class: Dist::Zilla::Plugin::FinderCode name: ':IncModules' version: 5.006 - class: Dist::Zilla::Plugin::FinderCode name: ':TestFiles' version: 5.006 - class: Dist::Zilla::Plugin::FinderCode name: ':ExecFiles' version: 5.006 - class: Dist::Zilla::Plugin::FinderCode name: ':ShareFiles' version: 5.006 - class: Dist::Zilla::Plugin::FinderCode name: ':MainModule' version: 5.006 zilla: class: Dist::Zilla::Dist::Builder config: is_trial: 0 version: 5.006 x_authority: cpan:STEVAN x_contributors: - 'Chris Prather ' - 'Cory Watson ' - 'Dagfinn Ilmari Mannsåker ' - 'David Golden ' - 'David Steinbrunner ' - 'Florian Ragwitz ' - 'Johannes Plunien ' - 'Jonathan Rockway ' - 'Jonathan Yu ' - 'Jos Boumans ' - 'Karen Etheridge ' - 'Ricardo Signes ' - 'Robert Boone ' - 'Shawn M Moore ' - 'Tomas Doran ' - 'Yuval Kogman ' MooseX-Storage-0.45/README000644 000767 000024 00000000504 12255433343 015415 0ustar00etherstaff000000 000000 This archive contains the distribution MooseX-Storage, version 0.45: A serialization framework for Moose classes This software is copyright (c) 2007 by Infinity Interactive, Inc.. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. MooseX-Storage-0.45/README.md000644 000767 000024 00000017424 12255433343 016025 0ustar00etherstaff000000 000000 # NAME MooseX::Storage - A serialization framework for Moose classes # VERSION version 0.45 # SYNOPSIS package Point; use Moose; use MooseX::Storage; with Storage('format' => 'JSON', 'io' => 'File'); has 'x' => (is => 'rw', isa => 'Int'); has 'y' => (is => 'rw', isa => 'Int'); 1; my $p = Point->new(x => 10, y => 10); ## methods to pack/unpack an ## object in perl data structures # pack the class into a hash $p->pack(); # { __CLASS__ => 'Point-0.01', x => 10, y => 10 } # unpack the hash into a class my $p2 = Point->unpack({ __CLASS__ => 'Point-0.01', x => 10, y => 10 }); ## methods to freeze/thaw into ## a specified serialization format ## (in this case JSON) # pack the class into a JSON string $p->freeze(); # { "__CLASS__" : "Point-0.01", "x" : 10, "y" : 10 } # unpack the JSON string into a class my $p2 = Point->thaw('{ "__CLASS__" : "Point-0.01", "x" : 10, "y" : 10 }'); ## methods to load/store a class ## on the file system $p->store('my_point.json'); my $p2 = Point->load('my_point.json'); # DESCRIPTION MooseX::Storage is a serialization framework for Moose, it provides a very flexible and highly pluggable way to serialize Moose classes to a number of different formats and styles. ## Important Note This is still an early release of this module, so use with caution. It's outward facing serialization API should be considered stable, but I still reserve the right to make tweaks if I need too. Anything beyond the basic pack/unpack, freeze/thaw and load/store should not be relied on. ## Levels of Serialization There are 3 levels to the serialization, each of which builds upon the other and each of which can be customized to the specific needs of your class. - __base__ The first (base) level is `pack` and `unpack`. In this level the class is serialized into a Perl HASH reference, it is tagged with the class name and each instance attribute is stored. Very simple. This level is not optional, it is the bare minimum that MooseX::Storage provides and all other levels build on top of this. See [MooseX::Storage::Basic](https://metacpan.org/pod/MooseX::Storage::Basic) for the fundamental implementation and options to `pack` and `unpack` - __format__ The second (format) level is `freeze` and `thaw`. In this level the output of `pack` is sent to `freeze` or the output of `thaw` is sent to `unpack`. This levels primary role is to convert to and from the specific serialization format and Perl land. This level is optional, if you don't want/need it, you don't have to have it. You can just use `pack`/`unpack` instead. - __io__ The third (io) level is `load` and `store`. In this level we are reading and writing data to file/network/database/etc. This level is also optional, in most cases it does require a `format` role to also be used, the exception being the `StorableFile` role. ## Behaviour modifiers The serialization behaviour can be changed by supplying `traits`. This can be done as follows: use MooseX::Storage; with Storage( traits => [Trait1, Trait2,...] ); The following traits are currently bundled with `MooseX::Storage`: - OnlyWhenBuilt Only attributes that have been built (i.e., where the predicate returns 'true') will be serialized. This avoids any potentially expensive computations. See [MooseX::Storage::Traits::OnlyWhenBuilt](https://metacpan.org/pod/MooseX::Storage::Traits::OnlyWhenBuilt) for details. ## How we serialize There are always limits to any serialization framework, there are just some things which are really difficult to serialize properly and some things which cannot be serialized at all. ## What can be serialized? Currently only numbers, string, ARRAY refs, HASH refs and other MooseX::Storage enabled objects are supported. With Array and Hash references the first level down is inspected and any objects found are serialized/deserialized for you. We do not do this recursively by default, however this feature may become an option eventually. The specific serialize/deserialize routine is determined by the Moose type constraint a specific attribute has. In most cases subtypes of the supported types are handled correctly, and there is a facility for adding handlers for custom types as well. This will get documented eventually, but it is currently still in development. ## What can not be serialized? We do not support CODE references yet, but this support might be added in using B::Deparse or some other deep magic. Scalar refs are not supported, mostly because there is no way to know if the value being referenced will be there when the object is inflated. I highly doubt will be ever support this in a general sense, but it would be possible to add this yourself for a small specific case. Circular references are specifically disallowed, however if you break the cycles yourself then re-assemble them later you can get around this. The reason we disallow circular refs is because they are not always supported in all formats we use, and they tend to be very tricky to do for all possible cases. It is almost always something you want to have tight control over anyway. # CAVEAT This is __not__ a persistence framework; changes to your object after you load or store it will not be reflected in the stored class. # EXPORTS - __Storage (%options)__ This module will export the `Storage` method and can be used to load a specific set of MooseX::Storage roles to implement a specific combination of features. It is meant to make things easier, but it is by no means the only way. You can still compose your roles by hand if you like. By default, options are assumed to be short forms. For example, this: Storage(format => 'JSON'); ...will result in looking for MooseX::Storage::Format::JSON. To use a role that is not under the default namespace prefix, start with an equal sign: Storage(format => '=My::Private::JSONFormat'); To use a parameterized role (for which, see [MooseX::Role::Parameterized](https://metacpan.org/pod/MooseX::Role::Parameterized)) you can pass an arrayref of the role name (in short or long form, as above) and its parameters: Storage(format => [ JSONpm => { json_opts => { pretty => 1 } } ]); # METHODS - __import__ ## Introspection - __meta__ # TODO This module needs docs and probably a Cookbook of some kind as well. This is an early release, so that is my excuse for now :) For the time being, please read the tests and feel free to email me if you have any questions. This module can also be discussed on IRC in the \#moose channel on irc.perl.org. # BUGS All complex software has bugs lurking in it, and this module is no exception. If you find a bug please either email me, or add the bug to cpan-RT. # AUTHORS - Chris Prather - Stevan Little - יובל קוג'מן (Yuval Kogman) # COPYRIGHT AND LICENSE This software is copyright (c) 2007 by Infinity Interactive, Inc.. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. # CONTRIBUTORS - Chris Prather - Cory Watson - Dagfinn Ilmari Mannsåker - David Golden - David Steinbrunner - Florian Ragwitz - Johannes Plunien - Jonathan Rockway - Jonathan Yu - Jos Boumans - Karen Etheridge - Ricardo Signes - Robert Boone - Shawn M Moore - Tomas Doran - Yuval Kogman MooseX-Storage-0.45/t/000755 000767 000024 00000000000 12255433343 015001 5ustar00etherstaff000000 000000 MooseX-Storage-0.45/TODO000644 000767 000024 00000000233 12255433343 015224 0ustar00etherstaff000000 000000 --------------------------------------------------------------------- :NOTES: --------------------------------------------------------------------- MooseX-Storage-0.45/weaver.ini000644 000767 000024 00000000114 12255433343 016524 0ustar00etherstaff000000 000000 [@Default] [-Transformer] transformer = List [-StopWords] [Contributors] MooseX-Storage-0.45/xt/000755 000767 000024 00000000000 12255433343 015171 5ustar00etherstaff000000 000000 MooseX-Storage-0.45/xt/author/000755 000767 000024 00000000000 12255433343 016473 5ustar00etherstaff000000 000000 MooseX-Storage-0.45/xt/release/000755 000767 000024 00000000000 12255433343 016611 5ustar00etherstaff000000 000000 MooseX-Storage-0.45/xt/release/changes_has_content.t000644 000767 000024 00000002010 12255433343 022764 0ustar00etherstaff000000 000000 #!perl use Test::More tests => 2; note 'Checking Changes'; my $changes_file = 'Changes'; my $newver = '0.45'; 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-Storage-0.45/xt/release/cpan-changes.t000644 000767 000024 00000000263 12255433343 021326 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-Storage-0.45/xt/release/distmeta.t000644 000767 000024 00000000217 12255433343 020610 0ustar00etherstaff000000 000000 #!perl use Test::More; eval "use Test::CPAN::Meta"; plan skip_all => "Test::CPAN::Meta required for testing META.yml" if $@; meta_yaml_ok(); MooseX-Storage-0.45/xt/release/eol.t000644 000767 000024 00000000240 12255433343 017551 0ustar00etherstaff000000 000000 use strict; use warnings; use Test::More; eval 'use Test::EOL'; plan skip_all => 'Test::EOL required' if $@; all_perl_files_ok({ trailing_whitespace => 1 }); MooseX-Storage-0.45/xt/release/kwalitee.t000644 000767 000024 00000000166 12255433343 020606 0ustar00etherstaff000000 000000 # this test was generated with Dist::Zilla::Plugin::Test::Kwalitee 2.07 use strict; use warnings; use Test::Kwalitee; MooseX-Storage-0.45/xt/release/minimum-version.t000644 000767 000024 00000000271 12255433343 022134 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-Storage-0.45/xt/release/mojibake.t000644 000767 000024 00000000406 12255433343 020557 0ustar00etherstaff000000 000000 #!perl use strict; use warnings qw(all); use Test::More; ## no critic (ProhibitStringyEval, RequireCheckingReturnValueOfEval) eval q(use Test::Mojibake); plan skip_all => q(Test::Mojibake required for source encoding testing) if $@; all_files_encoding_ok(); MooseX-Storage-0.45/xt/release/no-tabs.t000644 000767 000024 00000002134 12255433343 020341 0ustar00etherstaff000000 000000 use strict; use warnings; # this test was generated with Dist::Zilla::Plugin::Test::NoTabs 0.06 use Test::More 0.88; use Test::NoTabs; my @files = ( 'lib/MooseX/Storage.pm', 'lib/MooseX/Storage/Base/WithChecksum.pm', 'lib/MooseX/Storage/Basic.pm', 'lib/MooseX/Storage/Deferred.pm', 'lib/MooseX/Storage/Engine.pm', 'lib/MooseX/Storage/Engine/IO/AtomicFile.pm', 'lib/MooseX/Storage/Engine/IO/File.pm', 'lib/MooseX/Storage/Engine/Trait/DisableCycleDetection.pm', 'lib/MooseX/Storage/Engine/Trait/OnlyWhenBuilt.pm', 'lib/MooseX/Storage/Format/JSON.pm', 'lib/MooseX/Storage/Format/Storable.pm', 'lib/MooseX/Storage/Format/YAML.pm', 'lib/MooseX/Storage/IO/AtomicFile.pm', 'lib/MooseX/Storage/IO/File.pm', 'lib/MooseX/Storage/IO/StorableFile.pm', 'lib/MooseX/Storage/Meta/Attribute/DoNotSerialize.pm', 'lib/MooseX/Storage/Meta/Attribute/Trait/DoNotSerialize.pm', 'lib/MooseX/Storage/Traits/DisableCycleDetection.pm', 'lib/MooseX/Storage/Traits/OnlyWhenBuilt.pm', 'lib/MooseX/Storage/Util.pm' ); notabs_ok($_) foreach @files; done_testing; MooseX-Storage-0.45/xt/release/pod-coverage.t000644 000767 000024 00000000527 12255433343 021355 0ustar00etherstaff000000 000000 #!perl use Test::More; eval "use Test::Pod::Coverage 1.08"; plan skip_all => "Test::Pod::Coverage 1.08 required for testing POD coverage" if $@; eval "use Pod::Coverage::TrustPod"; plan skip_all => "Pod::Coverage::TrustPod required for testing POD coverage" if $@; all_pod_coverage_ok({ coverage_class => 'Pod::Coverage::TrustPod' }); MooseX-Storage-0.45/xt/release/pod-no404s.t000644 000767 000024 00000000527 12255433343 020611 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-Storage-0.45/xt/release/pod-syntax.t000644 000767 000024 00000000212 12255433343 021077 0ustar00etherstaff000000 000000 #!perl use Test::More; eval "use Test::Pod 1.41"; plan skip_all => "Test::Pod 1.41 required for testing POD" if $@; all_pod_files_ok(); MooseX-Storage-0.45/xt/release/portability.t000644 000767 000024 00000000276 12255433343 021345 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-Storage-0.45/xt/release/test-version.t000644 000767 000024 00000000643 12255433343 021443 0ustar00etherstaff000000 000000 use strict; use warnings; use Test::More; # generated by Dist::Zilla::Plugin::Test::Version 0.002004 BEGIN { eval "use Test::Version; 1;" or die $@; } my @imports = ( 'version_all_ok' ); my $params = { is_strict => 1, has_version => 1, }; push @imports, $params if version->parse( $Test::Version::VERSION ) >= version->parse('1.002'); Test::Version->import(@imports); version_all_ok; done_testing; MooseX-Storage-0.45/xt/release/unused-vars.t000644 000767 000024 00000000207 12255433343 021251 0ustar00etherstaff000000 000000 #!perl use Test::More; eval "use Test::Vars"; plan skip_all => "Test::Vars required for testing unused vars" if $@; all_vars_ok(); MooseX-Storage-0.45/xt/author/00-compile.t000644 000767 000024 00000003017 12255433343 020526 0ustar00etherstaff000000 000000 use 5.006; use strict; use warnings; # this test was generated with Dist::Zilla::Plugin::Test::Compile 2.039 use Test::More 0.94 tests => 12 + ($ENV{AUTHOR_TESTING} ? 1 : 0); my @module_files = ( 'MooseX/Storage.pm', 'MooseX/Storage/Base/WithChecksum.pm', 'MooseX/Storage/Basic.pm', 'MooseX/Storage/Deferred.pm', 'MooseX/Storage/Engine.pm', 'MooseX/Storage/Engine/Trait/DisableCycleDetection.pm', 'MooseX/Storage/Engine/Trait/OnlyWhenBuilt.pm', 'MooseX/Storage/Meta/Attribute/DoNotSerialize.pm', 'MooseX/Storage/Meta/Attribute/Trait/DoNotSerialize.pm', 'MooseX/Storage/Traits/DisableCycleDetection.pm', 'MooseX/Storage/Traits/OnlyWhenBuilt.pm', 'MooseX/Storage/Util.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"); if (@_warnings) { warn @_warnings; push @warnings, @_warnings; } } is(scalar(@warnings), 0, 'no warnings found') if $ENV{AUTHOR_TESTING}; BAIL_OUT("Compilation problems") if !Test::More->builder->is_passing; MooseX-Storage-0.45/xt/author/pod-spell.t000644 000767 000024 00000001506 12255433343 020561 0ustar00etherstaff000000 000000 use strict; use warnings; use Test::More; # generated by Dist::Zilla::Plugin::Test::PodSpelling 2.006002 use Test::Spelling 0.12; use Pod::Wordlist; add_stopwords(); all_pod_files_spelling_ok( qw( bin lib ) ); __DATA__ cpan Chris Prather chris Stevan Little stevan יובל קוג Yuval Kogman nothingmuch Infinity Interactive Inc Cory Watson gphat Dagfinn Ilmari Mannsåker ilmari David Golden dagolden Steinbrunner dsteinbrunner Florian Ragwitz rafl Johannes Plunien plu Jonathan Rockway jon Yu frequency Jos Boumans jos Karen Etheridge ether Ricardo Signes rjbs Robert Boone robo4288 Shawn Moore sartak Tomas Doran bobtfish lib MooseX Storage Engine IO File Util StorableFile Base WithChecksum Deferred AtomicFile Format JSON Trait OnlyWhenBuilt Storable YAML Traits DisableCycleDetection Basic Meta Attribute DoNotSerialize MooseX-Storage-0.45/t/00-report-prereqs.t000644 000767 000024 00000007252 12255433343 020403 0ustar00etherstaff000000 000000 #!perl use strict; use warnings; # This test was generated by Dist::Zilla::Plugin::Test::ReportPrereqs 0.010 use Test::More tests => 1; use ExtUtils::MakeMaker; use File::Spec::Functions; use List::Util qw/max/; my @modules = qw( CPAN::Meta CPAN::Meta::Requirements Data::Dumper Digest Digest::HMAC Digest::SHA ExtUtils::MakeMaker File::Spec::Functions IO::AtomicFile IO::File JSON::Any Module::Build::Tiny Module::Runtime Moose MooseX::Storage::Format::JSONpm Scalar::Util Storable String::RewritePrefix Test::Deep Test::Deep::JSON Test::Fatal Test::More Test::Requires Test::Without::Module YAML YAML::Any YAML::Syck YAML::XS perl ); my %exclude = map {; $_ => 1 } qw( ); my ($source) = grep { -f $_ } qw/MYMETA.json MYMETA.yml META.json/; $source = "META.yml" unless defined $source; # replace modules with dynamic results from MYMETA.json if we can # (hide CPAN::Meta from prereq scanner) my $cpan_meta = "CPAN::Meta"; my $cpan_meta_req = "CPAN::Meta::Requirements"; my $all_requires; if ( -f $source && eval "require $cpan_meta" ) { ## no critic if ( my $meta = eval { CPAN::Meta->load_file($source) } ) { # Get ALL modules mentioned in META (any phase/type) my $prereqs = $meta->prereqs; delete $prereqs->{develop} if not $ENV{AUTHOR_TESTING}; my %uniq = map {$_ => 1} map { keys %$_ } map { values %$_ } values %$prereqs; $uniq{$_} = 1 for @modules; # don't lose any static ones @modules = sort grep { ! $exclude{$_} } keys %uniq; # If verifying, merge 'requires' only for major phases if ( 1 ) { $prereqs = $meta->effective_prereqs; # get the object, not the hash if (eval "require $cpan_meta_req; 1") { ## no critic $all_requires = $cpan_meta_req->new; for my $phase ( qw/configure build test runtime/ ) { $all_requires->add_requirements( $prereqs->requirements_for($phase, 'requires') ); } } } } } my @reports = [qw/Version Module/]; my @dep_errors; my $req_hash = defined($all_requires) ? $all_requires->as_string_hash : {}; for my $mod ( @modules ) { next if $mod eq 'perl'; my $file = $mod; $file =~ s{::}{/}g; $file .= ".pm"; my ($prefix) = grep { -e catfile($_, $file) } @INC; if ( $prefix ) { my $ver = MM->parse_version( catfile($prefix, $file) ); $ver = "undef" unless defined $ver; # Newer MM should do this anyway push @reports, [$ver, $mod]; if ( 1 && $all_requires ) { my $req = $req_hash->{$mod}; if ( defined $req && length $req ) { if ( ! defined eval { version->parse($ver) } ) { push @dep_errors, "$mod version '$ver' cannot be parsed (version '$req' required)"; } elsif ( ! $all_requires->accepts_module( $mod => $ver ) ) { push @dep_errors, "$mod version '$ver' is not in required range '$req'"; } } } } else { push @reports, ["missing", $mod]; if ( 1 && $all_requires ) { my $req = $req_hash->{$mod}; if ( defined $req && length $req ) { push @dep_errors, "$mod is not installed (version '$req' required)"; } } } } if ( @reports ) { my $vl = max map { length $_->[0] } @reports; my $ml = max map { length $_->[1] } @reports; splice @reports, 1, 0, ["-" x $vl, "-" x $ml]; diag "\nVersions for all modules listed in $source (including optional ones):\n", map {sprintf(" %*s %*s\n",$vl,$_->[0],-$ml,$_->[1])} @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=2 sts=2 sw=2 et: MooseX-Storage-0.45/t/000_load.t000644 000767 000024 00000000140 12255433343 016457 0ustar00etherstaff000000 000000 use strict; use warnings; use Test::More tests => 1; BEGIN { use_ok('MooseX::Storage'); } MooseX-Storage-0.45/t/001_basic.t000644 000767 000024 00000005524 12255433343 016635 0ustar00etherstaff000000 000000 use strict; use warnings; use Test::More tests => 14; use Test::Deep; BEGIN { use_ok('MooseX::Storage'); } { package Foo; use Moose; use MooseX::Storage; with Storage; has 'number' => ( is => 'ro', isa => 'Int' ); has 'string' => ( is => 'ro', isa => 'Str' ); has 'boolean' => ( is => 'ro', isa => 'Bool' ); has 'float' => ( is => 'ro', isa => 'Num' ); has 'array' => ( is => 'ro', isa => 'ArrayRef' ); has 'hash' => ( is => 'ro', isa => 'HashRef' ); has 'object' => ( is => 'ro', isa => 'Foo' ); has 'union' => ( is => 'ro', isa => 'ArrayRef|Str' ); has 'union2' => ( is => 'ro', isa => 'ArrayRef|Str' ); } { my $foo = Foo->new( number => 10, string => 'foo', boolean => 1, float => 10.5, array => [ 1 .. 10 ], hash => { map { $_ => undef } ( 1 .. 10 ) }, object => Foo->new( number => 2 ), union => [ 1, 2, 3 ], union2 => 'A String' ); isa_ok( $foo, 'Foo' ); cmp_deeply( $foo->pack, { __CLASS__ => 'Foo', number => 10, string => 'foo', boolean => 1, float => 10.5, array => [ 1 .. 10 ], hash => { map { $_ => undef } ( 1 .. 10 ) }, object => { __CLASS__ => 'Foo', number => 2 }, union => [ 1, 2, 3 ], union2 => 'A String' }, '... got the right frozen class' ); } { my $foo = Foo->unpack( { __CLASS__ => 'Foo', number => 10, string => 'foo', boolean => 1, float => 10.5, array => [ 1 .. 10 ], hash => { map { $_ => undef } ( 1 .. 10 ) }, object => { __CLASS__ => 'Foo', number => 2 }, union => [ 1, 2, 3 ], union2 => 'A String' } ); isa_ok( $foo, 'Foo' ); is( $foo->number, 10, '... got the right number' ); is( $foo->string, 'foo', '... got the right string' ); ok( $foo->boolean, '... got the right boolean' ); is( $foo->float, 10.5, '... got the right float' ); cmp_deeply( $foo->array, [ 1 .. 10 ], '... got the right array' ); cmp_deeply( $foo->hash, { map { $_ => undef } ( 1 .. 10 ) }, '... got the right hash' ); isa_ok( $foo->object, 'Foo' ); is( $foo->object->number, 2, '... got the right number (in the embedded object)' ); cmp_deeply( $foo->union, [ 1 .. 3 ], '... got the right array (in the union)' ); is( $foo->union2, 'A String', '... got the right string (in the union)' ); } MooseX-Storage-0.45/t/002_basic_io.t000644 000767 000024 00000002737 12255433343 017330 0ustar00etherstaff000000 000000 use strict; use warnings; use Test::More; use Test::Deep; use File::Temp qw(tempdir); use File::Spec::Functions; my $dir = tempdir; use Test::Requires 'JSON::Any'; BEGIN { plan tests => 10; use_ok('MooseX::Storage'); } { package Foo; use Moose; use MooseX::Storage; with Storage( format => 'JSON', io => 'File', ); has 'number' => (is => 'ro', isa => 'Int'); has 'string' => (is => 'ro', isa => 'Str'); has 'float' => (is => 'ro', isa => 'Num'); has 'array' => (is => 'ro', isa => 'ArrayRef'); has 'hash' => (is => 'ro', isa => 'HashRef'); has 'object' => (is => 'ro', isa => 'Object'); } my $file = catfile($dir, 'temp.json'); { my $foo = Foo->new( number => 10, string => 'foo', float => 10.5, array => [ 1 .. 10 ], hash => { map { $_ => undef } (1 .. 10) }, object => Foo->new( number => 2 ), ); isa_ok($foo, 'Foo'); $foo->store($file); } { my $foo = Foo->load($file); isa_ok($foo, 'Foo'); is($foo->number, 10, '... got the right number'); is($foo->string, 'foo', '... got the right string'); is($foo->float, 10.5, '... got the right float'); cmp_deeply($foo->array, [ 1 .. 10], '... got the right array'); cmp_deeply($foo->hash, { map { $_ => undef } (1 .. 10) }, '... got the right hash'); isa_ok($foo->object, 'Foo'); is($foo->object->number, 2, '... got the right number (in the embedded object)'); } MooseX-Storage-0.45/t/002_basic_w_subtypes.t000644 000767 000024 00000005445 12255433343 021124 0ustar00etherstaff000000 000000 use strict; use warnings; use Test::More tests => 11; use Test::Deep; BEGIN { use_ok('MooseX::Storage'); } =pod This extends the 001_basic test to show that subtypes will DWIM in most cases. =cut { package Foo; use Moose; use Moose::Util::TypeConstraints; use MooseX::Storage; use Scalar::Util 'looks_like_number'; with Storage; subtype 'Natural' => as 'Int' => where { $_ > 0 }; subtype 'HalfNum' => as 'Num' => where { "$_" =~ /\.5$/ }; subtype 'FooString' => as 'Str' => where { lc($_) eq 'foo' }; subtype 'IntArray' => as 'ArrayRef' => where { scalar grep { looks_like_number($_) } @{$_} }; subtype 'UndefHash' => as 'HashRef' => where { scalar grep { !defined($_) } values %{$_} }; has 'number' => ( is => 'ro', isa => 'Natural' ); has 'string' => ( is => 'ro', isa => 'FooString' ); has 'float' => ( is => 'ro', isa => 'HalfNum' ); has 'array' => ( is => 'ro', isa => 'IntArray' ); has 'hash' => ( is => 'ro', isa => 'UndefHash' ); has 'object' => ( is => 'ro', isa => 'Foo' ); } { my $foo = Foo->new( number => 10, string => 'foo', float => 10.5, array => [ 1 .. 10 ], hash => { map { $_ => undef } ( 1 .. 10 ) }, object => Foo->new( number => 2 ), ); isa_ok( $foo, 'Foo' ); cmp_deeply( $foo->pack, { __CLASS__ => 'Foo', number => 10, string => 'foo', float => 10.5, array => [ 1 .. 10 ], hash => { map { $_ => undef } ( 1 .. 10 ) }, object => { __CLASS__ => 'Foo', number => 2 }, }, '... got the right frozen class' ); } { my $foo = Foo->unpack( { __CLASS__ => 'Foo', number => 10, string => 'foo', float => 10.5, array => [ 1 .. 10 ], hash => { map { $_ => undef } ( 1 .. 10 ) }, object => { __CLASS__ => 'Foo', number => 2 }, } ); isa_ok( $foo, 'Foo' ); is( $foo->number, 10, '... got the right number' ); is( $foo->string, 'foo', '... got the right string' ); is( $foo->float, 10.5, '... got the right float' ); cmp_deeply( $foo->array, [ 1 .. 10 ], '... got the right array' ); cmp_deeply( $foo->hash, { map { $_ => undef } ( 1 .. 10 ) }, '... got the right hash' ); isa_ok( $foo->object, 'Foo' ); is( $foo->object->number, 2, '... got the right number (in the embedded object)' ); } MooseX-Storage-0.45/t/003_basic_w_embedded_objects.t000644 000767 000024 00000005165 12255433343 022510 0ustar00etherstaff000000 000000 use strict; use warnings; use Test::More tests => 47; use Test::Deep; BEGIN { use_ok('MooseX::Storage'); } =pod This test checks the single level expansion and collpasing of the ArrayRef and HashRef type handlers. =cut { package Bar; use Moose; use MooseX::Storage; with Storage; has 'number' => (is => 'ro', isa => 'Int'); package Foo; use Moose; use MooseX::Storage; with Storage; has 'bars' => ( is => 'ro', isa => 'ArrayRef' ); package Baz; use Moose; use MooseX::Storage; with Storage; has 'bars' => ( is => 'ro', isa => 'HashRef' ); } { my $foo = Foo->new( bars => [ map { Bar->new(number => $_) } (1 .. 10) ] ); isa_ok( $foo, 'Foo' ); cmp_deeply( $foo->pack, { __CLASS__ => 'Foo', bars => [ map { { __CLASS__ => 'Bar', number => $_, } } (1 .. 10) ], }, '... got the right frozen class' ); } { my $foo = Foo->unpack( { __CLASS__ => 'Foo', bars => [ map { { __CLASS__ => 'Bar', number => $_, } } (1 .. 10) ], } ); isa_ok( $foo, 'Foo' ); foreach my $i (1 .. scalar @{$foo->bars}) { isa_ok($foo->bars->[$i - 1], 'Bar'); is($foo->bars->[$i - 1]->number, $i, "... got the right number ($i) in the Bar in Foo"); } } { my $baz = Baz->new( bars => { map { ($_ => Bar->new(number => $_)) } (1 .. 10) } ); isa_ok( $baz, 'Baz' ); cmp_deeply( $baz->pack, { __CLASS__ => 'Baz', bars => { map { ($_ => { __CLASS__ => 'Bar', number => $_, }) } (1 .. 10) }, }, '... got the right frozen class' ); } { my $baz = Baz->unpack( { __CLASS__ => 'Baz', bars => { map { ($_ => { __CLASS__ => 'Bar', number => $_, }) } (1 .. 10) }, } ); isa_ok( $baz, 'Baz' ); foreach my $k (keys %{$baz->bars}) { isa_ok($baz->bars->{$k}, 'Bar'); is($baz->bars->{$k}->number, $k, "... got the right number ($k) in the Bar in Baz"); } } MooseX-Storage-0.45/t/004_w_cycles.t000644 000767 000024 00000010160 12255433343 017357 0ustar00etherstaff000000 000000 use strict; use warnings; use Test::More tests => 18; use Test::Deep; use Test::Fatal; BEGIN { use_ok('MooseX::Storage'); } # This test demonstrates two things: # # - cycles will not work in the default engine # - you can use a special metaclass to tell MooseX::Storage to skip an attribute { package Circular; use Moose; use MooseX::Storage; with Storage; has 'cycle' => (is => 'rw', isa => 'Circular'); } { my $circular = Circular->new; isa_ok($circular, 'Circular'); $circular->cycle($circular); like(exception { $circular->pack; }, qr/^Basic Engine does not support cycles/, '... cannot collapse a cycle with the basic engine'); } { my $packed_circular = { __CLASS__ => 'Circular' }; $packed_circular->{cycle} = $packed_circular; like( exception { Circular->unpack($packed_circular); }, qr/^Basic Engine does not support cycles/, '... cannot expand a cycle with the basic engine'); } { package Tree; use Moose; use MooseX::Storage; with Storage; has 'node' => (is => 'rw'); has 'children' => ( is => 'ro', isa => 'ArrayRef', default => sub {[]} ); has 'parent' => ( metaclass => 'DoNotSerialize', is => 'rw', isa => 'Tree', ); sub add_child { my ($self, $child) = @_; $child->parent($self); push @{$self->children} => $child; } } { my $t = Tree->new(node => 100); isa_ok($t, 'Tree'); cmp_deeply( $t->pack, { __CLASS__ => 'Tree', node => 100, children => [], }, '... got the right packed version'); my $t2 = Tree->new(node => 200); isa_ok($t2, 'Tree'); $t->add_child($t2); cmp_deeply($t->children, [ $t2 ], '... got the right children in $t'); is($t2->parent, $t, '... created the cycle correctly'); isa_ok($t2->parent, 'Tree'); cmp_deeply( $t->pack, { __CLASS__ => 'Tree', node => 100, children => [ { __CLASS__ => 'Tree', node => 200, children => [], } ], }, '... got the right packed version (with parent attribute skipped in child)'); cmp_deeply( $t2->pack, { __CLASS__ => 'Tree', node => 200, children => [], }, '... got the right packed version (with parent attribute skipped)'); } ### this fails with cycle detection on { package Double; use Moose; use MooseX::Storage; with Storage; has 'x' => ( is => 'rw', isa => 'HashRef' ); has 'y' => ( is => 'rw', isa => 'HashRef' ); } { my $ref = {}; my $double = Double->new( 'x' => $ref, 'y' => $ref ); ### currently, the cycle checker's too naive to figure out this is not ### a problem, pass an empty hashref to the 2nd test to make sure it ### doesn't warn/die TODO: { local $TODO = "Cycle check is too naive"; my $pack = eval { $double->pack; }; ok( $pack, "Object with 2 references packed" ); ok( Double->unpack( $pack || {} ), " And unpacked again" ); } my $pack = $double->pack( engine_traits => [qw/DisableCycleDetection/] ); ok( $pack, " Object packs when cycle check is disabled"); ok( Double->unpack( $pack ), " And unpacked again" ); } ### the same as above, but now done with a trait ### this fails with cycle detection on { package DoubleNoCycle; use Moose; use MooseX::Storage; with Storage( traits => ['DisableCycleDetection'] ); has 'x' => ( is => 'rw', isa => 'HashRef' ); has 'y' => ( is => 'rw', isa => 'HashRef' ); } { my $ref = {}; my $double = DoubleNoCycle->new( 'x' => $ref, 'y' => $ref ); my $pack = $double->pack; ok( $pack, "Object packs with DisableCycleDetection trait"); ok( DoubleNoCycle->unpack( $pack ), " Unpacked again" ); } MooseX-Storage-0.45/t/005_w_versions_and_authority_check.t000644 000767 000024 00000004132 12255433343 024037 0ustar00etherstaff000000 000000 use strict; use warnings; use Test::More tests => 8; use Test::Deep; use Test::Fatal; BEGIN { use_ok('MooseX::Storage'); } =pod This tests that the version and authority checks are performed upon object expansion. =cut { package Bar; use Moose; use MooseX::Storage; our $VERSION = '0.01'; our $AUTHORITY = 'cpan:JRANDOM'; with Storage; has 'number' => (is => 'ro', isa => 'Int'); package Foo; use Moose; use MooseX::Storage; our $VERSION = '0.01'; our $AUTHORITY = 'cpan:JRANDOM'; with Storage; has 'bar' => ( is => 'ro', isa => 'Bar' ); } { my $foo = Foo->new( bar => Bar->new(number => 1) ); isa_ok( $foo, 'Foo' ); cmp_deeply( $foo->pack, { __CLASS__ => 'Foo-0.01-cpan:JRANDOM', bar => { __CLASS__ => 'Bar-0.01-cpan:JRANDOM', number => 1, } }, '... got the right frozen class' ); } { my $foo = Foo->unpack( { __CLASS__ => 'Foo-0.01-cpan:JRANDOM', bar => { __CLASS__ => 'Bar-0.01-cpan:JRANDOM', number => 1, } }, ); isa_ok( $foo, 'Foo' ); isa_ok( $foo->bar, 'Bar' ); is( $foo->bar->number, 1 , '... got the right number too' ); } Moose::Meta::Class->create('Bar', version => '0.02', authority => 'cpan:JRANDOM', ); ok(exception { Foo->unpack( { __CLASS__ => 'Foo-0.01-cpan:JRANDOM', bar => { __CLASS__ => 'Bar-0.01-cpan:JRANDOM', number => 1, } } ); }, '... could not unpack, versions are different ' . $@); Moose::Meta::Class->create('Bar', version => '0.01', authority => 'cpan:DSTATIC', ); ok(exception { Foo->unpack( { __CLASS__ => 'Foo-0.01-cpan:JRANDOM', bar => { __CLASS__ => 'Bar-0.01-cpan:JRANDOM', number => 1, } } ); }, '... could not unpack, authorities are different'); MooseX-Storage-0.45/t/006_w_custom_type_handlers.t000644 000767 000024 00000003103 12255433343 022331 0ustar00etherstaff000000 000000 use strict; use warnings; use Test::More tests => 9; use Test::Deep; use Test::Fatal; BEGIN { use_ok('MooseX::Storage'); use_ok('MooseX::Storage::Engine'); } =pod This is just a simple example of defining a custom type handler to take care of custom inflate and deflate needs. =cut { package Bar; use Moose; has 'baz' => (is => 'rw', isa => 'Str'); has 'boo' => (is => 'rw', isa => 'Str'); sub encode { my $self = shift; $self->baz . '|' . $self->boo; } sub decode { my ($class, $packed) = @_; my ($baz, $boo) = split /\|/ => $packed; $class->new( baz => $baz, boo => $boo, ); } MooseX::Storage::Engine->add_custom_type_handler( 'Bar' => ( expand => sub { Bar->decode(shift) }, collapse => sub { (shift)->encode }, ) ); package Foo; use Moose; use MooseX::Storage; with Storage; has 'bar' => ( is => 'ro', isa => 'Bar', default => sub { Bar->new(baz => 'BAZ', boo => 'BOO') } ); } my $foo = Foo->new; isa_ok($foo, 'Foo'); isa_ok($foo->bar, 'Bar'); cmp_deeply( $foo->pack, { __CLASS__ => "Foo", bar => "BAZ|BOO", }, '... got correct packed structure'); { my $foo = Foo->unpack({ __CLASS__ => "Foo", bar => "BAZ|BOO", }); isa_ok($foo, 'Foo'); isa_ok($foo->bar, 'Bar'); is($foo->bar->baz, 'BAZ', '... got the right stuff'); is($foo->bar->boo, 'BOO', '... got the right stuff'); } MooseX-Storage-0.45/t/007_false.t000644 000767 000024 00000002241 12255433343 016645 0ustar00etherstaff000000 000000 use strict; use warnings; use Test::More tests => 8; use Test::Deep; BEGIN { use_ok('MooseX::Storage'); } { package Foo; use Moose; use MooseX::Storage; with Storage; has 'number' => ( is => 'ro', isa => 'Int', default => 42 ); has 'string' => ( is => 'ro', isa => 'Str', default => "true" ); has 'boolean' => ( is => 'ro', isa => 'Bool', default => 1 ); } { my $foo = Foo->new( number => 0, string => '', boolean => 0, ); isa_ok( $foo, 'Foo' ); is($foo->boolean, 0, '... got the right boolean value'); cmp_deeply( $foo->pack, { __CLASS__ => 'Foo', number => 0, string => '', boolean => 0, }, '... got the right frozen class' ); } { my $foo = Foo->unpack( { __CLASS__ => 'Foo', number => 0, string => '', boolean => 0, } ); isa_ok( $foo, 'Foo' ); is( $foo->number, 0, '... got the right number' ); is( $foo->string, '', '... got the right string' ); ok( !$foo->boolean, '... got the right boolean' ); } MooseX-Storage-0.45/t/008_do_not_serialize.t000644 000767 000024 00000004140 12255433343 021105 0ustar00etherstaff000000 000000 use strict; use warnings; use Test::More tests => 13; use Test::Deep; use Test::Fatal; BEGIN { use_ok('MooseX::Storage'); } { package Foo; use Moose; use MooseX::Storage; with Storage; has 'bar' => ( metaclass => 'DoNotSerialize', is => 'rw', default => sub { 'BAR' } ); has 'baz' => ( traits => [ 'DoNotSerialize' ], is => 'rw', default => sub { 'BAZ' } ); has 'gorch' => ( is => 'rw', default => sub { 'GORCH' } ); 1; } { my $foo = Foo->new; isa_ok($foo, 'Foo'); is($foo->bar, 'BAR', '... got the value we expected'); is($foo->baz, 'BAZ', '... got the value we expected'); is($foo->gorch, 'GORCH', '... got the value we expected'); cmp_deeply( $foo->pack, { __CLASS__ => 'Foo', gorch => 'GORCH' }, '... got the right packed class data' ); } ### more involved test; required attribute that's not serialized { package Bar; use Moose; use MooseX::Storage; with Storage; has foo => ( metaclass => 'DoNotSerialize', required => 1, is => 'rw', isa => 'Object', # type constraint is important ); has zot => ( default => sub { $$ }, is => 'rw', ); } { my $obj = bless {}; my $bar = Bar->new( foo => $obj ); ok( $bar, "New object created" ); is( $bar->foo, $obj, " ->foo => $obj" ); is( $bar->zot, $$, " ->zot => $$" ); my $bpack = $bar->pack; cmp_deeply( $bpack, { __CLASS__ => 'Bar', zot => $$, }, " Packed correctly" ); eval { Bar->unpack( $bpack ) }; ok( $@, " Unpack without required attribute fails" ); like( $@, qr/foo/, " Proper error recorded" ); my $bar2 = Bar->unpack( $bpack, inject => { foo => bless {} } ); ok( $bar2, " Unpacked correctly with foo => Object"); } MooseX-Storage-0.45/t/009_do_not_serialize_lazy.t000644 000767 000024 00000001675 12255433343 022157 0ustar00etherstaff000000 000000 use strict; use warnings; use Test::More 'no_plan';#tests => 6; use Test::Deep; use Test::Fatal; BEGIN { use_ok('MooseX::Storage'); } { package Point; use Moose; use MooseX::Storage; with Storage( traits => [qw|OnlyWhenBuilt|] ); has 'x' => (is => 'rw', lazy_build => 1 ); has 'y' => (is => 'rw', lazy_build => 1 ); has 'z' => (is => 'rw', builder => '_build_z' ); sub _build_x { 'x' } sub _build_y { 'y' } sub _build_z { 'z' } } my $p = Point->new( 'x' => $$ ); ok( $p, "New object created" ); my $href = $p->pack; ok( $href, " Object packed" ); is( $href->{'x'}, $$, " x => $$" ); is( $href->{'z'}, 'z', " z => z" ); ok( not(exists($href->{'y'})), " y does not exist" ); cmp_deeply( $href, { '__CLASS__' => 'Point', 'x' => $$, 'z' => 'z' }, " Deep check passed" ); MooseX-Storage-0.45/t/010_basic_json.t000644 000767 000024 00000004107 12255433343 017662 0ustar00etherstaff000000 000000 use strict; use warnings; use Test::More; use Test::Deep; use Test::Requires qw( JSON::Any Test::Deep::JSON ); BEGIN { plan tests => 11; use_ok('MooseX::Storage'); } { package Foo; use Moose; use MooseX::Storage; with Storage( 'format' => 'JSON' ); has 'number' => ( is => 'ro', isa => 'Int' ); has 'string' => ( is => 'ro', isa => 'Str' ); has 'float' => ( is => 'ro', isa => 'Num' ); has 'array' => ( is => 'ro', isa => 'ArrayRef' ); has 'hash' => ( is => 'ro', isa => 'HashRef' ); has 'object' => ( is => 'ro', isa => 'Object' ); } { my $foo = Foo->new( number => 10, string => 'foo', float => 10.5, array => [ 1 .. 10 ], hash => { map { $_ => undef } ( 1 .. 10 ) }, object => Foo->new( number => 2 ), ); isa_ok( $foo, 'Foo' ); my $json = $foo->freeze; cmp_deeply( $json, json({ number => 10, string => 'foo', float => 10.5, array => [ 1 .. 10 ], hash => { map { $_ => undef } (1 .. 10) }, __CLASS__ => 'Foo', object => { number => 2, __CLASS__ => 'Foo' }, }), 'is valid JSON and content matches', ); } { my $foo = Foo->thaw( '{"array":[1,2,3,4,5,6,7,8,9,10],"hash":{"6":null,"3":null,"7":null,"9":null,"2":null,"8":null,"1":null,"4":null,"10":null,"5":null},"float":10.5,"object":{"number":2,"__CLASS__":"Foo"},"number":10,"__CLASS__":"Foo","string":"foo"}' ); isa_ok( $foo, 'Foo' ); is( $foo->number, 10, '... got the right number' ); is( $foo->string, 'foo', '... got the right string' ); is( $foo->float, 10.5, '... got the right float' ); cmp_deeply( $foo->array, [ 1 .. 10 ], '... got the right array' ); cmp_deeply( $foo->hash, { map { $_ => undef } ( 1 .. 10 ) }, '... got the right hash' ); isa_ok( $foo->object, 'Foo' ); is( $foo->object->number, 2, '... got the right number (in the embedded object)' ); } MooseX-Storage-0.45/t/011_basic_json_w_utf8.t000644 000767 000024 00000004126 12255433343 021160 0ustar00etherstaff000000 000000 use strict; use warnings; use Test::More; # NOTE: # this is because JSON::XS (and Cpanel::JSON::XS) is # the only one which really gets utf8 correct # - SL BEGIN { $ENV{JSON_ANY_ORDER} = 'XS CPANEL'; $ENV{JSON_ANY_CONFIG} = "utf8=0,canonical=1"; } use Test::Requires qw( Encode JSON::Any ); plan tests => 16; use_ok('MooseX::Storage'); { package Foo; use Moose; use MooseX::Storage; with Storage( 'format' => 'JSON' ); has 'utf8_string' => ( is => 'rw', isa => 'Str', default => sub { "ネットスーパー (Internet Shopping)" } ); } { my $foo = Foo->new; isa_ok( $foo, 'Foo' ); my $json = $foo->freeze; is($json, '{"__CLASS__":"Foo","utf8_string":"ネットスーパー (Internet Shopping)"}', '... got the right JSON'); my $foo2 = Foo->thaw($json); isa_ok( $foo, 'Foo' ); is($foo2->utf8_string, "ネットスーパー (Internet Shopping)", '... got the string we expected'); is($foo2->freeze, '{"__CLASS__":"Foo","utf8_string":"ネットスーパー (Internet Shopping)"}', '... got the right JSON'); } { my $test_string; { use utf8; $test_string = "ネットスーパー (Internet Shopping)"; no utf8; } ok(utf8::is_utf8($test_string), '... got a utf8 string'); ok(utf8::valid($test_string), '... got a valid utf8 string'); Encode::_utf8_off($test_string); ok(!utf8::is_utf8($test_string), '... no longer is utf8 string'); ok(utf8::valid($test_string), '... got a valid utf8 string'); my $foo = Foo->new( utf8_string => $test_string ); isa_ok( $foo, 'Foo' ); ok(!utf8::is_utf8($foo->utf8_string), '... not a utf8 string'); ok(utf8::valid($foo->utf8_string), '... but is a valid utf8 string'); my $json = $foo->freeze; ok(utf8::is_utf8($json), '... is a utf8 string now'); ok(utf8::valid($json), '... got a valid utf8 string'); is($json, '{"__CLASS__":"Foo","utf8_string":"ネットスーパー (Internet Shopping)"}', '... got the right JSON'); } MooseX-Storage-0.45/t/012_param_json.t000644 000767 000024 00000002536 12255433343 017707 0ustar00etherstaff000000 000000 use strict; use warnings; use Test::More; use Test::Deep; use Test::Requires 'MooseX::Storage::Format::JSONpm'; BEGIN { plan tests => 6; use_ok('MooseX::Storage'); } { package Foo; use Moose; use MooseX::Storage; with Storage(format => [ JSONpm => { json_opts => { pretty => 1 } } ] ); has 'string' => ( is => 'ro', isa => 'Str' ); has 'float' => ( is => 'ro', isa => 'Num' ); } { my $foo = Foo->new( string => 'foo', float => 10.5, ); isa_ok( $foo, 'Foo' ); my $json = $foo->freeze; isnt( index($json, "\n"), -1, "there are newlines in our JSON, because it is pretty", ) or diag $json; } { package Bar; use Moose; use MooseX::Storage; our $VERSION = '0.01'; with 'MooseX::Storage::Deferred'; has 'x' => (is => 'rw', isa => 'Int'); has 'y' => (is => 'rw', isa => 'Int'); } for my $jsonpm ( [ string => 'JSONpm' ], [ aref0p => [ JSONpm => ] ], [ aref1p => [ JSONpm => { json_opts => { pretty => 1 } } ] ], ) { my ($name, $p) = @$jsonpm; my $json = eval { Bar->new(x => 10, y => 20)->freeze({ format => $p }) }; cmp_deeply( JSON->new->decode($json), { '__CLASS__' => 'Bar-0.01', x => 10, y => 20, }, "correct deferred freeze from $name", ); } MooseX-Storage-0.45/t/020_basic_yaml.t000644 000767 000024 00000003051 12255433343 017651 0ustar00etherstaff000000 000000 $|++; use strict; use warnings; use Test::More; use Test::Deep; use Test::Requires qw( YAML::Any YAML Test::Without::Module ); BEGIN { Test::Without::Module->import(YAML::Any->order); Test::Without::Module->unimport('YAML'); plan tests => 10; use_ok('MooseX::Storage'); } { package Foo; use Moose; use MooseX::Storage; with Storage( 'format' => 'YAML' ); has 'number' => ( is => 'ro', isa => 'Int' ); has 'string' => ( is => 'ro', isa => 'Str' ); has 'float' => ( is => 'ro', isa => 'Num' ); has 'array' => ( is => 'ro', isa => 'ArrayRef' ); has 'hash' => ( is => 'ro', isa => 'HashRef' ); has 'object' => ( is => 'ro', isa => 'Object' ); } { my $foo = Foo->new( number => 10, string => 'foo', float => 10.5, array => [ 1 .. 10 ], hash => { map { $_ => undef } ( 1 .. 10 ) }, object => Foo->new( number => 2 ), ); isa_ok( $foo, 'Foo' ); my $yaml = $foo->freeze; my $bar = Foo->thaw( $yaml ); isa_ok( $bar, 'Foo' ); is( $bar->number, 10, '... got the right number' ); is( $bar->string, 'foo', '... got the right string' ); is( $bar->float, 10.5, '... got the right float' ); cmp_deeply( $bar->array, [ 1 .. 10 ], '... got the right array' ); cmp_deeply( $bar->hash, { map { $_ => undef } ( 1 .. 10 ) }, '... got the right hash' ); isa_ok( $bar->object, 'Foo' ); is( $bar->object->number, 2, '... got the right number (in the embedded object)' ); } MooseX-Storage-0.45/t/020_basic_yaml_syck.t000644 000767 000024 00000003064 12255433343 020706 0ustar00etherstaff000000 000000 $|++; use strict; use warnings; use Test::More; use Test::Deep; use Test::Requires qw( YAML::Any YAML::Syck Test::Without::Module ); BEGIN { Test::Without::Module->import(YAML::Any->order); Test::Without::Module->unimport('YAML::Syck'); plan tests => 10; use_ok('MooseX::Storage'); } { package Foo; use Moose; use MooseX::Storage; with Storage( 'format' => 'YAML' ); has 'number' => ( is => 'ro', isa => 'Int' ); has 'string' => ( is => 'ro', isa => 'Str' ); has 'float' => ( is => 'ro', isa => 'Num' ); has 'array' => ( is => 'ro', isa => 'ArrayRef' ); has 'hash' => ( is => 'ro', isa => 'HashRef' ); has 'object' => ( is => 'ro', isa => 'Object' ); } { my $foo = Foo->new( number => 10, string => 'foo', float => 10.5, array => [ 1 .. 10 ], hash => { map { $_ => undef } ( 1 .. 10 ) }, object => Foo->new( number => 2 ), ); isa_ok( $foo, 'Foo' ); my $yaml = $foo->freeze; my $bar = Foo->thaw( $yaml ); isa_ok( $bar, 'Foo' ); is( $bar->number, 10, '... got the right number' ); is( $bar->string, 'foo', '... got the right string' ); is( $bar->float, 10.5, '... got the right float' ); cmp_deeply( $bar->array, [ 1 .. 10 ], '... got the right array' ); cmp_deeply( $bar->hash, { map { $_ => undef } ( 1 .. 10 ) }, '... got the right hash' ); isa_ok( $bar->object, 'Foo' ); is( $bar->object->number, 2, '... got the right number (in the embedded object)' ); } MooseX-Storage-0.45/t/020_basic_yaml_xs.t000644 000767 000024 00000003060 12255433343 020363 0ustar00etherstaff000000 000000 $|++; use strict; use warnings; use Test::More; use Test::Deep; use Test::Requires qw( YAML::Any YAML::XS Test::Without::Module ); BEGIN { Test::Without::Module->import(YAML::Any->order); Test::Without::Module->unimport('YAML::XS'); plan tests => 10; use_ok('MooseX::Storage'); } { package Foo; use Moose; use MooseX::Storage; with Storage( 'format' => 'YAML' ); has 'number' => ( is => 'ro', isa => 'Int' ); has 'string' => ( is => 'ro', isa => 'Str' ); has 'float' => ( is => 'ro', isa => 'Num' ); has 'array' => ( is => 'ro', isa => 'ArrayRef' ); has 'hash' => ( is => 'ro', isa => 'HashRef' ); has 'object' => ( is => 'ro', isa => 'Object' ); } { my $foo = Foo->new( number => 10, string => 'foo', float => 10.5, array => [ 1 .. 10 ], hash => { map { $_ => undef } ( 1 .. 10 ) }, object => Foo->new( number => 2 ), ); isa_ok( $foo, 'Foo' ); my $yaml = $foo->freeze; my $bar = Foo->thaw( $yaml ); isa_ok( $bar, 'Foo' ); is( $bar->number, 10, '... got the right number' ); is( $bar->string, 'foo', '... got the right string' ); is( $bar->float, 10.5, '... got the right float' ); cmp_deeply( $bar->array, [ 1 .. 10 ], '... got the right array' ); cmp_deeply( $bar->hash, { map { $_ => undef } ( 1 .. 10 ) }, '... got the right hash' ); isa_ok( $bar->object, 'Foo' ); is( $bar->object->number, 2, '... got the right number (in the embedded object)' ); } MooseX-Storage-0.45/t/030_with_checksum.t000644 000767 000024 00000010641 12255433343 020407 0ustar00etherstaff000000 000000 use strict; use warnings; use Test::More; use Test::Fatal; use Test::Deep; use Test::Requires qw( Digest Digest::SHA JSON::Any ); BEGIN { plan tests => 26; use_ok('MooseX::Storage'); } { package Foo; use Moose; use MooseX::Storage; with Storage(base => 'WithChecksum', format => "JSON"); has 'number' => ( is => 'ro', isa => 'Int' ); has 'string' => ( is => 'ro', isa => 'Str' ); has 'float' => ( is => 'ro', isa => 'Num' ); has 'array' => ( is => 'ro', isa => 'ArrayRef' ); has 'hash' => ( is => 'ro', isa => 'HashRef' ); has 'object' => ( is => 'ro', isa => 'Foo' ); } { my $foo = Foo->new( number => 10, string => 'foo', float => 10.5, array => [ 1 .. 10 ], hash => { map { $_ => undef } ( 1 .. 10 ) }, object => Foo->new( number => 2 ), ); isa_ok( $foo, 'Foo' ); my $packed = $foo->pack; cmp_deeply( $packed, { __CLASS__ => 'Foo', __DIGEST__ => re('[0-9a-f]+'), number => 10, string => 'foo', float => 10.5, array => [ 1 .. 10 ], hash => { map { $_ => undef } ( 1 .. 10 ) }, object => { __CLASS__ => 'Foo', __DIGEST__ => re('[0-9a-f]+'), number => 2 }, }, '... got the right frozen class' ); my $foo2; is( exception { $foo2 = Foo->unpack($packed); }, undef, '... unpacked okay'); isa_ok($foo2, 'Foo'); cmp_deeply( $foo2->pack, { __CLASS__ => 'Foo', __DIGEST__ => re('[0-9a-f]+'), number => 10, string => 'foo', float => 10.5, array => [ 1 .. 10 ], hash => { map { $_ => undef } ( 1 .. 10 ) }, object => { __CLASS__ => 'Foo', __DIGEST__ => re('[0-9a-f]+'), number => 2 }, }, '... got the right frozen class' ); } { my $foo = Foo->new( number => 10, string => 'foo', float => 10.5, array => [ 1 .. 10 ], hash => { map { $_ => undef } ( 1 .. 10 ) }, object => Foo->new( number => 2 ), ); isa_ok( $foo, 'Foo' ); my $frozen = $foo->freeze; ok( length($frozen), "got frozen data" ); $frozen =~ s/foo/bar/; my $foo2 = eval { Foo->thaw( $frozen ) }; my $e = $@; ok( !$foo2, "not thawed" ); ok( $e, "has error" ); like( $e, qr/bad checksum/i, "bad checksum error" ); } SKIP: { eval { require Digest::HMAC_SHA1 }; if ($@) { my $message = join( " ", "no Digest::HMAC", ( $@ =~ /\@INC/ ? () : do { chomp(my $e = $@); "($e)" } ) ); die $message if $ENV{AUTHOR_TESTING}; skip $message, 15; } local $::DEBUG = 1; my $foo = Foo->new( number => 10, string => 'foo', float => 10.5, array => [ 1 .. 10 ], hash => { map { $_ => undef } ( 1 .. 10 ) }, object => Foo->new( number => 2 ), ); isa_ok( $foo, 'Foo' ); my $frozen1 = $foo->freeze( digest => [ "HMAC_SHA1", "secret" ] ); ok( length($frozen1), "got frozen data" ); $::DEBUG = 0; my $d2 = Digest::HMAC_SHA1->new("s3cr3t"); my $frozen2 = $foo->freeze( digest => $d2 ); ok( length($frozen2), "got frozen data" ); cmp_ok( $frozen1, "ne", $frozen2, "versions are different" ); is( $frozen1, $foo->freeze( digest => [ HMAC_SHA1 => "secret" ] ), "refreeze" ); $::DEBUG = 1; my $foo1 = eval { Foo->thaw( $frozen1, digest => [ "HMAC_SHA1", "secret" ] ) }; my $e = $@; ok( $foo1, "thawed" ); ok( !$e, "no error" ) || diag $e; my $foo2 = eval { Foo->thaw( $frozen2, digest => $d2 ) }; $e = $@; ok( $foo2, "thawed" ); ok( !$e, "no error" ) || diag $e; $foo1 = eval { Foo->thaw( $frozen1, digest => $d2 ) }; $e = $@; ok( !$foo1, "not thawed" ); ok( $e, "has error" ); like( $e, qr/bad checksum/i, "bad checksum error" ); $frozen1 =~ s/foo/bar/; $foo1 = eval { Foo->thaw( $frozen1, digest => [ "HMAC_SHA1", "secret" ] ) }; $e = $@; ok( !$foo1, "not thawed" ); ok( $e, "has error" ); like( $e, qr/bad checksum/i, "bad checksum error" ); } MooseX-Storage-0.45/t/040_basic_utils.t000644 000767 000024 00000003277 12255433343 020063 0ustar00etherstaff000000 000000 use strict; use warnings; use Test::More tests => 5; BEGIN { use_ok('MooseX::Storage'); use_ok('MooseX::Storage::Util'); } my $packed = { __CLASS__ => 'Foo', number => 10, string => 'foo', float => 10.5, array => [ 1 .. 10 ], hash => { map { $_ => undef } ( 1 .. 10 ) }, object => { __CLASS__ => 'Foo', number => 2 }, }; my $json = '{"array":[1,2,3,4,5,6,7,8,9,10],"hash":{"6":null,"3":null,"7":null,"9":null,"2":null,"8":null,"1":null,"4":null,"10":null,"5":null},"float":10.5,"object":{"number":2,"__CLASS__":"Foo"},"number":10,"__CLASS__":"Foo","string":"foo"}'; my $yaml = q{--- __CLASS__: Foo array: - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 float: 10.5 hash: 1: ~ 10: ~ 2: ~ 3: ~ 4: ~ 5: ~ 6: ~ 7: ~ 8: ~ 9: ~ number: 10 object: __CLASS__: Foo number: 2 string: foo }; is('Foo', MooseX::Storage::Util->peek($packed), '... got the right class name from the packed item'); SKIP: { my $classname = eval { MooseX::Storage::Util->peek($json => ('format' => 'JSON')) }; if ($@ =~ /^Could not load JSON module because/) { die 'No JSON module found' if $ENV{AUTHOR_TESTING}; skip "No JSON module found", 1; } is('Foo', $classname, '... got the right class name from the json item'); } SKIP: { my $classname = eval { MooseX::Storage::Util->peek($yaml => ('format' => 'YAML')) }; if ($@ =~ /^Could not load YAML module because/) { die 'No YAML module found' if $ENV{AUTHOR_TESTING}; skip "No YAML module found", 1; } is('Foo', $classname, '... got the right class name from the yaml item'); } MooseX-Storage-0.45/t/050_basic_storable.t000644 000767 000024 00000004323 12255433343 020530 0ustar00etherstaff000000 000000 $|++; use strict; use warnings; use Test::More tests => 11; use Test::Deep; use Storable; BEGIN { use_ok('MooseX::Storage'); } { package Foo; use Moose; use MooseX::Storage; with Storage( 'format' => 'Storable' ); has 'number' => ( is => 'ro', isa => 'Int' ); has 'string' => ( is => 'ro', isa => 'Str' ); has 'float' => ( is => 'ro', isa => 'Num' ); has 'array' => ( is => 'ro', isa => 'ArrayRef' ); has 'hash' => ( is => 'ro', isa => 'HashRef' ); has 'object' => ( is => 'ro', isa => 'Object' ); } { my $foo = Foo->new( number => 10, string => 'foo', float => 10.5, array => [ 1 .. 10 ], hash => { map { $_ => undef } ( 1 .. 10 ) }, object => Foo->new( number => 2 ), ); isa_ok( $foo, 'Foo' ); my $stored = $foo->freeze; my $struct = Storable::thaw($stored); cmp_deeply( $struct, { '__CLASS__' => 'Foo', 'float' => 10.5, 'number' => 10, 'string' => 'foo', 'array' => [ 1 .. 10], 'hash' => { map { $_ => undef } 1 .. 10 }, 'object' => { '__CLASS__' => 'Foo', 'number' => 2 }, }, '... got the data struct we expected' ); } { my $stored = Storable::nfreeze({ '__CLASS__' => 'Foo', 'float' => 10.5, 'number' => 10, 'string' => 'foo', 'array' => [ 1 .. 10], 'hash' => { map { $_ => undef } 1 .. 10 }, 'object' => { '__CLASS__' => 'Foo', 'number' => 2 }, }); my $foo = Foo->thaw($stored); isa_ok( $foo, 'Foo' ); is( $foo->number, 10, '... got the right number' ); is( $foo->string, 'foo', '... got the right string' ); is( $foo->float, 10.5, '... got the right float' ); cmp_deeply( $foo->array, [ 1 .. 10 ], '... got the right array' ); cmp_deeply( $foo->hash, { map { $_ => undef } ( 1 .. 10 ) }, '... got the right hash' ); isa_ok( $foo->object, 'Foo' ); is( $foo->object->number, 2, '... got the right number (in the embedded object)' ); } MooseX-Storage-0.45/t/060_basic_deferred.t000644 000767 000024 00000011474 12255433343 020503 0ustar00etherstaff000000 000000 $|++; use strict; use warnings; use Test::More; use Test::Deep; use Storable; use Test::Requires qw( Test::Deep::JSON JSON::Any YAML::Any ); BEGIN { plan tests => 30; use_ok('MooseX::Storage'); } diag('Using implementation: ', YAML::Any->implementation); { package Foo; use Moose; use MooseX::Storage; with 'MooseX::Storage::Deferred'; has 'number' => ( is => 'ro', isa => 'Int' ); has 'string' => ( is => 'ro', isa => 'Str' ); has 'float' => ( is => 'ro', isa => 'Num' ); has 'array' => ( is => 'ro', isa => 'ArrayRef' ); has 'hash' => ( is => 'ro', isa => 'HashRef' ); has 'object' => ( is => 'ro', isa => 'Object' ); } { my $foo = Foo->new( number => 10, string => 'foo', float => 10.5, array => [ 1 .. 10 ], hash => { map { $_ => undef } ( 1 .. 10 ) }, object => Foo->new( number => 2 ), ); isa_ok( $foo, 'Foo' ); my $json = $foo->freeze({ 'format' => 'JSON' }); cmp_deeply( $json, json({ number => 10, string => 'foo', float => 10.5, array => [ 1 .. 10 ], hash => { map { $_ => undef } ( 1 .. 10 ) }, __CLASS__ => 'Foo', object => { number => 2, __CLASS__ => 'Foo' }, }), '... got the right JSON' ); } { my $foo = Foo->thaw( '{"array":[1,2,3,4,5,6,7,8,9,10],"hash":{"6":null,"3":null,"7":null,"9":null,"2":null,"8":null,"1":null,"4":null,"10":null,"5":null},"float":10.5,"object":{"number":2,"__CLASS__":"Foo"},"number":10,"__CLASS__":"Foo","string":"foo"}', { 'format' => 'JSON' } ); isa_ok( $foo, 'Foo' ); is( $foo->number, 10, '... got the right number' ); is( $foo->string, 'foo', '... got the right string' ); is( $foo->float, 10.5, '... got the right float' ); cmp_deeply( $foo->array, [ 1 .. 10 ], '... got the right array' ); cmp_deeply( $foo->hash, { map { $_ => undef } ( 1 .. 10 ) }, '... got the right hash' ); isa_ok( $foo->object, 'Foo' ); is( $foo->object->number, 2, '... got the right number (in the embedded object)' ); } { my $foo = Foo->new( number => 10, string => 'foo', float => 10.5, array => [ 1 .. 10 ], hash => { map { $_ => undef } ( 1 .. 10 ) }, object => Foo->new( number => 2 ), ); isa_ok( $foo, 'Foo' ); my $stored = $foo->freeze({ 'format' => 'Storable' }); my $struct = Storable::thaw($stored); cmp_deeply( $struct, { '__CLASS__' => 'Foo', 'float' => 10.5, 'number' => 10, 'string' => 'foo', 'array' => [ 1 .. 10], 'hash' => { map { $_ => undef } 1 .. 10 }, 'object' => { '__CLASS__' => 'Foo', 'number' => 2 }, }, '... got the data struct we expected' ); } { my $stored = Storable::nfreeze({ '__CLASS__' => 'Foo', 'float' => 10.5, 'number' => 10, 'string' => 'foo', 'array' => [ 1 .. 10], 'hash' => { map { $_ => undef } 1 .. 10 }, 'object' => { '__CLASS__' => 'Foo', 'number' => 2 }, }); my $foo = Foo->thaw($stored, { 'format' => 'Storable' }); isa_ok( $foo, 'Foo' ); is( $foo->number, 10, '... got the right number' ); is( $foo->string, 'foo', '... got the right string' ); is( $foo->float, 10.5, '... got the right float' ); cmp_deeply( $foo->array, [ 1 .. 10 ], '... got the right array' ); cmp_deeply( $foo->hash, { map { $_ => undef } ( 1 .. 10 ) }, '... got the right hash' ); isa_ok( $foo->object, 'Foo' ); is( $foo->object->number, 2, '... got the right number (in the embedded object)' ); } { my $foo = Foo->new( number => 10, string => 'foo', float => 10.5, array => [ 1 .. 10 ], hash => { map { $_ => undef } ( 1 .. 10 ) }, object => Foo->new( number => 2 ), ); isa_ok( $foo, 'Foo' ); my $yaml = $foo->freeze({ 'format' => 'YAML' }); my $bar = Foo->thaw( $yaml, { 'format' => 'YAML' } ); isa_ok( $bar, 'Foo' ); is( $bar->number, 10, '... got the right number' ); is( $bar->string, 'foo', '... got the right string' ); is( $bar->float, 10.5, '... got the right float' ); cmp_deeply( $bar->array, [ 1 .. 10 ], '... got the right array' ); cmp_deeply( $bar->hash, { map { $_ => undef } ( 1 .. 10 ) }, '... got the right hash' ); isa_ok( $bar->object, 'Foo' ); is( $bar->object->number, 2, '... got the right number (in the embedded object)' ); } MooseX-Storage-0.45/t/061_basic_deferred_w_io.t000644 000767 000024 00000004705 12255433343 021520 0ustar00etherstaff000000 000000 use strict; use warnings; use Test::More; use Test::Deep; use File::Temp qw(tempdir); use File::Spec::Functions; my $dir = tempdir; use Test::Requires qw( IO::AtomicFile JSON::Any ); BEGIN { plan tests => 20; use_ok('MooseX::Storage'); } { package Foo; use Moose; use MooseX::Storage; with 'MooseX::Storage::Deferred'; has 'number' => (is => 'ro', isa => 'Int'); has 'string' => (is => 'ro', isa => 'Str'); has 'float' => (is => 'ro', isa => 'Num'); has 'array' => (is => 'ro', isa => 'ArrayRef'); has 'hash' => (is => 'ro', isa => 'HashRef'); has 'object' => (is => 'ro', isa => 'Object'); } my $file = catfile($dir, 'temp.json'); { my $foo = Foo->new( number => 10, string => 'foo', float => 10.5, array => [ 1 .. 10 ], hash => { map { $_ => undef } (1 .. 10) }, object => Foo->new( number => 2 ), ); isa_ok($foo, 'Foo'); $foo->store($file, { format => 'JSON', io => 'File' }); } { my $foo = Foo->load($file, { format => 'JSON', io => 'File' }); isa_ok($foo, 'Foo'); is($foo->number, 10, '... got the right number'); is($foo->string, 'foo', '... got the right string'); is($foo->float, 10.5, '... got the right float'); cmp_deeply($foo->array, [ 1 .. 10], '... got the right array'); cmp_deeply($foo->hash, { map { $_ => undef } (1 .. 10) }, '... got the right hash'); isa_ok($foo->object, 'Foo'); is($foo->object->number, 2, '... got the right number (in the embedded object)'); } unlink $file; ok(!(-e $file), '... the file has been deleted'); { my $foo = Foo->new( number => 10, string => 'foo', float => 10.5, array => [ 1 .. 10 ], hash => { map { $_ => undef } (1 .. 10) }, object => Foo->new( number => 2 ), ); isa_ok($foo, 'Foo'); $foo->store($file, { format => 'JSON', io => 'AtomicFile' }); } { my $foo = Foo->load($file, { format => 'JSON', io => 'AtomicFile' }); isa_ok($foo, 'Foo'); is($foo->number, 10, '... got the right number'); is($foo->string, 'foo', '... got the right string'); is($foo->float, 10.5, '... got the right float'); cmp_deeply($foo->array, [ 1 .. 10], '... got the right array'); cmp_deeply($foo->hash, { map { $_ => undef } (1 .. 10) }, '... got the right hash'); isa_ok($foo->object, 'Foo'); is($foo->object->number, 2, '... got the right number (in the embedded object)'); } MooseX-Storage-0.45/t/070_basic_maybe.t000644 000767 000024 00000012027 12255433343 020014 0ustar00etherstaff000000 000000 use strict; use warnings; use Test::More tests => 22; use Test::Deep; BEGIN { use_ok('MooseX::Storage'); } { package Foo; use Moose; use MooseX::Storage; with Storage; has 'number' => ( is => 'ro', isa => 'Maybe[Int]' ); has 'string' => ( is => 'ro', isa => 'Maybe[Str]' ); has 'boolean' => ( is => 'ro', isa => 'Maybe[Bool]' ); has 'float' => ( is => 'ro', isa => 'Maybe[Num]' ); has 'array' => ( is => 'ro', isa => 'Maybe[ArrayRef]' ); has 'hash' => ( is => 'ro', isa => 'Maybe[HashRef]' ); has 'object' => ( is => 'ro', isa => 'Maybe[Foo]' ); } { my $foo = Foo->new( number => 10, string => 'foo', boolean => 1, float => 10.5, array => [ 1 .. 10 ], hash => { map { $_ => undef } ( 1 .. 10 ) }, object => Foo->new( number => 2 ), ); isa_ok( $foo, 'Foo' ); cmp_deeply( $foo->pack, { __CLASS__ => 'Foo', number => 10, string => 'foo', boolean => 1, float => 10.5, array => [ 1 .. 10 ], hash => { map { $_ => undef } ( 1 .. 10 ) }, object => { __CLASS__ => 'Foo', number => 2 }, }, '... got the right frozen class' ); } { my $foo = Foo->unpack( { __CLASS__ => 'Foo', number => 10, string => 'foo', boolean => 1, float => 10.5, array => [ 1 .. 10 ], hash => { map { $_ => undef } ( 1 .. 10 ) }, object => { __CLASS__ => 'Foo', number => 2 }, } ); isa_ok( $foo, 'Foo' ); is( $foo->number, 10, '... got the right number' ); is( $foo->string, 'foo', '... got the right string' ); ok( $foo->boolean, '... got the right boolean' ); is( $foo->float, 10.5, '... got the right float' ); cmp_deeply( $foo->array, [ 1 .. 10 ], '... got the right array' ); cmp_deeply( $foo->hash, { map { $_ => undef } ( 1 .. 10 ) }, '... got the right hash' ); isa_ok( $foo->object, 'Foo' ); is( $foo->object->number, 2, '... got the right number (in the embedded object)' ); } { package Foo; use Moose; use Moose::Util::TypeConstraints; use MooseX::Storage; use Scalar::Util 'looks_like_number'; with Storage; subtype 'Natural' => as 'Int' => where { $_ > 0 }; subtype 'HalfNum' => as 'Num' => where { "$_" =~ /\.5$/ }; subtype 'FooString' => as 'Str' => where { lc($_) eq 'foo' }; subtype 'IntArray' => as 'ArrayRef' => where { scalar grep { looks_like_number($_) } @{$_} }; subtype 'UndefHash' => as 'HashRef' => where { scalar grep { !defined($_) } values %{$_} }; has 'number' => ( is => 'ro', isa => 'Maybe[Natural]' ); has 'string' => ( is => 'ro', isa => 'Maybe[FooString]' ); has 'float' => ( is => 'ro', isa => 'Maybe[HalfNum]' ); has 'array' => ( is => 'ro', isa => 'Maybe[IntArray]' ); has 'hash' => ( is => 'ro', isa => 'Maybe[UndefHash]' ); has 'object' => ( is => 'ro', isa => 'Maybe[Foo]' ); } { my $foo = Foo->new( number => 10, string => 'foo', float => 10.5, array => [ 1 .. 10 ], hash => { map { $_ => undef } ( 1 .. 10 ) }, object => Foo->new( number => 2 ), ); isa_ok( $foo, 'Foo' ); cmp_deeply( $foo->pack, { __CLASS__ => 'Foo', number => 10, string => 'foo', float => 10.5, array => [ 1 .. 10 ], hash => { map { $_ => undef } ( 1 .. 10 ) }, object => { __CLASS__ => 'Foo', number => 2 }, }, '... got the right frozen class' ); } { my $foo = Foo->unpack( { __CLASS__ => 'Foo', number => 10, string => 'foo', float => 10.5, array => [ 1 .. 10 ], hash => { map { $_ => undef } ( 1 .. 10 ) }, object => { __CLASS__ => 'Foo', number => 2 }, } ); isa_ok( $foo, 'Foo' ); is( $foo->number, 10, '... got the right number' ); is( $foo->string, 'foo', '... got the right string' ); is( $foo->float, 10.5, '... got the right float' ); cmp_deeply( $foo->array, [ 1 .. 10 ], '... got the right array' ); cmp_deeply( $foo->hash, { map { $_ => undef } ( 1 .. 10 ) }, '... got the right hash' ); isa_ok( $foo->object, 'Foo' ); is( $foo->object->number, 2, '... got the right number (in the embedded object)' ); } MooseX-Storage-0.45/t/100_io.t000644 000767 000024 00000002704 12255433343 016160 0ustar00etherstaff000000 000000 use strict; use warnings; use Test::More; use Test::Deep; use File::Temp qw(tempdir); use File::Spec::Functions; my $dir = tempdir; use Test::Requires 'JSON::Any'; BEGIN { plan tests => 10; use_ok('MooseX::Storage'); } { package Foo; use Moose; use MooseX::Storage; with Storage(format => 'JSON', io => 'File'); has 'number' => (is => 'ro', isa => 'Int'); has 'string' => (is => 'ro', isa => 'Str'); has 'float' => (is => 'ro', isa => 'Num'); has 'array' => (is => 'ro', isa => 'ArrayRef'); has 'hash' => (is => 'ro', isa => 'HashRef'); has 'object' => (is => 'ro', isa => 'Object'); } my $file = catfile( $dir, 'temp.json' ); { my $foo = Foo->new( number => 10, string => 'foo', float => 10.5, array => [ 1 .. 10 ], hash => { map { $_ => undef } (1 .. 10) }, object => Foo->new( number => 2 ), ); isa_ok($foo, 'Foo'); $foo->store($file); } { my $foo = Foo->load($file); isa_ok($foo, 'Foo'); is($foo->number, 10, '... got the right number'); is($foo->string, 'foo', '... got the right string'); is($foo->float, 10.5, '... got the right float'); cmp_deeply($foo->array, [ 1 .. 10], '... got the right array'); cmp_deeply($foo->hash, { map { $_ => undef } (1 .. 10) }, '... got the right hash'); isa_ok($foo->object, 'Foo'); is($foo->object->number, 2, '... got the right number (in the embedded object)'); } MooseX-Storage-0.45/t/101_io_atomic.t000644 000767 000024 00000002762 12255433343 017521 0ustar00etherstaff000000 000000 use strict; use warnings; use Test::More; use Test::Deep; use File::Temp qw(tempdir); use File::Spec::Functions; my $dir = tempdir( CLEANUP => 1 ); use Test::Requires qw( JSON::Any IO::AtomicFile ); BEGIN { plan tests => 10; use_ok('MooseX::Storage'); } { package Foo; use Moose; use MooseX::Storage; with Storage(format => 'JSON', io => 'AtomicFile'); has 'number' => (is => 'ro', isa => 'Int'); has 'string' => (is => 'ro', isa => 'Str'); has 'float' => (is => 'ro', isa => 'Num'); has 'array' => (is => 'ro', isa => 'ArrayRef'); has 'hash' => (is => 'ro', isa => 'HashRef'); has 'object' => (is => 'ro', isa => 'Object'); } my $file = catfile($dir,'temp.json'); { my $foo = Foo->new( number => 10, string => 'foo', float => 10.5, array => [ 1 .. 10 ], hash => { map { $_ => undef } (1 .. 10) }, object => Foo->new( number => 2 ), ); isa_ok($foo, 'Foo'); $foo->store($file); } { my $foo = Foo->load($file); isa_ok($foo, 'Foo'); is($foo->number, 10, '... got the right number'); is($foo->string, 'foo', '... got the right string'); is($foo->float, 10.5, '... got the right float'); cmp_deeply($foo->array, [ 1 .. 10], '... got the right array'); cmp_deeply($foo->hash, { map { $_ => undef } (1 .. 10) }, '... got the right hash'); isa_ok($foo->object, 'Foo'); is($foo->object->number, 2, '... got the right number (in the embedded object)'); } MooseX-Storage-0.45/t/102_io_storable_file.t000644 000767 000024 00000002640 12255433343 021053 0ustar00etherstaff000000 000000 use strict; use warnings; use Test::More tests => 10; use Test::Deep; use File::Temp qw(tempdir); use File::Spec::Functions; my $dir = tempdir( CLEANUP => 1 ); BEGIN { use_ok('MooseX::Storage'); } { package Foo; use Moose; use MooseX::Storage; with Storage(io => 'StorableFile'); has 'number' => (is => 'ro', isa => 'Int'); has 'string' => (is => 'ro', isa => 'Str'); has 'float' => (is => 'ro', isa => 'Num'); has 'array' => (is => 'ro', isa => 'ArrayRef'); has 'hash' => (is => 'ro', isa => 'HashRef'); has 'object' => (is => 'ro', isa => 'Object'); } my $file = catfile($dir,'temp.storable'); { my $foo = Foo->new( number => 10, string => 'foo', float => 10.5, array => [ 1 .. 10 ], hash => { map { $_ => undef } (1 .. 10) }, object => Foo->new( number => 2 ), ); isa_ok($foo, 'Foo'); $foo->store($file); } { my $foo = Foo->load($file); isa_ok($foo, 'Foo'); is($foo->number, 10, '... got the right number'); is($foo->string, 'foo', '... got the right string'); is($foo->float, 10.5, '... got the right float'); cmp_deeply($foo->array, [ 1 .. 10], '... got the right array'); cmp_deeply($foo->hash, { map { $_ => undef } (1 .. 10) }, '... got the right hash'); isa_ok($foo->object, 'Foo'); is($foo->object->number, 2, '... got the right number (in the embedded object)'); } MooseX-Storage-0.45/t/103_io_storable_file_custom.t000644 000767 000024 00000004552 12255433343 022452 0ustar00etherstaff000000 000000 use strict; use warnings; use Test::More tests => 11; use Test::Deep; use Storable (); use File::Temp qw(tempdir); use File::Spec::Functions; my $dir = tempdir( CLEANUP => 1 ); BEGIN { use_ok('MooseX::Storage'); } { package Foo; use Moose; use MooseX::Storage; with Storage(io => 'StorableFile'); has 'number' => (is => 'ro', isa => 'Int'); has 'string' => (is => 'rw', isa => 'Str'); has 'float' => (is => 'ro', isa => 'Num'); has 'array' => (is => 'ro', isa => 'ArrayRef'); has 'hash' => (is => 'ro', isa => 'HashRef'); has 'object' => (is => 'ro', isa => 'Object'); ## add some custom freeze/thaw hooks here ... sub thaw { my ( $class, $data ) = @_; my $self = $class->unpack( $data ); $self->string("Hello World"); $self; } sub freeze { my ( $self, @args ) = @_; my $data = $self->pack(@args); $data->{string} = "HELLO WORLD"; $data; } } my $file = catfile($dir,'temp.storable'); { my $foo = Foo->new( number => 10, string => 'foo', float => 10.5, array => [ 1 .. 10 ], hash => { map { $_ => undef } (1 .. 10) }, object => Foo->new( number => 2 ), ); isa_ok($foo, 'Foo'); $foo->store($file); # check our custom freeze hook fired ... my $data = Storable::retrieve($file); cmp_deeply( $data, { '__CLASS__' => 'Foo', 'float' => 10.5, 'number' => 10, 'string' => 'HELLO WORLD', 'array' => [ 1 .. 10], 'hash' => { map { $_ => undef } 1 .. 10 }, 'object' => { '__CLASS__' => 'Foo', 'number' => 2 }, }, '... got the data struct we expected' ); } { my $foo = Foo->load($file); isa_ok($foo, 'Foo'); ## check our custom thaw hook fired is($foo->string, 'Hello World', '... got the right string'); is($foo->number, 10, '... got the right number'); is($foo->float, 10.5, '... got the right float'); cmp_deeply($foo->array, [ 1 .. 10], '... got the right array'); cmp_deeply($foo->hash, { map { $_ => undef } (1 .. 10) }, '... got the right hash'); isa_ok($foo->object, 'Foo'); is($foo->object->number, 2, '... got the right number (in the embedded object)'); } MooseX-Storage-0.45/t/104_io_w_utf8.t000644 000767 000024 00000002613 12255433343 017457 0ustar00etherstaff000000 000000 use strict; use warnings; use Test::More; use File::Temp qw(tempdir); use File::Spec::Functions; my $dir = tempdir( CLEANUP => 1 ); # NOTE: # this is because JSON::XS (and Cpanel::JSON::XS) is # the only one which really gets utf8 correct # - SL BEGIN { $ENV{JSON_ANY_ORDER} = 'XS CPANEL'; $ENV{JSON_ANY_CONFIG} = "utf8=0,canonical=1"; } use Test::Requires qw( JSON::Any IO::AtomicFile ); plan tests => 8; use_ok('MooseX::Storage'); use utf8; { package Foo; use Moose; use MooseX::Storage; with Storage( 'format' => 'JSON', 'io' => 'File' ); has 'utf8_string' => ( is => 'rw', isa => 'Str', default => sub { "ネットスーパー (Internet Shopping)" } ); } my $file = catfile($dir,'temp.json'); { my $foo = Foo->new; isa_ok( $foo, 'Foo' ); $foo->store($file); } { my $foo = Foo->load($file); isa_ok($foo, 'Foo'); is($foo->utf8_string, "ネットスーパー (Internet Shopping)", '... got the string we expected'); } no utf8; unlink $file; { my $foo = Foo->new( utf8_string => 'Escritório' ); isa_ok( $foo, 'Foo' ); $foo->store($file); } { my $foo = Foo->load($file); isa_ok($foo, 'Foo'); ok(utf8::is_utf8($foo->utf8_string), '... the string is still utf8'); is($foo->utf8_string, "Escritório", '... got the string we expected'); } MooseX-Storage-0.45/t/105_io_atomic_w_utf8.t000644 000767 000024 00000002602 12255433343 021012 0ustar00etherstaff000000 000000 use strict; use warnings; use Test::More; use File::Temp qw(tempdir); use File::Spec::Functions; my $dir = tempdir; # NOTE: # this is because JSON::XS (and Cpanel::JSON::XS) is # the only one which really gets utf8 correct # - SL BEGIN { $ENV{JSON_ANY_ORDER} = 'XS CPANEL'; $ENV{JSON_ANY_CONFIG} = "utf8=0,canonical=1"; } use Test::Requires qw( JSON::Any IO::AtomicFile ); plan tests => 8; use_ok('MooseX::Storage'); use utf8; { package Foo; use Moose; use MooseX::Storage; with Storage( 'format' => 'JSON', 'io' => 'AtomicFile' ); has 'utf8_string' => ( is => 'rw', isa => 'Str', default => sub { "ネットスーパー (Internet Shopping)" } ); } my $file = catfile($dir, 'temp.json'); { my $foo = Foo->new; isa_ok( $foo, 'Foo' ); $foo->store($file); } { my $foo = Foo->load($file); isa_ok($foo, 'Foo'); is($foo->utf8_string, "ネットスーパー (Internet Shopping)", '... got the string we expected'); } no utf8; unlink $file; { my $foo = Foo->new( utf8_string => 'Escritório' ); isa_ok( $foo, 'Foo' ); $foo->store($file); } { my $foo = Foo->load($file); isa_ok($foo, 'Foo'); ok(utf8::is_utf8($foo->utf8_string), '... the string is still utf8'); is($foo->utf8_string, "Escritório", '... got the string we expected'); } MooseX-Storage-0.45/t/200_combined_in_roles.t000755 000767 000024 00000000567 12255433343 021234 0ustar00etherstaff000000 000000 use strict; use warnings; use Test::More tests => 1; use Test::Fatal; { package ClassOne; use Moose::Role; use MooseX::Storage; } { package ClassTwo; use Moose::Role; use MooseX::Storage; } is( exception { package CombineClasses; use Moose; with qw/ClassOne ClassTwo/; }, undef, 'Can include two roles which both use MooseX::Storage'); MooseX-Storage-0.45/t/300_overloaded.t000644 000767 000024 00000000745 12255433343 017702 0ustar00etherstaff000000 000000 use strict; use warnings; use Test::More; use Test::Fatal; use Test::Requires 'JSON::Any'; { package Thing; use Moose; use MooseX::Storage; use overload q{""} => 'as_string', fallback => 1; with Storage('format' => 'JSON'); has foo => ( is => 'ro' ); sub as_string { shift->freeze } no Moose; } my $i = Thing->new(foo => "bar"); is( exception { $i . ""; }, undef, 'Can stringify without deep recursion'); done_testing; MooseX-Storage-0.45/lib/MooseX/000755 000767 000024 00000000000 12255433343 016516 5ustar00etherstaff000000 000000 MooseX-Storage-0.45/lib/MooseX/Storage/000755 000767 000024 00000000000 12255433343 020122 5ustar00etherstaff000000 000000 MooseX-Storage-0.45/lib/MooseX/Storage.pm000644 000767 000024 00000026172 12255433343 020470 0ustar00etherstaff000000 000000 package MooseX::Storage; { $MooseX::Storage::VERSION = '0.45'; } # git description: v0.44-10-g01cb843 BEGIN { $MooseX::Storage::AUTHORITY = 'cpan:STEVAN'; } # ABSTRACT: A serialization framework for Moose classes use Moose qw(confess); use MooseX::Storage::Meta::Attribute::DoNotSerialize; use String::RewritePrefix (); use Module::Runtime 'use_module'; sub import { my $pkg = caller(); return if $pkg eq 'main'; ($pkg->can('meta')) || confess "This package can only be used in Moose based classes"; $pkg->meta->add_method('Storage' => __PACKAGE__->meta->find_method_by_name('_injected_storage_role_generator')); } my %HORRIBLE_GC_AVOIDANCE_HACK; sub _rewrite_role_name { my ($self, $base, $string) = @_; my $role_name = scalar String::RewritePrefix->rewrite( { '' => "MooseX::Storage::$base\::", '=' => '', }, $string, ); } sub _expand_role { my ($self, $base, $value) = @_; return unless defined $value; if (ref $value) { confess "too many args in arrayref role declaration" if @$value > 2; my ($class, $param) = @$value; $class = $self->_rewrite_role_name($base => $class); use_module($class); my $role = $class->meta->generate_role(parameters => $param); $HORRIBLE_GC_AVOIDANCE_HACK{ $role->name } = $role; return $role->name; } else { my $class = $self->_rewrite_role_name($base, $value); use_module($class); my $role = $class; if ($class->meta->isa( 'MooseX::Role::Parameterized::Meta::Role::Parameterizable' )) { $role = $class->meta->generate_role(parameters => undef); $HORRIBLE_GC_AVOIDANCE_HACK{ $role->name } = $role; return $role->name; } return $class; } } sub _injected_storage_role_generator { my %params = @_; $params{base} = '=MooseX::Storage::Basic' unless defined $params{base}; my @roles = __PACKAGE__->_expand_role(Base => $params{base}); # NOTE: # you don't have to have a format # role, this just means you don't # get anything other than pack/unpack push @roles, __PACKAGE__->_expand_role(Format => $params{format}); # NOTE: # many IO roles don't make sense unless # you have also have a format role chosen # too, the exception being StorableFile # # NOTE: # we don't need this code anymore, because # the role composition will catch it for # us. This allows the StorableFile to work #(exists $params{'format'}) # || confess "You must specify a format role in order to use an IO role"; push @roles, __PACKAGE__->_expand_role(IO => $params{io}); # Note: # These traits alter the behaviour of the engine, the user can # specify these per role-usage for my $trait ( @{ $params{'traits'} ||= [] } ) { push @roles, __PACKAGE__->_expand_role(Traits => $trait); } return @roles; } 1; __END__ =pod =encoding UTF-8 =for :stopwords Chris Prather Stevan Little יובל קוג'מן (Yuval Kogman) Infinity Interactive, Inc. Florian Ragwitz Johannes Plunien Jonathan Rockway Yu Jos Boumans Karen Etheridge Ricardo Signes Robert Boone Shawn M Moore Tomas Doran Cory Yuval Kogman Watson Dagfinn Ilmari Mannsåker David Golden Steinbrunner io subtypes parameterized TODO =head1 NAME MooseX::Storage - A serialization framework for Moose classes =head1 VERSION version 0.45 =head1 SYNOPSIS package Point; use Moose; use MooseX::Storage; with Storage('format' => 'JSON', 'io' => 'File'); has 'x' => (is => 'rw', isa => 'Int'); has 'y' => (is => 'rw', isa => 'Int'); 1; my $p = Point->new(x => 10, y => 10); ## methods to pack/unpack an ## object in perl data structures # pack the class into a hash $p->pack(); # { __CLASS__ => 'Point-0.01', x => 10, y => 10 } # unpack the hash into a class my $p2 = Point->unpack({ __CLASS__ => 'Point-0.01', x => 10, y => 10 }); ## methods to freeze/thaw into ## a specified serialization format ## (in this case JSON) # pack the class into a JSON string $p->freeze(); # { "__CLASS__" : "Point-0.01", "x" : 10, "y" : 10 } # unpack the JSON string into a class my $p2 = Point->thaw('{ "__CLASS__" : "Point-0.01", "x" : 10, "y" : 10 }'); ## methods to load/store a class ## on the file system $p->store('my_point.json'); my $p2 = Point->load('my_point.json'); =head1 DESCRIPTION MooseX::Storage is a serialization framework for Moose, it provides a very flexible and highly pluggable way to serialize Moose classes to a number of different formats and styles. =head2 Important Note This is still an early release of this module, so use with caution. It's outward facing serialization API should be considered stable, but I still reserve the right to make tweaks if I need too. Anything beyond the basic pack/unpack, freeze/thaw and load/store should not be relied on. =head2 Levels of Serialization There are 3 levels to the serialization, each of which builds upon the other and each of which can be customized to the specific needs of your class. =over 4 =item B The first (base) level is C and C. In this level the class is serialized into a Perl HASH reference, it is tagged with the class name and each instance attribute is stored. Very simple. This level is not optional, it is the bare minimum that MooseX::Storage provides and all other levels build on top of this. See L for the fundamental implementation and options to C and C =item B The second (format) level is C and C. In this level the output of C is sent to C or the output of C is sent to C. This levels primary role is to convert to and from the specific serialization format and Perl land. This level is optional, if you don't want/need it, you don't have to have it. You can just use C/C instead. =item B The third (io) level is C and C. In this level we are reading and writing data to file/network/database/etc. This level is also optional, in most cases it does require a C role to also be used, the exception being the C role. =back =head2 Behaviour modifiers The serialization behaviour can be changed by supplying C. This can be done as follows: use MooseX::Storage; with Storage( traits => [Trait1, Trait2,...] ); The following traits are currently bundled with C: =over 4 =item OnlyWhenBuilt Only attributes that have been built (i.e., where the predicate returns 'true') will be serialized. This avoids any potentially expensive computations. See L for details. =back =head2 How we serialize There are always limits to any serialization framework, there are just some things which are really difficult to serialize properly and some things which cannot be serialized at all. =head2 What can be serialized? Currently only numbers, string, ARRAY refs, HASH refs and other MooseX::Storage enabled objects are supported. With Array and Hash references the first level down is inspected and any objects found are serialized/deserialized for you. We do not do this recursively by default, however this feature may become an option eventually. The specific serialize/deserialize routine is determined by the Moose type constraint a specific attribute has. In most cases subtypes of the supported types are handled correctly, and there is a facility for adding handlers for custom types as well. This will get documented eventually, but it is currently still in development. =head2 What can not be serialized? We do not support CODE references yet, but this support might be added in using B::Deparse or some other deep magic. Scalar refs are not supported, mostly because there is no way to know if the value being referenced will be there when the object is inflated. I highly doubt will be ever support this in a general sense, but it would be possible to add this yourself for a small specific case. Circular references are specifically disallowed, however if you break the cycles yourself then re-assemble them later you can get around this. The reason we disallow circular refs is because they are not always supported in all formats we use, and they tend to be very tricky to do for all possible cases. It is almost always something you want to have tight control over anyway. =head1 CAVEAT This is B a persistence framework; changes to your object after you load or store it will not be reflected in the stored class. =head1 EXPORTS =over 4 =item B This module will export the C method and can be used to load a specific set of MooseX::Storage roles to implement a specific combination of features. It is meant to make things easier, but it is by no means the only way. You can still compose your roles by hand if you like. By default, options are assumed to be short forms. For example, this: Storage(format => 'JSON'); ...will result in looking for MooseX::Storage::Format::JSON. To use a role that is not under the default namespace prefix, start with an equal sign: Storage(format => '=My::Private::JSONFormat'); To use a parameterized role (for which, see L) you can pass an arrayref of the role name (in short or long form, as above) and its parameters: Storage(format => [ JSONpm => { json_opts => { pretty => 1 } } ]); =back =head1 METHODS =over 4 =item B =back =head2 Introspection =over 4 =item B =back =head1 TODO This module needs docs and probably a Cookbook of some kind as well. This is an early release, so that is my excuse for now :) For the time being, please read the tests and feel free to email me if you have any questions. This module can also be discussed on IRC in the #moose channel on irc.perl.org. =head1 BUGS All complex software has bugs lurking in it, and this module is no exception. If you find a bug please either email me, or add the bug to cpan-RT. =head1 AUTHORS =over 4 =item * Chris Prather =item * Stevan Little =item * יובל קוג'מן (Yuval Kogman) =back =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2007 by Infinity Interactive, Inc.. 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 CONTRIBUTORS =over 4 =item * Chris Prather =item * Cory Watson =item * Dagfinn Ilmari Mannsåker =item * David Golden =item * David Steinbrunner =item * Florian Ragwitz =item * Johannes Plunien =item * Jonathan Rockway =item * Jonathan Yu =item * Jos Boumans =item * Karen Etheridge =item * Ricardo Signes =item * Robert Boone =item * Shawn M Moore =item * Tomas Doran =item * Yuval Kogman =back =cut MooseX-Storage-0.45/lib/MooseX/Storage/Base/000755 000767 000024 00000000000 12255433343 020774 5ustar00etherstaff000000 000000 MooseX-Storage-0.45/lib/MooseX/Storage/Basic.pm000644 000767 000024 00000007604 12255433343 021510 0ustar00etherstaff000000 000000 package MooseX::Storage::Basic; { $MooseX::Storage::Basic::VERSION = '0.45'; } BEGIN { $MooseX::Storage::Basic::AUTHORITY = 'cpan:STEVAN'; } # ABSTRACT: The simplest level of serialization use Moose::Role; use MooseX::Storage::Engine; use String::RewritePrefix; sub pack { my ( $self, %args ) = @_; my $e = $self->_storage_get_engine_class(%args)->new( object => $self ); $e->collapse_object(%args); } sub unpack { my ($class, $data, %args) = @_; my $e = $class->_storage_get_engine_class(%args)->new(class => $class); $class->_storage_construct_instance( $e->expand_object($data, %args), \%args ); } sub _storage_get_engine_class { my ($self, %args) = @_; return 'MooseX::Storage::Engine' unless ( exists $args{engine_traits} && ref($args{engine_traits}) eq 'ARRAY' && scalar(@{$args{engine_traits}}) ); my @roles = String::RewritePrefix->rewrite( { '' => 'MooseX::Storage::Engine::Trait::', '+' => '', }, @{$args{engine_traits}} ); Moose::Meta::Class->create_anon_class( superclasses => ['MooseX::Storage::Engine'], roles => [ @roles ], cache => 1, )->name; } sub _storage_construct_instance { my ($class, $args, $opts) = @_; my %i = defined $opts->{'inject'} ? %{ $opts->{'inject'} } : (); $class->new( %$args, %i ); } no Moose::Role; 1; __END__ =pod =encoding UTF-8 =for :stopwords Chris Prather Stevan Little יובל קוג'מן (Yuval Kogman) Infinity Interactive, Inc. Florian Ragwitz Johannes Plunien Jonathan Rockway Yu Jos Boumans Karen Etheridge Ricardo Signes Robert Boone Shawn M Moore Tomas Doran Cory Yuval Kogman Watson Dagfinn Ilmari Mannsåker David Golden Steinbrunner =head1 NAME MooseX::Storage::Basic - The simplest level of serialization =head1 VERSION version 0.45 =head1 SYNOPSIS package Point; use Moose; use MooseX::Storage; with Storage; has 'x' => (is => 'rw', isa => 'Int'); has 'y' => (is => 'rw', isa => 'Int'); 1; my $p = Point->new(x => 10, y => 10); ## methods to pack/unpack an ## object in perl data structures # pack the class into a hash $p->pack(); # { __CLASS__ => 'Point-0.01', x => 10, y => 10 } # unpack the hash into a class my $p2 = Point->unpack({ __CLASS__ => 'Point-0.01', x => 10, y => 10 }); # unpack the hash, with insertion of paramaters my $p3 = Point->unpack( $p->pack, inject => { x => 11 } ); =head1 DESCRIPTION This is the most basic form of serialization. This is used by default but the exported C function. =head1 METHODS =over 4 =item B 1])> Providing the C argument disables checks for any cyclical references. The current implementation for this check is rather naive, so if you know what you are doing, you can bypass this check. This trait is applied on a perl-case basis. To set this flag for all objects that inherit from this role, see L. =item B { key => val, ... } ] )> Providing the C argument let's you supply additional arguments to the class' C function, or override ones from the serialized data. =back =head2 Introspection =over 4 =item B =back =head1 BUGS All complex software has bugs lurking in it, and this module is no exception. If you find a bug please either email me, or add the bug to cpan-RT. =head1 AUTHORS =over 4 =item * Chris Prather =item * Stevan Little =item * יובל קוג'מן (Yuval Kogman) =back =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2007 by Infinity Interactive, Inc.. 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-Storage-0.45/lib/MooseX/Storage/Deferred.pm000644 000767 000024 00000010076 12255433343 022204 0ustar00etherstaff000000 000000 package MooseX::Storage::Deferred; { $MooseX::Storage::Deferred::VERSION = '0.45'; } BEGIN { $MooseX::Storage::Deferred::AUTHORITY = 'cpan:STEVAN'; } # ABSTRACT: A role for indecisive programmers use Moose::Role; with 'MooseX::Storage::Basic'; sub __get_method { my ( $self, $basename, $value, $method_name ) = @_; my $role = MooseX::Storage->_expand_role($basename => $value)->meta; my $method = $role->get_method($method_name)->body; } sub thaw { my ( $class, $packed, $type, @args ) = @_; (exists $type->{format}) || confess "You must specify a format type to thaw from"; my $code = $class->__get_method(Format => $type->{format} => 'thaw'); $class->$code($packed, @args); } sub freeze { my ( $self, $type, @args ) = @_; (exists $type->{format}) || confess "You must specify a format type to freeze into"; my $code = $self->__get_method(Format => $type->{format} => 'freeze'); $self->$code(@args); } sub load { my ( $class, $filename, $type, @args ) = @_; (exists $type->{io}) || confess "You must specify an I/O type to load with"; my $code = $class->__get_method(IO => $type->{io} => 'load'); $class->$code($filename, $type, @args); } sub store { my ( $self, $filename, $type, @args ) = @_; (exists $type->{io}) || confess "You must specify an I/O type to store with"; my $code = $self->__get_method(IO => $type->{io} => 'store'); $self->$code($filename, $type, @args); } no Moose::Role; 1; __END__ =pod =encoding UTF-8 =for :stopwords Chris Prather Stevan Little יובל קוג'מן (Yuval Kogman) Infinity Interactive, Inc. JSONpm =head1 NAME MooseX::Storage::Deferred - A role for indecisive programmers =head1 VERSION version 0.45 =head1 SYNOPSIS package Point; use Moose; use MooseX::Storage; with 'MooseX::Storage::Deferred'; has 'x' => (is => 'rw', isa => 'Int'); has 'y' => (is => 'rw', isa => 'Int'); 1; my $p = Point->new(x => 10, y => 10); ## methods to freeze/thaw into ## a specified serialization format ## (in this case JSON) # pack the class into a JSON string $p->freeze({ format => 'JSON' }); # { "__CLASS__" : "Point", "x" : 10, "y" : 10 } # pack the class into a JSON string using parameterized JSONpm role $p->freeze({ format => [ JSONpm => { json_opts => { pretty => 1 } } ] }); # unpack the JSON string into a class my $p2 = Point->thaw( '{ "__CLASS__" : "Point", "x" : 10, "y" : 10 }', { format => 'JSON' } ); =head1 DESCRIPTION This role is designed for those times when you need to serialize into many different formats or I/O options. It basically allows you to choose the format and IO options only when you actually use them (see the SYNOPSIS for more info) =head1 SUPPORTED FORMATS =over 4 =item I =item I =item I =item I =back =head1 SUPPORTED I/O =over 4 =item I =item I =back B The B I/O option is not supported, this is because it does not mix well with options who also have a C and C methods like this. It is possible to probably work around this issue, but I don't currently have the need for it. If you need this supported, talk to me and I will see what I can do. =head1 METHODS =over 4 =item B =item B =item B =item B =back =head2 Introspection =over 4 =item B =back =head1 BUGS All complex software has bugs lurking in it, and this module is no exception. If you find a bug please either email me, or add the bug to cpan-RT. =head1 AUTHORS =over 4 =item * Chris Prather =item * Stevan Little =item * יובל קוג'מן (Yuval Kogman) =back =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2007 by Infinity Interactive, Inc.. 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-Storage-0.45/lib/MooseX/Storage/Engine/000755 000767 000024 00000000000 12255433343 021327 5ustar00etherstaff000000 000000 MooseX-Storage-0.45/lib/MooseX/Storage/Engine.pm000644 000767 000024 00000035451 12255433343 021675 0ustar00etherstaff000000 000000 package MooseX::Storage::Engine; { $MooseX::Storage::Engine::VERSION = '0.45'; } BEGIN { $MooseX::Storage::Engine::AUTHORITY = 'cpan:STEVAN'; } # ABSTRACT: The meta-engine to handle collapsing and expanding objects use Moose; use Scalar::Util qw(refaddr); # the class marker when # serializing an object. our $CLASS_MARKER = '__CLASS__'; has 'storage' => ( is => 'ro', isa => 'HashRef', default => sub {{}} ); has 'seen' => ( is => 'ro', isa => 'HashRef[Int]', # int is the refaddr default => sub {{}} ); has 'object' => (is => 'rw', isa => 'Object', predicate => '_has_object'); has 'class' => (is => 'rw', isa => 'Str'); ## this is the API used by other modules ... sub collapse_object { my ( $self, %options ) = @_; # NOTE: # mark the root object as seen ... $self->seen->{refaddr $self->object} = undef; $self->map_attributes('collapse_attribute', \%options); $self->storage->{$CLASS_MARKER} = $self->object->meta->identifier; return $self->storage; } sub expand_object { my ($self, $data, %options) = @_; $options{check_version} = 1 unless exists $options{check_version}; $options{check_authority} = 1 unless exists $options{check_authority}; # NOTE: # mark the root object as seen ... $self->seen->{refaddr $data} = undef; $self->map_attributes('expand_attribute', $data, \%options); return $self->storage; } ## this is the internal API ... sub collapse_attribute { my ($self, $attr, $options) = @_; my $value = $self->collapse_attribute_value($attr, $options); return if !defined($value); $self->storage->{$attr->name} = $value; } sub expand_attribute { my ($self, $attr, $data, $options) = @_; my $value = $self->expand_attribute_value($attr, $data->{$attr->name}, $options); $self->storage->{$attr->name} = defined $value ? $value : return; } sub collapse_attribute_value { my ($self, $attr, $options) = @_; # Faster, but breaks attributes without readers, do we care? #my $value = $attr->get_read_method_ref->($self->object); my $value = $attr->get_value($self->object); # NOTE: # this might not be enough, we might # need to make it possible for the # cycle checker to return the value $self->check_for_cycle_in_collapse($attr, $value) if ref $value; if (defined $value && $attr->has_type_constraint) { my $type_converter = $self->find_type_handler($attr->type_constraint, $value); (defined $type_converter) || confess "Cannot convert " . $attr->type_constraint->name; $value = $type_converter->{collapse}->($value, $options); } return $value; } sub expand_attribute_value { my ($self, $attr, $value, $options) = @_; # NOTE: # (see comment in method above ^^) if( ref $value and not( $options->{disable_cycle_check} or $self->class->does('MooseX::Storage::Traits::DisableCycleDetection') )) { $self->check_for_cycle_in_collapse($attr, $value) } if (defined $value && $attr->has_type_constraint) { my $type_converter = $self->find_type_handler($attr->type_constraint, $value); $value = $type_converter->{expand}->($value, $options); } return $value; } # NOTE: # possibly these two methods will # be used by a cycle supporting # engine. However, I am not sure # if I can make a cycle one work # anyway. sub check_for_cycle_in_collapse { my ($self, $attr, $value) = @_; (!exists $self->seen->{refaddr $value}) || confess "Basic Engine does not support cycles in class(" . ($attr->associated_class->name) . ").attr(" . ($attr->name) . ") with $value"; $self->seen->{refaddr $value} = undef; } sub check_for_cycle_in_expansion { my ($self, $attr, $value) = @_; (!exists $self->seen->{refaddr $value}) || confess "Basic Engine does not support cycles in class(" . ($attr->associated_class->name) . ").attr(" . ($attr->name) . ") with $value"; $self->seen->{refaddr $value} = undef; } # util methods ... sub map_attributes { my ($self, $method_name, @args) = @_; map { $self->$method_name($_, @args) } grep { # Skip our special skip attribute :) !$_->does('MooseX::Storage::Meta::Attribute::Trait::DoNotSerialize') } ($self->_has_object ? $self->object : $self->class)->meta->get_all_attributes; } ## ------------------------------------------------------------------ ## This is all the type handler stuff, it is in a state of flux ## right now, so this may change, or it may just continue to be ## improved upon. Comments and suggestions are welcomed. ## ------------------------------------------------------------------ # NOTE: # these are needed by the # ArrayRef and HashRef handlers # below, so I need easy access my %OBJECT_HANDLERS = ( expand => sub { my ($data, $options) = @_; (exists $data->{$CLASS_MARKER}) || confess "Serialized item has no class marker"; # check the class more thoroughly here ... my ($class, $version, $authority) = (split '-' => $data->{$CLASS_MARKER}); my $meta = eval { $class->meta }; confess "Class ($class) is not loaded, cannot unpack" if $@; if ($options->{check_version}) { my $meta_version = $meta->version; if (defined $meta_version && $version) { if ($options->{check_version} eq 'allow_less_than') { ($meta_version <= $version) || confess "Class ($class) versions is not less than currently available." . " got=($version) available=($meta_version)"; } elsif ($options->{check_version} eq 'allow_greater_than') { ($meta->version >= $version) || confess "Class ($class) versions is not greater than currently available." . " got=($version) available=($meta_version)"; } else { ($meta->version == $version) || confess "Class ($class) versions don't match." . " got=($version) available=($meta_version)"; } } } if ($options->{check_authority}) { my $meta_authority = $meta->authority; ($meta->authority eq $authority) || confess "Class ($class) authorities don't match." . " got=($authority) available=($meta_authority)" if defined $meta_authority && defined $authority; } # all is well ... $class->unpack($data, %$options); }, collapse => sub { my ( $obj, $options ) = @_; # ($obj->can('does') && $obj->does('MooseX::Storage::Basic')) # || confess "Bad object ($obj) does not do MooseX::Storage::Basic role"; ($obj->can('pack')) || confess "Object ($obj) does not have a &pack method, cannot collapse"; $obj->pack(%$options); }, ); my %TYPES = ( # NOTE: # we need to make sure that we properly numify the numbers # before and after them being futzed with, because some of # the JSON engines are stupid/annoying/frustrating 'Int' => { expand => sub { $_[0] + 0 }, collapse => sub { $_[0] + 0 } }, 'Num' => { expand => sub { $_[0] + 0 }, collapse => sub { $_[0] + 0 } }, # These are boring ones, so they use the identity function ... 'Str' => { expand => sub { shift }, collapse => sub { shift } }, 'Value' => { expand => sub { shift }, collapse => sub { shift } }, 'Bool' => { expand => sub { shift }, collapse => sub { shift } }, # These are the trickier ones, (see notes) # NOTE: # Because we are nice guys, we will check # your ArrayRef and/or HashRef one level # down and inflate any objects we find. # But this is where it ends, it is too # expensive to try and do this any more # recursively, when it is probably not # nessecary in most of the use cases. # However, if you need more then this, subtype # and add a custom handler. 'ArrayRef' => { expand => sub { my ( $array, @args ) = @_; foreach my $i (0 .. $#{$array}) { next unless ref($array->[$i]) eq 'HASH' && exists $array->[$i]->{$CLASS_MARKER}; $array->[$i] = $OBJECT_HANDLERS{expand}->($array->[$i], @args); } $array; }, collapse => sub { my ( $array, @args ) = @_; # NOTE: # we need to make a copy because # otherwise it will affect the # other real version. [ map { blessed($_) ? $OBJECT_HANDLERS{collapse}->($_, @args) : $_ } @$array ] } }, 'HashRef' => { expand => sub { my ( $hash, @args ) = @_; foreach my $k (keys %$hash) { next unless ref($hash->{$k}) eq 'HASH' && exists $hash->{$k}->{$CLASS_MARKER}; $hash->{$k} = $OBJECT_HANDLERS{expand}->($hash->{$k}, @args); } $hash; }, collapse => sub { my ( $hash, @args ) = @_; # NOTE: # we need to make a copy because # otherwise it will affect the # other real version. +{ map { blessed($hash->{$_}) ? ($_ => $OBJECT_HANDLERS{collapse}->($hash->{$_}, @args)) : ($_ => $hash->{$_}) } keys %$hash } } }, 'Object' => \%OBJECT_HANDLERS, # NOTE: # The sanity of enabling this feature by # default is very questionable. # - SL #'CodeRef' => { # expand => sub {}, # use eval ... # collapse => sub {}, # use B::Deparse ... #} ); sub add_custom_type_handler { my ($self, $type_name, %handlers) = @_; (exists $handlers{expand} && exists $handlers{collapse}) || confess "Custom type handlers need an expand *and* a collapse method"; $TYPES{$type_name} = \%handlers; } sub remove_custom_type_handler { my ($self, $type_name) = @_; delete $TYPES{$type_name} if exists $TYPES{$type_name}; } sub find_type_handler { my ($self, $type_constraint, $value) = @_; # check if the type is a Maybe and # if its parent is not parameterized. # If both is true recurse this method # using ->type_parameter. return $self->find_type_handler($type_constraint->type_parameter, $value) if ($type_constraint->parent && $type_constraint->parent eq 'Maybe' and not $type_constraint->parent->can('type_parameter')); # find_type_for is a method of a union type. If we can call that method # then we are dealign with a union and we need to ascertain which of # the union's types we need to use for the value we are serializing. if($type_constraint->can('find_type_for')) { my $tc = $type_constraint->find_type_for($value); return $self->find_type_handler($tc, $value) if defined($tc); } # this should handle most type usages # since they they are usually just # the standard set of built-ins return $TYPES{$type_constraint->name} if exists $TYPES{$type_constraint->name}; # the next possibility is they are # a subtype of the built-in types, # in which case this will DWIM in # most cases. It is probably not # 100% ideal though, but until I # come up with a decent test case # it will do for now. We need to # check more-specific types first. my %seen; my @fallback = grep { !$seen{$_}++ } qw/Int Num Str Value/, keys %TYPES; foreach my $type ( @fallback ) { return $TYPES{$type} if $type_constraint->is_subtype_of($type); } # NOTE: # the reason the above will work has to # do with the fact that custom subtypes # are mostly used for validation of # the guts of a type, and not for some # weird structural thing which would # need to be accomidated by the serializer. # Of course, mst or phaylon will probably # do something to throw this assumption # totally out the door ;) # - SL # NOTE: # if this method hasnt returned by now # then we have no been able to find a # type constraint handler to match confess "Cannot handle type constraint (" . $type_constraint->name . ")"; } sub find_type_handler_for { my ($self, $type_handler_name) = @_; $TYPES{$type_handler_name} } no Moose::Role; 1; __END__ =pod =encoding UTF-8 =for :stopwords Chris Prather Stevan Little יובל קוג'מן (Yuval Kogman) Infinity Interactive, Inc. Florian Ragwitz Johannes Plunien Jonathan Rockway Yu Jos Boumans Karen Etheridge Ricardo Signes Robert Boone Shawn M Moore Tomas Doran Cory Yuval Kogman Watson Dagfinn Ilmari Mannsåker David Golden Steinbrunner =head1 NAME MooseX::Storage::Engine - The meta-engine to handle collapsing and expanding objects =head1 VERSION version 0.45 =head1 DESCRIPTION There really aren't any major user serviceable parts here. However the typical use case is adding new non-Moose classes to the type registry for serialization. Here is an example of this for DateTime objects. This assumes a C type has been registered. MooseX::Storage::Engine->add_custom_type_handler( 'DateTime' => ( expand => sub { DateTime->new(shift) }, collapse => sub { (shift)->iso8601 }, ) ); =head1 METHODS =head2 Accessors =over 4 =item B =item B =item B =item B =back =head2 API =over 4 =item B =item B =back =head2 ... =over 4 =item B =item B =item B =item B =item B =item B =item B =back =head2 Type Constraint Handlers =over 4 =item B =item B =item B =item B =back =head2 Introspection =over 4 =item B =back =head1 BUGS All complex software has bugs lurking in it, and this module is no exception. If you find a bug please either email me, or add the bug to cpan-RT. =head1 AUTHORS =over 4 =item * Chris Prather =item * Stevan Little =item * יובל קוג'מן (Yuval Kogman) =back =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2007 by Infinity Interactive, Inc.. 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-Storage-0.45/lib/MooseX/Storage/Format/000755 000767 000024 00000000000 12255433343 021352 5ustar00etherstaff000000 000000 MooseX-Storage-0.45/lib/MooseX/Storage/IO/000755 000767 000024 00000000000 12255433343 020431 5ustar00etherstaff000000 000000 MooseX-Storage-0.45/lib/MooseX/Storage/Meta/000755 000767 000024 00000000000 12255433343 021010 5ustar00etherstaff000000 000000 MooseX-Storage-0.45/lib/MooseX/Storage/Traits/000755 000767 000024 00000000000 12255433343 021370 5ustar00etherstaff000000 000000 MooseX-Storage-0.45/lib/MooseX/Storage/Util.pm000644 000767 000024 00000007271 12255433343 021404 0ustar00etherstaff000000 000000 package MooseX::Storage::Util; { $MooseX::Storage::Util::VERSION = '0.45'; } BEGIN { $MooseX::Storage::Util::AUTHORITY = 'cpan:STEVAN'; } # ABSTRACT: A MooseX::Storage Swiss Army chainsaw use Moose qw(confess blessed); use MooseX::Storage::Engine (); sub peek { my ($class, $data, %options) = @_; if (exists $options{'format'}) { my $inflater = $class->can('_inflate_' . lc($options{'format'})); (defined $inflater) || confess "No inflater found for " . $options{'format'}; $data = $class->$inflater($data); } (ref($data) && ref($data) eq 'HASH' && !blessed($data)) || confess "The data has to be a HASH reference, but not blessed"; $options{'key'} ||= $MooseX::Storage::Engine::CLASS_MARKER; return $data->{$options{'key'}}; } sub _inflate_json { my ($self, $json) = @_; eval { require JSON::Any; JSON::Any->import }; confess "Could not load JSON module because : $@" if $@; utf8::encode($json) if utf8::is_utf8($json); my $data = eval { JSON::Any->jsonToObj($json) }; if ($@) { confess "There was an error when attempting to peek at JSON: $@"; } return $data; } sub _inflate_yaml { my ($self, $yaml) = @_; eval { require YAML::Any; YAML::Any->import }; confess "Could not load YAML module because : $@" if $@; my $data = eval { Load($yaml) }; if ($@) { confess "There was an error when attempting to peek at YAML : $@"; } return $data; } no Moose::Role; 1; __END__ =pod =encoding UTF-8 =for :stopwords Chris Prather Stevan Little יובל קוג'מן (Yuval Kogman) Infinity Interactive, Inc. Florian Ragwitz Johannes Plunien Jonathan Rockway Yu Jos Boumans Karen Etheridge Ricardo Signes Robert Boone Shawn M Moore Tomas Doran Cory Yuval Kogman Watson Dagfinn Ilmari Mannsåker David Golden Steinbrunner TODO =head1 NAME MooseX::Storage::Util - A MooseX::Storage Swiss Army chainsaw =head1 VERSION version 0.45 =head1 DESCRIPTION This module provides a set of tools, some sharp and focused, others more blunt and crude. But no matter what, they are useful bits to have around when dealing with MooseX::Storage code. =head1 METHODS All the methods in this package are class methods and should be called appropriately. =over 4 =item B This method will help you to verify that the serialized class you have gotten is what you expect it to be before you actually unfreeze/unpack it. The C<$data> can be either a perl HASH ref or some kind of serialized data (JSON, YAML, etc.). The C<%options> are as follows: =over 4 =item I If this is left blank, we assume that C<$data> is a plain perl HASH ref otherwise we attempt to inflate C<$data> based on the value of this option. Currently only JSON and YAML are supported here. =item I The default is to try and extract the class name, but if you want to check another key in the data, you can set this option. It will return the value found in the key for you. =back =back =head2 Introspection =over 4 =item B =back =head1 TODO Add more stuff to this module :) =head1 BUGS All complex software has bugs lurking in it, and this module is no exception. If you find a bug please either email me, or add the bug to cpan-RT. =head1 AUTHORS =over 4 =item * Chris Prather =item * Stevan Little =item * יובל קוג'מן (Yuval Kogman) =back =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2007 by Infinity Interactive, Inc.. 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-Storage-0.45/lib/MooseX/Storage/Traits/DisableCycleDetection.pm000644 000767 000024 00000005321 12255433343 026111 0ustar00etherstaff000000 000000 package MooseX::Storage::Traits::DisableCycleDetection; { $MooseX::Storage::Traits::DisableCycleDetection::VERSION = '0.45'; } BEGIN { $MooseX::Storage::Traits::DisableCycleDetection::AUTHORITY = 'cpan:STEVAN'; } # ABSTRACT: A custom trait to bypass cycle detection use Moose::Role; requires 'pack'; requires 'unpack'; around 'pack' => sub { my ($orig, $self, %args) = @_; $args{engine_traits} ||= []; push(@{$args{engine_traits}}, 'DisableCycleDetection'); $self->$orig(%args); }; around 'unpack' => sub { my ($orig, $self, $data, %args) = @_; $args{engine_traits} ||= []; push(@{$args{engine_traits}}, 'DisableCycleDetection'); $self->$orig($data, %args); }; no Moose::Role; 1; __END__ =pod =encoding UTF-8 =for :stopwords Chris Prather Stevan Little יובל קוג'מן (Yuval Kogman) Infinity Interactive, Inc. Florian Ragwitz Johannes Plunien Jonathan Rockway Yu Jos Boumans Karen Etheridge Ricardo Signes Robert Boone Shawn M Moore Tomas Doran Cory Yuval Kogman Watson Dagfinn Ilmari Mannsåker David Golden Steinbrunner culted =head1 NAME MooseX::Storage::Traits::DisableCycleDetection - A custom trait to bypass cycle detection =head1 VERSION version 0.45 =head1 SYNOPSIS package Double; use Moose; use MooseX::Storage; with Storage( traits => ['DisableCycleDetection'] ); has 'x' => ( is => 'rw', isa => 'HashRef' ); has 'y' => ( is => 'rw', isa => 'HashRef' ); my $ref = {}; my $double = Double->new( 'x' => $ref, 'y' => $ref ); $double->pack; =head1 DESCRIPTION C implements a primitive check for circular references. This check also triggers on simple cases as shown in the Synopsis. Providing the C traits disables checks for any cyclical references, so if you know what you are doing, you can bypass this check. This trait is applied to all objects that inherit from it. To use this on a per-case basis, see C in L. See the SYNOPSIS for a nice example that can be easily cargo-culted. =head1 METHODS =head2 Introspection =over 4 =item B =back =head1 BUGS All complex software has bugs lurking in it, and this module is no exception. If you find a bug please either email me, or add the bug to cpan-RT. =head1 AUTHORS =over 4 =item * Chris Prather =item * Stevan Little =item * יובל קוג'מן (Yuval Kogman) =back =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2007 by Infinity Interactive, Inc.. 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-Storage-0.45/lib/MooseX/Storage/Traits/OnlyWhenBuilt.pm000644 000767 000024 00000005355 12255433343 024501 0ustar00etherstaff000000 000000 package MooseX::Storage::Traits::OnlyWhenBuilt; { $MooseX::Storage::Traits::OnlyWhenBuilt::VERSION = '0.45'; } BEGIN { $MooseX::Storage::Traits::OnlyWhenBuilt::AUTHORITY = 'cpan:STEVAN'; } # ABSTRACT: A custom trait to bypass serialization use Moose::Role; requires 'pack'; requires 'unpack'; around 'pack' => sub { my ($orig, $self, %args) = @_; $args{engine_traits} ||= []; push(@{$args{engine_traits}}, 'OnlyWhenBuilt'); $self->$orig(%args); }; around 'unpack' => sub { my ($orig, $self, $data, %args) = @_; $args{engine_traits} ||= []; push(@{$args{engine_traits}}, 'OnlyWhenBuilt'); $self->$orig($data, %args); }; no Moose::Role; 1; __END__ =pod =encoding UTF-8 =for :stopwords Chris Prather Stevan Little יובל קוג'מן (Yuval Kogman) Infinity Interactive, Inc. Florian Ragwitz Johannes Plunien Jonathan Rockway Yu Jos Boumans Karen Etheridge Ricardo Signes Robert Boone Shawn M Moore Tomas Doran Cory Yuval Kogman Watson Dagfinn Ilmari Mannsåker David Golden Steinbrunner culted =head1 NAME MooseX::Storage::Traits::OnlyWhenBuilt - A custom trait to bypass serialization =head1 VERSION version 0.45 =head1 SYNOPSIS { package Point; use Moose; use MooseX::Storage; with Storage( traits => [qw|OnlyWhenBuilt|] ); has 'x' => (is => 'rw', lazy_build => 1 ); has 'y' => (is => 'rw', lazy_build => 1 ); has 'z' => (is => 'rw', builder => '_build_z' ); sub _build_x { 3 } sub _build_y { expensive_computation() } sub _build_z { 3 } } my $p = Point->new( 'x' => 4 ); # the result of ->pack will contain: # { x => 4, z => 3 } $p->pack; =head1 DESCRIPTION Sometimes you don't want a particular attribute to be part of the serialization if it has not been built yet. If you invoke C as outlined in the C, only attributes that have been built (i.e., where the predicate returns 'true') will be serialized. This avoids any potentially expensive computations. See the SYNOPSIS for a nice example that can be easily cargo-culted. =head1 METHODS =head2 Introspection =over 4 =item B =back =head1 BUGS All complex software has bugs lurking in it, and this module is no exception. If you find a bug please either email me, or add the bug to cpan-RT. =head1 AUTHORS =over 4 =item * Chris Prather =item * Stevan Little =item * יובל קוג'מן (Yuval Kogman) =back =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2007 by Infinity Interactive, Inc.. 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-Storage-0.45/lib/MooseX/Storage/Meta/Attribute/000755 000767 000024 00000000000 12255433343 022753 5ustar00etherstaff000000 000000 MooseX-Storage-0.45/lib/MooseX/Storage/Meta/Attribute/DoNotSerialize.pm000644 000767 000024 00000004706 12255433343 026213 0ustar00etherstaff000000 000000 package MooseX::Storage::Meta::Attribute::DoNotSerialize; { $MooseX::Storage::Meta::Attribute::DoNotSerialize::VERSION = '0.45'; } BEGIN { $MooseX::Storage::Meta::Attribute::DoNotSerialize::AUTHORITY = 'cpan:STEVAN'; } # ABSTRACT: A custom meta-attribute to bypass serialization use Moose; extends 'Moose::Meta::Attribute'; with 'MooseX::Storage::Meta::Attribute::Trait::DoNotSerialize'; # register this alias ... package Moose::Meta::Attribute::Custom::DoNotSerialize; { $Moose::Meta::Attribute::Custom::DoNotSerialize::VERSION = '0.45'; } BEGIN { $Moose::Meta::Attribute::Custom::DoNotSerialize::AUTHORITY = 'cpan:STEVAN'; } sub register_implementation { 'MooseX::Storage::Meta::Attribute::DoNotSerialize' } 1; __END__ =pod =encoding UTF-8 =for :stopwords Chris Prather Stevan Little יובל קוג'מן (Yuval Kogman) Infinity Interactive, Inc. Florian Ragwitz Johannes Plunien Jonathan Rockway Yu Jos Boumans Karen Etheridge Ricardo Signes Robert Boone Shawn M Moore Tomas Doran Cory Yuval Kogman Watson Dagfinn Ilmari Mannsåker David Golden Steinbrunner culted =head1 NAME MooseX::Storage::Meta::Attribute::DoNotSerialize - A custom meta-attribute to bypass serialization =head1 VERSION version 0.45 =head1 SYNOPSIS package Point; use Moose; use MooseX::Storage; with Storage('format' => 'JSON', 'io' => 'File'); has 'x' => (is => 'rw', isa => 'Int'); has 'y' => (is => 'rw', isa => 'Int'); has 'foo' => ( metaclass => 'DoNotSerialize', is => 'rw', isa => 'CodeRef', ); 1; =head1 DESCRIPTION Sometimes you don't want a particular attribute to be part of the serialization, in this case, you want to make sure that attribute uses this custom meta-attribute. See the SYNOPSIS for a nice example that can be easily cargo-culted. =head1 METHODS =head2 Introspection =over 4 =item B =back =head1 BUGS All complex software has bugs lurking in it, and this module is no exception. If you find a bug please either email me, or add the bug to cpan-RT. =head1 AUTHORS =over 4 =item * Chris Prather =item * Stevan Little =item * יובל קוג'מן (Yuval Kogman) =back =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2007 by Infinity Interactive, Inc.. 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-Storage-0.45/lib/MooseX/Storage/Meta/Attribute/Trait/000755 000767 000024 00000000000 12255433343 024036 5ustar00etherstaff000000 000000 MooseX-Storage-0.45/lib/MooseX/Storage/Meta/Attribute/Trait/DoNotSerialize.pm000644 000767 000024 00000004654 12255433343 027300 0ustar00etherstaff000000 000000 package MooseX::Storage::Meta::Attribute::Trait::DoNotSerialize; { $MooseX::Storage::Meta::Attribute::Trait::DoNotSerialize::VERSION = '0.45'; } BEGIN { $MooseX::Storage::Meta::Attribute::Trait::DoNotSerialize::AUTHORITY = 'cpan:STEVAN'; } # ABSTRACT: A custom meta-attribute-trait to bypass serialization use Moose::Role; # register this alias ... package Moose::Meta::Attribute::Custom::Trait::DoNotSerialize; { $Moose::Meta::Attribute::Custom::Trait::DoNotSerialize::VERSION = '0.45'; } BEGIN { $Moose::Meta::Attribute::Custom::Trait::DoNotSerialize::AUTHORITY = 'cpan:STEVAN'; } sub register_implementation { 'MooseX::Storage::Meta::Attribute::Trait::DoNotSerialize' } 1; __END__ =pod =encoding UTF-8 =for :stopwords Chris Prather Stevan Little יובל קוג'מן (Yuval Kogman) Infinity Interactive, Inc. Florian Ragwitz Johannes Plunien Jonathan Rockway Yu Jos Boumans Karen Etheridge Ricardo Signes Robert Boone Shawn M Moore Tomas Doran Cory Yuval Kogman Watson Dagfinn Ilmari Mannsåker David Golden Steinbrunner culted =head1 NAME MooseX::Storage::Meta::Attribute::Trait::DoNotSerialize - A custom meta-attribute-trait to bypass serialization =head1 VERSION version 0.45 =head1 SYNOPSIS package Point; use Moose; use MooseX::Storage; with Storage('format' => 'JSON', 'io' => 'File'); has 'x' => (is => 'rw', isa => 'Int'); has 'y' => (is => 'rw', isa => 'Int'); has 'foo' => ( traits => [ 'DoNotSerialize' ], is => 'rw', isa => 'CodeRef', ); 1; =head1 DESCRIPTION Sometimes you don't want a particular attribute to be part of the serialization, in this case, you want to make sure that attribute uses this custom meta-attribute-trait. See the SYNOPSIS for a nice example that can be easily cargo-culted. =head1 METHODS =head2 Introspection =over 4 =item B =back =head1 BUGS All complex software has bugs lurking in it, and this module is no exception. If you find a bug please either email me, or add the bug to cpan-RT. =head1 AUTHORS =over 4 =item * Chris Prather =item * Stevan Little =item * יובל קוג'מן (Yuval Kogman) =back =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2007 by Infinity Interactive, Inc.. 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-Storage-0.45/lib/MooseX/Storage/IO/AtomicFile.pm000644 000767 000024 00000003530 12255433343 023004 0ustar00etherstaff000000 000000 package MooseX::Storage::IO::AtomicFile; { $MooseX::Storage::IO::AtomicFile::VERSION = '0.45'; } BEGIN { $MooseX::Storage::IO::AtomicFile::AUTHORITY = 'cpan:STEVAN'; } # ABSTRACT: An Atomic File I/O role use Moose::Role; use MooseX::Storage::Engine::IO::AtomicFile; with 'MooseX::Storage::IO::File'; sub store { my ( $self, $filename, @args ) = @_; MooseX::Storage::Engine::IO::AtomicFile->new( file => $filename )->store( $self->freeze(@args) ); } no Moose::Role; 1; __END__ =pod =encoding UTF-8 =for :stopwords Chris Prather Stevan Little יובל קוג'מן (Yuval Kogman) Infinity Interactive, Inc. =head1 NAME MooseX::Storage::IO::AtomicFile - An Atomic File I/O role =head1 VERSION version 0.45 =head1 SYNOPSIS package Point; use Moose; use MooseX::Storage; with Storage('format' => 'JSON', 'io' => 'AtomicFile'); has 'x' => (is => 'rw', isa => 'Int'); has 'y' => (is => 'rw', isa => 'Int'); 1; my $p = Point->new(x => 10, y => 10); ## methods to load/store a class ## on the file system $p->store('my_point.json'); my $p2 = Point->load('my_point.json'); =head1 METHODS =over 4 =item B =item B =back =head2 Introspection =over 4 =item B =back =head1 BUGS All complex software has bugs lurking in it, and this module is no exception. If you find a bug please either email me, or add the bug to cpan-RT. =head1 AUTHORS =over 4 =item * Chris Prather =item * Stevan Little =item * יובל קוג'מן (Yuval Kogman) =back =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2007 by Infinity Interactive, Inc.. 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-Storage-0.45/lib/MooseX/Storage/IO/File.pm000644 000767 000024 00000004230 12255433343 021645 0ustar00etherstaff000000 000000 package MooseX::Storage::IO::File; { $MooseX::Storage::IO::File::VERSION = '0.45'; } BEGIN { $MooseX::Storage::IO::File::AUTHORITY = 'cpan:STEVAN'; } # ABSTRACT: A basic File I/O role use Moose::Role; use MooseX::Storage::Engine::IO::File; requires 'thaw'; requires 'freeze'; sub load { my ( $class, $filename, @args ) = @_; $class->thaw( MooseX::Storage::Engine::IO::File->new( file => $filename )->load(), @args ); } sub store { my ( $self, $filename, @args ) = @_; MooseX::Storage::Engine::IO::File->new( file => $filename )->store( $self->freeze(@args) ); } no Moose::Role; 1; __END__ =pod =encoding UTF-8 =for :stopwords Chris Prather Stevan Little יובל קוג'מן (Yuval Kogman) Infinity Interactive, Inc. Florian Ragwitz Johannes Plunien Jonathan Rockway Yu Jos Boumans Karen Etheridge Ricardo Signes Robert Boone Shawn M Moore Tomas Doran Cory Yuval Kogman Watson Dagfinn Ilmari Mannsåker David Golden Steinbrunner =head1 NAME MooseX::Storage::IO::File - A basic File I/O role =head1 VERSION version 0.45 =head1 SYNOPSIS package Point; use Moose; use MooseX::Storage; with Storage('format' => 'JSON', 'io' => 'File'); has 'x' => (is => 'rw', isa => 'Int'); has 'y' => (is => 'rw', isa => 'Int'); 1; my $p = Point->new(x => 10, y => 10); ## methods to load/store a class ## on the file system $p->store('my_point.json'); my $p2 = Point->load('my_point.json'); =head1 METHODS =over 4 =item B =item B =back =head2 Introspection =over 4 =item B =back =head1 BUGS All complex software has bugs lurking in it, and this module is no exception. If you find a bug please either email me, or add the bug to cpan-RT. =head1 AUTHORS =over 4 =item * Chris Prather =item * Stevan Little =item * יובל קוג'מן (Yuval Kogman) =back =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2007 by Infinity Interactive, Inc.. 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-Storage-0.45/lib/MooseX/Storage/IO/StorableFile.pm000644 000767 000024 00000006020 12255433343 023340 0ustar00etherstaff000000 000000 package MooseX::Storage::IO::StorableFile; { $MooseX::Storage::IO::StorableFile::VERSION = '0.45'; } BEGIN { $MooseX::Storage::IO::StorableFile::AUTHORITY = 'cpan:STEVAN'; } # ABSTRACT: An Storable File I/O role use Moose::Role; use Storable (); requires 'pack'; requires 'unpack'; sub load { my ( $class, $filename, @args ) = @_; # try thawing return $class->thaw( Storable::retrieve($filename), @args ) if $class->can('thaw'); # otherwise just unpack $class->unpack( Storable::retrieve($filename), @args ); } sub store { my ( $self, $filename, @args ) = @_; Storable::nstore( # try freezing, otherwise just pack ($self->can('freeze') ? $self->freeze(@args) : $self->pack(@args)), $filename ); } no Moose::Role; 1; __END__ =pod =encoding UTF-8 =for :stopwords Chris Prather Stevan Little יובל קוג'מן (Yuval Kogman) Infinity Interactive, Inc. Florian Ragwitz Johannes Plunien Jonathan Rockway Yu Jos Boumans Karen Etheridge Ricardo Signes Robert Boone Shawn M Moore Tomas Doran Cory Yuval Kogman Watson Dagfinn Ilmari Mannsåker David Golden Steinbrunner =head1 NAME MooseX::Storage::IO::StorableFile - An Storable File I/O role =head1 VERSION version 0.45 =head1 SYNOPSIS package Point; use Moose; use MooseX::Storage; with Storage('io' => 'StorableFile'); has 'x' => (is => 'rw', isa => 'Int'); has 'y' => (is => 'rw', isa => 'Int'); 1; my $p = Point->new(x => 10, y => 10); ## methods to load/store a class ## on the file system $p->store('my_point'); my $p2 = Point->load('my_point'); =head1 DESCRIPTION This module will C and C Moose classes using Storable. It uses C by default so that it can be easily used across machines or just locally. One important thing to note is that this module does not mix well with the other Format modules. Since Storable serialized perl data structures in it's own format, those roles are largely unnecessary. However, there is always the possibility that having a set of C hooks can be useful, so because of that this module will attempt to use C or C if that method is available. Of course, you should be careful when doing this as it could lead to all sorts of hairy issues. But you have been warned. =head1 METHODS =over 4 =item B =item B =back =head2 Introspection =over 4 =item B =back =head1 BUGS All complex software has bugs lurking in it, and this module is no exception. If you find a bug please either email me, or add the bug to cpan-RT. =head1 AUTHORS =over 4 =item * Chris Prather =item * Stevan Little =item * יובל קוג'מן (Yuval Kogman) =back =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2007 by Infinity Interactive, Inc.. 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-Storage-0.45/lib/MooseX/Storage/Format/JSON.pm000644 000767 000024 00000004341 12255433343 022463 0ustar00etherstaff000000 000000 package MooseX::Storage::Format::JSON; { $MooseX::Storage::Format::JSON::VERSION = '0.45'; } BEGIN { $MooseX::Storage::Format::JSON::AUTHORITY = 'cpan:STEVAN'; } # ABSTRACT: A JSON serialization role use Moose::Role; no warnings 'once'; use JSON::Any; requires 'pack'; requires 'unpack'; sub thaw { my ( $class, $json, @args ) = @_; utf8::encode($json) if utf8::is_utf8($json); $class->unpack( JSON::Any->new->jsonToObj($json), @args ); } sub freeze { my ( $self, @args ) = @_; my $json = JSON::Any->new(canonical => 1)->objToJson( $self->pack(@args) ); utf8::decode($json) if !utf8::is_utf8($json) and utf8::valid($json); # if it's valid utf8 mark it as such return $json; } no Moose::Role; 1; __END__ =pod =encoding UTF-8 =for :stopwords Chris Prather Stevan Little יובל קוג'מן (Yuval Kogman) Infinity Interactive, Inc. =head1 NAME MooseX::Storage::Format::JSON - A JSON serialization role =head1 VERSION version 0.45 =head1 SYNOPSIS package Point; use Moose; use MooseX::Storage; with Storage('format' => 'JSON'); has 'x' => (is => 'rw', isa => 'Int'); has 'y' => (is => 'rw', isa => 'Int'); 1; my $p = Point->new(x => 10, y => 10); ## methods to freeze/thaw into ## a specified serialization format ## (in this case JSON) # pack the class into a JSON string $p->freeze(); # { "__CLASS__" : "Point", "x" : 10, "y" : 10 } # unpack the JSON string into a class my $p2 = Point->thaw('{ "__CLASS__" : "Point", "x" : 10, "y" : 10 }'); =head1 METHODS =over 4 =item B =item B =back =head2 Introspection =over 4 =item B =back =head1 BUGS All complex software has bugs lurking in it, and this module is no exception. If you find a bug please either email me, or add the bug to cpan-RT. =head1 AUTHORS =over 4 =item * Chris Prather =item * Stevan Little =item * יובל קוג'מן (Yuval Kogman) =back =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2007 by Infinity Interactive, Inc.. 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-Storage-0.45/lib/MooseX/Storage/Format/Storable.pm000644 000767 000024 00000005343 12255433343 023470 0ustar00etherstaff000000 000000 package MooseX::Storage::Format::Storable; { $MooseX::Storage::Format::Storable::VERSION = '0.45'; } BEGIN { $MooseX::Storage::Format::Storable::AUTHORITY = 'cpan:STEVAN'; } # ABSTRACT: A Storable serialization role use Moose::Role; use Storable (); requires 'pack'; requires 'unpack'; sub thaw { my ( $class, $stored, @args ) = @_; $class->unpack( Storable::thaw($stored), @args ); } sub freeze { my ( $self, @args ) = @_; Storable::nfreeze( $self->pack(@args) ); } no Moose::Role; 1; __END__ =pod =encoding UTF-8 =for :stopwords Chris Prather Stevan Little יובל קוג'מן (Yuval Kogman) Infinity Interactive, Inc. Florian Ragwitz Johannes Plunien Jonathan Rockway Yu Jos Boumans Karen Etheridge Ricardo Signes Robert Boone Shawn M Moore Tomas Doran Cory Yuval Kogman Watson Dagfinn Ilmari Mannsåker David Golden Steinbrunner IPC Storable's =head1 NAME MooseX::Storage::Format::Storable - A Storable serialization role =head1 VERSION version 0.45 =head1 SYNOPSIS package Point; use Moose; use MooseX::Storage; with Storage('format' => 'Storable'); has 'x' => (is => 'rw', isa => 'Int'); has 'y' => (is => 'rw', isa => 'Int'); 1; my $p = Point->new(x => 10, y => 10); ## methods to freeze/thaw into ## a specified serialization format # pack the class with Storable my $storable_data = $p->freeze(); # unpack the storable data into the class my $p2 = Point->thaw($storable_data); =head1 DESCRIPTION This module will C and C Moose classes using Storable. It uses C by default so that it can be easily used in IPC scenarios across machines or just locally. One important thing to note is that this module does not mix well with the IO modules. The structures that C and C deal with are Storable's memory representation, and (as far as I know) that is not easily just written onto a file. If you want file based serialization with Storable, the please look at the L role instead. =head1 METHODS =over 4 =item B =item B =back =head2 Introspection =over 4 =item B =back =head1 BUGS All complex software has bugs lurking in it, and this module is no exception. If you find a bug please either email me, or add the bug to cpan-RT. =head1 AUTHORS =over 4 =item * Chris Prather =item * Stevan Little =item * יובל קוג'מן (Yuval Kogman) =back =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2007 by Infinity Interactive, Inc.. 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-Storage-0.45/lib/MooseX/Storage/Format/YAML.pm000644 000767 000024 00000004430 12255433343 022453 0ustar00etherstaff000000 000000 package MooseX::Storage::Format::YAML; { $MooseX::Storage::Format::YAML::VERSION = '0.45'; } BEGIN { $MooseX::Storage::Format::YAML::AUTHORITY = 'cpan:STEVAN'; } # ABSTRACT: A YAML serialization role use Moose::Role; # When I add YAML::LibYAML # Tests break because tye YAML is invalid...? # -dcp use YAML::Any qw(Load Dump); requires 'pack'; requires 'unpack'; sub thaw { my ( $class, $yaml, @args ) = @_; $class->unpack( Load($yaml), @args ); } sub freeze { my ( $self, @args ) = @_; Dump( $self->pack(@args) ); } no Moose::Role; 1; __END__ =pod =encoding UTF-8 =for :stopwords Chris Prather Stevan Little יובל קוג'מן (Yuval Kogman) Infinity Interactive, Inc. Florian Ragwitz Johannes Plunien Jonathan Rockway Yu Jos Boumans Karen Etheridge Ricardo Signes Robert Boone Shawn M Moore Tomas Doran Cory Yuval Kogman Watson Dagfinn Ilmari Mannsåker David Golden Steinbrunner =head1 NAME MooseX::Storage::Format::YAML - A YAML serialization role =head1 VERSION version 0.45 =head1 SYNOPSIS package Point; use Moose; use MooseX::Storage; with Storage('format' => 'YAML'); has 'x' => (is => 'rw', isa => 'Int'); has 'y' => (is => 'rw', isa => 'Int'); 1; my $p = Point->new(x => 10, y => 10); ## methods to freeze/thaw into ## a specified serialization format ## (in this case YAML) # pack the class into a YAML string $p->freeze(); # ---- # __CLASS__: "Point" # x: 10 # y: 10 # unpack the JSON string into a class my $p2 = Point->thaw(< =item B =back =head2 Introspection =over 4 =item B =back =head1 BUGS All complex software has bugs lurking in it, and this module is no exception. If you find a bug please either email me, or add the bug to cpan-RT. =head1 AUTHORS =over 4 =item * Chris Prather =item * Stevan Little =item * יובל קוג'מן (Yuval Kogman) =back =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2007 by Infinity Interactive, Inc.. 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-Storage-0.45/lib/MooseX/Storage/Engine/IO/000755 000767 000024 00000000000 12255433343 021636 5ustar00etherstaff000000 000000 MooseX-Storage-0.45/lib/MooseX/Storage/Engine/Trait/000755 000767 000024 00000000000 12255433343 022412 5ustar00etherstaff000000 000000 MooseX-Storage-0.45/lib/MooseX/Storage/Engine/Trait/DisableCycleDetection.pm000644 000767 000024 00000004642 12255433343 027140 0ustar00etherstaff000000 000000 package MooseX::Storage::Engine::Trait::DisableCycleDetection; { $MooseX::Storage::Engine::Trait::DisableCycleDetection::VERSION = '0.45'; } BEGIN { $MooseX::Storage::Engine::Trait::DisableCycleDetection::AUTHORITY = 'cpan:STEVAN'; } # ABSTRACT: A custom trait to bypass cycle detection use Moose::Role; around 'check_for_cycle_in_collapse' => sub { my ($orig, $self, $attr, $value) = @_; # See NOTE in MX::Storage::Engine return $value; }; 1; __END__ =pod =encoding UTF-8 =for :stopwords Chris Prather Stevan Little יובל קוג'מן (Yuval Kogman) Infinity Interactive, Inc. Florian Ragwitz Johannes Plunien Jonathan Rockway Yu Jos Boumans Karen Etheridge Ricardo Signes Robert Boone Shawn M Moore Tomas Doran Cory Yuval Kogman Watson Dagfinn Ilmari Mannsåker David Golden Steinbrunner =head1 NAME MooseX::Storage::Engine::Trait::DisableCycleDetection - A custom trait to bypass cycle detection =head1 VERSION version 0.45 =head1 SYNOPSIS package Double; use Moose; use MooseX::Storage; with Storage( traits => ['DisableCycleDetection'] ); has 'x' => ( is => 'rw', isa => 'HashRef' ); has 'y' => ( is => 'rw', isa => 'HashRef' ); my $ref = {}; my $double = Double->new( 'x' => $ref, 'y' => $ref ); $double->pack; =head1 DESCRIPTION C implements a primitive check for circular references. This check also triggers on simple cases as shown in the Synopsis. Providing the C traits disables checks for any cyclical references, so if you know what you are doing, you can bypass this check. This trait is applied to an instance of L, for the user-visible version shown in the SYNOPSIS, see L =head1 METHODS =head2 Introspection =over 4 =item B =back =head1 BUGS All complex software has bugs lurking in it, and this module is no exception. If you find a bug please either email me, or add the bug to cpan-RT. =head1 AUTHORS =over 4 =item * Chris Prather =item * Stevan Little =item * יובל קוג'מן (Yuval Kogman) =back =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2007 by Infinity Interactive, Inc.. 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-Storage-0.45/lib/MooseX/Storage/Engine/Trait/OnlyWhenBuilt.pm000644 000767 000024 00000005576 12255433343 025530 0ustar00etherstaff000000 000000 package MooseX::Storage::Engine::Trait::OnlyWhenBuilt; { $MooseX::Storage::Engine::Trait::OnlyWhenBuilt::VERSION = '0.45'; } BEGIN { $MooseX::Storage::Engine::Trait::OnlyWhenBuilt::AUTHORITY = 'cpan:STEVAN'; } # ABSTRACT: An engine trait to bypass serialization use Moose::Role; # we should # only serialize the attribute if it's already built. So, go ahead # and check if the attribute has a predicate. If so, check if it's # set and then go ahead and look it up. around 'collapse_attribute' => sub { my ($orig, $self, $attr, @args) = @_; my $pred = $attr->predicate if $attr->has_predicate; if ($pred) { return () unless $self->object->$pred(); } return $self->$orig($attr, @args); }; 1; __END__ =pod =encoding UTF-8 =for :stopwords Chris Prather Stevan Little יובל קוג'מן (Yuval Kogman) Infinity Interactive, Inc. Florian Ragwitz Johannes Plunien Jonathan Rockway Yu Jos Boumans Karen Etheridge Ricardo Signes Robert Boone Shawn M Moore Tomas Doran Cory Yuval Kogman Watson Dagfinn Ilmari Mannsåker David Golden Steinbrunner =head1 NAME MooseX::Storage::Engine::Trait::OnlyWhenBuilt - An engine trait to bypass serialization =head1 VERSION version 0.45 =head1 SYNOPSIS { package Point; use Moose; use MooseX::Storage; with Storage( traits => [qw|OnlyWhenBuilt|] ); has 'x' => (is => 'rw', lazy_build => 1 ); has 'y' => (is => 'rw', lazy_build => 1 ); has 'z' => (is => 'rw', builder => '_build_z' ); sub _build_x { 3 } sub _build_y { expensive_computation() } sub _build_z { 3 } } my $p = Point->new( 'x' => 4 ); # the result of ->pack will contain: # { x => 4, z => 3 } $p->pack; =head1 DESCRIPTION Sometimes you don't want a particular attribute to be part of the serialization if it has not been built yet. If you invoke C as outlined in the C, only attributes that have been built (i.e., where the predicate returns 'true') will be serialized. This avoids any potentially expensive computations. This trait is applied to an instance of L, for the user-visible version shown in the SYNOPSIS, see L =head1 METHODS =head2 Introspection =over 4 =item B =back =head1 BUGS All complex software has bugs lurking in it, and this module is no exception. If you find a bug please either email me, or add the bug to cpan-RT. =head1 AUTHORS =over 4 =item * Chris Prather =item * Stevan Little =item * יובל קוג'מן (Yuval Kogman) =back =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2007 by Infinity Interactive, Inc.. 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-Storage-0.45/lib/MooseX/Storage/Engine/IO/AtomicFile.pm000644 000767 000024 00000003407 12255433343 024214 0ustar00etherstaff000000 000000 package MooseX::Storage::Engine::IO::AtomicFile; { $MooseX::Storage::Engine::IO::AtomicFile::VERSION = '0.45'; } BEGIN { $MooseX::Storage::Engine::IO::AtomicFile::AUTHORITY = 'cpan:STEVAN'; } # ABSTRACT: The actually atomic file storage mechanism. use Moose; use IO::AtomicFile; extends 'MooseX::Storage::Engine::IO::File'; sub store { my ($self, $data) = @_; my $fh = IO::AtomicFile->new($self->file, 'w') || confess "Unable to open file (" . $self->file . ") for storing : $!"; $fh->binmode(':utf8') if utf8::is_utf8($data); print $fh $data; $fh->close() || confess "Could not write atomic file (" . $self->file . ") because: $!"; } 1; __END__ =pod =encoding UTF-8 =for :stopwords Chris Prather Stevan Little יובל קוג'מן (Yuval Kogman) Infinity Interactive, Inc. =head1 NAME MooseX::Storage::Engine::IO::AtomicFile - The actually atomic file storage mechanism. =head1 VERSION version 0.45 =head1 DESCRIPTION This provides the actual means to store data to a file atomically. =head1 METHODS =over 4 =item B =item B =item B =back =head2 Introspection =over 4 =item B =back =head1 BUGS All complex software has bugs lurking in it, and this module is no exception. If you find a bug please either email me, or add the bug to cpan-RT. =head1 AUTHORS =over 4 =item * Chris Prather =item * Stevan Little =item * יובל קוג'מן (Yuval Kogman) =back =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2007 by Infinity Interactive, Inc.. 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-Storage-0.45/lib/MooseX/Storage/Engine/IO/File.pm000644 000767 000024 00000004044 12255433343 023055 0ustar00etherstaff000000 000000 package MooseX::Storage::Engine::IO::File; { $MooseX::Storage::Engine::IO::File::VERSION = '0.45'; } BEGIN { $MooseX::Storage::Engine::IO::File::AUTHORITY = 'cpan:STEVAN'; } # ABSTRACT: The actually file storage mechanism. use Moose; use IO::File; has 'file' => ( is => 'ro', isa => 'Str', required => 1, ); sub load { my ($self) = @_; my $fh = IO::File->new($self->file, 'r') || confess "Unable to open file (" . $self->file . ") for loading : $!"; return do { local $/; <$fh>; }; } sub store { my ($self, $data) = @_; my $fh = IO::File->new($self->file, 'w') || confess "Unable to open file (" . $self->file . ") for storing : $!"; $fh->binmode(':utf8') if utf8::is_utf8($data); print $fh $data; } 1; __END__ =pod =encoding UTF-8 =for :stopwords Chris Prather Stevan Little יובל קוג'מן (Yuval Kogman) Infinity Interactive, Inc. Florian Ragwitz Johannes Plunien Jonathan Rockway Yu Jos Boumans Karen Etheridge Ricardo Signes Robert Boone Shawn M Moore Tomas Doran Cory Yuval Kogman Watson Dagfinn Ilmari Mannsåker David Golden Steinbrunner =head1 NAME MooseX::Storage::Engine::IO::File - The actually file storage mechanism. =head1 VERSION version 0.45 =head1 DESCRIPTION This provides the actual means to store data to a file. =head1 METHODS =over 4 =item B =item B =item B =back =head2 Introspection =over 4 =item B =back =head1 BUGS All complex software has bugs lurking in it, and this module is no exception. If you find a bug please either email me, or add the bug to cpan-RT. =head1 AUTHORS =over 4 =item * Chris Prather =item * Stevan Little =item * יובל קוג'מן (Yuval Kogman) =back =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2007 by Infinity Interactive, Inc.. 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-Storage-0.45/lib/MooseX/Storage/Base/WithChecksum.pm000644 000767 000024 00000007301 12255433343 023731 0ustar00etherstaff000000 000000 package MooseX::Storage::Base::WithChecksum; { $MooseX::Storage::Base::WithChecksum::VERSION = '0.45'; } BEGIN { $MooseX::Storage::Base::WithChecksum::AUTHORITY = 'cpan:STEVAN'; } # ABSTRACT: A more secure serialization role use Moose::Role; with 'MooseX::Storage::Basic'; use Digest (); use Data::Dumper (); our $DIGEST_MARKER = '__DIGEST__'; around pack => sub { my $orig = shift; my $self = shift; my @args = @_; my $collapsed = $self->$orig( @args ); $collapsed->{$DIGEST_MARKER} = $self->_digest_packed($collapsed, @args); return $collapsed; }; around unpack => sub { my ($orig, $class, $data, @args) = @_; # check checksum on data my $old_checksum = delete $data->{$DIGEST_MARKER}; my $checksum = $class->_digest_packed($data, @args); ($checksum eq $old_checksum) || confess "Bad Checksum got=($checksum) expected=($old_checksum)"; $class->$orig( $data, @args ); }; sub _digest_packed { my ( $self, $collapsed, @args ) = @_; my $d = $self->_digest_object(@args); { local $Data::Dumper::Indent = 0; local $Data::Dumper::Sortkeys = 1; local $Data::Dumper::Terse = 1; local $Data::Dumper::Useqq = 0; local $Data::Dumper::Deparse = 0; # FIXME? my $str = Data::Dumper::Dumper($collapsed); # NOTE: # Canonicalize numbers to strings even if it # mangles numbers inside strings. It really # does not matter since its just the checksum # anyway. # - YK/SL $str =~ s/(?add( $str ); } return $d->hexdigest; } sub _digest_object { my ( $self, %options ) = @_; my $digest_opts = $options{digest}; $digest_opts = [ $digest_opts ] if !ref($digest_opts) or ref($digest_opts) ne 'ARRAY'; my ( $d, @args ) = @$digest_opts; if ( ref $d ) { if ( $d->can("clone") ) { return $d->clone; } elsif ( $d->can("reset") ) { $d->reset; return $d; } else { die "Can't clone or reset digest object: $d"; } } else { return Digest->new($d || "SHA-1", @args); } } no Moose::Role; 1; __END__ =pod =encoding UTF-8 =for :stopwords Chris Prather Stevan Little יובל קוג'מן (Yuval Kogman) Infinity Interactive, Inc. Florian Ragwitz Johannes Plunien Jonathan Rockway Yu Jos Boumans Karen Etheridge Ricardo Signes Robert Boone Shawn M Moore Tomas Doran Cory Yuval Kogman Watson Dagfinn Ilmari Mannsåker David Golden Steinbrunner =head1 NAME MooseX::Storage::Base::WithChecksum - A more secure serialization role =head1 VERSION version 0.45 =head1 DESCRIPTION This is an early implementation of a more secure Storage role, which does integrity checks on the data. It is still being developed so I recommend using it with caution. Any thoughts, ideas or suggestions on improving our technique are very welcome. =head1 METHODS =over 4 =item B =item B =back =head2 Introspection =over 4 =item B =back =head1 BUGS All complex software has bugs lurking in it, and this module is no exception. If you find a bug please either email me, or add the bug to cpan-RT. =head1 AUTHORS =over 4 =item * Chris Prather =item * Stevan Little =item * יובל קוג'מן (Yuval Kogman) =back =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2007 by Infinity Interactive, Inc.. 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