r51789 - in /branches/upstream/libclass-loader-perl: ./ current/ current/lib/ current/lib/Class/ current/t/
jawnsy-guest at users.alioth.debian.org
jawnsy-guest at users.alioth.debian.org
Sat Jan 30 02:28:26 UTC 2010
Author: jawnsy-guest
Date: Sat Jan 30 02:28:21 2010
New Revision: 51789
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=51789
Log:
[svn-inject] Installing original source of libclass-loader-perl
Added:
branches/upstream/libclass-loader-perl/
branches/upstream/libclass-loader-perl/current/
branches/upstream/libclass-loader-perl/current/ARTISTIC
branches/upstream/libclass-loader-perl/current/Changes
branches/upstream/libclass-loader-perl/current/MANIFEST
branches/upstream/libclass-loader-perl/current/META.yml
branches/upstream/libclass-loader-perl/current/Makefile.PL
branches/upstream/libclass-loader-perl/current/lib/
branches/upstream/libclass-loader-perl/current/lib/Class/
branches/upstream/libclass-loader-perl/current/lib/Class/Loader.pm
branches/upstream/libclass-loader-perl/current/lib/Class/LoaderTest.pm
branches/upstream/libclass-loader-perl/current/t/
branches/upstream/libclass-loader-perl/current/t/01-require.t (with props)
branches/upstream/libclass-loader-perl/current/t/02-map.t (with props)
branches/upstream/libclass-loader-perl/current/t/03-args.t (with props)
Added: branches/upstream/libclass-loader-perl/current/ARTISTIC
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libclass-loader-perl/current/ARTISTIC?rev=51789&op=file
==============================================================================
--- branches/upstream/libclass-loader-perl/current/ARTISTIC (added)
+++ branches/upstream/libclass-loader-perl/current/ARTISTIC Sat Jan 30 02:28:21 2010
@@ -1,0 +1,117 @@
+
+
+ The "Artistic License"
+
+ Preamble
+
+The intent of this document is to state the conditions under which a
+Package may be copied, such that the Copyright Holder maintains some
+semblance of artistic control over the development of the package, while
+giving the users of the package the right to use and distribute the
+Package in a more-or-less customary fashion, plus the right to make
+reasonable modifications.
+
+Definitions:
+
+ "Package" refers to the collection of files distributed by the
+ Copyright Holder, and derivatives of that collection of files
+ created through textual modification.
+
+ "Standard Version" refers to such a Package if it has not been
+ modified, or has been modified in accordance with the wishes of
+ the Copyright Holder.
+
+ "Copyright Holder" is whoever is named in the copyright or
+ copyrights for the package.
+
+ "You" is you, if you're thinking about copying or distributing
+ this Package.
+
+ "Reasonable copying fee" is whatever you can justify on the basis
+ of media cost, duplication charges, time of people involved, and
+ so on. (You will not be required to justify it to the Copyright
+ Holder, but only to the computing community at large as a market
+ that must bear the fee.)
+
+ "Freely Available" means that no fee is charged for the item
+ itself, though there may be fees involved in handling the item. It
+ also means that recipients of the item may redistribute it under
+ the same conditions they received it.
+
+1. You may make and give away verbatim copies of the source form of the
+ Standard Version of this Package without restriction, provided that you
+ duplicate all of the original copyright notices and associated
+ disclaimers.
+
+2. You may apply bug fixes, portability fixes and other modifications
+ derived from the Public Domain or from the Copyright Holder. A Package
+ modified in such a way shall still be considered the Standard Version.
+
+3. You may otherwise modify your copy of this Package in any way, provided
+ that you insert a prominent notice in each changed file stating how and
+ when you changed that file, and provided that you do at least ONE of
+ the following:
+
+ a) place your modifications in the Public Domain or otherwise make
+ them Freely Available, such as by posting said modifications to
+ Usenet or an equivalent medium, or placing the modifications on a
+ major archive site such as ftp.uu.net, or by allowing the
+ Copyright Holder to include your modifications in the Standard
+ Version of the Package.
+
+ b) use the modified Package only within your corporation or
+ organization.
+
+ c) rename any non-standard executables so the names do not conflict
+ with standard executables, which must also be provided, and provide
+ a separate manual page for each non-standard executable that
+ clearly documents how it differs from the Standard Version.
+
+ d) make other distribution arrangements with the Copyright Holder.
+
+4. You may distribute the programs of this Package in object code or
+ executable form, provided that you do at least ONE of the following:
+
+ a) distribute a Standard Version of the executables and library files,
+ together with instructions (in the manual page or equivalent) on
+ where to get the Standard Version.
+
+ b) accompany the distribution with the machine-readable source of the
+ Package with your modifications.
+
+ c) accompany any non-standard executables with their corresponding
+ Standard Version executables, giving the non-standard executables
+ non-standard names, and clearly documenting the differences in
+ manual pages (or equivalent), together with instructions on where
+ to get the Standard Version.
+
+ d) make other distribution arrangements with the Copyright Holder.
+
+5. You may charge a reasonable copying fee for any distribution of this
+ Package. You may charge any fee you choose for support of this Package.
+ You may not charge a fee for this Package itself. However, you may
+ distribute this Package in aggregate with other (possibly commercial)
+ programs as part of a larger (possibly commercial) software
+ distribution provided that you do not advertise this Package as a
+ product of your own.
+
+6. The scripts and library files supplied as input to or produced as
+ output from the programs of this Package do not automatically fall
+ under the copyright of this Package, but belong to whomever
+ generated them, and may be sold commercially, and may be aggregated
+ with this Package.
+
+7. C or perl subroutines supplied by you and linked into this Package
+ shall not be considered part of this Package.
+
+8. The name of the Copyright Holder may not be used to endorse or promote
+ products derived from this software without specific prior written
+ permission.
+
+9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
+ WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+ MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+
+ The End
+
+
Added: branches/upstream/libclass-loader-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libclass-loader-perl/current/Changes?rev=51789&op=file
==============================================================================
--- branches/upstream/libclass-loader-perl/current/Changes (added)
+++ branches/upstream/libclass-loader-perl/current/Changes Sat Jan 30 02:28:21 2010
@@ -1,0 +1,40 @@
+
+ CHANGELOG for Class::Loader
+ $Id: Changes,v 1.4 2001/07/18 20:21:38 vipul Exp $
+
+--------------------------------------------------------------------------
+
+2.03 Apr 27, 2005
+
+ * Taint fix.
+
+2.02 July 18, 2001
+
+ * CPAN.pm is loaded on demand only. Thanks to Benjamin Trott for the
+ patch.
+
+2.00 May 29, 2001
+
+ * A versioning fix. No change to the code.
+
+1.12 April 30, 2001
+
+ * Changed the code to handle escaping of Args in _load(). Args are now
+ serialized with Data::Dumper (and processed a bit) before eval().
+ This lets us handle references & nested structures properly.
+
+1.8 April 28, 2001
+
+ * Included tests in the distribition.
+
+1.7 April 28, 2001
+
+ * Introduced CPAN switch in calls to _load()
+
+ * Wrote ::new()
+
+ * Small Documentation changes.
+
+1.6 April 27, 2001
+
+ * First release.
Added: branches/upstream/libclass-loader-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libclass-loader-perl/current/MANIFEST?rev=51789&op=file
==============================================================================
--- branches/upstream/libclass-loader-perl/current/MANIFEST (added)
+++ branches/upstream/libclass-loader-perl/current/MANIFEST Sat Jan 30 02:28:21 2010
@@ -1,0 +1,19 @@
+
+# Files in Class::Loader bundle.
+
+MANIFEST
+ARTISTIC
+Changes
+
+Makefile.PL
+
+lib/Class/Loader.pm
+lib/Class/LoaderTest.pm
+
+t/01-require.t
+t/02-map.t
+t/03-args.t
+
+# $Id: MANIFEST,v 1.4 2001/05/02 02:57:01 vipul Exp $
+
+META.yml Module meta-data (added by MakeMaker)
Added: branches/upstream/libclass-loader-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libclass-loader-perl/current/META.yml?rev=51789&op=file
==============================================================================
--- branches/upstream/libclass-loader-perl/current/META.yml (added)
+++ branches/upstream/libclass-loader-perl/current/META.yml Sat Jan 30 02:28:21 2010
@@ -1,0 +1,10 @@
+# http://module-build.sourceforge.net/META-spec.html
+#XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX#
+name: Class-Loader
+version: 2.03
+version_from: lib/Class/Loader.pm
+installdirs: site
+requires:
+
+distribution_type: module
+generated_by: ExtUtils::MakeMaker version 6.17
Added: branches/upstream/libclass-loader-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libclass-loader-perl/current/Makefile.PL?rev=51789&op=file
==============================================================================
--- branches/upstream/libclass-loader-perl/current/Makefile.PL (added)
+++ branches/upstream/libclass-loader-perl/current/Makefile.PL Sat Jan 30 02:28:21 2010
@@ -1,0 +1,17 @@
+#!/usr/bin/perl -sw
+##
+## Makefile.PL for Class-Loader
+##
+## Copyright (c) 2001, Vipul Ved Prakash. All rights reserved.
+## This code is free software; you can redistribute it and/or modify
+## it under the same terms as Perl itself.
+##
+## $Id: Makefile.PL,v 1.1.1.1 2001/04/22 01:11:40 vipul Exp $
+
+use ExtUtils::MakeMaker;
+WriteMakefile(
+ 'NAME' => 'Class::Loader',
+ 'AUTHOR' => 'Vipul Ved Prakash <mail at vipul.net>',
+ 'VERSION_FROM' => 'lib/Class/Loader.pm',
+);
+
Added: branches/upstream/libclass-loader-perl/current/lib/Class/Loader.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libclass-loader-perl/current/lib/Class/Loader.pm?rev=51789&op=file
==============================================================================
--- branches/upstream/libclass-loader-perl/current/lib/Class/Loader.pm (added)
+++ branches/upstream/libclass-loader-perl/current/lib/Class/Loader.pm Sat Jan 30 02:28:21 2010
@@ -1,0 +1,221 @@
+#!/usr/bin/perl -sw
+##
+## Class::Loader
+##
+## Copyright (c) 2001, Vipul Ved Prakash. All rights reserved.
+## This code is free software; you can redistribute it and/or modify
+## it under the same terms as Perl itself.
+##
+## $Id: Loader.pm,v 2.2 2001/07/18 20:21:39 vipul Exp $
+
+package Class::Loader;
+use Data::Dumper;
+use vars qw($VERSION);
+
+($VERSION) = '$Revision: 2.03 $' =~ /\s(\d+\.\d+)\s/;
+my %MAPS = ();
+
+sub new {
+ return bless {}, shift;
+}
+
+
+sub _load {
+
+ my ($self, $field, @source) = @_;
+ if ((scalar @source) % 2) {
+ unshift @source, $field;
+ $field = ""
+ }
+
+ local ($name, $module, $constructor, $args);
+ my %source = @source;
+ my $class = ref $self || $self;
+ my $object;
+
+ for (keys %source) { ${lc($_)} = $source{$_} }
+
+ if ($name) {
+ my $classmap = $self->_retrmap ($class) || return;
+ my $map = $$classmap{$name} || return;
+ for (keys %$map) { ${lc($_)} = $$map{$_} };
+ }
+
+ if ($module) {
+ unless (eval "require $module") {
+ if ($source{CPAN}) {
+ require CPAN; CPAN->import;
+ my $obj = CPAN::Shell->expand ('Module', $module);
+ return unless $obj;
+ $obj->install;
+ eval "require $module" || return;
+ } else { return }
+ }
+ $constructor ||= 'new';
+ if ($args) {
+ my $topass = __prepare_args ($args);
+ $object = eval "$module->$constructor($topass)" or return;
+ undef $topass; undef $args;
+ } else { $object = eval "$module->$constructor" or return }
+ } else { return }
+
+ return $field ? $$self{$field} = $object : $object
+
+}
+
+
+sub _storemap {
+ my ($self, %map) = @_;
+ my $class = ref $self;
+ for (keys %map) { $MAPS{$class}{$_} = $map{$_} }
+}
+
+
+sub _retrmap {
+ my ($self) = @_;
+ my $class = ref $self;
+ return $MAPS{$class} if $MAPS{$class};
+ return;
+}
+
+
+sub __prepare_args {
+
+ my $topass = Dumper shift;
+ $topass =~ s/\$VAR1 = \[//;
+ $topass =~ s/];\s*//g;
+ $topass =~ m/(.*)/s;
+ $topass = $1;
+ return $topass;
+
+}
+
+1;
+
+=head1 NAME
+
+Class::Loader - Load modules and create objects on demand.
+
+=head1 VERSION
+
+ $Revision: 2.2 $
+ $Date: 2001/07/18 20:21:39 $
+
+=head1 SYNOPSIS
+
+ package Web::Server;
+ use Class::Loader;
+ @ISA = qw(Class::Loader);
+
+ $self->_load( 'Content_Handler', {
+ Module => "Filter::URL",
+ Constructor => "new",
+ Args => [ ],
+ }
+ );
+
+
+=head1 DESCRIPTION
+
+Certain applications like to defer the decision to use a particular module
+till runtime. This is possible in perl, and is a useful trick in
+situations where the type of data is not known at compile time and the
+application doesn't wish to pre-compile modules to handle all types of
+data it can work with. Loading modules at runtime can also provide
+flexible interfaces for perl modules. Modules can let the programmer
+decide what modules will be used by it instead of hard-coding their names.
+
+Class::Loader is an inheritable class that provides a method, _load(),
+to load a module from disk and construct an object by calling its
+constructor. It also provides a way to map modules names and
+associated metadata with symbolic names that can be used in place of
+module names at _load().
+
+=head1 METHODS
+
+=over 4
+
+=item B<new()>
+
+A basic constructor. You can use this to create an object of
+Class::Loader, in case you don't want to inherit Class::Loader.
+
+=item B<_load()>
+
+_load() loads a module and calls its constructor. It returns the newly
+constructed object on success or a non-true value on failure. The first
+argument can be the name of the key in which the returned object is
+stored. This argument is optional. The second (or the first) argument is a
+hash which can take the following keys:
+
+=over 4
+
+=item B<Module>
+
+This is name of the class to load. (It is not the module's filename.)
+
+=item B<Name>
+
+Symbolic name of the module defined with _storemap(). Either one of Module
+or Name keys must be present in a call to _load().
+
+=item B<Constructor>
+
+Name of the Module constructor. Defaults to "new".
+
+=item B<Args>
+
+A reference to the list of arguments for the constructor. _load() calls
+the constructor with this list. If no Args are present, _load() will call
+the constructor without any arguments.
+
+=item B<CPAN>
+
+If the Module is not installed on the local system, _load() can fetch &
+install it from CPAN provided the CPAN key is present. This functionality
+assumes availability of a pre-configured CPAN shell.
+
+=back
+
+=item B<_storemap()>
+
+Class::Loader maintains a class table that maps symbolic names to
+parameters accepted by _load(). It takes a hash as argument whose keys are
+symbolic names and value are hash references that contain a set of _load()
+arguments. Here's an example:
+
+ $self->_storemap ( "URL" => { Module => "Filter::URL",
+ Constructor => "foo",
+ Args => [qw(bar baz)],
+ }
+ );
+
+ # time passes...
+
+ $self->{handler} = $self->_load ( Name => 'URL' );
+
+=item B<_retrmap()>
+
+_retrmap() returns the entire map stored with Class::Loader. Class::Loader
+maintains separate maps for different classes, and _retrmap() returns the
+map valid in the caller class.
+
+=back
+
+=head1 SEE ALSO
+
+AnyLoader(3)
+
+=head1 AUTHOR
+
+Vipul Ved Prakash, E<lt>mail at vipul.netE<gt>
+
+=head1 LICENSE
+
+Copyright (c) 2001, Vipul Ved Prakash. All rights reserved. This code is
+free software; you can redistribute it and/or modify it under the same
+terms as Perl itself.
+
+=cut
+
+
Added: branches/upstream/libclass-loader-perl/current/lib/Class/LoaderTest.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libclass-loader-perl/current/lib/Class/LoaderTest.pm?rev=51789&op=file
==============================================================================
--- branches/upstream/libclass-loader-perl/current/lib/Class/LoaderTest.pm (added)
+++ branches/upstream/libclass-loader-perl/current/lib/Class/LoaderTest.pm Sat Jan 30 02:28:21 2010
@@ -1,0 +1,41 @@
+#!/usr/bin/perl -sw
+##
+##
+##
+## Copyright (c) 2001, Vipul Ved Prakash. All rights reserved.
+## This code is free software; you can redistribute it and/or modify
+## it under the same terms as Perl itself.
+##
+## $Id: LoaderTest.pm,v 1.2 2001/05/01 00:09:12 vipul Exp $
+
+package Class::LoaderTest;
+use Data::Dumper;
+
+sub new {
+
+ my $self = { Method => 'new' };
+ return bless $self, shift;
+
+}
+
+
+sub foo {
+
+ my ($class, $embed) = @_;
+ $embed ||= 'foo';
+ my $self = { Method => $embed };
+ return bless $self, shift;
+
+}
+
+sub blah {
+
+ my ($class, %params) = @_;
+ my $self = { %params };
+ return bless $self, $class;
+
+}
+
+1;
+
+
Added: branches/upstream/libclass-loader-perl/current/t/01-require.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libclass-loader-perl/current/t/01-require.t?rev=51789&op=file
==============================================================================
--- branches/upstream/libclass-loader-perl/current/t/01-require.t (added)
+++ branches/upstream/libclass-loader-perl/current/t/01-require.t Sat Jan 30 02:28:21 2010
@@ -1,0 +1,70 @@
+#!/usr/bin/perl -st
+##
+## Class::Loader Test Suite
+##
+## Copyright (c) 2001, Vipul Ved Prakash. All rights reserved.
+## This code is free software; you can redistribute it and/or modify
+## it under the same terms as Perl itself.
+##
+## $Id: 01-require.t,v 1.2 2001/04/28 03:21:47 vipul Exp $
+
+use lib '../lib', 'lib';
+package Class::Loader::Test01;
+use Class::Loader;
+use vars qw(@ISA);
+ at ISA = (Class::Loader);
+
+sub new {
+
+ my $self = { Method => 'new' };
+ return bless $self, shift;
+
+}
+
+sub test {
+
+ my $self = shift;
+ $self->{Handler} = $self->_load ( Module => "Class::LoaderTest" );
+
+}
+
+sub test2 {
+
+ my ($self, $param) = @_;
+ if ($param) {
+ $self->_load ( 'Handler2', Module => "Class::LoaderTest",
+ Constructor => "foo",
+ Args => ["$param"],
+ );
+ } else {
+ $self->_load ( 'Handler2', Module => "Class::LoaderTest", Constructor => "foo" );
+ }
+
+}
+
+
+package main;
+
+use Data::Dumper;
+use Test;
+BEGIN { plan tests => 5 };
+
+print "construction by module name...\n";
+my $test = new Class::Loader::Test01;
+$test->test();
+ok(1) if ref $test->{Handler} eq "Class::LoaderTest";
+
+print "construction by module name and constructor name...\n";
+$test = new Class::Loader::Test01;
+$test->test2;
+ok(ref $test->{Handler2}, "Class::LoaderTest");
+ok($test->{Handler2}{Method}, "foo");
+
+print "construction by module, constructor and arguments...\n";
+$test = new Class::Loader::Test01;
+$test->test2 ("few");
+ok(ref $test->{Handler2}, "Class::LoaderTest");
+ok($test->{Handler2}{Method}, "few");
+
+
+
Propchange: branches/upstream/libclass-loader-perl/current/t/01-require.t
------------------------------------------------------------------------------
svn:executable =
Added: branches/upstream/libclass-loader-perl/current/t/02-map.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libclass-loader-perl/current/t/02-map.t?rev=51789&op=file
==============================================================================
--- branches/upstream/libclass-loader-perl/current/t/02-map.t (added)
+++ branches/upstream/libclass-loader-perl/current/t/02-map.t Sat Jan 30 02:28:21 2010
@@ -1,0 +1,52 @@
+#!/usr/bin/perl -s
+##
+## Class::Loader Test Suite
+##
+## Copyright (c) 2001, Vipul Ved Prakash. All rights reserved.
+## This code is free software; you can redistribute it and/or modify
+## it under the same terms as Perl itself.
+##
+## $Id: 02-map.t,v 1.1.1.1 2001/04/22 01:11:40 vipul Exp $
+
+use lib '../lib', 'lib';
+package Class::Loader::Test02;
+use Class::Loader;
+use vars qw(@ISA);
+ at ISA = (Class::Loader);
+
+sub new {
+
+ my $self = { Method => 'new' };
+ return bless $self, shift;
+
+}
+
+sub test {
+
+ my $self = shift;
+ $self->_storemap ( 'URLFILTER' => { Module => "Class::LoaderTest",
+ Constructor => "foo" } );
+
+}
+
+sub load {
+
+ my $self = shift;
+ $self->_load ( 'Handler', Name => 'URLFILTER' );
+
+}
+
+package main;
+
+use Data::Dumper;
+use Test;
+BEGIN { plan tests => 3 };
+
+my $test = new Class::Loader::Test02;
+$test->test();
+$test->load();
+my $map = $test->_retrmap;
+ok(1) if $map;
+ok(ref $test->{Handler}, "Class::LoaderTest");
+ok($test->{Handler}->{Method}, "foo");
+
Propchange: branches/upstream/libclass-loader-perl/current/t/02-map.t
------------------------------------------------------------------------------
svn:executable =
Added: branches/upstream/libclass-loader-perl/current/t/03-args.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libclass-loader-perl/current/t/03-args.t?rev=51789&op=file
==============================================================================
--- branches/upstream/libclass-loader-perl/current/t/03-args.t (added)
+++ branches/upstream/libclass-loader-perl/current/t/03-args.t Sat Jan 30 02:28:21 2010
@@ -1,0 +1,47 @@
+#!/usr/bin/perl -st
+##
+## Class::Loader Test Suite
+##
+## Copyright (c) 2001, Vipul Ved Prakash. All rights reserved.
+## This code is free software; you can redistribute it and/or modify
+## it under the same terms as Perl itself.
+##
+## $Id: 03-args.t,v 1.1 2001/05/02 02:57:03 vipul Exp $
+
+use lib '../lib', 'lib';
+package Class::Loader::Test01;
+use Class::Loader;
+use vars qw(@ISA);
+ at ISA = (Class::Loader);
+
+sub new {
+
+ return bless {}, shift;
+
+}
+
+sub test {
+
+ my $self = shift;
+ my $n = "value";
+ my $ref = { 4 => 2 };
+ $self->{Handler} = $self->_load (
+ Module => "Class::LoaderTest",
+ Constructor => "blah",
+ Args => [ "abc" => "xyz", $n => [qw(sd ds dd)], 'c' => $ref ],
+ ) || die $!;
+
+}
+
+package main;
+
+use Test;
+BEGIN { plan tests => 4 };
+
+my $test = new Class::Loader::Test01;
+$test->test();
+ok("sd", @{$test->{Handler}->{value}}[0]);
+ok("dd", @{$test->{Handler}->{value}}[2]);
+ok("xyz", $test->{Handler}->{abc});
+ok("2", $test->{Handler}->{c}->{4});
+
Propchange: branches/upstream/libclass-loader-perl/current/t/03-args.t
------------------------------------------------------------------------------
svn:executable =
More information about the Pkg-perl-cvs-commits
mailing list