[libfindbin-libs-perl] 01/06: Imported Upstream version 2.110
gregor herrmann
gregoa at debian.org
Sun Sep 7 16:00:53 UTC 2014
This is an automated email from the git hooks/post-receive script.
gregoa pushed a commit to branch master
in repository libfindbin-libs-perl.
commit 5ab288cea9adfb22f809501ca42eae7ddbc98fbd
Author: gregor herrmann <gregoa at debian.org>
Date: Sun Sep 7 17:46:34 2014 +0200
Imported Upstream version 2.110
---
Changes | 62 +++++++++++++++++++-
MANIFEST | 2 +-
META.json | 6 +-
META.yml | 30 +++++-----
Makefile.PL | 5 +-
lib/FindBin/libs.pm | 141 +++++++++++++++++++++++++++++++++++++---------
libs_curr_pm | 141 +++++++++++++++++++++++++++++++++++++---------
libs_old_pm | 16 ++----
t/09-base-subdir-scalar.t | 2 +-
9 files changed, 319 insertions(+), 86 deletions(-)
diff --git a/Changes b/Changes
index 120b3a2..d108849 100644
--- a/Changes
+++ b/Changes
@@ -1,7 +1,63 @@
-2.09 Sat Aug 9 14:43:10 CDT 2014
+2.11 Tue Sep 2 13:28:18 CDT 2014
-Fix bug in handling of scalar arg in old (5.10 or older) module.
-Whitespace & POD cleanups.
+"append" causes appends array exports from multiple searches using the
+same variable to append (vs. overwrite) their values. default is old
+behavior (i.e., "noappend" which overwrites).
+
+e.g., from t/10*t:
+
+ FindBin::libs->import
+ (
+ qw
+ (
+ base=foo
+ subdir=etc
+ subonly
+ export=etc
+ append
+ )
+ );
+ FindBin::libs->import
+ (
+ qw
+ (
+ base=bar
+ subdir=etc
+ subonly
+ export=etc
+ append
+ )
+ );
+
+generates:
+
+ # Second pass looks for bar/etc:[
+ # '/sandbox/lembark/Modules/FindBin-libs/foo/etc',
+ # '/sandbox/lembark/Modules/FindBin-libs/bar/etc'
+ # ]
+
+
+Main use is finding, say, multiple ./etc dir's and exporting
+them all into a search list for config files.
+
+Given:
+
+ ./myproj/etc
+ ./shared/etc
+
+then #! code in ./myproj/bin could:
+
+ use FindBin::libs qw( export base=etc );
+ use FindBin::libs qw( export base=shared subdir=etc subonly );
+
+and get @etc of ( .../myproj/etc, .../shared/etc ).
+
+The old behavior, 'noappend' overwrites the variable (which can be
+handy for re-setting the dirs also).
+
+2.10 Tue Sep 2 10:30:12 CDT 2014
+
+"scalar" seems to work; update POD so that people know to use it.
2.07 Mon Jul 28 02:48:49 CDT 2014
diff --git a/MANIFEST b/MANIFEST
index 901e86c..e3c0589 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -2,9 +2,9 @@ Changes
example/multi_config_dir
example/p5run
example/single_config_dir
-lib/FindBin/libs.pm
libs_curr_pm
libs_old_pm
+lib/FindBin/libs.pm
Makefile.PL
MANIFEST
META.json
diff --git a/META.json b/META.json
index d352e1d..564c28c 100644
--- a/META.json
+++ b/META.json
@@ -1,10 +1,10 @@
{
- "abstract" : "locate and a 'use lib' or export ",
+ "abstract" : "locate and a 'use lib' or export directories based on $FindBin::Bin.",
"author" : [
"unknown"
],
"dynamic_config" : 1,
- "generated_by" : "ExtUtils::MakeMaker version 6.68, CPAN::Meta::Converter version 2.131560",
+ "generated_by" : "ExtUtils::MakeMaker version 6.98, CPAN::Meta::Converter version 2.142060",
"license" : [
"unknown"
],
@@ -45,5 +45,5 @@
}
},
"release_status" : "stable",
- "version" : "2.09"
+ "version" : 2.11
}
diff --git a/META.yml b/META.yml
index 17b1fec..798b92d 100644
--- a/META.yml
+++ b/META.yml
@@ -1,30 +1,30 @@
---
-abstract: "locate and a 'use lib' or export "
+abstract: "locate and a 'use lib' or export directories based on $FindBin::Bin."
author:
- unknown
build_requires:
- ExtUtils::MakeMaker: 0
+ ExtUtils::MakeMaker: '0'
configure_requires:
- ExtUtils::MakeMaker: 0
+ ExtUtils::MakeMaker: '0'
dynamic_config: 1
-generated_by: 'ExtUtils::MakeMaker version 6.68, CPAN::Meta::Converter version 2.131560'
+generated_by: 'ExtUtils::MakeMaker version 6.98, CPAN::Meta::Converter version 2.142060'
license: unknown
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
- version: 1.4
+ version: '1.4'
name: FindBin-libs
no_index:
directory:
- t
- inc
requires:
- Carp: 0
- Cwd: 0
- File::Spec: 0
- File::Temp: 0
- FindBin: 0
- List::Util: 0
- Symbol: 0
- Test::More: 0
- strict: 0
-version: 2.09
+ Carp: '0'
+ Cwd: '0'
+ File::Spec: '0'
+ File::Temp: '0'
+ FindBin: '0'
+ List::Util: '0'
+ Symbol: '0'
+ Test::More: '0'
+ strict: '0'
+version: 2.11
diff --git a/Makefile.PL b/Makefile.PL
index c2e7d3c..474289c 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -23,10 +23,13 @@ link $from => $dest;
print STDOUT "Installing: '$from' ($dest)\n";
+our $VERSION = '2.11';
+$VERSION = eval $VERSION;
+
WriteMakefile
(
NAME => 'FindBin::libs',
- VERSION_FROM => 'libs_curr_pm',
+ VERSION => $VERSION,
ABSTRACT_FROM => $dest,
PREREQ_PM =>
{
diff --git a/lib/FindBin/libs.pm b/lib/FindBin/libs.pm
index befffc0..4a8a5b6 100644
--- a/lib/FindBin/libs.pm
+++ b/lib/FindBin/libs.pm
@@ -23,12 +23,11 @@ use v5.10;
use strict;
use FindBin;
-use Symbol;
use File::Basename;
-use Carp qw( croak );
-use Symbol qw( qualify_to_ref );
+use Carp qw( croak );
+use Symbol qw( qualify qualify_to_ref );
use File::Spec::Functions
qw
@@ -76,7 +75,7 @@ BEGIN
# package variables
########################################################################
-our $VERSION = '2.09';
+our $VERSION = '2.10';
$VERSION = eval $VERSION;
my %defaultz =
@@ -88,6 +87,7 @@ my %defaultz =
subdir => '', # add this subdir also if found.
subonly => undef, # leave out lib's, use only subdir.
export => undef, # push variable into caller's space.
+ append => undef, # push onto existing array (vs. overwrite)
verbose => undef, # boolean: print inputs, results.
debug => undef, # boolean: set internal breakpoints.
@@ -234,8 +234,6 @@ my $handle_args
my ( $k, $v ) = split '=', $_, 2;
- # leave $v undef?
-
exists $use_undef->{ $k }
or $v //= 1;
@@ -258,15 +256,15 @@ my $handle_args
if( exists $argz{ use } )
{
- # nothing further to do
+ # nothing further to do
}
elsif( defined $argz{ export } || defined $argz{ p5lib } )
{
- $argz{ use } = undef;
+ $argz{ use } = undef;
}
else
{
- $argz{ use } = 1;
+ $argz{ use } = 1;
}
local $defaultz{ Bin }
@@ -366,10 +364,23 @@ sub import
;
}
- $argz{ scalar }
- ? *$ref = \$libz[0]
- : *$ref = \@libz;
- ;
+ if( $argz{ scalar } )
+ {
+ *$ref = \$libz[0]
+ }
+ elsif
+ (
+ $argz{ append }
+ and
+ my $ary = *{ $ref }{ ARRAY }
+ )
+ {
+ push @$ary, @libz;
+ }
+ else
+ {
+ *$ref = \@libz
+ }
}
if( defined $argz{ p5lib } )
@@ -538,11 +549,24 @@ that
will search for directories named "altlib" and "use lib" them.
-=head3 Exporting a variable: 'export'
+=head3 Exporting a variable: "export", "scalar", "append"
+
+=over 4
+
+=item "export"
-The 'export' option will push an array of the directories found
-and takes an optional argument of the array name, which defaults
-to the basename searched for:
+This installs the results of locating directories into the caller's
+space. Without any argument, export pushes out a variable named after
+the located [sub]dir; an argument can be supplied to give the variable
+name. Without the "scalar" option, the exported variable will be an
+array in increasing order of "distance" (i.e., "up" the file tree);
+with the "scalar" option only the first (i.e., "nearest") path is
+exported.
+
+If "export" is given then "nouse" is assumed; using both leaves the
+variable exported and its contents handed to "use lib".
+
+For example:
use FindBin::libs qw( export );
@@ -572,7 +596,7 @@ exports @meta while
use FindBin::libs qw( export=metadirs base=meta );
-exports @metadirs.
+exports @metadirs as a list of paths ending in "/meta".
The use and export switches are not exclusive:
@@ -581,21 +605,88 @@ The use and export switches are not exclusive:
will locate "lib" directories, use lib them, and export
@mylibs into the caller's package.
+=item "scalar"
+
+Only searches for the first directory, which is exported (or
+overwritten) as a scalar rather than array. For example, if
+a project directory has ./bin and ./etc dir's then #! code in
+bin with
+
+ use FindBin::libs qw( export scalar base=etc );
+
+will have an $etc variable with the absolute path to ./bin/../etc.
+For configuration varibles this is usually what you want and allows
+for "$etc/Foo.conf" rather than "$etc[0]/Foo.conf".
+
+=item "append"
+
+Sometimes it's simpler to accumulate multiple searches into a
+single array. Say for ./etc dir's in collection of standard
+locations.
+
+In that case:
+
+ use FindBin::libs qw( export=etc base=foo subdir=etc );
+ use FindBin::libs qw( export=etc base=bar subdir=etc append );
+
+produces something like
+
+ (
+ /path/to/foo/etc
+ /path/to/bar/etc
+ )
+
+without append @etc will have only ./bar/etc since the array would
+be overwritten with each call to FB::l::import.
+
+=back
+
=head3 Subdirectories
+=over 4
+
The "subdir" and "subonly" settings will add or
exclusively use subdir's. This is useful if some
of your lib's are in ../lib/perl5 along with
-../lib (subdir=perl5) or all of the lib's are
-in ../lib/perl5 (subonly=perl5).
+../lib or all of the lib's are in ../lib/perl5.
+
+These could be handled with:
+
+ use FindBin::libs;
+ use FindBin::libs qw( subdir=perl5 subonly );
+
+which uses the "lib" dir's along with any lib/perl5 dirs.
+
This can also be handy for locating subdir's used
for configuring packages:
use FindBin::libs qw( export base=config subonly=mypackage );
-Will leave @config with any "mypacakge" holding
-any "mypackage" subdir's.
+Will leave @config containing any mypackage dir's found up
+the tree, nearest to closest.
+
+The array format is convienent for locating configuration files
+shared between projects in separate, sibling directories. For
+example given:
+
+ ./proj/Foo/etc
+ ./proj/etc
+
+with
+
+ use FindBin::libs qw( export subdir=etc subonly )
+
+will export @etc with qw( ../proj/Foo/etc ../proj/etc ) in lexical
+order by distance from the #! code. At that point
+
+ use List::Util qw( first );
+
+ my $path = first { -e "$_/Global.config" } @etc;
+
+will locate the nearest "Global.confg" file. Note that this is
+not the same as using "scalar" since that will export
+$etc with only ./Foo/etc.
=head3 Setting PERL5LIB: p5lib
@@ -626,8 +717,6 @@ to something like:
This can make controlling the paths used simpler and avoid
the use of symlinks for some testing (see examples below).
-Note that "p5lib" and "nouse" are proably worth
-
=head2 Skipping directories
By default, lib directories under / and /usr are
@@ -990,6 +1079,6 @@ Steven Lembark, Workhorse Computing <lembark at wrkhors.com>
=head1 COPYRIGHT
-Copyright (C) 2003-2012, Steven Lembark, Workhorse Computing.
-This code is released under the same terms as Perl-5.10
+Copyright (C) 2003-2014, Steven Lembark, Workhorse Computing.
+This code is released under the same terms as Perl-5.20
or any later version of Perl.
diff --git a/libs_curr_pm b/libs_curr_pm
index befffc0..4a8a5b6 100644
--- a/libs_curr_pm
+++ b/libs_curr_pm
@@ -23,12 +23,11 @@ use v5.10;
use strict;
use FindBin;
-use Symbol;
use File::Basename;
-use Carp qw( croak );
-use Symbol qw( qualify_to_ref );
+use Carp qw( croak );
+use Symbol qw( qualify qualify_to_ref );
use File::Spec::Functions
qw
@@ -76,7 +75,7 @@ BEGIN
# package variables
########################################################################
-our $VERSION = '2.09';
+our $VERSION = '2.10';
$VERSION = eval $VERSION;
my %defaultz =
@@ -88,6 +87,7 @@ my %defaultz =
subdir => '', # add this subdir also if found.
subonly => undef, # leave out lib's, use only subdir.
export => undef, # push variable into caller's space.
+ append => undef, # push onto existing array (vs. overwrite)
verbose => undef, # boolean: print inputs, results.
debug => undef, # boolean: set internal breakpoints.
@@ -234,8 +234,6 @@ my $handle_args
my ( $k, $v ) = split '=', $_, 2;
- # leave $v undef?
-
exists $use_undef->{ $k }
or $v //= 1;
@@ -258,15 +256,15 @@ my $handle_args
if( exists $argz{ use } )
{
- # nothing further to do
+ # nothing further to do
}
elsif( defined $argz{ export } || defined $argz{ p5lib } )
{
- $argz{ use } = undef;
+ $argz{ use } = undef;
}
else
{
- $argz{ use } = 1;
+ $argz{ use } = 1;
}
local $defaultz{ Bin }
@@ -366,10 +364,23 @@ sub import
;
}
- $argz{ scalar }
- ? *$ref = \$libz[0]
- : *$ref = \@libz;
- ;
+ if( $argz{ scalar } )
+ {
+ *$ref = \$libz[0]
+ }
+ elsif
+ (
+ $argz{ append }
+ and
+ my $ary = *{ $ref }{ ARRAY }
+ )
+ {
+ push @$ary, @libz;
+ }
+ else
+ {
+ *$ref = \@libz
+ }
}
if( defined $argz{ p5lib } )
@@ -538,11 +549,24 @@ that
will search for directories named "altlib" and "use lib" them.
-=head3 Exporting a variable: 'export'
+=head3 Exporting a variable: "export", "scalar", "append"
+
+=over 4
+
+=item "export"
-The 'export' option will push an array of the directories found
-and takes an optional argument of the array name, which defaults
-to the basename searched for:
+This installs the results of locating directories into the caller's
+space. Without any argument, export pushes out a variable named after
+the located [sub]dir; an argument can be supplied to give the variable
+name. Without the "scalar" option, the exported variable will be an
+array in increasing order of "distance" (i.e., "up" the file tree);
+with the "scalar" option only the first (i.e., "nearest") path is
+exported.
+
+If "export" is given then "nouse" is assumed; using both leaves the
+variable exported and its contents handed to "use lib".
+
+For example:
use FindBin::libs qw( export );
@@ -572,7 +596,7 @@ exports @meta while
use FindBin::libs qw( export=metadirs base=meta );
-exports @metadirs.
+exports @metadirs as a list of paths ending in "/meta".
The use and export switches are not exclusive:
@@ -581,21 +605,88 @@ The use and export switches are not exclusive:
will locate "lib" directories, use lib them, and export
@mylibs into the caller's package.
+=item "scalar"
+
+Only searches for the first directory, which is exported (or
+overwritten) as a scalar rather than array. For example, if
+a project directory has ./bin and ./etc dir's then #! code in
+bin with
+
+ use FindBin::libs qw( export scalar base=etc );
+
+will have an $etc variable with the absolute path to ./bin/../etc.
+For configuration varibles this is usually what you want and allows
+for "$etc/Foo.conf" rather than "$etc[0]/Foo.conf".
+
+=item "append"
+
+Sometimes it's simpler to accumulate multiple searches into a
+single array. Say for ./etc dir's in collection of standard
+locations.
+
+In that case:
+
+ use FindBin::libs qw( export=etc base=foo subdir=etc );
+ use FindBin::libs qw( export=etc base=bar subdir=etc append );
+
+produces something like
+
+ (
+ /path/to/foo/etc
+ /path/to/bar/etc
+ )
+
+without append @etc will have only ./bar/etc since the array would
+be overwritten with each call to FB::l::import.
+
+=back
+
=head3 Subdirectories
+=over 4
+
The "subdir" and "subonly" settings will add or
exclusively use subdir's. This is useful if some
of your lib's are in ../lib/perl5 along with
-../lib (subdir=perl5) or all of the lib's are
-in ../lib/perl5 (subonly=perl5).
+../lib or all of the lib's are in ../lib/perl5.
+
+These could be handled with:
+
+ use FindBin::libs;
+ use FindBin::libs qw( subdir=perl5 subonly );
+
+which uses the "lib" dir's along with any lib/perl5 dirs.
+
This can also be handy for locating subdir's used
for configuring packages:
use FindBin::libs qw( export base=config subonly=mypackage );
-Will leave @config with any "mypacakge" holding
-any "mypackage" subdir's.
+Will leave @config containing any mypackage dir's found up
+the tree, nearest to closest.
+
+The array format is convienent for locating configuration files
+shared between projects in separate, sibling directories. For
+example given:
+
+ ./proj/Foo/etc
+ ./proj/etc
+
+with
+
+ use FindBin::libs qw( export subdir=etc subonly )
+
+will export @etc with qw( ../proj/Foo/etc ../proj/etc ) in lexical
+order by distance from the #! code. At that point
+
+ use List::Util qw( first );
+
+ my $path = first { -e "$_/Global.config" } @etc;
+
+will locate the nearest "Global.confg" file. Note that this is
+not the same as using "scalar" since that will export
+$etc with only ./Foo/etc.
=head3 Setting PERL5LIB: p5lib
@@ -626,8 +717,6 @@ to something like:
This can make controlling the paths used simpler and avoid
the use of symlinks for some testing (see examples below).
-Note that "p5lib" and "nouse" are proably worth
-
=head2 Skipping directories
By default, lib directories under / and /usr are
@@ -990,6 +1079,6 @@ Steven Lembark, Workhorse Computing <lembark at wrkhors.com>
=head1 COPYRIGHT
-Copyright (C) 2003-2012, Steven Lembark, Workhorse Computing.
-This code is released under the same terms as Perl-5.10
+Copyright (C) 2003-2014, Steven Lembark, Workhorse Computing.
+This code is released under the same terms as Perl-5.20
or any later version of Perl.
diff --git a/libs_old_pm b/libs_old_pm
index ab62a9c..01ce867 100644
--- a/libs_old_pm
+++ b/libs_old_pm
@@ -92,7 +92,8 @@ BEGIN
# package variables
########################################################################
-our $VERSION = v1.63;
+our $VERSION = '1.62';
+$VERSION = eval $VERSION;
my %defaultz =
(
@@ -200,8 +201,6 @@ my $find_libs
$found{ $dir } = 1;
push @libz, $dir;
-
- last if $argz{ scalar };
}
}
@@ -216,7 +215,7 @@ my $find_libs
# painful for a few paths.
wantarray ? @libz : \@libz
-};
+};;
# break out the messy part into a separate block.
@@ -243,7 +242,7 @@ my $handle_args
# stuff "debug=1" into your arguments and perl -d will stop here.
- $DB::single = 1 if defined $argz{ debug };
+ $DB::single = 1 if defined $argz{debug};
# default if nothing is supplied is to use the result;
# otherwise, without use supplied either of export or
@@ -347,10 +346,7 @@ sub import
my $ref = qualify_to_ref $argz{ export }, $caller;
- exists $argz{ scalar }
- ? *$ref = \$libz[0]
- : *$ref = \@libz
- ;
+ *$ref = \@libz;
}
if( defined $argz{ p5lib } )
@@ -658,7 +654,7 @@ having to modify a single line of code.
Say your sandbox is in ./sandbox and you are currently
working in ./sandbox/projects/package/bin on a perl
executable. You may have some number of modules that
-are specific -- or customized -- for this pacakge,
+are specific -- or customized -- for this package,
share some modules within the project, and may want
to use company-wide modules that are managed out of
./sandbox in development. All of this lives under a
diff --git a/t/09-base-subdir-scalar.t b/t/09-base-subdir-scalar.t
index 7e74429..ac9c4d0 100644
--- a/t/09-base-subdir-scalar.t
+++ b/t/09-base-subdir-scalar.t
@@ -30,6 +30,6 @@ my $expect = catpath '' => qw( blib blort );
my $value = ${ *$ref };
ok $value, "Exported scalar '\$snark'";
-like $value, qr{ \Q$expect\E $}x, "Found 'blib/blort' ($value)";
+like $value, qr{\Q$expect\E $}x, "Found 'blib/blort' ($value)";
__END__
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libfindbin-libs-perl.git
More information about the Pkg-perl-cvs-commits
mailing list