r2904 - in /packages/libmodule-pluggable-perl/trunk: Changes
MANIFEST
META.yml debian/changelog debian/control lib/Devel/ lib/Module/Pluggable.pm
lib/Module/Pluggable/ t/01use.t t/16different_extension.t
t/17devel_inner_package.t t/lib/ExtTest/ t/lib/TA/
eloy at users.alioth.debian.org
eloy at users.alioth.debian.org
Wed Jun 7 13:14:29 UTC 2006
Author: eloy
Date: Wed Jun 7 13:14:28 2006
New Revision: 2904
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=2904
Log:
eloy: new upstream version
Added:
packages/libmodule-pluggable-perl/trunk/lib/Devel/
- copied from r2903, packages/libmodule-pluggable-perl/branches/upstream/current/lib/Devel/
packages/libmodule-pluggable-perl/trunk/lib/Module/Pluggable/
- copied from r2903, packages/libmodule-pluggable-perl/branches/upstream/current/lib/Module/Pluggable/
packages/libmodule-pluggable-perl/trunk/t/16different_extension.t
- copied unchanged from r2903, packages/libmodule-pluggable-perl/branches/upstream/current/t/16different_extension.t
packages/libmodule-pluggable-perl/trunk/t/17devel_inner_package.t
- copied unchanged from r2903, packages/libmodule-pluggable-perl/branches/upstream/current/t/17devel_inner_package.t
packages/libmodule-pluggable-perl/trunk/t/lib/ExtTest/
- copied from r2903, packages/libmodule-pluggable-perl/branches/upstream/current/t/lib/ExtTest/
packages/libmodule-pluggable-perl/trunk/t/lib/TA/
- copied from r2903, packages/libmodule-pluggable-perl/branches/upstream/current/t/lib/TA/
Modified:
packages/libmodule-pluggable-perl/trunk/Changes
packages/libmodule-pluggable-perl/trunk/MANIFEST
packages/libmodule-pluggable-perl/trunk/META.yml
packages/libmodule-pluggable-perl/trunk/debian/changelog
packages/libmodule-pluggable-perl/trunk/debian/control
packages/libmodule-pluggable-perl/trunk/lib/Module/Pluggable.pm
packages/libmodule-pluggable-perl/trunk/t/01use.t
Modified: packages/libmodule-pluggable-perl/trunk/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libmodule-pluggable-perl/trunk/Changes?rev=2904&op=diff
==============================================================================
--- packages/libmodule-pluggable-perl/trunk/Changes (original)
+++ packages/libmodule-pluggable-perl/trunk/Changes Wed Jun 7 13:14:28 2006
@@ -1,3 +1,13 @@
+2006-06-07 - 3.01
+ Fix from Brian Cassidy in Devel::InnerPackage
+
+2006-06-06 - 3.0
+ Big refactor to split stuff up into more manageable pieces
+
+
+2006-04-05 - 2.98
+ Allow the ability to provide the file matching regex
+
2006-02-06 - 2.97
Patch from Ricardo Signes to fix bug where File::Find
is not topic-safe in 5.6.1
Modified: packages/libmodule-pluggable-perl/trunk/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libmodule-pluggable-perl/trunk/MANIFEST?rev=2904&op=diff
==============================================================================
--- packages/libmodule-pluggable-perl/trunk/MANIFEST (original)
+++ packages/libmodule-pluggable-perl/trunk/MANIFEST Wed Jun 7 13:14:28 2006
@@ -6,7 +6,9 @@
META.yml
Makefile.PL
README
+lib/Devel/InnerPackage.pm
lib/Module/Pluggable.pm
+lib/Module/Pluggable/Object.pm
t/01use.t
t/02alsoworks.t
t/02works.t
@@ -33,8 +35,13 @@
t/13exceptregex.t
t/14package.t
t/15topicsafe.t
+t/16different_extension.t
+t/17devel_inner_package.t
t/acme/Acme/MyTest/Plugin/Foo.pm
t/lib/Acme/MyTest/Plugin/Foo.pm
+t/lib/ExtTest/Plugin/Bar.plugin
+t/lib/ExtTest/Plugin/Foo.plugin
+t/lib/ExtTest/Plugin/Quux/Foo.plugin
t/lib/MyTest/Extend/Plugin/Bar.pm
t/lib/MyTest/Plugin/Bar.pm
t/lib/MyTest/Plugin/Foo.pm
@@ -45,5 +52,6 @@
t/lib/MyOtherTest/Plugin/Quux/Foo.pm
t/lib/InnerTest/Plugin/Foo.pm
t/plugins/test.plugin
+t/lib/TA/C/A/I.pm
Modified: packages/libmodule-pluggable-perl/trunk/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libmodule-pluggable-perl/trunk/META.yml?rev=2904&op=diff
==============================================================================
--- packages/libmodule-pluggable-perl/trunk/META.yml (original)
+++ packages/libmodule-pluggable-perl/trunk/META.yml Wed Jun 7 13:14:28 2006
@@ -1,6 +1,6 @@
---
name: Module-Pluggable
-version: 2.97
+version: 3.01
author:
- Simon Wistow <simon at thegestalt.org>
abstract: automatically give your module the ability to have plugins
@@ -10,7 +10,12 @@
File::Spec::Functions: 0
Test::More: 0
provides:
+ Devel::InnerPackage:
+ file: lib/Devel/InnerPackage.pm
+ version: 0.2
Module::Pluggable:
file: lib/Module/Pluggable.pm
- version: 2.97
+ version: 3.01
+ Module::Pluggable::Object:
+ file: lib/Module/Pluggable/Object.pm
generated_by: Module::Build version 0.2611
Modified: packages/libmodule-pluggable-perl/trunk/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libmodule-pluggable-perl/trunk/debian/changelog?rev=2904&op=diff
==============================================================================
--- packages/libmodule-pluggable-perl/trunk/debian/changelog (original)
+++ packages/libmodule-pluggable-perl/trunk/debian/changelog Wed Jun 7 13:14:28 2006
@@ -1,3 +1,12 @@
+libmodule-pluggable-perl (3.01-1) unstable; urgency=low
+
+ * New upstream release
+ * debian/control:
+ - Uploaders: added me
+ - Standards-Version: increased to 3.7.2 without any changes
+
+ -- Krzysztof Krzyzaniak (eloy) <eloy at debian.org> Wed, 7 Jun 2006 15:09:35 +0200
+
libmodule-pluggable-perl (2.97-1) unstable; urgency=low
* New upstream release (Closes: #329593)
Modified: packages/libmodule-pluggable-perl/trunk/debian/control
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libmodule-pluggable-perl/trunk/debian/control?rev=2904&op=diff
==============================================================================
--- packages/libmodule-pluggable-perl/trunk/debian/control (original)
+++ packages/libmodule-pluggable-perl/trunk/debian/control Wed Jun 7 13:14:28 2006
@@ -2,10 +2,10 @@
Section: perl
Priority: optional
Maintainer: Debian Perl Group <pkg-perl-maintainers at lists.alioth.debian.org>
-Uploaders: Niko Tyni <ntyni at iki.fi>
+Uploaders: Niko Tyni <ntyni at iki.fi>, Krzysztof Krzyzaniak (eloy) <eloy at debian.org>
Build-Depends: debhelper (>= 5)
Build-Depends-Indep: perl (>= 5.6.0-16), perl-modules
-Standards-Version: 3.6.2
+Standards-Version: 3.7.2
Package: libmodule-pluggable-perl
Architecture: all
Modified: packages/libmodule-pluggable-perl/trunk/lib/Module/Pluggable.pm
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libmodule-pluggable-perl/trunk/lib/Module/Pluggable.pm?rev=2904&op=diff
==============================================================================
--- packages/libmodule-pluggable-perl/trunk/lib/Module/Pluggable.pm (original)
+++ packages/libmodule-pluggable-perl/trunk/lib/Module/Pluggable.pm Wed Jun 7 13:14:28 2006
@@ -2,18 +2,73 @@
use strict;
use vars qw($VERSION);
-use File::Find ();
-use File::Basename;
-use File::Spec::Functions qw(splitdir catdir abs2rel);
-use Carp qw(croak carp);
-
+use Module::Pluggable::Object;
# ObQuote:
# Bob Porter: Looks like you've been missing a lot of work lately.
# Peter Gibbons: I wouldn't say I've been missing it, Bob!
-$VERSION = '2.97';
+$VERSION = '3.01';
+
+sub import {
+ my $class = shift;
+ my %opts = @_;
+
+ my ($pkg, $file) = caller;
+ # the default name for the method is 'plugins'
+ my $sub = $opts{'sub_name'} || 'plugins';
+ # get our package
+ my ($package) = $opts{'package'} || $pkg;
+ $opts{filename} = $file;
+ $opts{package} = $package;
+
+
+ my $finder = Module::Pluggable::Object->new(%opts);
+ my $subroutine = sub { my $self = shift; return $finder->plugins(@_) };
+
+ my $searchsub = sub {
+ my $self = shift;
+ my ($action, at paths) = @_;
+
+ $finder->{'search_path'} = ["${package}::Plugin"] if ($action eq 'add' and not $finder->{'search_path'} );
+ push @{$finder->{'search_path'}}, @paths if ($action eq 'add');
+ $finder->{'search_path'} = \@paths if ($action eq 'new');
+ return $finder->{'search_path'};
+ };
+
+
+ my $onlysub = sub {
+ my ($self, $only) = @_;
+
+ if (defined $only) {
+ $finder->{'only'} = $only;
+ };
+
+ return $finder->{'only'};
+ };
+
+ my $exceptsub = sub {
+ my ($self, $except) = @_;
+
+ if (defined $except) {
+ $finder->{'except'} = $except;
+ };
+
+ return $finder->{'except'};
+ };
+
+
+ no strict 'refs';
+ no warnings 'redefine';
+ *{"$package\::$sub"} = $subroutine;
+ *{"$package\::search_path"} = $searchsub;
+ *{"$package\::only"} = $onlysub;
+ *{"$package\::except"} = $exceptsub;
+
+}
+
+1;
=pod
@@ -234,6 +289,16 @@
passing a C<package> option allows you to place the plugin method in a
different package other than your own.
+=head2 file_regex
+
+By default C<Module::Pluggable> only looks for I<.pm> files.
+
+By supplying a new C<file_regex> then you can change this behaviour e.g
+
+ file_regex => qr/\.plugin$/
+
+
+
=head1 METHODs
=head2 search_path
@@ -264,7 +329,7 @@
=head1 COPYING
-Copyright, 2003 Simon Wistow
+Copyright, 2006 Simon Wistow
Distributed under the same terms as Perl itself.
@@ -279,236 +344,3 @@
=cut
-sub import {
- my $class = shift;
- my %opts = @_;
-
- # override 'require'
- $opts{'require'} = 1 if $opts{'inner'};
-
- if ($opts{'par'}) {
-
- }
-
- my ($package, $filename) = caller;
-
- # automatically turn a scalar search path or namespace into a arrayref
- for (qw(search_path search_dirs)) {
- $opts{$_} = [ $opts{$_} ] if exists $opts{$_} && !ref($opts{$_});
- }
-
-
- # the default name for the method is 'plugins'
- my $sub = $opts{'sub_name'} || 'plugins';
-
-
- # get our package
- my ($pkg) = $opts{'package'} || $package;
-
- my $subroutine = sub {
- my $self = shift;
-
-
- # default search path is '<Module>::<Name>::Plugin'
- $opts{'search_path'} = ["${pkg}::Plugin"] unless $opts{'search_path'};
-
- # predeclare
- my @plugins;
-
-
- # check to see if we're running under test
- my @SEARCHDIR = exists $INC{"blib.pm"} && $filename =~ m!(^|/)blib/! ? grep {/blib/} @INC : @INC;
-
- # add any search_dir params
- unshift @SEARCHDIR, @{$opts{'search_dirs'}} if defined $opts{'search_dirs'};
-
-
- # go through our @INC
- foreach my $dir (@SEARCHDIR) {
-
- # and each directory in our search path
- foreach my $searchpath (@{$opts{'search_path'}}) {
- # create the search directory in a cross platform goodness way
- my $sp = catdir($dir, (split /::/, $searchpath));
- # if it doesn't exist or it's not a dir then skip it
- next unless ( -e $sp && -d _ ); # Use the cached stat the second time
-
-
- # find all the .pm files in it
- # this isn't perfect and won't find multiple plugins per file
- #my $cwd = Cwd::getcwd;
- my @files = ();
- { # for the benefit of perl 5.6.1's Find, localize topic
- local $_;
- File::Find::find( { no_chdir => 1, wanted =>
- sub { # Inlined from File::Find::Rule C< name => '*.pm' >
- return unless $File::Find::name =~ /\.pm$/;
- (my $path = $File::Find::name) =~ s#^\\./##;
- push @files, $path;
- }},
- $sp );
- }
- #chdir $cwd;
-
- # foreach one we've found
- foreach my $file (@files) {
- # untaint the file; accept .pm only
- next unless ($file) = ($file =~ /(.*\.pm)$/);
- # parse the file to get the name
- my ($name, $directory) = fileparse($file, qr{\.pm$});
- $directory = abs2rel($directory, $sp);
- # then create the class name in a cross platform way
- $directory =~ s/^[a-z]://i if($^O =~ /MSWin32|dos/); # remove volume
- if ($directory) {
- ($directory) = ($directory =~ /(.*)/);
- }
- else {
- $directory = "";
- }
- my $plugin = join "::", splitdir catdir($searchpath, $directory, $name);
- if (defined $opts{'instantiate'} || $opts{'require'}) {
-
- eval "CORE::require $plugin";
- carp "Couldn't require $plugin : $@" if $@;
- }
- push @plugins, $plugin;
- }
-
- # now add stuff that may have been in package
- # NOTE we should probably use all the stuff we've been given already
- # but then we can't unload it :(
- unless (exists $opts{inner} && !$opts{inner}) {
- for (list_packages($searchpath)) {
- if (defined $opts{'instantiate'} || $opts{'require'}) {
- eval "CORE::require $_";
- # *No warnings here*
- # next if $@;
- }
- push @plugins, $_;
- } # for list packages
- } # unless inner
- } # foreach $searchpath
- } # foreach $dir
-
-
-
-
- # push @plugins, map { print STDERR "$_\n"; $_->require } list_packages($_) for (@{$opts{'search_path'}});
-
- # return blank unless we've found anything
- return () unless @plugins;
-
-
- # exceptions
- my %only;
- my %except;
- my $only;
- my $except;
-
- if (defined $opts{'only'}) {
- if (ref($opts{'only'}) eq 'ARRAY') {
- %only = map { $_ => 1 } @{$opts{'only'}};
- } elsif (ref($opts{'only'}) eq 'Regexp') {
- $only = $opts{'only'}
- } elsif (ref($opts{'only'}) eq '') {
- $only{$opts{'only'}} = 1;
- }
- }
-
-
- if (defined $opts{'except'}) {
- if (ref($opts{'except'}) eq 'ARRAY') {
- %except = map { $_ => 1 } @{$opts{'except'}};
- } elsif (ref($opts{'except'}) eq 'Regexp') {
- $except = $opts{'except'}
- } elsif (ref($opts{'except'}) eq '') {
- $except{$opts{'except'}} = 1;
- }
- }
-
-
-
-
-
-
- # remove duplicates
- # probably not necessary but hey ho
- my %plugins;
- for(@plugins) {
- next if (keys %only && !$only{$_} );
- next unless (!defined $only || m!$only! );
-
- next if (keys %except && $except{$_} );
- next if (defined $except && m!$except! );
- $plugins{$_} = 1;
- }
-
- # are we instantiating or requring?
- if (defined $opts{'instantiate'}) {
- my $method = $opts{'instantiate'};
- return map { ($_->can($method)) ? $_->$method(@_) : () } keys %plugins;
- } else {
- # no? just return the names
- return keys %plugins;
- }
-
-
- };
-
-
- my $searchsub = sub {
- my $self = shift;
- my ($action, at paths) = @_;
-
- $opts{'search_path'} = ["${pkg}::Plugin"] if ($action eq 'add' and not $opts{'search_path'} );;
- push @{$opts{'search_path'}}, @paths if ($action eq 'add');
- $opts{'search_path'} = \@paths if ($action eq 'new');
- return $opts{'search_path'};
- };
-
- my $onlysub = sub {
- my ($self, $only) = @_;
-
- if (defined $only) {
- $opts{'only'} = $only;
- };
-
- return $opts{'only'};
- };
-
- my $exceptsub = sub {
- my ($self, $except) = @_;
-
- if (defined $except) {
- $opts{'except'} = $except;
- };
-
- return $opts{'except'};
- };
-
- no strict 'refs';
- no warnings 'redefine';
- *{"$pkg\::$sub"} = $subroutine;
- *{"$pkg\::search_path"} = $searchsub;
- *{"$pkg\::only"} = $onlysub;
- *{"$pkg\::except"} = $exceptsub;
-}
-
-
-sub list_packages {
- my $pack = shift; $pack .= "::" unless $pack =~ m!::$!;
-
- no strict 'refs';
- my @packs;
- for (grep !/^(main|)::$/, grep /::$/, keys %{$pack})
- {
- s!::$!!;
- my @children = list_packages($pack.$_);
- push @packs, "$pack$_" unless @children or /^::/;
- push @packs, @children;
- }
- return grep {$_ !~ /::::ISA::CACHE/} @packs;
-}
-
-
-1;
Modified: packages/libmodule-pluggable-perl/trunk/t/01use.t
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libmodule-pluggable-perl/trunk/t/01use.t?rev=2904&op=diff
==============================================================================
--- packages/libmodule-pluggable-perl/trunk/t/01use.t (original)
+++ packages/libmodule-pluggable-perl/trunk/t/01use.t Wed Jun 7 13:14:28 2006
@@ -1,7 +1,9 @@
#!perl -wT
use strict;
-use Test::More tests => 1;
+use Test::More tests => 3;
use_ok('Module::Pluggable');
+use_ok('Module::Pluggable::Object');
+use_ok('Devel::InnerPackage');
More information about the Pkg-perl-cvs-commits
mailing list