r40847 - in /branches/upstream/libmodule-pluggable-ordered-perl: ./ current/ current/t/ current/t/modules/ current/t/modules/Foo/
jawnsy-guest at users.alioth.debian.org
jawnsy-guest at users.alioth.debian.org
Tue Jul 28 02:26:57 UTC 2009
Author: jawnsy-guest
Date: Tue Jul 28 02:26:31 2009
New Revision: 40847
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=40847
Log:
[svn-inject] Installing original source of libmodule-pluggable-ordered-perl
Added:
branches/upstream/libmodule-pluggable-ordered-perl/
branches/upstream/libmodule-pluggable-ordered-perl/current/
branches/upstream/libmodule-pluggable-ordered-perl/current/Changes
branches/upstream/libmodule-pluggable-ordered-perl/current/MANIFEST
branches/upstream/libmodule-pluggable-ordered-perl/current/META.yml
branches/upstream/libmodule-pluggable-ordered-perl/current/Makefile.PL
branches/upstream/libmodule-pluggable-ordered-perl/current/Ordered.pm
branches/upstream/libmodule-pluggable-ordered-perl/current/README
branches/upstream/libmodule-pluggable-ordered-perl/current/t/
branches/upstream/libmodule-pluggable-ordered-perl/current/t/1.t
branches/upstream/libmodule-pluggable-ordered-perl/current/t/2.t
branches/upstream/libmodule-pluggable-ordered-perl/current/t/3.t
branches/upstream/libmodule-pluggable-ordered-perl/current/t/4.t
branches/upstream/libmodule-pluggable-ordered-perl/current/t/modules/
branches/upstream/libmodule-pluggable-ordered-perl/current/t/modules/Foo/
branches/upstream/libmodule-pluggable-ordered-perl/current/t/modules/Foo/One.pm
branches/upstream/libmodule-pluggable-ordered-perl/current/t/modules/Foo/Three.pm
branches/upstream/libmodule-pluggable-ordered-perl/current/t/modules/Foo/Two.pm
Added: branches/upstream/libmodule-pluggable-ordered-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmodule-pluggable-ordered-perl/current/Changes?rev=40847&op=file
==============================================================================
--- branches/upstream/libmodule-pluggable-ordered-perl/current/Changes (added)
+++ branches/upstream/libmodule-pluggable-ordered-perl/current/Changes Tue Jul 28 02:26:31 2009
@@ -1,0 +1,47 @@
+Revision history for Perl extension Module::Pluggable::Ordered.
+
+1.5
+ - Mark Grimes <mgrimes at cpan.org> submitted a cool new feature implementing
+ the plugins_ordered() method. This allows plugins to be returned sorted
+ from the plugins() method. Note that this is a numeric sort using the <=>
+ operator. Possible future improvement: allowing a custom sort method. Not
+ sure how this would work; all plugins would have to agree to be sorted
+ this way, and the sort method would need to be passed by the code calling
+ the plugins to be registered properly.
+ - SVN had been broken for a long time. It's working again, albeit at a
+ different URL (albeit albeit on the same machine and in the same physical
+ location in the filesystem). You can snag the code from
+ http://www.coitusmentis.info/repos/Module-Pluggable-Ordered/ .
+
+1.4
+ - Fixed some nasty bugs in the POD that cropped up in 1.3. DOH! Thanks to
+ Lars Thegler <lth at FreeBSD.org> for bringing my attention to the fact that
+ 1.3 was finally publically available on CPAN.
+ - Import some patches which originated in the FreeBSD ports system which fix
+ the module with old versions of Perl (for the most part; I don't want to
+ remove "use warnings" for obvious reasons).
+ - All publically released versions of Module-Pluggable-Ordered are now
+ available via the SVN repository. Feel free to browse around via the web
+ frontend. Tags are under the tags/ subdirectory, and include all public
+ releases. As an aside, if anyone has version 0.01, I'd greatly appreciate
+ being able to add it to the collection.
+
+1.3
+ - Now under maintainership by Christopher Nehren (note: previous revision
+ history item written by Christopher Nehren).
+ - The latest code is now available via an SVN repository located at
+ http{,s}://www.incunabulum.info/repos/Module-Pluggable-Ordered/ .
+ Anonymous checkouts are allowed; write access will be granted based upon
+ merit of submitted patches. Branches, tags (releases) and other items to
+ follow.
+
+1.2 Sat Jul 17 2004
+ - Added the package option.
+
+1.1 Sun Jul 11 12:19:57 BST 2004
+ - Patches from SW to make exclude and only work.
+
+0.01 Wed May 19 16:40:41 2004
+ - original version; created by h2xs 1.22 with options
+ -AX -b 5.6.0 -n Module::Pluggable::Ordered
+
Added: branches/upstream/libmodule-pluggable-ordered-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmodule-pluggable-ordered-perl/current/MANIFEST?rev=40847&op=file
==============================================================================
--- branches/upstream/libmodule-pluggable-ordered-perl/current/MANIFEST (added)
+++ branches/upstream/libmodule-pluggable-ordered-perl/current/MANIFEST Tue Jul 28 02:26:31 2009
@@ -1,0 +1,13 @@
+Changes
+Makefile.PL
+MANIFEST
+Ordered.pm
+README
+t/1.t
+t/2.t
+t/3.t
+t/4.t
+t/modules/Foo/One.pm
+t/modules/Foo/Three.pm
+t/modules/Foo/Two.pm
+META.yml Module meta-data (added by MakeMaker)
Added: branches/upstream/libmodule-pluggable-ordered-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmodule-pluggable-ordered-perl/current/META.yml?rev=40847&op=file
==============================================================================
--- branches/upstream/libmodule-pluggable-ordered-perl/current/META.yml (added)
+++ branches/upstream/libmodule-pluggable-ordered-perl/current/META.yml Tue Jul 28 02:26:31 2009
@@ -1,0 +1,12 @@
+# http://module-build.sourceforge.net/META-spec.html
+#XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX#
+name: Module-Pluggable-Ordered
+version: 1.5
+version_from: Ordered.pm
+installdirs: site
+requires:
+ Module::Pluggable: 1.9
+ UNIVERSAL::require: 0
+
+distribution_type: module
+generated_by: ExtUtils::MakeMaker version 6.30
Added: branches/upstream/libmodule-pluggable-ordered-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmodule-pluggable-ordered-perl/current/Makefile.PL?rev=40847&op=file
==============================================================================
--- branches/upstream/libmodule-pluggable-ordered-perl/current/Makefile.PL (added)
+++ branches/upstream/libmodule-pluggable-ordered-perl/current/Makefile.PL Tue Jul 28 02:26:31 2009
@@ -1,0 +1,11 @@
+use ExtUtils::MakeMaker;
+# See lib/ExtUtils/MakeMaker.pm for details of how to influence
+# the contents of the Makefile that is written.
+WriteMakefile(
+ NAME => 'Module::Pluggable::Ordered',
+ VERSION_FROM => 'Ordered.pm', # finds $VERSION
+ PREREQ_PM => {
+ Module::Pluggable => 1.9,
+ UNIVERSAL::require => 0
+ }, # e.g., Module::Name => 1.1
+);
Added: branches/upstream/libmodule-pluggable-ordered-perl/current/Ordered.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmodule-pluggable-ordered-perl/current/Ordered.pm?rev=40847&op=file
==============================================================================
--- branches/upstream/libmodule-pluggable-ordered-perl/current/Ordered.pm (added)
+++ branches/upstream/libmodule-pluggable-ordered-perl/current/Ordered.pm Tue Jul 28 02:26:31 2009
@@ -1,0 +1,175 @@
+package Module::Pluggable::Ordered;
+# I really regret this ugliness, but it's needed in the face of backwards
+# compatibility, and I don't want "code this funky" wandering around CPAN
+# without warnings if I can help it. :) Those using ancient versions of Perl can
+# use -w for global warnings. Unfortunately, there's not much else I can do. If
+# anyone has any suggestions, please do file a bug report. Thanks.
+
+BEGIN
+{
+ if($] >= 5.00600)
+ {
+ require warnings;
+ import warnings;
+ }
+}
+use strict;
+require Module::Pluggable;
+use UNIVERSAL::require;
+use vars qw($VERSION);
+$VERSION = '1.5';
+
+sub import {
+ my ($self, %args) = @_;
+ my $subname = $args{sub_name} || "plugins";
+
+ my %only;
+ my %except;
+
+ %only = map { $_ => 1 } @{$args{'only'}} if defined $args{'only'};
+ %except = map { $_ => 1 } @{$args{'$except'}} if defined $args{'except'};
+
+ my $caller = $args{package} || caller;
+
+ no strict;
+
+ *{"${caller}::call_plugins"} = sub {
+ my ($thing, $name, @args) = @_;
+ my @plugins = ();
+ for ($thing->$subname()) {
+ next if (keys %only && !$only{$_} );
+ next if (keys %except && $except{$_} );
+ push @plugins, $_;
+ }
+
+ $_->require for @plugins;
+
+ my $order_name = "${name}_order";
+ for my $class (sort { $a->$order_name() <=> $b->$order_name() }
+ grep { $_->can($order_name) }
+ @plugins) {
+ $class->$name(@args);
+ }
+ };
+
+ *{"${caller}::${subname}_ordered"} = sub {
+ my $thing = shift;
+
+ my @plugins = $thing->$subname();
+ $_->require for @plugins;
+
+ return map { $_->[0] }
+ sort { $a->[1] <=> $b->[1] }
+ map { [ $_, ( $_->can('_order') ? $_->_order : 50 ) ] }
+ @plugins;
+ };
+
+ goto &Module::Pluggable::import;
+}
+
+1;
+__END__
+
+=head1 NAME
+
+Module::Pluggable::Ordered - Call module plugins in a specified order
+
+=head1 SYNOPSIS
+
+ package Foo;
+ use Module::Pluggable::Ordered;
+
+ Foo->call_plugins("some_event", @stuff);
+
+ for my $plugin (Foo->plugins()){
+ $plugin->method();
+ }
+
+Meanwhile, in a nearby module...
+
+ package Foo::Plugin::One;
+ sub some_event_order { 99 } # I get called last of all
+ sub some_event { my ($self, @stuff) = @_; warn "Hello!" }
+
+ sub _order { 99 } # I get listed by plugins_ordered() last
+
+And in another:
+
+ package Foo::Plugin::Two;
+ sub some_event_order { 13 } # I get called relatively early
+ sub some_event { ... }
+
+ sub _order { 10 } # I get listed by plugins_ordered() early
+
+=head1 DESCRIPTION
+
+This module behaves exactly the same as C<Module::Pluggable>, supporting all of
+its options, but also mixes in the C<call_plugins> and C<plugins_ordered>
+methods to your class. C<call_plugins> acts a little like C<Class::Trigger>; it
+takes the name of a method, and some parameters. Let's say we call it like so:
+
+ __PACKAGE__->call_plugins("my_method", @something);
+
+C<call_plugins> looks at the plugin modules found using C<Module::Pluggable>
+for ones which provide C<my_method_order>. It sorts the modules
+numerically based on the result of this method, and then calls
+C<$_-E<gt>my_method(@something)> on them in order. This produces an
+effect a little like the System V init process, where files can specify
+where in the init sequence they want to be called.
+
+C<plugins_ordered> extends the C<plugins> method created by
+C<Module::Pluggable> to list the plugins in defined order. It looks for
+a C<_order> method in the modules found using C<Module::Pluggable>, and
+returns the modules sorted numerically in that order. For example:
+
+ my @plugins = __PACKAGE__->plugins();
+
+The resulting array of plugins will be sorted. If no C<_order> subroutine
+is defined for a module, an arbitrary default value of 50 is used.
+
+=head1 OPTIONS
+
+The C<package> option can be used to put the pluggability into another
+package, to be used for modules building on the functionality of this
+one.
+
+It also provides the C<only> and C<except> options.
+
+ # will only return the Foo::Plugin::Quux plugin
+ use Module::Pluggable::Ordered only => [ "Foo::Plugin::Quux" ];
+
+ # will not return the Foo::Plugin::Quux plugin
+ use Module::Pluggable::Ordered except => [ "Foo::Plugin::Quux" ];
+
+
+=head1 SEE ALSO
+
+L<Module::Pluggable>, L<Class::Trigger>
+
+=head1 AUTHOR
+
+Simon Cozens, E<lt>simon at cpan.orgE<gt> (author emeritus)
+
+Christopher Nehren, E<lt>apeiron at cpan.orgE<gt> (current maintainer)
+
+Please report bugs via the CPAN RT tracker at http://rt.cpan.org.
+
+=head1 COPYRIGHT AND LICENSE
+
+Copyright 2004 by Simon Cozens
+
+Copyright 2004 by Christopher Nehren (current copyright holder)
+
+This library is free software; you can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+=head1 ACKNOWLEDGEMENTS
+
+Thank you to Simon Cozens for originally writing this module.
+
+Thanks to Lars Thegler for indirectly alerting me to the fact that my POD was
+horribly broken, for providing patches to make this module work with Perl
+versions < 5.6, for maintaining the port up to version 1.3, and for allowing me
+to take maintainership for versions 1.3 onwards.
+
+=cut
Added: branches/upstream/libmodule-pluggable-ordered-perl/current/README
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmodule-pluggable-ordered-perl/current/README?rev=40847&op=file
==============================================================================
--- branches/upstream/libmodule-pluggable-ordered-perl/current/README (added)
+++ branches/upstream/libmodule-pluggable-ordered-perl/current/README Tue Jul 28 02:26:31 2009
@@ -1,0 +1,52 @@
+NAME
+ Module::Pluggable::Ordered - Call module plugins in a specified order
+
+SYNOPSIS
+ package Foo;
+ use Module::Pluggable::Ordered;
+
+ Foo->call_plugins("some_event", @stuff);
+
+ Meanwhile, in a nearby module...
+
+ package Foo::Plugin::One;
+ sub some_event_order { 99 } # I get called last of all
+ sub some_event { my ($self, @stuff) = @_; warn "Hello!" }
+
+ And in another:
+
+ package Foo::Plugin::Two;
+ sub some_event_order { 13 } # I get called relatively early
+ sub some_event { ... }
+
+DESCRIPTION
+ This module behaves exactly the same as "Module::Pluggable", supporting
+ all of its options, but also mixes in the "call_plugins" method to your
+ class. "call_plugins" acts a little like "Class::Trigger"; it takes the
+ name of a method, and some parameters. Let's say we call it like so:
+
+ __PACKAGE__->call_plugins("my_method", @something);
+
+ "call_plugins" looks at the plugin modules found using
+ "Module::Pluggable" for ones which provide "my_method_order". It sorts
+ the modules numerically based on the result of this method, and then
+ calls "$_->my_method(@something)" on them in order. This produces an
+ effect a little like the System V init process, where files can specify
+ where in the init sequence they want to be called.
+
+SEE ALSO
+ Module::Pluggable, Class::Trigger
+
+AUTHORS
+ Simon Cozens, <simon at cpan.org> (author emeritus)
+ Christopher Nehren, <apeiron at cpan.org> (current maintainer)
+
+COPYRIGHT AND LICENSE
+ Copyright 2004 by Simon Cozens
+ Copyright 2004 by Christopher Nehren (current copyright holder)
+
+ This library is free software; you can redistribute it and/or modify it
+ under the same terms as Perl itself.
+
+ACKNOWLEDGEMENTS
+ Thanks to Simon Cozens for originally writing this module.
Added: branches/upstream/libmodule-pluggable-ordered-perl/current/t/1.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmodule-pluggable-ordered-perl/current/t/1.t?rev=40847&op=file
==============================================================================
--- branches/upstream/libmodule-pluggable-ordered-perl/current/t/1.t (added)
+++ branches/upstream/libmodule-pluggable-ordered-perl/current/t/1.t Tue Jul 28 02:26:31 2009
@@ -1,0 +1,12 @@
+package Foo;
+use Test::More tests => 4;
+use lib 't/modules/';
+use Module::Pluggable::Ordered search_dirs => ['t/modules'],
+ search_path => ['Foo'],
+ sub_name => "test_plugins";
+ok(eq_set([Foo->test_plugins],
+ ["Foo::One", "Foo::Two", "Foo::Three"]), "We have three test plugins");
+
+$main::order = 1;
+Foo->call_plugins("mycallback");
+is($main::order, 3, "Only two plugins have been called");
Added: branches/upstream/libmodule-pluggable-ordered-perl/current/t/2.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmodule-pluggable-ordered-perl/current/t/2.t?rev=40847&op=file
==============================================================================
--- branches/upstream/libmodule-pluggable-ordered-perl/current/t/2.t (added)
+++ branches/upstream/libmodule-pluggable-ordered-perl/current/t/2.t Tue Jul 28 02:26:31 2009
@@ -1,0 +1,15 @@
+package Foo;
+use Test::More tests => 3;
+use lib 't/modules/';
+use Module::Pluggable::Ordered search_dirs => ['t/modules'],
+ search_path => ['Foo'],
+ sub_name => "test_plugins",
+ except => ["Foo::One"];
+
+
+ok(eq_set([Foo->test_plugins],
+ ["Foo::Two", "Foo::Three"]), "We have two test plugins");
+
+$main::order = 1;
+Foo->call_plugins("mycallback");
+is($main::order, 2, "Only two plugins have been called");
Added: branches/upstream/libmodule-pluggable-ordered-perl/current/t/3.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmodule-pluggable-ordered-perl/current/t/3.t?rev=40847&op=file
==============================================================================
--- branches/upstream/libmodule-pluggable-ordered-perl/current/t/3.t (added)
+++ branches/upstream/libmodule-pluggable-ordered-perl/current/t/3.t Tue Jul 28 02:26:31 2009
@@ -1,0 +1,13 @@
+package Foo;
+use Test::More tests => 3;
+use lib 't/modules/';
+use Module::Pluggable::Ordered search_dirs => ['t/modules'],
+ search_path => ['Foo'],
+ sub_name => "test_plugins",
+ only => ["Foo::Two"];
+ok(eq_set([Foo->test_plugins],
+ ["Foo::Two"]), "We have one test plugin");
+
+$main::order = 1;
+Foo->call_plugins("mycallback");
+is($main::order, 2, "Only 1 plugin have been called");
Added: branches/upstream/libmodule-pluggable-ordered-perl/current/t/4.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmodule-pluggable-ordered-perl/current/t/4.t?rev=40847&op=file
==============================================================================
--- branches/upstream/libmodule-pluggable-ordered-perl/current/t/4.t (added)
+++ branches/upstream/libmodule-pluggable-ordered-perl/current/t/4.t Tue Jul 28 02:26:31 2009
@@ -1,0 +1,12 @@
+package Foo;
+use Test::More tests => 1;
+use lib 't/modules/';
+use Module::Pluggable::Ordered search_dirs => ['t/modules'],
+ search_path => ['Foo'],
+ sub_name => "test_plugins";
+is_deeply(
+ [Foo->test_plugins_ordered],
+ ["Foo::Two", "Foo::Three", "Foo::One"],
+ 'Three test pluggins in order'
+ );
+
Added: branches/upstream/libmodule-pluggable-ordered-perl/current/t/modules/Foo/One.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmodule-pluggable-ordered-perl/current/t/modules/Foo/One.pm?rev=40847&op=file
==============================================================================
--- branches/upstream/libmodule-pluggable-ordered-perl/current/t/modules/Foo/One.pm (added)
+++ branches/upstream/libmodule-pluggable-ordered-perl/current/t/modules/Foo/One.pm Tue Jul 28 02:26:31 2009
@@ -1,0 +1,8 @@
+package Foo::One;
+
+sub _order { 70 };
+
+sub mycallback_order { 20 }
+sub mycallback { Test::More::is($::order++, 2, "Second plugin") }
+
+1;
Added: branches/upstream/libmodule-pluggable-ordered-perl/current/t/modules/Foo/Three.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmodule-pluggable-ordered-perl/current/t/modules/Foo/Three.pm?rev=40847&op=file
==============================================================================
--- branches/upstream/libmodule-pluggable-ordered-perl/current/t/modules/Foo/Three.pm (added)
+++ branches/upstream/libmodule-pluggable-ordered-perl/current/t/modules/Foo/Three.pm Tue Jul 28 02:26:31 2009
@@ -1,0 +1,5 @@
+package Foo::Three;
+
+# This doesn't have that callback at all.
+
+1;
Added: branches/upstream/libmodule-pluggable-ordered-perl/current/t/modules/Foo/Two.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmodule-pluggable-ordered-perl/current/t/modules/Foo/Two.pm?rev=40847&op=file
==============================================================================
--- branches/upstream/libmodule-pluggable-ordered-perl/current/t/modules/Foo/Two.pm (added)
+++ branches/upstream/libmodule-pluggable-ordered-perl/current/t/modules/Foo/Two.pm Tue Jul 28 02:26:31 2009
@@ -1,0 +1,8 @@
+package Foo::Two;
+
+sub _order { 10 }
+
+sub mycallback_order { 0 }
+sub mycallback { Test::More::is($::order++, 1, "First plugin") }
+
+1;
More information about the Pkg-perl-cvs-commits
mailing list