r5016 - in
/packages/libclass-factory-perl/branches/upstream/current:
Changes META.yml README lib/Class/Factory.pm t/factory.t
eloy at users.alioth.debian.org
eloy at users.alioth.debian.org
Fri Apr 13 07:54:50 UTC 2007
Author: eloy
Date: Fri Apr 13 07:54:49 2007
New Revision: 5016
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=5016
Log:
[svn-upgrade] Integrating new upstream version, libclass-factory-perl (1.05)
Modified:
packages/libclass-factory-perl/branches/upstream/current/Changes
packages/libclass-factory-perl/branches/upstream/current/META.yml
packages/libclass-factory-perl/branches/upstream/current/README
packages/libclass-factory-perl/branches/upstream/current/lib/Class/Factory.pm
packages/libclass-factory-perl/branches/upstream/current/t/factory.t
Modified: packages/libclass-factory-perl/branches/upstream/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libclass-factory-perl/branches/upstream/current/Changes?rev=5016&op=diff
==============================================================================
--- packages/libclass-factory-perl/branches/upstream/current/Changes (original)
+++ packages/libclass-factory-perl/branches/upstream/current/Changes Fri Apr 13 07:54:49 2007
@@ -1,10 +1,14 @@
Revision history for Perl extension Class::Factory.
+
+1.05 Thu Feb 1 22:57:21 PST 2007
+ - Added method get_registered_class(), suggested by
+ Sebastian Knapp <giftnuss at netscape.net>
1.04 Mon Aug 20 22:26:15 PST 2006
- New maintainer, Fred Moyer <fred at redhotpenguin.com>
- - Add Devel::Cover support, current coverage is 71%
- - Moved check for Test::More to MY::test
+ - Add Devel::Cover support, current coverage is 71%
+ - Moved check for Test::More to MY::test
1.03 Thu Oct 14 10:08:08 EDT 2004
@@ -76,7 +80,7 @@
0.01 Mon Jan 28 08:35:09 EST 2002
-
+
Original version with tests, documentation and everything,
written after the third or fourth time I cut-and-pasted a
'add_type()' method to implement a dynamic factory class :-)
Modified: packages/libclass-factory-perl/branches/upstream/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libclass-factory-perl/branches/upstream/current/META.yml?rev=5016&op=diff
==============================================================================
--- packages/libclass-factory-perl/branches/upstream/current/META.yml (original)
+++ packages/libclass-factory-perl/branches/upstream/current/META.yml Fri Apr 13 07:54:49 2007
@@ -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: Class-Factory
-version: 1.04
+version: 1.05
version_from: lib/Class/Factory.pm
installdirs: site
requires:
Modified: packages/libclass-factory-perl/branches/upstream/current/README
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libclass-factory-perl/branches/upstream/current/README?rev=5016&op=diff
==============================================================================
--- packages/libclass-factory-perl/branches/upstream/current/README (original)
+++ packages/libclass-factory-perl/branches/upstream/current/README Fri Apr 13 07:54:49 2007
@@ -37,6 +37,10 @@
My::Factory->register_factory_type( bleededge => 'Other::Customized::Class' );
my $edgy_object = My::Factory->new( 'bleededge', this => 'that' );
+ # Get a registered class name given it's factory type
+
+ my $registered_class = MyFactory->get_registered_class( 'bleededge' );
+
See POD for details
INSTALLATION
@@ -53,6 +57,8 @@
None, although this module was written almost entirely under the
influence of Weezer.
+get_registered_class() was written under the influence of Phix.
+
SIDE-EFFECTS
May include headache, insomnia, and growth spurts, although a control
@@ -60,7 +66,7 @@
COPYRIGHT AND LICENCE
-Copyright (c) 2002-2006 Chris Winters. All rights reserved.
+Copyright (c) 2002-2007 Chris Winters. All rights reserved.
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
@@ -76,3 +82,6 @@
Srdjan Jankovic <srdjan at catalyst.net.nz> contributed the idea for
'get_my_factory()' and 'get_my_factory_type()'
+
+Sebastian Knapp <giftnuss at netscape.net> contributed the idea for
+'get_registered_class()'
Modified: packages/libclass-factory-perl/branches/upstream/current/lib/Class/Factory.pm
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libclass-factory-perl/branches/upstream/current/lib/Class/Factory.pm?rev=5016&op=diff
==============================================================================
--- packages/libclass-factory-perl/branches/upstream/current/lib/Class/Factory.pm (original)
+++ packages/libclass-factory-perl/branches/upstream/current/lib/Class/Factory.pm Fri Apr 13 07:54:49 2007
@@ -4,7 +4,7 @@
use strict;
-$Class::Factory::VERSION = '1.04';
+$Class::Factory::VERSION = '1.05';
my %CLASS_BY_FACTORY_AND_TYPE = ();
my %FACTORY_INFO_BY_CLASS = ();
@@ -144,6 +144,17 @@
return sort values %{ $REGISTER{ $class } };
}
+sub get_registered_class {
+ my ( $item, $type ) = @_;
+ unless ( $type ) {
+ warn("No factory type passed");
+ return undef;
+ }
+ my $class = ref $item || $item;
+ return undef unless ( ref $REGISTER{ $class } eq 'HASH' );
+ return $REGISTER{ $class }{ $type };
+}
+
sub get_registered_types {
my ( $item ) = @_;
my $class = ref $item || $item;
@@ -230,6 +241,10 @@
my @loaded_types = My::Factory->get_loaded_types;
my @registered_classes = My::Factory->get_registered_classes;
my @registered_types = My::Factory->get_registered_types;
+
+ # Get a registered class by it's factory type
+
+ my $registered_class = My::Factory->get_registered_class( 'type' );
# Ask the object created by the factory: Where did I come from?
@@ -605,6 +620,12 @@
clear out the registration once a registered class has been loaded on
demand.
+B<get_registered_class( $factory_type )>
+
+Returns a registered class given a factory type.
+If no class of type $factory_type is registered, returns undef.
+If no classes have been registered yet, returns undef.
+
B<get_registered_types()>
Returns a sorted list of the types that were ever registered. If no
@@ -667,7 +688,7 @@
=head1 COPYRIGHT
-Copyright (c) 2002-2004 Chris Winters. All rights reserved.
+Copyright (c) 2002-2006 Chris Winters. All rights reserved.
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
@@ -687,3 +708,6 @@
Srdjan Jankovic E<lt>srdjan at catalyst.net.nzE<gt> contributed the idea
for 'get_my_factory()' and 'get_my_factory_type()'
+
+Sebastian Knapp <giftnuss at netscape.net> contributed the idea for
+'get_registered_class()'
Modified: packages/libclass-factory-perl/branches/upstream/current/t/factory.t
URL: http://svn.debian.org/wsvn/pkg-perl/packages/libclass-factory-perl/branches/upstream/current/t/factory.t?rev=5016&op=diff
==============================================================================
--- packages/libclass-factory-perl/branches/upstream/current/t/factory.t (original)
+++ packages/libclass-factory-perl/branches/upstream/current/t/factory.t Fri Apr 13 07:54:49 2007
@@ -1,7 +1,7 @@
# -*-perl-*-
use strict;
-use Test::More tests => 32;
+use Test::More tests => 33;
use lib qw( ./t ./lib );
@@ -37,6 +37,9 @@
my @registered_types = MySimpleBand->get_registered_types;
is( scalar @registered_types, 1, 'Number of types registered so far' );
is( $registered_types[0], 'country', 'Default type registered' );
+
+ my $registered_class = MySimpleBand->get_registered_class( 'country' );
+ is( $registered_class, 'MyCountryBand', 'Get registered class from type');
my $rock = MySimpleBand->new( 'rock', { band_name => $rock_band } );
is( ref( $rock ), 'MyRockBand', 'Type of added object returned' );
More information about the Pkg-perl-cvs-commits
mailing list