r5641 - in /packages/libscope-guard-perl: ./ branches/ branches/upstream/ branches/upstream/current/ branches/upstream/current/lib/ branches/upstream/current/lib/Scope/ branches/upstream/current/t/ tags/

eloy at users.alioth.debian.org eloy at users.alioth.debian.org
Fri Jun 22 09:04:40 UTC 2007


Author: eloy
Date: Fri Jun 22 09:04:39 2007
New Revision: 5641

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=5641
Log:
[svn-inject] Installing original source of libscope-guard-perl

Added:
    packages/libscope-guard-perl/
    packages/libscope-guard-perl/branches/
    packages/libscope-guard-perl/branches/upstream/
    packages/libscope-guard-perl/branches/upstream/current/
    packages/libscope-guard-perl/branches/upstream/current/Changes
    packages/libscope-guard-perl/branches/upstream/current/MANIFEST
    packages/libscope-guard-perl/branches/upstream/current/META.yml
    packages/libscope-guard-perl/branches/upstream/current/Makefile.PL
    packages/libscope-guard-perl/branches/upstream/current/README
    packages/libscope-guard-perl/branches/upstream/current/lib/
    packages/libscope-guard-perl/branches/upstream/current/lib/Scope/
    packages/libscope-guard-perl/branches/upstream/current/lib/Scope/Guard.pm
    packages/libscope-guard-perl/branches/upstream/current/t/
    packages/libscope-guard-perl/branches/upstream/current/t/Scope-Guard.t
    packages/libscope-guard-perl/branches/upstream/current/t/pod.t
    packages/libscope-guard-perl/branches/upstream/current/t/pod_coverage.t
    packages/libscope-guard-perl/tags/

Added: packages/libscope-guard-perl/branches/upstream/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libscope-guard-perl/branches/upstream/current/Changes?rev=5641&op=file
==============================================================================
--- packages/libscope-guard-perl/branches/upstream/current/Changes (added)
+++ packages/libscope-guard-perl/branches/upstream/current/Changes Fri Jun 22 09:04:39 2007
@@ -1,0 +1,11 @@
+Revision history for Perl extension Scope::Guard.
+
+0.03 Sun Jan  7 19:19:17 2007
+    - POD fix (thanks Craig Manley)
+    - added test suite
+
+0.02 Tue Apr 12 02:12:04 2005
+    - POD fixlet
+
+0.01 Tue Apr 12 00:32:52 2005
+    - original version; created by h2xs 1.23 with options -X -v 0.01 -n Scope::Guard

Added: packages/libscope-guard-perl/branches/upstream/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libscope-guard-perl/branches/upstream/current/MANIFEST?rev=5641&op=file
==============================================================================
--- packages/libscope-guard-perl/branches/upstream/current/MANIFEST (added)
+++ packages/libscope-guard-perl/branches/upstream/current/MANIFEST Fri Jun 22 09:04:39 2007
@@ -1,0 +1,9 @@
+Changes
+MANIFEST
+META.yml
+Makefile.PL
+README
+lib/Scope/Guard.pm
+t/Scope-Guard.t
+t/pod.t
+t/pod_coverage.t

Added: packages/libscope-guard-perl/branches/upstream/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libscope-guard-perl/branches/upstream/current/META.yml?rev=5641&op=file
==============================================================================
--- packages/libscope-guard-perl/branches/upstream/current/META.yml (added)
+++ packages/libscope-guard-perl/branches/upstream/current/META.yml Fri Jun 22 09:04:39 2007
@@ -1,0 +1,11 @@
+# http://module-build.sourceforge.net/META-spec.html
+#XXXXXXX This is a prototype!!!  It will change in the future!!! XXXXX#
+name:         Scope-Guard
+version:      0.03
+version_from: lib/Scope/Guard.pm
+installdirs:  site
+requires:
+    Test::More:                    0
+
+distribution_type: module
+generated_by: ExtUtils::MakeMaker version 6.17

Added: packages/libscope-guard-perl/branches/upstream/current/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libscope-guard-perl/branches/upstream/current/Makefile.PL?rev=5641&op=file
==============================================================================
--- packages/libscope-guard-perl/branches/upstream/current/Makefile.PL (added)
+++ packages/libscope-guard-perl/branches/upstream/current/Makefile.PL Fri Jun 22 09:04:39 2007
@@ -1,0 +1,14 @@
+use 5.006001;
+use ExtUtils::MakeMaker;
+# See lib/ExtUtils/MakeMaker.pm for details of how to influence
+# the contents of the Makefile that is written.
+WriteMakefile(
+    NAME              => 'Scope::Guard',
+    VERSION_FROM      => 'lib/Scope/Guard.pm', # finds $VERSION
+    PREREQ_PM         => {
+	'Test::More'	=> 0,
+    }, # e.g., Module::Name => 1.1
+    ($] >= 5.005 ?     ## Add these new keywords supported since 5.005
+      (ABSTRACT_FROM  => 'lib/Scope/Guard.pm', # retrieve abstract from module
+       AUTHOR         => 'chocolateboy <chocolate.boy at email.com>') : ()),
+);

Added: packages/libscope-guard-perl/branches/upstream/current/README
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libscope-guard-perl/branches/upstream/current/README?rev=5641&op=file
==============================================================================
--- packages/libscope-guard-perl/branches/upstream/current/README (added)
+++ packages/libscope-guard-perl/branches/upstream/current/README Fri Jun 22 09:04:39 2007
@@ -1,0 +1,28 @@
+Scope-Guard version 0.03
+========================
+
+This module provides a convenient way to perform cleanup or other forms of resource
+management at the end of a scope. It is particularly useful when dealing with exceptions:
+the Scope::Guard constructor takes a reference to a subroutine that is guaranteed to
+be called even if the thread of execution is aborted prematurely. This effectively allows
+lexically-scoped "promises" to be made that are automatically honoured by perl's garbage
+collector.
+
+For more information, see: http://www.cuj.com/documents/s=8000/cujcexp1812alexandr/
+
+INSTALLATION
+
+To install this module, type the following:
+
+   perl Makefile.PL
+   make
+   make test
+   make install
+
+COPYRIGHT AND LICENCE
+
+Copyright (c) 2005-2007 by chocolateboy <chocolate.boy at email.com>
+
+This library is free software; you can redistribute it and/or modify
+it under the same terms as Perl itself, either Perl version 5.8.6 or,
+at your option, any later version of Perl 5 you may have available.

Added: packages/libscope-guard-perl/branches/upstream/current/lib/Scope/Guard.pm
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libscope-guard-perl/branches/upstream/current/lib/Scope/Guard.pm?rev=5641&op=file
==============================================================================
--- packages/libscope-guard-perl/branches/upstream/current/lib/Scope/Guard.pm (added)
+++ packages/libscope-guard-perl/branches/upstream/current/lib/Scope/Guard.pm Fri Jun 22 09:04:39 2007
@@ -1,0 +1,129 @@
+package Scope::Guard;
+
+use strict;
+use warnings;
+
+use vars qw($VERSION);
+
+$VERSION = '0.03';
+
+sub new {
+    my $class = shift;
+    my $handler = shift() || die "Scope::Guard::new: no handler supplied";
+    my $ref = ref $handler || '';
+
+    die "Scope::Guard::new: invalid handler - expected CODE ref, got: '$ref'"
+	unless (UNIVERSAL::isa($handler, 'CODE'));
+
+    bless [ 0, $handler ], ref $class || $class;
+}
+
+sub dismiss {
+    my $self = shift;
+    my $dismiss = @_ ? shift : 1;
+
+    $self->[0] = $dismiss;
+}
+
+sub DESTROY {
+    my $self = shift;
+    my ($dismiss, $handler) = @$self;
+
+    $handler->() unless ($dismiss);
+}
+
+1;
+
+__END__
+
+=pod
+
+=head1 NAME
+
+Scope::Guard - lexically scoped resource management
+
+=head1 SYNOPSIS
+
+	my $sg = Scope::Guard->new(sub { ... });
+
+	  # or
+
+	my $sg = Scope::Guard->new(\&handler);
+
+	$sg->dismiss(); # disable the handler
+
+=head1 DESCRIPTION
+
+This module provides a convenient way to perform cleanup or other forms of resource
+management at the end of a scope. It is particularly useful when dealing with exceptions:
+the Scope::Guard constructor takes a reference to a subroutine that is guaranteed to
+be called even if the thread of execution is aborted prematurely. This effectively allows
+lexically-scoped "promises" to be made that are automatically honoured by perl's garbage
+collector.
+
+For more information, see: L<http://www.cuj.com/documents/s=8000/cujcexp1812alexandr/>
+
+=head2 new
+
+=head3 usage
+
+    my $sg = Scope::Guard->new(sub { ... });
+
+	  # or
+
+    my $sg = Scope::Guard->new(\&handler);
+
+=head3 description
+
+Create a new Scope::Guard object which calls the supplied handler when its C<DESTROY> method is
+called, typically when it goes out of scope.
+
+=head2 dismiss
+
+=head3 usage
+
+    $sg->dismiss();
+
+	  # or
+
+    $sg->dismiss(1);
+
+=head3 description
+
+Detach the handler from the Scope::Guard object. This revokes the "promise" to call the
+handler when the object is destroyed.
+
+The handler can be re-enabled by calling:
+
+	$sg->dismiss(0);
+
+=head1 VERSION
+
+0.03
+
+=head1 SEE ALSO
+
+=over
+
+=item * L<Hook::LexWrap|Hook::LexWrap>
+
+=item * L<Hook::Scope|Hook::Scope>
+
+=item * L<Sub::ScopeFinalizer|Sub::ScopeFinalizer>
+
+=item * L<Object::Destroyer|Object::Destroyer>
+
+=back
+
+=head1 AUTHOR
+
+chocolateboy: <chocolate.boy at email.com>
+
+=head1 COPYRIGHT
+
+Copyright (c) 2005-2007, chocolateboy.
+
+This module is free software. It may be used, redistributed and/or modified under the same terms
+as Perl itself.
+
+=cut

Added: packages/libscope-guard-perl/branches/upstream/current/t/Scope-Guard.t
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libscope-guard-perl/branches/upstream/current/t/Scope-Guard.t?rev=5641&op=file
==============================================================================
--- packages/libscope-guard-perl/branches/upstream/current/t/Scope-Guard.t (added)
+++ packages/libscope-guard-perl/branches/upstream/current/t/Scope-Guard.t Fri Jun 22 09:04:39 2007
@@ -1,0 +1,49 @@
+# Before `make install' is performed this script should be runnable with
+# `make test'. After `make install' it should work as `perl Scope-Guard.t'
+
+use blib;
+use strict;
+use warnings;
+
+use Test::More tests => 8;
+
+BEGIN { use_ok('Scope::Guard') };
+
+my $i = 1;
+
+{
+    my $sg = Scope::Guard->new(sub { ok($i++ == 1, 'handler invoked at scope end') });
+}
+
+sub {
+    my $sg = Scope::Guard->new(sub { ok($i++ == 2, 'handler invoked on return') });
+    return;
+}->();
+
+eval {
+    my $sg = Scope::Guard->new(sub { ok($i++ == 3, 'handler invoked on exception') });
+    my $j = 0;
+    my $k = $j / $j;
+};
+
+like($@, qr{^Illegal division by zero}, 'exception was raised');
+
+{
+    my $sg = Scope::Guard->new(sub { ++$i });
+    $sg->dismiss();
+}
+
+ok($i++ == 4, 'dismiss() disables handler');
+
+{
+    my $sg = Scope::Guard->new(sub { ++$i });
+    $sg->dismiss(1);
+}
+
+ok($i++ == 5, 'dismiss(1) disables handler');
+
+{
+    my $sg = Scope::Guard->new(sub { ok($i++ == 6, 'dismiss(0) enables handler') });
+    $sg->dismiss();
+    $sg->dismiss(0);
+}

Added: packages/libscope-guard-perl/branches/upstream/current/t/pod.t
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libscope-guard-perl/branches/upstream/current/t/pod.t?rev=5641&op=file
==============================================================================
--- packages/libscope-guard-perl/branches/upstream/current/t/pod.t (added)
+++ packages/libscope-guard-perl/branches/upstream/current/t/pod.t Fri Jun 22 09:04:39 2007
@@ -1,0 +1,9 @@
+eval "use Test::Pod";
+if ($@) {
+	    print "1..0 # Skip Test::Pod not installed\n";
+		    exit;
+} 
+ 
+ my @PODS = qw#../blib#;
+
+all_pod_files_ok( all_pod_files(@PODS) );

Added: packages/libscope-guard-perl/branches/upstream/current/t/pod_coverage.t
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libscope-guard-perl/branches/upstream/current/t/pod_coverage.t?rev=5641&op=file
==============================================================================
--- packages/libscope-guard-perl/branches/upstream/current/t/pod_coverage.t (added)
+++ packages/libscope-guard-perl/branches/upstream/current/t/pod_coverage.t Fri Jun 22 09:04:39 2007
@@ -1,0 +1,13 @@
+eval "use Test::Pod::Coverage";
+
+if ($@) {
+	print "1..0 # Skip Test::Pod::Coverage not installed", $/;
+	exit;
+} 
+
+my $ARGS = {
+	also_private    => [],
+	trustme			=> [],
+};
+
+all_pod_coverage_ok($ARGS);




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