[SCM] libpackage-variant-perl Debian packaging branch, master, updated. debian/1.001003-1-16-g363631d
Jonas Smedegaard
dr at jones.dk
Thu May 9 17:14:05 UTC 2013
The following commit has been merged in the master branch:
commit 8723827e3e913976ac3040127d065839cce98258
Merge: 54c942521d23d110c855fe254b87ada46186b268 6556b18f3af7c24ba9c5d270572d5d5ab9b8b8b5
Author: Jonas Smedegaard <dr at jones.dk>
Date: Thu May 9 19:07:28 2013 +0200
Imported Upstream version 1.001004
diff --combined META.json
index 7df7edc,0000000..126b81a
mode 100644,000000..100644
--- a/META.json
+++ b/META.json
@@@ -1,50 -1,0 +1,50 @@@
+{
+ "abstract" : "Parameterizable packages",
+ "author" : [
+ "mst - Matt S. Trout (cpan:MSTROUT) <mst at shadowcat.co.uk>"
+ ],
+ "dynamic_config" : 0,
- "generated_by" : "ExtUtils::MakeMaker version 6.64, CPAN::Meta::Converter version 2.120921",
++ "generated_by" : "ExtUtils::MakeMaker version 6.66, CPAN::Meta::Converter version 2.130880",
+ "license" : [
+ "perl_5"
+ ],
+ "meta-spec" : {
+ "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",
+ "version" : "2"
+ },
+ "name" : "Package-Variant",
+ "no_index" : {
+ "directory" : [
+ "t",
+ "inc"
+ ]
+ },
+ "prereqs" : {
+ "build" : {
+ "requires" : {
+ "Test::Fatal" : "0"
+ }
+ },
+ "configure" : {
+ "requires" : {
+ "ExtUtils::MakeMaker" : "6.55_01"
+ }
+ },
+ "runtime" : {
+ "requires" : {
+ "Carp" : "0",
+ "Import::Into" : "1",
+ "Module::Runtime" : "0.013",
+ "strictures" : "1"
+ }
+ }
+ },
+ "release_status" : "stable",
+ "resources" : {
+ "homepage" : "http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=p5sagit/Package-Variant.git",
+ "repository" : {
+ "url" : "git://git.shadowcat.co.uk/p5sagit/Package-Variant.git"
+ }
+ },
- "version" : "1.001003"
++ "version" : "1.001004"
+}
diff --combined META.yml
index bb342c6,0000000..7ec267b
mode 100644,000000..100644
--- a/META.yml
+++ b/META.yml
@@@ -1,28 -1,0 +1,28 @@@
+---
+abstract: 'Parameterizable packages'
+author:
+ - 'mst - Matt S. Trout (cpan:MSTROUT) <mst at shadowcat.co.uk>'
+build_requires:
+ Test::Fatal: 0
+configure_requires:
+ ExtUtils::MakeMaker: 6.55_01
+dynamic_config: 0
- generated_by: 'ExtUtils::MakeMaker version 6.64, CPAN::Meta::Converter version 2.120921'
++generated_by: 'ExtUtils::MakeMaker version 6.66, CPAN::Meta::Converter version 2.130880'
+license: perl
+meta-spec:
+ url: http://module-build.sourceforge.net/META-spec-v1.4.html
+ version: 1.4
+name: Package-Variant
+no_index:
+ directory:
+ - t
+ - inc
+requires:
+ Carp: 0
+ Import::Into: 1
+ Module::Runtime: 0.013
+ strictures: 1
+resources:
+ homepage: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=p5sagit/Package-Variant.git
+ repository: git://git.shadowcat.co.uk/p5sagit/Package-Variant.git
- version: 1.001003
++version: 1.001004
diff --combined README
index 507b10b,0000000..c0bcf7b
mode 100644,000000..100644
--- a/README
+++ b/README
@@@ -1,239 -1,0 +1,239 @@@
+NAME
+ Package::Variant - Parameterizable packages
+
+SYNOPSIS
+ # declaring a variable Moo role
+ package My::Role::ObjectAttr;
+ use strictures 1;
+ use Package::Variant
+ # what modules to 'use'
+ importing => ['Moo::Role'],
+ # proxied subroutines
+ subs => [ qw(has around before after with) ],
+
+ sub make_variant {
+ my ($class, $target_package, %arguments) = @_;
+ # access arguments
+ my $name = $arguments{name};
+ # use proxied 'has' to add an attribute
+ has $name => (is => 'lazy');
+ # install a builder method
+ install "_build_${name}" => sub {
+ return $arguments{class}->new;
+ };
+ }
+
+ # using the role
+ package My::Class::WithObjectAttr;
+ use strictures 1;
+ use Moo;
+ use My::Role::ObjectAttr;
+
+ with ObjectAttr(name => 'some_obj', class => 'Some::Class');
+
+ # using our class
+ my $obj = My::Class::WithObjectAttr->new;
+ $obj->some_obj; # returns a Some::Class instance
+
+DESCRIPTION
+ This module allows you to build packages that return different
+ variations depending on what parameters are given.
+
+ Users of your package will receive a subroutine able to take parameters
+ and return the name of a suitable variant package. The implmenetation
+ does not care about what kind of package it builds.
+
+ Declaring a variable package
+ There are two important parts to creating a variable package. You first
+ have to give "Package::Variant" some basic information about what kind
+ of package you want to provide, and how. The second part is implementing
+ a method receiving the user's arguments and generating your variants.
+
+ Setting up the environment for building variations
+ When you "use Package::Variant", you pass along some arguments that
+ describe how you intend to build your variations.
+
+ use Package::Variant
+ importing => { $package => \@import_arguments, ... },
+ subs => [ @proxied_subroutine_names ];
+
+ The "importing" option needs to be a hash or array reference with
+ package names to be "use"d as keys, and array references containing the
+ import arguments as values. These packages will be imported into every
+ new variant, and need to set up every declarative subroutine you require
+ to build your variable package. The next option will allow you to use
+ these functions. See "importing" for more options. You can omit empty
+ import argument lists when passing an array reference.
+
+ The "subs" option is an array reference of subroutine names that are
+ exported by the packages specified with "importing". These subroutines
+ will be proxied from your declaration package to the variant to be
+ generated.
+
+ With "importing" initializing your package and "subs" declaring what
+ subroutines you want to use to build a variant, you can now write a
+ "make_variant" method building your variants.
+
+ Declaring a method to produce variants
+ Every time a user requests a new variant a method named "make_variant"
+ will be called with the name of the target package and the arguments
+ from the user.
+
+ It can then use the proxied subroutines declared with "subs" to
+ customize the new package. An "install" subroutine is exported as well
+ allowing you to dynamically install methods into the new package. If
+ these options aren't flexible enough, you can use the passed name of the
+ new package to do any other kind of customizations.
+
+ sub make_variant {
+ my ($class, $target, @arguments) = @_;
+ # ...
+ # customization goes here
+ # ...
+ }
+
+ When the method is finished, the user will receive the name of the new
+ package variant you just set up.
+
+ Using variable packages
+ After your variable package is created your users can get a variant
+ generating subroutine by simply importing your package.
+
+ use My::Variant;
+ my $new_variant_package = Variant(@variant_arguments);
+
+ The package is now fully initialized and used. You can import the
+ subroutine under a different name by specifying an "as" argument.
+
+ Dynamic creation of variant packages
+ For regular uses, the normal import provides more than enough
+ flexibility. However, if you want to create variations of dynamically
- determined packages, you can use the "build_variation_of" method.
++ determined packages, you can use the "build_variant_of" method.
+
+ You can use this to create variations of other packages and pass
+ arguments on to them to allow more modular and extensible variations.
+
+OPTIONS
+ These are the options that can be passed when importing
+ "Package::Variant". They describe the environment in which the variants
+ are created.
+
+ use Package::Variant
+ importing => { $package => \@import_arguments, ... },
+ subs => [ @proxied_subroutines ];
+
+ importing
+ This option is a hash reference mapping package names to array
+ references containing import arguments. The packages will be imported
+ with the given arguments by every variation before the "make_variant"
+ method is asked to create the package (this is done using Import::Into).
+
+ If import order is important to you, you can also pass the "importing"
+ arguments as a flat array reference:
+
+ use Package::Variant
+ importing => [ 'PackageA', 'PackageB' ];
+
+ # same as
+ use Package::Variant
+ importing => [ 'PackageA' => [], 'PackageB' => [] ];
+
+ # or
+ use Package::Variant
+ importing => { 'PackageA' => [], 'PackageB' => [] };
+
+ The import method will be called even if the list of import arguments is
+ empty or not specified,
+
+ If you just want to import a single package's default exports, you can
+ also pass a string instead:
+
+ use Package::Variant importing => 'Package';
+
+ subs
+ An array reference of strings listing the names of subroutines that
+ should be proxied. These subroutines are expected to be installed into
+ the new variant package by the modules imported with "importing".
+ Subroutines with the same name will be availabe in your declaration
+ package, and will proxy through to the newly created package when used
+ within "make_variant".
+
+VARIABLE PACKAGE METHODS
+ These are methods on the variable package you declare when you import
+ "Package::Variant".
+
+ make_variant
+ Some::Variant::Package->make_variant( $target, @arguments );
+
+ You need to provide this method. This method will be called for every
+ new variant of your package. This method should use the subroutines
+ declared in "subs" to customize the new variant package.
+
+ This is a class method receiving the $target package and the @arguments
+ defining the requested variant.
+
+ import
+ use Some::Variant::Package;
+ my $variant_package = Package( @arguments );
+
+ This method is provided for you. It will allow a user to "use" your
+ package and receive a subroutine taking @arguments defining the variant
+ and returning the name of the newly created variant package.
+
+ The following options can be specified when importing:
+
+ * as
+
+ use Some::Variant::Package as => 'Foo';
+ my $variant_package = Foo(@arguments);
+
+ Exports the generator subroutine under a different name than the
+ default.
+
+"Package::Variant" METHODS
+ These methods are available on "Package::Variant" itself.
+
- build_variation_of
++ build_variant_of
+ my $variant_package = Package::Variant
- ->build_variation_of($variable_package, @arguments);
++ ->build_variant_of($variable_package, @arguments);
+
+ This is the dynamic method of creating new variants. It takes the
+ $variable_package, which is a pre-declared variable package, and a set
+ of @arguments passed to the package to generate a new $variant_package,
+ which will be returned.
+
+ import
+ use Package::Variant @options;
+
+ Sets up the environment in which you declare the variants of your
+ packages. See "OPTIONS" for details on the available options and
+ "EXPORTS" for a list of exported subroutines.
+
+EXPORTS
+ Additionally to the proxies for subroutines provided in "subs", the
+ following exports will be available in your variable package:
+
+ install
+ install($method_name, $code_reference);
+
+ Installs a method with the given $method_name into the newly created
+ variant package. The $code_reference will be used as the body for the
+ method, and if Sub::Name is available the coderef will be named. If you
+ want to name it something else, then use:
+
+ install($method_name, $name_to_use, $code_reference);
+
+AUTHOR
+ mst - Matt S. Trout (cpan:MSTROUT) <mst at shadowcat.co.uk>
+
+CONTRIBUTORS
+ phaylon - Robert Sedlacek (cpan:PHAYLON) <r.sedlacek at shadowcat.co.uk>
+
+COPYRIGHT
+ Copyright (c) 2010-2012 the "Package::Variant" "AUTHOR" and
+ "CONTRIBUTORS" as listed above.
+
+LICENSE
+ This library is free software and may be distributed under the same
+ terms as perl itself.
+
--
libpackage-variant-perl Debian packaging
More information about the Pkg-perl-cvs-commits
mailing list