r2801 - in /packages/libsub-install-perl/trunk: Changes MANIFEST
META.yml debian/changelog lib/Sub/Install.pm t/export.t
eloy at users.alioth.debian.org
eloy at users.alioth.debian.org
Tue May 23 14:37:58 UTC 2006
Author: eloy
Date: Tue May 23 14:37:56 2006
New Revision: 2801
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=2801
Log:
eloy: new upstream version
Added:
packages/libsub-install-perl/trunk/t/export.t
- copied unchanged from r2800, packages/libsub-install-perl/branches/upstream/current/t/export.t
Modified:
packages/libsub-install-perl/trunk/Changes
packages/libsub-install-perl/trunk/MANIFEST
packages/libsub-install-perl/trunk/META.yml
packages/libsub-install-perl/trunk/debian/changelog
packages/libsub-install-perl/trunk/lib/Sub/Install.pm
Modified: packages/libsub-install-perl/trunk/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libsub-install-perl/trunk/Changes?rev=2801&op=diff
==============================================================================
--- packages/libsub-install-perl/trunk/Changes (original)
+++ packages/libsub-install-perl/trunk/Changes Tue May 23 14:37:56 2006
@@ -1,4 +1,8 @@
Revision history for Sub-Install
+
+0.92 2006-05-11
+ allow other users to build exporters like our tiny one (&exporter)
+ rename _CALLABLE to _CODELIKE to keep up with Params::Util
0.91 2006-04-30
use _CALLABLE to determine callability of code, not ref
Modified: packages/libsub-install-perl/trunk/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libsub-install-perl/trunk/MANIFEST?rev=2801&op=diff
==============================================================================
--- packages/libsub-install-perl/trunk/MANIFEST (original)
+++ packages/libsub-install-perl/trunk/MANIFEST Tue May 23 14:37:56 2006
@@ -5,6 +5,7 @@
README
t/00-load.t
t/auto_as.t
+t/export.t
t/install.t
t/inst-blessed.t
t/misc_errors.t
Modified: packages/libsub-install-perl/trunk/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libsub-install-perl/trunk/META.yml?rev=2801&op=diff
==============================================================================
--- packages/libsub-install-perl/trunk/META.yml (original)
+++ packages/libsub-install-perl/trunk/META.yml Tue May 23 14:37:56 2006
@@ -1,7 +1,7 @@
# http://module-build.sourceforge.net/META-spec.html
#XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX#
name: Sub-Install
-version: 0.91
+version: 0.92
version_from: lib/Sub/Install.pm
installdirs: site
requires:
Modified: packages/libsub-install-perl/trunk/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libsub-install-perl/trunk/debian/changelog?rev=2801&op=diff
==============================================================================
--- packages/libsub-install-perl/trunk/debian/changelog (original)
+++ packages/libsub-install-perl/trunk/debian/changelog Tue May 23 14:37:56 2006
@@ -1,3 +1,9 @@
+libsub-install-perl (0.92-1) unstable; urgency=low
+
+ * New upstream release
+
+ -- Krzysztof Krzyzaniak (eloy) <eloy at debian.org> Tue, 23 May 2006 16:31:29 +0200
+
libsub-install-perl (0.91-1) unstable; urgency=low
* New upstream release (closes: #366249)
Modified: packages/libsub-install-perl/trunk/lib/Sub/Install.pm
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libsub-install-perl/trunk/lib/Sub/Install.pm?rev=2801&op=diff
==============================================================================
--- packages/libsub-install-perl/trunk/lib/Sub/Install.pm (original)
+++ packages/libsub-install-perl/trunk/lib/Sub/Install.pm Tue May 23 14:37:56 2006
@@ -3,7 +3,7 @@
use warnings;
use strict;
-use Carp qw(croak);
+use Carp;
use Scalar::Util ();
=head1 NAME
@@ -12,13 +12,13 @@
=head1 VERSION
-version 0.91
+version 0.92
$Id: /my/rjbs/subinst/trunk/lib/Sub/Install.pm 16622 2005-11-23T00:17:55.304991Z rjbs $
=cut
-our $VERSION = '0.91';
+our $VERSION = '0.92';
=head1 SYNOPSIS
@@ -38,7 +38,7 @@
=head1 FUNCTIONS
-=head2 C< install_sub >
+=head2 install_sub
Sub::Install::install_sub({
code => \&subroutine,
@@ -80,7 +80,7 @@
as => 'dance',
});
-=head2 C< reinstall_sub >
+=head2 reinstall_sub
This routine behaves exactly like C<L</install_sub>>, but does not emit a
warning if warnings are on and the destination is already defined.
@@ -95,7 +95,8 @@
return;
}
-sub _CALLABLE {
+# See also Params::Util, to which this code was donated.
+sub _CODELIKE {
(Scalar::Util::reftype($_[0])||'') eq 'CODE' or Scalar::Util::blessed($_[0])
and overload::Method($_[0],'&{}') ? $_[0] : undef;
}
@@ -112,12 +113,12 @@
for (qw(into from)) { $arg->{$_} = $calling_pkg unless $arg->{$_} }
# This is the only absolutely required argument, in many cases.
- croak "named argument 'code' is not optional" unless $arg->{code};
-
- if (_CALLABLE($arg->{code})) {
+ Carp::croak "named argument 'code' is not optional" unless $arg->{code};
+
+ if (_CODELIKE($arg->{code})) {
$arg->{as} ||= _name_of_code($arg->{code});
} else {
- croak
+ Carp::croak
"couldn't find subroutine named $arg->{code} in package $arg->{from}"
unless my $code = $arg->{from}->can($arg->{code});
@@ -125,7 +126,7 @@
$arg->{code} = $code;
}
- croak "couldn't determine name under which to install subroutine"
+ Carp::croak "couldn't determine name under which to install subroutine"
unless $arg->{as};
$installer->(@$arg{qw(into as code) });
@@ -208,7 +209,7 @@
});
}
-=head2 C< install_installers >
+=head2 install_installers
This routine is provided to allow Sub::Install compatibility with
Sub::Installer. It installs C<install_sub> and C<reinstall_sub> methods into
@@ -258,19 +259,34 @@
Sub::Install exports C<install_sub> and C<reinstall_sub> only if they are
requested.
-=cut
-
-my @EXPORT_OK;
-BEGIN { @EXPORT_OK = qw(install_sub reinstall_sub); }
-
-sub import {
- my $class = shift;
- my %todo = map { $_ => 1 } @_;
- my ($target) = caller(0);
-
- # eating my own dogfood
- install_sub({ code => $_, into => $target }) for grep {$todo{$_}} @EXPORT_OK;
-}
+=head2 exporter
+
+Sub::Install has a never-exported subroutine called C<exporter>, which is used
+to implement its C<import> routine. It takes a hashref of named arguments,
+only one of which is currently recognize: C<exports>. This must be an arrayref
+of subroutines to offer for export.
+
+This routine is mainly for Sub::Install's own consumption. Instead, consider
+L<Sub::Exporter>.
+
+=cut
+
+sub exporter {
+ my ($arg) = @_;
+
+ my %is_exported = map { $_ => undef } @{ $arg->{exports} };
+
+ sub {
+ my $class = shift;
+ my $target = caller;
+ for (@_) {
+ Carp::croak "'$_' is not exported by $class" if !exists $is_exported{$_};
+ install_sub({ code => $_, from => $class, into => $target });
+ }
+ }
+}
+
+BEGIN { *import = exporter({ exports => [ qw(install_sub reinstall_sub) ] }); }
=head1 SEE ALSO
More information about the Pkg-perl-cvs-commits
mailing list