diff options
author | Andrej Shadura <andrewsh@debian.org> | 2019-06-23 13:32:29 -0500 |
---|---|---|
committer | Andrej Shadura <andrewsh@debian.org> | 2019-06-23 13:32:29 -0500 |
commit | fedd443cfa43bb7ccdfe16b1088a7d8c08c6d393 (patch) | |
tree | e1e69251e2d32da9a3c5afbee9e5fe9f720af266 |
Import original source of Variable-Disposition 0.004
-rw-r--r-- | Changes | 27 | ||||
-rw-r--r-- | INSTALL | 43 | ||||
-rw-r--r-- | LICENSE | 379 | ||||
-rw-r--r-- | MANIFEST | 25 | ||||
-rw-r--r-- | META.json | 63 | ||||
-rw-r--r-- | META.yml | 28 | ||||
-rw-r--r-- | Makefile.PL | 67 | ||||
-rw-r--r-- | README | 15 | ||||
-rw-r--r-- | SIGNATURE | 50 | ||||
-rw-r--r-- | cpanfile | 8 | ||||
-rw-r--r-- | dist.ini | 72 | ||||
-rw-r--r-- | lib/Variable/Disposition.pm | 156 | ||||
-rw-r--r-- | lib/Variable/Disposition.pod | 120 | ||||
-rw-r--r-- | t/00-check-deps.t | 17 | ||||
-rw-r--r-- | t/00-compile.t | 51 | ||||
-rw-r--r-- | t/000-report-versions-tiny.t | 78 | ||||
-rw-r--r-- | t/basic.t | 54 | ||||
-rw-r--r-- | t/retain.t | 26 | ||||
-rw-r--r-- | t/retain_future.t | 32 | ||||
-rw-r--r-- | xt/release/common_spelling.t | 11 | ||||
-rw-r--r-- | xt/release/mojibake.t | 12 | ||||
-rw-r--r-- | xt/release/pod-syntax.t | 6 | ||||
-rw-r--r-- | xt/release/synopsis.t | 5 | ||||
-rw-r--r-- | xt/release/test-version.t | 22 |
24 files changed, 1367 insertions, 0 deletions
@@ -0,0 +1,27 @@ +Revision history for Variable-Disposition + +0.004 2015-02-11 22:17:44+00:00 Europe/London + No new features. + + Dependencies: + * Require Future.pm, there's some test failures on older versions of Future and + I don't feel like messing around with version checks, given that everything else + I use depends on Future.pm anyway - patches welcome if anyone feels differently. + +0.003 2015-02-09 02:51:40+00:00 Europe/London + No new features. + + Bugs fixed: + * retain_future was returning undef for completed Futures + +0.002 2015-01-30 20:40:28+00:00 Europe/London + New features: + * retain - holds on to a variable until dispose/exit + * retain_future - holds on to a Future until it's ready + + Documentation: + * Expanded description of some details of the dispose() function + including mention of the ($) prototype. + +0.001 2014-08-30 20:43:59+01:00 Europe/London + Initial CPAN release @@ -0,0 +1,43 @@ +This is the Perl distribution Variable-Disposition. + +Installing Variable-Disposition is straightforward. + +## Installation with cpanm + +If you have cpanm, you only need one line: + + % cpanm Variable::Disposition + +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 Variable::Disposition + +## Installing with the CPAN shell + +Alternatively, if your CPAN shell is set up, you should just be able to do: + + % cpan Variable::Disposition + +## Manual installation + +As a last resort, you can manually install it. Download the tarball, untar it, +then build it: + + % perl Makefile.PL + % make && make test + +Then install it: + + % make install + +If you are installing into a system-wide directory, you may need to run: + + % sudo make install + +## Documentation + +Variable-Disposition documentation is available as POD. +You can run perldoc from a shell to read the documentation: + + % perldoc Variable::Disposition @@ -0,0 +1,379 @@ +This software is copyright (c) 2014 by Tom Molesworth. + +This is free software; you can redistribute it and/or modify it under +the same terms as the Perl 5 programming language system itself. + +Terms of the Perl programming language system itself + +a) the GNU General Public License as published by the Free + Software Foundation; either version 1, or (at your option) any + later version, or +b) the "Artistic License" + +--- The GNU General Public License, Version 1, February 1989 --- + +This software is Copyright (c) 2014 by Tom Molesworth. + +This is free software, licensed under: + + The GNU General Public License, Version 1, February 1989 + + GNU GENERAL PUBLIC LICENSE + Version 1, February 1989 + + Copyright (C) 1989 Free Software Foundation, Inc. + 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The license agreements of most software companies try to keep users +at the mercy of those companies. By contrast, our General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. The +General Public License applies to the Free Software Foundation's +software and to any other program whose authors commit to using it. +You can use it for your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Specifically, the General Public License is designed to make +sure that you have the freedom to give away or sell copies of free +software, that you receive source code or can get it if you want it, +that you can change the software or use pieces of it in new free +programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of a such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must tell them their rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any program or other work which +contains a notice placed by the copyright holder saying it may be +distributed under the terms of this General Public License. The +"Program", below, refers to any such program or work, and a "work based +on the Program" means either the Program or any work containing the +Program or a portion of it, either verbatim or with modifications. Each +licensee is addressed as "you". + + 1. You may copy and distribute verbatim copies of the Program's source +code as you receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice and +disclaimer of warranty; keep intact all the notices that refer to this +General Public License and to the absence of any warranty; and give any +other recipients of the Program a copy of this General Public License +along with the Program. You may charge a fee for the physical act of +transferring a copy. + + 2. You may modify your copy or copies of the Program or any portion of +it, and copy and distribute such modifications under the terms of Paragraph +1 above, provided that you also do the following: + + a) cause the modified files to carry prominent notices stating that + you changed the files and the date of any change; and + + b) cause the whole of any work that you distribute or publish, that + in whole or in part contains the Program or any part thereof, either + with or without modifications, to be licensed at no charge to all + third parties under the terms of this General Public License (except + that you may choose to grant warranty protection to some or all + third parties, at your option). + + c) If the modified program normally reads commands interactively when + run, you must cause it, when started running for such interactive use + in the simplest and most usual way, to print or display an + announcement including an appropriate copyright notice and a notice + that there is no warranty (or else, saying that you provide a + warranty) and that users may redistribute the program under these + conditions, and telling the user how to view a copy of this General + Public License. + + d) You may charge a fee for the physical act of transferring a + copy, and you may at your option offer warranty protection in + exchange for a fee. + +Mere aggregation of another independent work with the Program (or its +derivative) on a volume of a storage or distribution medium does not bring +the other work under the scope of these terms. + + 3. You may copy and distribute the Program (or a portion or derivative of +it, under Paragraph 2) in object code or executable form under the terms of +Paragraphs 1 and 2 above provided that you also do one of the following: + + a) accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of + Paragraphs 1 and 2 above; or, + + b) accompany it with a written offer, valid for at least three + years, to give any third party free (except for a nominal charge + for the cost of distribution) a complete machine-readable copy of the + corresponding source code, to be distributed under the terms of + Paragraphs 1 and 2 above; or, + + c) accompany it with the information you received as to where the + corresponding source code may be obtained. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form alone.) + +Source code for a work means the preferred form of the work for making +modifications to it. For an executable file, complete source code means +all the source code for all modules it contains; but, as a special +exception, it need not include source code for modules which are standard +libraries that accompany the operating system on which the executable +file runs, or for standard header files or definitions files that +accompany that operating system. + + 4. You may not copy, modify, sublicense, distribute or transfer the +Program except as expressly provided under this General Public License. +Any attempt otherwise to copy, modify, sublicense, distribute or transfer +the Program is void, and will automatically terminate your rights to use +the Program under this License. However, parties who have received +copies, or rights to use copies, from you under this General Public +License will not have their licenses terminated so long as such parties +remain in full compliance. + + 5. By copying, distributing or modifying the Program (or any work based +on the Program) you indicate your acceptance of this license to do so, +and all its terms and conditions. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the original +licensor to copy, distribute or modify the Program subject to these +terms and conditions. You may not impose any further restrictions on the +recipients' exercise of the rights granted herein. + + 7. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of the license which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +the license, you may choose any version ever published by the Free Software +Foundation. + + 8. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + Appendix: How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to humanity, the best way to achieve this is to make it +free software which everyone can redistribute and change under these +terms. + + To do so, attach the following notices to the program. It is safest to +attach them to the start of each source file to most effectively convey +the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) 19yy <name of author> + + 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. + + <signature of Ty Coon>, 1 April 1989 + Ty Coon, President of Vice + +That's all there is to it! + + +--- The Artistic License 1.0 --- + +This software is Copyright (c) 2014 by Tom Molesworth. + +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 + diff --git a/MANIFEST b/MANIFEST new file mode 100644 index 0000000..621c7cb --- /dev/null +++ b/MANIFEST @@ -0,0 +1,25 @@ +# This file was automatically generated by Dist::Zilla::Plugin::Manifest v5.029. +Changes +INSTALL +LICENSE +MANIFEST +META.json +META.yml +Makefile.PL +README +SIGNATURE +cpanfile +dist.ini +lib/Variable/Disposition.pm +lib/Variable/Disposition.pod +t/00-check-deps.t +t/00-compile.t +t/000-report-versions-tiny.t +t/basic.t +t/retain.t +t/retain_future.t +xt/release/common_spelling.t +xt/release/mojibake.t +xt/release/pod-syntax.t +xt/release/synopsis.t +xt/release/test-version.t diff --git a/META.json b/META.json new file mode 100644 index 0000000..94b7ffd --- /dev/null +++ b/META.json @@ -0,0 +1,63 @@ +{ + "abstract" : "dispose of variables", + "author" : [ + "Tom Molesworth <cpan@perlsite.co.uk>" + ], + "dynamic_config" : 0, + "generated_by" : "Dist::Zilla version 5.029, CPAN::Meta::Converter version 2.143240", + "license" : [ + "perl_5" + ], + "meta-spec" : { + "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", + "version" : 2 + }, + "name" : "Variable-Disposition", + "prereqs" : { + "build" : { + "requires" : { + "perl" : "5.010001" + } + }, + "configure" : { + "requires" : { + "ExtUtils::MakeMaker" : "6.48" + } + }, + "develop" : { + "requires" : { + "Test::More" : "0", + "Test::Pod" : "1.41", + "Test::Synopsis" : "0", + "Test::Version" : "1", + "version" : "0.9901" + } + }, + "runtime" : { + "requires" : { + "Future" : "0.30" + } + }, + "test" : { + "requires" : { + "File::Spec" : "0", + "IO::Handle" : "0", + "IPC::Open3" : "0", + "Test::CheckDeps" : "0.010", + "Test::Fatal" : "0.010", + "Test::More" : "0.98", + "Test::Refcount" : "0" + } + } + }, + "release_status" : "stable", + "resources" : { + "bugtracker" : { + "mailto" : "bug-variable-disposition at rt.cpan.org", + "web" : "http://rt.cpan.org/Public/Dist/Display.html?Name=Variable-Disposition" + }, + "homepage" : "http://search.cpan.org/dist/Variable-Disposition/" + }, + "version" : "0.004" +} + diff --git a/META.yml b/META.yml new file mode 100644 index 0000000..1224895 --- /dev/null +++ b/META.yml @@ -0,0 +1,28 @@ +--- +abstract: 'dispose of variables' +author: + - 'Tom Molesworth <cpan@perlsite.co.uk>' +build_requires: + File::Spec: '0' + IO::Handle: '0' + IPC::Open3: '0' + Test::CheckDeps: '0.010' + Test::Fatal: '0.010' + Test::More: '0.98' + Test::Refcount: '0' + perl: '5.010001' +configure_requires: + ExtUtils::MakeMaker: '6.48' +dynamic_config: 0 +generated_by: 'Dist::Zilla version 5.029, CPAN::Meta::Converter version 2.143240' +license: perl +meta-spec: + url: http://module-build.sourceforge.net/META-spec-v1.4.html + version: '1.4' +name: Variable-Disposition +requires: + Future: '0.30' +resources: + bugtracker: http://rt.cpan.org/Public/Dist/Display.html?Name=Variable-Disposition + homepage: http://search.cpan.org/dist/Variable-Disposition/ +version: '0.004' diff --git a/Makefile.PL b/Makefile.PL new file mode 100644 index 0000000..9ab7b51 --- /dev/null +++ b/Makefile.PL @@ -0,0 +1,67 @@ + +# This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v5.029. +use strict; +use warnings; + +use 5.010001; + +use ExtUtils::MakeMaker 6.48; + + + +my %WriteMakefileArgs = ( + "ABSTRACT" => "dispose of variables", + "AUTHOR" => "Tom Molesworth <cpan\@perlsite.co.uk>", + "CONFIGURE_REQUIRES" => { + "ExtUtils::MakeMaker" => "6.48" + }, + "DISTNAME" => "Variable-Disposition", + "EXE_FILES" => [], + "LICENSE" => "perl", + "MIN_PERL_VERSION" => "5.010001", + "NAME" => "Variable::Disposition", + "PREREQ_PM" => { + "Future" => "0.30" + }, + "TEST_REQUIRES" => { + "File::Spec" => 0, + "IO::Handle" => 0, + "IPC::Open3" => 0, + "Test::CheckDeps" => "0.010", + "Test::Fatal" => "0.010", + "Test::More" => "0.98", + "Test::Refcount" => 0 + }, + "VERSION" => "0.004", + "test" => { + "TESTS" => "t/*.t" + } +); + + +my %FallbackPrereqs = ( + "ExtUtils::MakeMaker" => "6.48", + "File::Spec" => 0, + "Future" => "0.30", + "IO::Handle" => 0, + "IPC::Open3" => 0, + "Test::CheckDeps" => "0.010", + "Test::Fatal" => "0.010", + "Test::More" => "0.98", + "Test::Refcount" => 0 +); + + +unless ( eval { ExtUtils::MakeMaker->VERSION(6.63_03) } ) { + delete $WriteMakefileArgs{TEST_REQUIRES}; + delete $WriteMakefileArgs{BUILD_REQUIRES}; + $WriteMakefileArgs{PREREQ_PM} = \%FallbackPrereqs; +} + +delete $WriteMakefileArgs{CONFIGURE_REQUIRES} + unless eval { ExtUtils::MakeMaker->VERSION(6.52) }; + +WriteMakefile(%WriteMakefileArgs); + + + @@ -0,0 +1,15 @@ + + +This archive contains the distribution Variable-Disposition, +version 0.004: + + dispose of variables + +This software is copyright (c) 2014 by Tom Molesworth. + +This is free software; you can redistribute it and/or modify it under +the same terms as the Perl 5 programming language system itself. + + +This README file was generated by Dist::Zilla::Plugin::Readme v5.029. + diff --git a/SIGNATURE b/SIGNATURE new file mode 100644 index 0000000..ec3db68 --- /dev/null +++ b/SIGNATURE @@ -0,0 +1,50 @@ +This file contains message digests of all files listed in MANIFEST, +signed via the Module::Signature module, version 0.73. + +To verify the content in this distribution, first make sure you have +Module::Signature installed, then type: + + % cpansign -v + +It will check each file's integrity, as well as the signature's +validity. If "==> Signature verified OK! <==" is not displayed, +the distribution may already have been compromised, and you should +not run its Makefile.PL or Build.PL. + +-----BEGIN PGP SIGNED MESSAGE----- +Hash: SHA1 + +SHA1 7445a489122f66de963a7484f676382ad08a915d Changes +SHA1 a208cbdb5fc156a5564a59d8ca963bc058de387a INSTALL +SHA1 6b50b30fa6f8d063d96e32c9a81f3f82328925f7 LICENSE +SHA1 c90184c27fc3cd644268f853cad64a9a593906a1 MANIFEST +SHA1 b8b30966a55bdc7196163dfb499c0c136851c573 META.json +SHA1 881383469e96fdf9d15904354ddd4777ba1eb28f META.yml +SHA1 721d11532d78982ee5981c4bd1ededb86bd90840 Makefile.PL +SHA1 1c0b3d9c0f74e70fa2a9022934be815b3064bb26 README +SHA1 fc2137b26983f5e33292da8fa380c46fdf2983ca cpanfile +SHA1 a702916540e62702a72929de0b4e16bc6418e6a6 dist.ini +SHA1 ecd01527275ee7896d31ce8f56d32f71601b281d lib/Variable/Disposition.pm +SHA1 1cebbca4aef6bda130e545a4dba99c86343682d9 lib/Variable/Disposition.pod +SHA1 985d9ded8d8ed7e344a09e52b1402e878e91da28 t/00-check-deps.t +SHA1 77225336bf5068280a1f7252b84c3aa8c4199749 t/00-compile.t +SHA1 549c15beab8d9f8a854cc47bd60a9c2b7dac2562 t/000-report-versions-tiny.t +SHA1 5c940c8bc25f9a3388286d88e2e2f1062fc71d11 t/basic.t +SHA1 c893d49f25a52a9b9cbe636b7079a33aa7da31e2 t/retain.t +SHA1 069b1d6178f2e339e2854e7ec906dc7036d54d96 t/retain_future.t +SHA1 198d1665317c3d91e3bb81f0a3b8dad8d4d66f20 xt/release/common_spelling.t +SHA1 c6c3c9f7fe12058b4771449dff874b1c450c982c xt/release/mojibake.t +SHA1 296928dbbcaffd1514ccc9b77a1e6e03cfe9b068 xt/release/pod-syntax.t +SHA1 34513f89a70b96f6412fe2ef0ad4d475e8cac66c xt/release/synopsis.t +SHA1 1294a6710ea8e2626e43722e50111bf872668316 xt/release/test-version.t +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1 + +iQEcBAEBAgAGBQJU29USAAoJEFKElMNpjtyDIAcH+gK1vLutxm3ocFsoCCktbV/d +FtG6Mkex8PZ0GQGHc0Idy6lectQ5j9B2Is+1Ke9sI0X0dnvF4eYy2d9wUipVhM30 +94X7blgGfY6QiOi6VYlxMm8rh65SJgybC+RviiioFDtD2KNhJrH6MR0kDLq5E26W +KVTF9Cxs0vAdqqkzgq8O5hIuXLn6/6cHATS4t7QJ6FL/OEGTK8jnUDFHPV4YpPcP +SxLTHwCN7tE39eLmHY0Jltzr4ebYrhYDpYM20T2SSZhcWEU/OmQUfQybk14iDzDf ++I0d0MJpXJ7dAZmz2hdh6WHYvYGAfNLcrf1F1BTBjmGLvnsgQ6qzlB6PHJP9d2o= +=n6dr +-----END PGP SIGNATURE----- diff --git a/cpanfile b/cpanfile new file mode 100644 index 0000000..25d3590 --- /dev/null +++ b/cpanfile @@ -0,0 +1,8 @@ +requires 'Future', '>= 0.30'; + +on 'test' => sub { + requires 'Test::More', '>= 0.98'; + requires 'Test::Fatal', '>= 0.010'; + requires 'Test::Refcount', 0; +}; + diff --git a/dist.ini b/dist.ini new file mode 100644 index 0000000..abfc118 --- /dev/null +++ b/dist.ini @@ -0,0 +1,72 @@ +name = Variable-Disposition +author = Tom Molesworth <cpan@perlsite.co.uk> +license = Perl_5 +copyright_holder = Tom Molesworth +copyright_year = 2014 +main_module = lib/Variable/Disposition.pm + +[Git::GatherDir] +exclude_filename = Makefile.PL +[PruneCruft] +;[PruneFiles] +[ManifestSkip] +[MetaYAML] +[License] +[Readme] +[MakeMaker] +eumm_version = 6.48 +prereq_fatal = 1 +[ExecDir] +[ShareDir] +dir = share +[Manifest] +[TestRelease] +[ConfirmRelease] +[UploadToCPAN] +[Prereqs::FromCPANfile] +[Prereqs / BuildRequires] +perl = 5.010001 +[CheckPrereqsIndexed] +[CheckExtraTests] +[NextRelease] +[VersionFromModule] +[PodVersion] +[PkgVersion] +[Homepage] +[Bugtracker] +; [PrePAN] +; author = http://prepan.org/user/xyz +; module = http://prepan.org/user/xyz +[InstallGuide] +[MetaJSON] +[InsertExample] +[PodInherit] +[PodSyntaxTests] +[MojibakeTests] +[Test::CheckDeps] +[Test::Compile] +[Test::Synopsis] +; [Test::EOL] +[Test::Version] +; [Test::Pod::LinkCheck] +; [PodCoverageTests] +; [Test::UnusedVars] +[ReportVersions::Tiny] +[SpellingCommonMistakesTests] +[Signature] +[CopyMakefilePLFromBuild] +[ArchiveRelease] +directory = /home/tom/dev/CPAN-Archive +;[Git::Check] +;allow_dirty = dist.ini +;changelog = Changes +[Git::Commit] +allow_dirty = dist.ini +allow_dirty = cpanfile +allow_dirty = Changes +allow_dirty = Makefile.PL +[Git::Tag] +tag_format = v%v +tag_message = Tag v%v for CPAN release +[ReversionOnRelease] + diff --git a/lib/Variable/Disposition.pm b/lib/Variable/Disposition.pm new file mode 100644 index 0000000..98b2847 --- /dev/null +++ b/lib/Variable/Disposition.pm @@ -0,0 +1,156 @@ +package Variable::Disposition; +# ABSTRACT: dispose of variables +use strict; +use warnings; + +use parent qw(Exporter); + +our $VERSION = '0.004'; + +=head1 NAME + +Variable::Disposition - helper functions for disposing of variables + +=head1 VERSION + +version 0.004 + +=head1 SYNOPSIS + + use feature qw(say); + use Variable::Disposition; + my $x = []; + dispose $x; + say '$x is no longer defined'; + +=head1 DESCRIPTION + +Provides some basic helper functions for making sure variables go away +when you want them to. + +Currently provides L</dispose> as a default import. To avoid this: + + use Variable::Disposition (); + +In addition, L</retain> and L</retain_future> are available as optional +imports. + + use Variable::Disposition qw(dispose retain retain_future); + +The C< :all > tag can be used to import every available function: + + use Variable::Disposition qw(:all); + +but it would be safer to use a version instead: + + use Variable::Disposition qw(:v1); + +since these are guaranteed not to change in future. + +Other functions for use with L<Future> and L<IO::Async> are likely to be +added later. + +=cut + +our @EXPORT_OK = qw(dispose retain retain_future); + +our %EXPORT_TAGS = ( + all => [ @EXPORT_OK ], + v1 => [ qw(dispose retain retain_future) ], +); + +our @EXPORT = qw(dispose); + +use Scalar::Util (); + +our %RETAINED; + +=head1 FUNCTIONS + +=cut + +=head2 dispose + +Undefines the given variable, then checks that the original ref was destroyed. + + my $x = [1,2,3]; + dispose $x; + # $x is no longer defined. + +This is primarily intended for cases where you no longer need a variable, and want +to ensure that you haven't accidentally captured a strong reference to it elsewhere. + +Note that this clears the B<caller>'s variable. + +This function is defined with a prototype of ($), since it is only intended for use +on scalar variables. To clear multiple variables, use a L<foreach> loop: + + my ($x, $y, $z) = ...; + dispose $_ for $x, $y, $z; + is($x, undef); + is($y, undef); + is($z, undef); + +=cut + +sub dispose($) { + die "Variable not defined" unless defined $_[0]; + die "Variable was not a ref" unless ref $_[0]; + delete $RETAINED{$_[0]}; # just in case we'd previously retained this one + Scalar::Util::weaken(my $copy = $_[0]); + undef $_[0]; + die "Variable was not released" if defined $copy; +} + +=head2 retain + +Keeps a copy of this variable until program exit or L</dispose>. + +Returns the original variable. + +=cut + +sub retain($) { + die "Variable not defined" unless defined $_[0]; + die "Variable was not a ref" unless ref $_[0]; + $RETAINED{$_[0]} = $_[0]; + $_[0] +} + +=head2 retain_future + +Holds a copy of the given L<Future> until it's marked ready, then releases our copy. +Does not use L</dispose>, since that could interfere with other callbacks attached +to the L<Future>. + +Returns the original L<Future>. + +=cut + +sub retain_future { + my ($f) = @_; + die "Variable does not seem to be a Future, since it has no ->on_ready method" unless $f->can('on_ready'); + $f->on_ready(sub { undef $f }); +} + +1; + +__END__ + +=head1 SEE ALSO + +=over 4 + +=item * L<Devel::Refcount> - assert_oneref is almost identical to this, although it doesn't clear the variable it's called on + +=item * L<Closure::Explicit> - provides a sub{} wrapper that will complain if you capture a lexical without explicitly declaring that you're going to do that. + +=back + +=head1 AUTHOR + +Tom Molesworth <cpan@perlsite.co.uk> + +=head1 LICENSE + +Copyright Tom Molesworth 2014-2015. Licensed under the same terms as Perl itself. diff --git a/lib/Variable/Disposition.pod b/lib/Variable/Disposition.pod new file mode 100644 index 0000000..ab97eb0 --- /dev/null +++ b/lib/Variable/Disposition.pod @@ -0,0 +1,120 @@ +=for comment POD_DERIVED_INDEX_GENERATED +The following documentation is automatically generated. Please do not edit +this file, but rather the original, inline with Variable::Disposition +at lib/Variable/Disposition.pm +(on the system that originally ran this). +If you do edit this file, and don't want your changes to be removed, make +sure you change the first line. + +=encoding utf8 + +=cut + +=head1 NAME + +Variable::Disposition - helper functions for disposing of variables + +=head1 VERSION + +version 0.004 + +=head1 SYNOPSIS + + use feature qw(say); + use Variable::Disposition; + my $x = []; + dispose $x; + say '$x is no longer defined'; + +=head1 DESCRIPTION + +Provides some basic helper functions for making sure variables go away +when you want them to. + +Currently provides L</dispose> as a default import. To avoid this: + + use Variable::Disposition (); + +In addition, L</retain> and L</retain_future> are available as optional +imports. + + use Variable::Disposition qw(dispose retain retain_future); + +The C< :all > tag can be used to import every available function: + + use Variable::Disposition qw(:all); + +but it would be safer to use a version instead: + + use Variable::Disposition qw(:v1); + +since these are guaranteed not to change in future. + +Other functions for use with L<Future> and L<IO::Async> are likely to be +added later. + +=head1 FUNCTIONS + +=head2 dispose + +Undefines the given variable, then checks that the original ref was destroyed. + + my $x = [1,2,3]; + dispose $x; + # $x is no longer defined. + +This is primarily intended for cases where you no longer need a variable, and want +to ensure that you haven't accidentally captured a strong reference to it elsewhere. + +Note that this clears the B<caller>'s variable. + +This function is defined with a prototype of ($), since it is only intended for use +on scalar variables. To clear multiple variables, use a L<foreach> loop: + + my ($x, $y, $z) = ...; + dispose $_ for $x, $y, $z; + is($x, undef); + is($y, undef); + is($z, undef); + +=head2 retain + +Keeps a copy of this variable until program exit or L</dispose>. + +Returns the original variable. + +=head2 retain_future + +Holds a copy of the given L<Future> until it's marked ready, then releases our copy. +Does not use L</dispose>, since that could interfere with other callbacks attached +to the L<Future>. + +Returns the original L<Future>. + +=head1 SEE ALSO + +=over 4 + +=item * L<Devel::Refcount> - assert_oneref is almost identical to this, although it doesn't clear the variable it's called on + +=item * L<Closure::Explicit> - provides a sub{} wrapper that will complain if you capture a lexical without explicitly declaring that you're going to do that. + +=back + +=head1 INHERITED METHODS + +=over 4 + +=item L<Exporter> + +L<as_heavy|Exporter/as_heavy>, L<export|Exporter/export>, L<export_fail|Exporter/export_fail>, L<export_ok_tags|Exporter/export_ok_tags>, L<export_tags|Exporter/export_tags>, L<export_to_level|Exporter/export_to_level>, L<import|Exporter/import>, L<require_version|Exporter/require_version> + +=back + +=head1 AUTHOR + +Tom Molesworth <cpan@perlsite.co.uk> + +=head1 LICENSE + +Copyright Tom Molesworth 2014-2015. Licensed under the same terms as Perl itself. diff --git a/t/00-check-deps.t b/t/00-check-deps.t new file mode 100644 index 0000000..175a3f1 --- /dev/null +++ b/t/00-check-deps.t @@ -0,0 +1,17 @@ +use strict; +use warnings; + +# this test was generated with Dist::Zilla::Plugin::Test::CheckDeps 0.012 + +use Test::More 0.94; +use Test::CheckDeps 0.010; + + +check_dependencies('classic'); + + +if (0) { + BAIL_OUT("Missing dependencies") if !Test::More->builder->is_passing; +} + +done_testing; diff --git a/t/00-compile.t b/t/00-compile.t new file mode 100644 index 0000000..f6155dc --- /dev/null +++ b/t/00-compile.t @@ -0,0 +1,51 @@ +use 5.006; +use strict; +use warnings; + +# this test was generated with Dist::Zilla::Plugin::Test::Compile 2.051 + +use Test::More; + +plan tests => 1 + ($ENV{AUTHOR_TESTING} ? 1 : 0); + +my @module_files = ( + 'Variable/Disposition.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<perlfaq8/How can I capture STDERR from an external command?> + 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') + or diag 'got warnings: ', ( Test::More->can('explain') ? Test::More::explain(\@warnings) : join("\n", '', @warnings) ) if $ENV{AUTHOR_TESTING}; + + diff --git a/t/000-report-versions-tiny.t b/t/000-report-versions-tiny.t new file mode 100644 index 0000000..721419e --- /dev/null +++ b/t/000-report-versions-tiny.t @@ -0,0 +1,78 @@ +use strict; +use warnings; +use Test::More 0.88; +# This is a relatively nice way to avoid Test::NoWarnings breaking our +# expectations by adding extra tests, without using no_plan. It also helps +# avoid any other test module that feels introducing random tests, or even +# test plans, is a nice idea. +our $success = 0; +END { $success && done_testing; } + +# List our own version used to generate this +my $v = "\nGenerated by Dist::Zilla::Plugin::ReportVersions::Tiny v1.10\n"; + +eval { # no excuses! + # report our Perl details + my $want = '5.010001'; + $v .= "perl: $] (wanted $want) on $^O from $^X\n\n"; +}; +defined($@) and diag("$@"); + +# Now, our module version dependencies: +sub pmver { + my ($module, $wanted) = @_; + $wanted = " (want $wanted)"; + my $pmver; + eval "require $module;"; + if ($@) { + if ($@ =~ m/Can't locate .* in \@INC/) { + $pmver = 'module not found.'; + } else { + diag("${module}: $@"); + $pmver = 'died during require.'; + } + } else { + my $version; + eval { $version = $module->VERSION; }; + if ($@) { + diag("${module}: $@"); + $pmver = 'died during VERSION check.'; + } elsif (defined $version) { + $pmver = "$version"; + } else { + $pmver = '<undef>'; + } + } + + # So, we should be good, right? + return sprintf('%-45s => %-10s%-15s%s', $module, $pmver, $wanted, "\n"); +} + +eval { $v .= pmver('ExtUtils::MakeMaker','6.48') }; +eval { $v .= pmver('File::Spec','any version') }; +eval { $v .= pmver('Future','0.30') }; +eval { $v .= pmver('IO::Handle','any version') }; +eval { $v .= pmver('IPC::Open3','any version') }; +eval { $v .= pmver('Test::CheckDeps','0.010') }; +eval { $v .= pmver('Test::Fatal','0.010') }; +eval { $v .= pmver('Test::More','0.98') }; +eval { $v .= pmver('Test::Refcount','any version') }; + + +# All done. +$v .= <<'EOT'; + +Thanks for using my code. I hope it works for you. +If not, please try and include this output in the bug report. +That will help me reproduce the issue and solve your problem. + +EOT + +diag($v); +ok(1, "we really didn't test anything, just reporting data"); +$success = 1; + +# Work around another nasty module on CPAN. :/ +no warnings 'once'; +$Template::Test::NO_FLUSH = 1; +exit 0; diff --git a/t/basic.t b/t/basic.t new file mode 100644 index 0000000..42c0310 --- /dev/null +++ b/t/basic.t @@ -0,0 +1,54 @@ +use strict; +use warnings; + +use Test::More; +use Test::Fatal; +use Variable::Disposition; + +{ + my $x = [1,2,3]; + isa_ok($x, 'ARRAY'); + dispose $x; + is($x, undef, 'was undefined correctly'); +} + +{ + my $x = [1,2,3]; + my $copy = $x; + like(exception { + dispose $x; + }, qr/not released/, 'raise an exception if variable is still around'); + is($x, undef, 'was still undefined correctly'); + is(exception { + dispose $copy; + }, undef, 'no exception when last copy goes'); +} + +{ + my $x = 'test'; + like(exception { + dispose $x; + }, qr/not a ref/, 'raise an exception when called on non-ref'); + is($x, 'test', 'still defined'); + undef $x; + like(exception { + dispose $x; + }, qr/not defined/, 'raise an exception when called on undef'); +} + +my $destroyed = 0; +{ + { + package Local::Test; + sub DESTROY { ++$destroyed } + } + my $x = bless {}, 'Local::Test'; + is($destroyed, 0, 'not yet destroyed'); + dispose $x; + is($destroyed, 1, 'destroyed after dispose()'); + is($x, undef, 'was undef'); +} +is($destroyed, 1, 'still only a single DESTROY called when leaving scope'); + +done_testing; + diff --git a/t/retain.t b/t/retain.t new file mode 100644 index 0000000..9e74ac5 --- /dev/null +++ b/t/retain.t @@ -0,0 +1,26 @@ +use strict; +use warnings; + +use Test::More; +use Test::Refcount; +use Variable::Disposition qw(retain dispose); + +my $copy; +{ + my $x = []; + Scalar::Util::weaken($copy = $x); + ok($x, 'have a variable'); + is_refcount($x, 1, 'refcount is now 1'); + Scalar::Util::weaken($copy = $x); + is_refcount($x, 1, 'refcount is still 1'); + retain($x); + is_refcount($x, 2, 'refcount is now 2'); +} +is_refcount($copy, 1, 'refcount is still 1'); +ok($copy, 'copy still exists'); +dispose($copy); +is($copy, undef, 'copy went away'); + +done_testing; + + diff --git a/t/retain_future.t b/t/retain_future.t new file mode 100644 index 0000000..022c972 --- /dev/null +++ b/t/retain_future.t @@ -0,0 +1,32 @@ +use strict; +use warnings; + +use Test::More; +use Test::Refcount; +use Variable::Disposition qw(retain_future dispose); + +unless(eval { require Future }) { + plan skip_all => 'this test requires Future.pm'; +} + +for my $resolution (qw(done fail cancel)) { + my $f = Future->new; + is_refcount($f, 1, 'refcount is 1'); + retain_future($f); + is_refcount($f, 2, 'refcount is now 2'); + $f->$resolution('...'); + is_refcount($f, 1, 'refcount is back to 1 after ' . $resolution); + dispose($f); + is($f, undef, 'goes away after dispose'); +} + +{ + ok(retain_future(Future->done), 'can retain ->done Future'); + ok(retain_future(Future->fail("...")), 'can retain ->failed Future'); + ok(retain_future(Future->new->cancel), 'can retain ->cancelled Future'); +} + + +done_testing; + + diff --git a/xt/release/common_spelling.t b/xt/release/common_spelling.t new file mode 100644 index 0000000..7aed722 --- /dev/null +++ b/xt/release/common_spelling.t @@ -0,0 +1,11 @@ +#!/usr/bin/perl +use strict; use warnings; + +use Test::More; + +eval "use Test::Pod::Spelling::CommonMistakes"; +if ( $@ ) { + plan skip_all => 'Test::Pod::Spelling::CommonMistakes required for testing POD'; +} else { + all_pod_files_ok(); +} diff --git a/xt/release/mojibake.t b/xt/release/mojibake.t new file mode 100644 index 0000000..390c632 --- /dev/null +++ b/xt/release/mojibake.t @@ -0,0 +1,12 @@ +#!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(); diff --git a/xt/release/pod-syntax.t b/xt/release/pod-syntax.t new file mode 100644 index 0000000..f0468f1 --- /dev/null +++ b/xt/release/pod-syntax.t @@ -0,0 +1,6 @@ +#!perl +# This file was automatically generated by Dist::Zilla::Plugin::PodSyntaxTests. +use Test::More; +use Test::Pod 1.41; + +all_pod_files_ok(); diff --git a/xt/release/synopsis.t b/xt/release/synopsis.t new file mode 100644 index 0000000..3e03427 --- /dev/null +++ b/xt/release/synopsis.t @@ -0,0 +1,5 @@ +#!perl + +use Test::Synopsis; + +all_synopsis_ok(); diff --git a/xt/release/test-version.t b/xt/release/test-version.t new file mode 100644 index 0000000..9bccdf0 --- /dev/null +++ b/xt/release/test-version.t @@ -0,0 +1,22 @@ +use strict; +use warnings; +use Test::More; + +# generated by Dist::Zilla::Plugin::Test::Version 0.003001 +use Test::Version; + +my @imports = ( 'version_all_ok' ); + +my $params = { + is_strict => 0, + 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; |