r33022 - in /branches/upstream/libend-perl/current: End.pm MANIFEST META.yml Makefile.PL lib/ lib/End.pm t/ t/000_tests.t test.pl

ryan52-guest at users.alioth.debian.org ryan52-guest at users.alioth.debian.org
Sat Apr 11 04:32:55 UTC 2009


Author: ryan52-guest
Date: Sat Apr 11 04:32:48 2009
New Revision: 33022

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=33022
Log:
[svn-upgrade] Integrating new upstream version, libend-perl (2009040201)

Added:
    branches/upstream/libend-perl/current/META.yml
    branches/upstream/libend-perl/current/lib/
    branches/upstream/libend-perl/current/lib/End.pm
    branches/upstream/libend-perl/current/t/
    branches/upstream/libend-perl/current/t/000_tests.t   (with props)
Removed:
    branches/upstream/libend-perl/current/End.pm
    branches/upstream/libend-perl/current/test.pl
Modified:
    branches/upstream/libend-perl/current/MANIFEST
    branches/upstream/libend-perl/current/Makefile.PL

Modified: branches/upstream/libend-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libend-perl/current/MANIFEST?rev=33022&op=diff
==============================================================================
--- branches/upstream/libend-perl/current/MANIFEST (original)
+++ branches/upstream/libend-perl/current/MANIFEST Sat Apr 11 04:32:48 2009
@@ -1,4 +1,5 @@
-End.pm
+lib/End.pm
 MANIFEST
 Makefile.PL
-test.pl
+t/000_tests.t
+META.yml                                 Module meta-data (added by MakeMaker)

Added: branches/upstream/libend-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libend-perl/current/META.yml?rev=33022&op=file
==============================================================================
--- branches/upstream/libend-perl/current/META.yml (added)
+++ branches/upstream/libend-perl/current/META.yml Sat Apr 11 04:32:48 2009
@@ -1,0 +1,13 @@
+--- #YAML:1.0
+name:                End
+version:             2009040201
+abstract:            ~
+license:             ~
+author:              
+    - Abigail <cpan at abigail.be>
+generated_by:        ExtUtils::MakeMaker version 6.42
+distribution_type:   module
+requires:     
+meta-spec:
+    url:     http://module-build.sourceforge.net/META-spec-v1.3.html
+    version: 1.3

Modified: branches/upstream/libend-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libend-perl/current/Makefile.PL?rev=33022&op=diff
==============================================================================
--- branches/upstream/libend-perl/current/Makefile.PL (original)
+++ branches/upstream/libend-perl/current/Makefile.PL Sat Apr 11 04:32:48 2009
@@ -3,6 +3,7 @@
 # the contents of the Makefile that is written.
 WriteMakefile(
     'NAME'		=> 'End',
-    'VERSION_FROM'	=> 'End.pm', # finds $VERSION
+    'VERSION_FROM'	=> 'lib/End.pm', # finds $VERSION
     'PREREQ_PM'		=> {}, # e.g., Module::Name => 1.1
+     AUTHOR             => 'Abigail <cpan at abigail.be>',
 );

Added: branches/upstream/libend-perl/current/lib/End.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libend-perl/current/lib/End.pm?rev=33022&op=file
==============================================================================
--- branches/upstream/libend-perl/current/lib/End.pm (added)
+++ branches/upstream/libend-perl/current/lib/End.pm Sat Apr 11 04:32:48 2009
@@ -1,0 +1,107 @@
+package End;
+
+use 5.006;
+
+use strict;
+use warnings;
+no  warnings 'syntax';
+
+use Exporter;
+
+our @ISA     = qw /Exporter/;
+our @EXPORT  = qw /end/;
+
+our $VERSION = '2009040201';
+
+sub end (&) {
+    my    $code =  shift;
+    # Due to a bug in Perl 5.6.0, we can't just bless $code.
+    # But by creating an extra closure, it'll work.
+    bless sub {$code -> ()} => __PACKAGE__;
+}
+
+DESTROY {$_ [0] -> ()}
+
+1;
+
+__END__
+
+=pod
+
+=head1 NAME 
+
+End - generalized END {}.
+
+=head1 SYNOPSIS
+
+    use End;
+
+    {  my $foo = end {print "Leaving the block\n"};
+       ...
+       last;    # prints "Leaving the block\n".
+       ...
+    }
+
+
+=head1 DESCRIPTION
+
+The module C<End> exports a single subroutine C<end>, which allows
+you to set up some code that is run whenever the current block is exited,
+regardless whether that is due to a C<return>, C<next>, C<last>, C<redo>,
+C<exit>, C<die>, C<goto> or just reaching the end of the block.
+
+To be more precise, C<end> returns an object, that will execute the
+code when the object is destroyed; that is, when the variable assigned
+to goes out of scope. If the variable is lexical to the current block,
+the code will be executed when leaving the block. 
+
+One can force premature execution of the code by undefining the variable
+assigned to, or assigning another value to the variable. 
+
+C<end> only takes one argument, a code reference. If one wishes the code
+reference to take arguments, wrapping the code reference in a closure
+suffices.
+
+=head1 BUGS
+
+Due to a bug in Perl 5.6.0 (and perhaps before), anonymous subroutines
+that are not a closure will not go out of scope, not even on program
+termination. That is why C<end> wraps the code fragment in a closure.
+
+There is a second bug in Perl 5.6.0 (and perhaps before) why this is
+necessary. If the code fragment isn't wrapped in another code reference,
+the original subroutine will be blessed in the package, making that C<ref>
+on that code no longer returns the right value.
+
+=head1 DEVELOPMENT
+
+The current sources of this module are found on github,
+L<< git://github.com/Abigail/end.git >>.
+
+=head1 AUTHOR
+
+This package was written by Abigail, L<< mailto:cpan at abigail.be >>
+
+=head1 COPYRIGHT & LICENSE
+
+Copyright (C) 2000 - 2009, Abigail
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the "Software"),
+to deal in the Software without restriction, including without limitation
+the rights to use, copy, modify, merge, publish, distribute, sublicense,
+and/or sell copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
+OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+
+=cut

Added: branches/upstream/libend-perl/current/t/000_tests.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libend-perl/current/t/000_tests.t?rev=33022&op=file
==============================================================================
--- branches/upstream/libend-perl/current/t/000_tests.t (added)
+++ branches/upstream/libend-perl/current/t/000_tests.t Sat Apr 11 04:32:48 2009
@@ -1,0 +1,34 @@
+# Before `make install' is performed this script should be runnable with
+# `make test'. After `make install' it should work as `perl test.pl'
+
+######################### We start with some black magic to print on failure.
+
+# Change 1..1 below to 1..last_test_to_print .
+# (It may become useful if the test is moved to ./t subdirectory.)
+
+BEGIN { $| = 1; print "1..3\n"; }
+END {print "not ok 1\n" unless $loaded;}
+use End;
+$loaded = 1;
+print "ok 1\n";
+
+######################### End of black magic.
+
+# Insert your test code below (better if it prints "ok 13"
+# (correspondingly "not ok 13") depending on the success of chunk 13
+# of the test code):
+
+my $i = 1;
+{  my $foo = end {$i ++};
+   $i += 2;
+   last;
+   $i += 2;
+}
+print $i == 4 ? "ok 2\n" : "not ok 2\n";
+
+my $sum = 0;
+foreach my $i (1 .. 9) {
+    my $foo = end {$sum += $i};
+    next;
+}
+print $sum == 45 ? "ok 3\n" : "not ok 3\n";

Propchange: branches/upstream/libend-perl/current/t/000_tests.t
------------------------------------------------------------------------------
    svn:executable = *




More information about the Pkg-perl-cvs-commits mailing list