Config-Find-0.31/0000755000175000017500000000000012531056144012517 5ustar salvasalvaConfig-Find-0.31/Changes0000755000175000017500000001165112531050062014012 0ustar salvasalvaRevision history for Config::Find. 0.31 2015-05-26 - Fix tests for meta files - Generate META.(yml|json) on the fly when the dist is built - Several doc fixes, remove non-ASCII characters 0.30 2015-05-25 - Fix testing on Windows (bug report and patch by Alexandr Ciornii) 0.29 2015-04-21 - Config::Find::Any::_find must return undef when file not found. PBP does not apply. - added initial test script for find() method. - default to WinAny for Windows OSes, and separate exceptions. - report versions when testing. 0.28 2015-04-17 - documentation updates. - fixed error message typo. - added POD coverage tests. - acknowledged Barbie's contribution, at Salvador's request. - switched to correct POD encoding. 0.27 2015-04-16 - added POD UTF8 encoding directives. (RT#78944) - fixed minor typos. (RT#82001) - added Win7.pm. (RT#57625) - change file dates changed to meet W3CDTF standards. - updated module versions to be consistent for the distribution. - added META.json & updated META.yml. - added META and changefile tests. - moved older test scripts to newer names. 0.26 2008-11-24 - remove warning from File::Spec 0.25 2008-11-20 - paths began with '//' on cygwin, use catpath to undo splitpath (bug report from Pablo Torres). 0.24 2008-11-12 - add Config::Find::Where->script_dir() - some minor doc improvements 0.23 2008-09-17 - add Config::Find::Where->lib_dir method - Config::Find::Where->application_dir documented - update to use new File::HomeDir API 0.22 2005-09-22 - pod errors corrected on Config::Find::Where and now using Test::Pod for automatically finding those errors. 0.21 2005-08-08 - added work around on WinAny module when ${APPDATA} or ${LOCAL_APPDATA} point to the user desktop to ignore them. 0.20 2005-07-27 - look for ~/.foo.conf and ~/.foo.cfg in addition to ~/.foo 0.19 2005-07-13 - bug on look_for_dir_file passing the wrong app name to app_dir. 0.18 2005-04-13 - bug on parent_dir('') going to an inf. loop corrected. - convert path to absolute on create_dir and create_parent_dir - create_parent_dirs renamed to create_parent_dir and exported via Config::Find::Where. 0.17 2005-04-13 - bug on var_dir corrected, when using scope 'app' a 'var' part was missing on the path. - Config::Find::Where::var_dir documented 0.16 2004-09-16 - create_dir function exported on Config::Find::Where - support for 'dir' option on Where module functions. 0.15 2004-02-11 - Corrected bug on "names" handling reported by Bart Schaefer - Better handling of Win32::GetFolderPath returning invalid results 0.14 2004-01-15 - Win2k3.pm missing from MANIFEST - Use regexps to match Win OSs - corrected bug on guess_script_dir 0.13 2004-01-13 - NT4 was not being recognised as NT (bug reported by Philip Grivell). 0.12 2003-09-30 - Unix module accepts .cfg extension for read mode 0.11 2003-06-12 - improved Config::Find::Where->var_dir(scope=>user) on Unix. - new Config::Find::Where->helper_path method 0.10 2003-06-12 - corrected several bugs in Windows modules - new test script 2_where.t 0.09 2003-06-05 - new file layout, now all the .pm files are under a common lib dir. - new Config::Find::Where module with some utility methods (maybe unrelated to Config::Find, but useful anyway). - Win32.pm module deleted. - added supoprt for Windows 2003 - corrected some errors in the docs 0.08 2003-05-29 - look for script on current dir when it doesn't have the path included in its name and it has not been found on the system path. 0.07 2003-04-29 - Accept "WinXP/.NET" as OS 0.06 2003-04-15 - File::HomeDir dependency added to main module, CPANPLUS doesn't catch it on the inner module 0.05 2003-04-14 - support for one liners added to Unix module 0.04 2003-04-10 - added File::HomeDir dependecy to Config::Find::Unix 0.03 2003-04-09 - corrected bug in open that returned a valid file handler even when the configuration file was not found 0.02 2003-04-09 - corrected bug in 'parent_dir' that was not correctly handling trailing '/' - corrected bug in 'guess_script_dir' that was not removing the script name - support for 'file' option added - dependencies added in Makefile.PL 0.01 2003-03-31T13:09:40 - original version; created by h2xs 1.22 with options - AX -n Config::Find Config-Find-0.31/lib/0000755000175000017500000000000012531056144013265 5ustar salvasalvaConfig-Find-0.31/lib/Config/0000755000175000017500000000000012531056144014472 5ustar salvasalvaConfig-Find-0.31/lib/Config/Find/0000755000175000017500000000000012531056144015352 5ustar salvasalvaConfig-Find-0.31/lib/Config/Find/Win95.pm0000755000175000017500000000202112531046300016612 0ustar salvasalvapackage Config::Find::Win95; use strict; use warnings; use Config::Find::WinAny our @ISA = qw(Config::Find::WinAny); 1; __END__ =encoding latin1 =head1 NAME Config::Find::Win95 - Win95 idiosyncrasies for Config::Find =head1 SYNOPSIS # don't use Config::Find::Win95 directly use Config::Find; =head1 ABSTRACT Implements Win95 specific features for Config::Find =head1 DESCRIPTION Contains any idiosyncrasies found within Win95, that do not apply to the standard Win32 base. =head1 SEE ALSO L, L, L =head1 AUTHOR Salvador FandiEo GarcEa, Esfandino@yahoo.comE =head1 CONTRIBUTORS Barbie, Ebarbie@missbarbell.co.ukE (some bug fixes and documentation) =head1 COPYRIGHT AND LICENSE Copyright 2003-2015 by Salvador FandiEo GarcEa (sfandino@yahoo.com) Copyright 2015 by Barbie (barbie@missbarbell.co.uk) This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut Config-Find-0.31/lib/Config/Find/Unix.pm0000755000175000017500000001616312531046310016637 0ustar salvasalvapackage Config::Find::Unix; use strict; use warnings; use Carp; use File::HomeDir; use Config::Find::Any; our @ISA=qw(Config::Find::Any); sub app_dir { my ($class, $name)=@_; $name=$class->guess_script_name unless defined $name; my $ename = uc($name).'_HOME'; return $ENV{$ename} if (exists $ENV{$ename}); $class->parent_dir($class->guess_script_dir); } sub _my_home { my $home = File::HomeDir->my_home; return $home if defined $home; my ($user, $dir) = (getpwuid $>)[0, 7]; return $dir if defined $dir; return "/home/$user" if defined $user; return "/" }; sub system_temp { '/tmp' } sub _var_dir { my ($class, $name, $more_name, $scope) = @_; if ($scope eq 'global') { $class->my_catfile('/var', $name, $more_name); } elsif ($scope eq 'user') { File::Spec->catfile(_my_home(), '.'.$name, 'var', $more_name); } elsif ($scope eq 'app') { $class->my_catfile($class->app_dir($name), 'var', $more_name); } else { croak "scope '$scope' is not valid for var_dir method"; } } sub _bin_dir { my ($class, $name, $more_name, $scope) = @_; if ($scope eq 'global') { '/usr/bin'; } elsif ($scope eq 'user') { File::Spec->catfile(_my_home(), 'bin'); } elsif ($scope eq 'app') { File::Spec->catfile($class->app_dir($name), 'bin'); } else { croak "scope '$scope' is not valid for bin_dir method"; } } sub _lib_dir { my ($class, $name, $more_name, $scope) = @_; if ($scope eq 'global') { '/usr/lib'; } elsif ($scope eq 'user') { File::Spec->catfile(_my_home(), 'lib'); } elsif ($scope eq 'app') { File::Spec->catfile($class->app_dir($name), 'lib'); } else { croak "scope '$scope' is not valid for lib_dir method"; } } sub look_for_file { my ($class, $name, $write, $global)=@_; my $fn; if ($write) { if ($global) { my $fnwe=$class->add_extension($name, 'conf'); unless ($class->is_one_liner) { my $etc=File::Spec->catfile($class->app_dir($name), 'etc'); return File::Spec->catfile($etc, $fnwe) if -e $etc; $etc=File::Spec->catfile($class->app_dir($name), 'conf'); return File::Spec->catfile($etc, $fnwe) if -e $etc; } return File::Spec->catfile('/etc', $fnwe); } return File::Spec->catfile(_my_home(), ".$name"); } else { # looks in ~/.whatever unless ($global) { $fn=File::Spec->catfile(_my_home(), ".$name"); return $fn if -f $fn; for my $ext (qw(conf cfg)) { return "$fn.$ext" if -f "$fn.$ext"; } } for my $fnwe (map {$class->add_extension($name, $_)} qw(conf cfg)) { unless ($class->is_one_liner) { # looks in ./../etc/whatever.conf relative to the running script $fn=File::Spec->catfile($class->app_dir($name), 'etc', $fnwe); return $fn if -f $fn; # looks in ./../conf/whatever.conf relative to the running script $fn=File::Spec->catfile($class->app_dir($name), 'conf', $fnwe); return $fn if -f $fn; } # looks in /etc/whatever.conf $fn=File::Spec->catfile('/etc', $fnwe); return $fn if -f $fn; } } return; } sub look_for_helper { my ($class, $dir, $helper)=@_; my $path=File::Spec->catfile($dir, $helper); -e $path or croak "helper '$helper' not found"; ((-f $path or -l $path) and -x $path) or croak "helper '$helper' found at '$path' but it is not executable"; return $path } sub look_for_dir_file { my ($class, $dir, $name, $write, $global)=@_; my $fn; if ($write) { my $fnwe=$class->add_extension($name, 'conf'); if ($global) { unless ($class->is_one_liner) { my $etc=File::Spec->catfile($class->app_dir($dir), 'etc'); return File::Spec->catfile($etc, $dir, $fnwe) if -e $etc; $etc=File::Spec->catfile($class->app_dir($dir), 'conf'); return File::Spec->catfile($etc, $dir, $fnwe) if -e $etc; } return File::Spec->catfile('/etc', $dir, $fnwe); } return File::Spec->catfile(_my_home(), ".$dir", $fnwe); } else { # looks in ~/.whatever for my $fnwe (map {$class->add_extension($name, $_)} qw(conf cfg)) { unless ($global) { my $fn=File::Spec->catfile(_my_home(), ".$dir", $fnwe); return $fn if -f $fn; } unless ($class->is_one_liner and not defined $dir) { # looks in ./../etc/whatever.conf relative to the running script $fn=File::Spec->catfile($class->app_dir($dir), 'etc', $dir, $fnwe); return $fn if -f $fn; # looks in ./../conf/whatever.conf relative to the running script $fn=File::Spec->catfile($class->app_dir($dir), 'conf', $dir, $fnwe); return $fn if -f $fn; } # looks in system /etc/whatever.conf $fn=File::Spec->catfile('/etc', $dir, $fnwe); return $fn if -f $fn; } } return; } 1; __END__ =encoding latin1 =head1 NAME Config::Find::Unix - Config::Find plugin for Unixen =head1 SYNOPSIS # don't use Config::Find::Unix directly use Config::Find; =head1 ABSTRACT Config::Find plugin for Unixen =head1 DESCRIPTION This module implements Config::Find for Unix The order for searching the config files is: 1 ~/.$name [user] 1b ~/.$name.conf [user] 2 /$path_to_script/../etc/$name.conf [global] 3 /$path_to_script/../conf/$name.conf [global] 4 /etc/$name.conf [global] although if the environment variable C<$ENV{${name}_HOME}> is defined it does 1 ~/.$name [user] 1b ~/.$name.conf [user] 2 $ENV{${name}_HOME}/etc/$name.conf [global] 3 $ENV{${name}_HOME}/conf/$name.conf [global] 4 /etc/$name.conf [global] instead. When the "several configuration files in one directory" approach is used, the order is somewhat different: 1 ~/.$dir/$name.conf [user] 2 /$path_to_script/../etc/$dir/$name.conf [global] 3 /$path_to_script/../conf/$dir/$name.conf [global] 4 /etc/$dir/$name.conf [global] (also affected by C<$ENV{${name}_HOME}>) =head1 SEE ALSO L, L. =head1 AUTHOR Salvador FandiEo GarcEa, Esfandino@yahoo.comE =head1 CONTRIBUTORS Barbie, Ebarbie@missbarbell.co.ukE (some bug fixes and documentation) =head1 COPYRIGHT AND LICENSE Copyright 2003-2015 by Salvador FandiEo GarcEa (sfandino@yahoo.com) Copyright 2015 by Barbie (barbie@missbarbell.co.uk) This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut Config-Find-0.31/lib/Config/Find/Where.pm0000644000175000017500000001623412531046306016767 0ustar salvasalvapackage Config::Find::Where; use strict; use warnings; use Carp; use Config::Find; our @ISA=@Config::Find::ISA; sub temp_dir { my $class = shift; my ($name, $more_name, $create, $dn, $scope)= $class->parse_opts(scope=> 'user', @_); $class->create_dir_if( (defined $dn ? $dn : $class->_temp_dir($name, $more_name, $scope)), $create) } sub var_dir { my $class = shift; my ($name, $more_name, $create, $dn, $scope)= $class->parse_opts(scope => 'app', @_); $class->create_dir_if( (defined $dn ? $dn : $class->_var_dir($name, $more_name, $scope) ), $create) } sub bin_dir { my $class = shift; my ($name, $more_name, $create, $dn, $scope)= $class->parse_opts(scope=> 'app', @_); $class->create_dir_if( (defined $dn ? $dn : $class->_bin_dir($name, $more_name, $scope) ), $create); } sub lib_dir { my $class = shift; my ($name, $more_name, $create, $dn, $scope) = $class->parse_opts(scope => 'app', @_); $class->create_dir_if( (defined $dn ? $dn : $class->_lib_dir($name, $more_name, $scope) ), $create); } sub application_dir { my $class=shift; my ($name, $more_name, $create, $dn, $scope)= $class->parse_opts(@_); $class->create_dir_if( (defined $dn ? $dn : $class->app_dir($name) ), $create) } sub create_dir_if { my ($class, $dir, $create)=@_; # warn ("$class->create_dir($dir, $create)"); if ($create) { $class->create_dir($dir); } $dir; } sub create_dir { my ($class, $dir)=@_; $class->SUPER::create_dir(File::Spec->rel2abs($dir)); } sub create_parent_dir { my ($class, $dir)=@_; $class->SUPER::create_parent_dir(File::Spec->rel2abs($dir)); } sub script_full_path { shift->guess_full_script_name } sub script_name { shift->guess_script_name } sub script_dir { shift->guess_script_dir } sub helper_path { my $class=shift; my $helper=shift; my $path=$class->bin_dir(@_); $class->look_for_helper($path, $helper); } sub parse_opts { my ($class, %opts)=@_; my ($name, $more_name, $create, $dn, $scope); $dn=$opts{dir}; $create=$opts{create}; if (defined $opts{name}) { $opts{name}=~m{^([^/]*)(?:/(.*))?$} or croak "invalid name '$opts{name}' specification"; $name=$1; $more_name=$2; } else { $name=$class->guess_script_name; } if (defined $opts{scope}) { if ($opts{scope}=~/^u(ser)?$/i) { $scope='user' } elsif ($opts{scope}=~/^g(lobal)?$/i) { $scope='global' } elsif ($opts{scope}=~/^a(pp(lication)?)?$/i) { $scope='app' } elsif ($opts{scope}=~/^p(rocess)?$/i) { $scope='process' } else { croak "invalid option scope => '$opts{scope}'"; } } else { $scope='global'; } return ($name, $more_name, $create, $dn, $scope); } 1; __END__ =encoding latin1 =head1 NAME Config::Find::Where - Find locations in the native OS fashion =head1 SYNOPSIS use Config::Find::Where; my $temp_dir=Config::Find::Where->temp_dir( name => 'my_app', scope => 'process', create => 1 ); my $path=Config::Find::Where->bin_dir( scope => 'app' ); system $path."/app_helper.exe"; =head1 ABSTRACT Config::Find searches for locations using OS dependant heuristics. =head1 DESCRIPTION After releasing L I found much of its code could be reused to also find other interesting things like temporary directories, the script location, etc. This module adds a public API to all the hidden functionality. =head2 OPTIONS As in L, all the methods in this package accept a common set of options: =over 4 =item name => C or C specifies the primary application name used to generate the location paths or to search for them. =item scope => C, C, C or C - =item create => 1 creates any nonexistent directory in the path returned =back =head2 METHODS All the methods in this package are class methods (you don't need an object to call them). =over 4 =item $path=Config::Find::Where-Etemp_dir(%opts) returns a directory path inside a system temporary location. i.e.: Config::Find::Where->temp_dir( name =>'hello/world', scope => 'process', create => 1 ) returns something similar to '/tmp/jacks/hello/974/world/' on unix like systems and 'C:\Windows\Temp\jacks\hello\974\world' on some Windows ones ('jacks' is supposed to be the current user name and '974' the process number). The default scope for this method is C. =item $path=Config::Find::Where-Ebin_dir(%opts) returns a place to find/place binary files. The default scope for this method is C. i.e. Config::Find::Where->bin_dir() returns the path to the directory where binaries are located. Note that this directory is not necessarily the same as the one containing the running script. See documentation for C below. =item $path=Config::Find::Where-Evar_dir(%opts) returns a place to find/place working files. The default scope for this method is C. =item $path = Config::Find::Where-Elib_dir(%opts) returns a place to find/place library files. The default scope for this method is C. For instance: use lib => Config::Find::Where->lib_dir; =item $path = Config::Find::Where-Eapplication_dir(%opts) returns the application root directory. =item $name=Config::Find::Where-Escript_name() returns the name of the running script without any path information =item $path=Config::Find::Where-Escript_full_path() returns the name of the script as the absolute full path to it. =item $path=Config::Find::Where-Escript_dir() returns the name of the directory containing the current script =item Config::Find::Where-Ecreate_dir($dir) creates directory C<$dir> and any needed parents =item Config::Find::Where-Ecreate_parent_dir($file) recursively creates all the nonexistent parent directories for C<$file>. =item Config::Find::Where-Ehelper_path($file, %opts) searches for a script, based on the directories given in %opts, which are the same as bin_dir() method. =back =head1 BUGS Some Win32 operating systems are not completely implemented and default to inferior modes, but hey, this is a work in progress!!! Contributions, bug reports, feedback and any kind of comments are welcome. =head1 SEE ALSO L =head1 AUTHOR Salvador FandiEo GarcEa, Esfandino@yahoo.comE =head1 CONTRIBUTORS Barbie, Ebarbie@missbarbell.co.ukE (some bug fixes and documentation) =head1 COPYRIGHT AND LICENSE Copyright 2003-2015 by Salvador FandiEo GarcEa (sfandino@yahoo.com) Copyright 2015 by Barbie (barbie@missbarbell.co.uk) This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut Config-Find-0.31/lib/Config/Find/Any.pm0000755000175000017500000001333512531046612016446 0ustar salvasalvapackage Config::Find::Any; use strict; use warnings; use Carp; use File::Spec; use File::Which; use IO::File; # private methods sub _find { my ($class, $write, $global, @names)=@_; for my $n (@names) { my $fn; if ($n=~/^(.*?)\/(.*)$/) { my ($dir, $file)=($1, $2); $fn=$class->look_for_dir_file($dir, $file, $write, $global); } else { $fn=$class->look_for_file($n, $write, $global); } return $fn if defined $fn; } return undef; } sub _open { my ($class, $write, $global, $fn)=@_; if ($write) { $class->create_parent_dir($fn); return IO::File->new($fn, 'w'); } defined($fn) ? IO::File->new($fn, 'r') : undef; } sub _install { my ($class, $orig, $write, $global, $fn)=@_; croak "install mode has to be 'write'" unless $write; my $oh=IO::File->new($orig, 'r') or croak "unable to open '$orig'"; my $fh=$class->_open($write, $global, $fn) or croak "unable to create config file '$fn'"; while(<$oh>) { $fh->print($_) } close $fh or die "unable to write config file '$fn'"; close $oh or die "unable to read '$orig'"; return $fn; } sub _temp_dir { my ($class, $name, $more_name, $scope)=@_; my $stemp=$class->system_temp; if ($scope eq 'global') { $class->my_catdir($stemp, $name, $more_name) } elsif ($scope eq 'user') { $class->my_catdir($stemp, $class->my_getlogin, $name, $more_name) } elsif ($scope eq 'app') { $class->my_catdir($class->app_dir($name), 'tmp', $more_name) } elsif ($scope eq 'process') { $class->my_catdir($stemp, $class->my_getlogin, $name, $$, $more_name) } else { croak "scope '$scope' is not valid for temp_dir method"; } } # public methods, to be overridden sub look_for_file { my $class=shift; die "unimplemented virtual method $class->look_for_file() called"; } sub look_for_dir_file { my $class=shift; die "unimplemented virtual method $class->look_for_dir_file() called"; } # public methods, inherited by sub-classes sub guess_full_script_name { my $path = (File::Spec->splitpath($0))[1]; if ($path eq '') { if (my $script = File::Which::which($0)) { return File::Spec->rel2abs($script); } } return File::Spec->rel2abs($0) if -e $0; carp "unable to determine script '$0' location"; } sub guess_script_name { my $name; (undef, undef, $name)=File::Spec->splitpath($0); $name=~/^(.+)\..*$/ and return $1; return undef if $name eq ''; return $name; } sub guess_script_dir { my $class=shift; my $script=$class->guess_full_script_name; my ($unit, $dir)=File::Spec->splitpath($script, 0); File::Spec->catpath($unit, $dir, ''); } sub is_one_liner { return $0 eq '-e' } sub add_extension { my ($class, $name, $ext)=@_; return $name if ($name=~/\./); return $name.'.'.$ext; } sub create_parent_dir { my ($class, $fn)=@_; my $parent=$class->parent_dir($fn); if (-e $parent) { -d $parent or croak "'$parent' exists but is not a directory"; -W $parent or croak "not allowed to write on directory '$parent'"; } else { $class->create_parent_dir($parent); mkdir $parent or die "unable to create directory '$parent' ($!)"; } } sub parent_dir { my ($class, $dir)=@_; # print "creating dir $dir\n"; my @dirs=File::Spec->splitdir($dir); pop(@dirs) eq '' and pop(@dirs); File::Spec->catfile(@dirs ? @dirs : File::Spec->rootdir); } sub create_dir { my ($class, $dir)=@_; if (-e $dir) { -d $dir or croak "'$dir' exists but is not a directory"; } else { $class->create_parent_dir($dir); mkdir $dir or die "unable to create directory '$dir' ($!)"; } $dir; } sub my_catfile { my $class=shift; pop @_ unless defined $_[-1]; File::Spec->catfile(@_); } sub my_catdir { my $class=shift; pop @_ unless defined $_[-1]; File::Spec->catdir(@_); } sub my_getlogin { my $login=getlogin(); $login = '_UNKNOW_' unless defined $login; $login; } 1; __END__ =encoding latin1 =head1 NAME Config::Find::Any - Perl base class for Config::Find =head1 SYNOPSIS # don't use Config::Find::Any; use Config::Find; =head1 ABSTRACT This module implements basic methods for L. =head1 DESCRIPTION Every L class has to be derived from this one and two methods have to be redefined, while the remainder can be utilized by the class as required. =head2 OVERRIDE METHODS =over 4 =item $class->look_for_file($name, $write, $global) =item $class->look_for_dir_file($dir, $name, $write, $global) =back =head2 CLASS METHODS =over 4 =item $class->guess_full_script_name($file) =item $class->guess_script_name($file) =item $class->guess_script_dir($file) =item $class->is_one_liner($file) =item $class->add_extension($name, $extension) =item $class->create_parent_dir($file) =item $class->parent_dir($dir) =item $class->create_dir($dir) =item $class->my_catfile($path,$to,$file,...) =item $class->my_catdir($path,$to,$dir,...) =item $class->my_getlogin() =back =head1 SEE ALSO L, L, L. =head1 AUTHOR Salvador FandiEo GarcEa, Esfandino@yahoo.comE =head1 CONTRIBUTORS Barbie, Ebarbie@missbarbell.co.ukE (some bug fixes and documentation) =head1 COPYRIGHT AND LICENSE Copyright 2003-2015 by Salvador FandiEo GarcEa (sfandino@yahoo.com) Copyright 2015 by Barbie (barbie@missbarbell.co.uk) This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut Config-Find-0.31/lib/Config/Find/Win2k.pm0000644000175000017500000000202112531046305016673 0ustar salvasalvapackage Config::Find::Win2k; use strict; use warnings; use Config::Find::WinAny our @ISA = qw(Config::Find::WinAny); 1; __END__ =encoding latin1 =head1 NAME Config::Find::Win2k - Win2k idiosyncrasies for Config::Find =head1 SYNOPSIS # don't use Config::Find::Win2k directly use Config::Find; =head1 ABSTRACT Implements Win2k specific features for Config::Find =head1 DESCRIPTION Contains any idiosyncrasies found within Win2k, that do not apply to the standard Win32 base. =head1 SEE ALSO L, L, L =head1 AUTHOR Salvador FandiEo GarcEa, Esfandino@yahoo.comE =head1 CONTRIBUTORS Barbie, Ebarbie@missbarbell.co.ukE (some bug fixes and documentation) =head1 COPYRIGHT AND LICENSE Copyright 2003-2015 by Salvador FandiEo GarcEa (sfandino@yahoo.com) Copyright 2015 by Barbie (barbie@missbarbell.co.uk) This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut Config-Find-0.31/lib/Config/Find/WinXP.pm0000755000175000017500000000202212531046267016721 0ustar salvasalvapackage Config::Find::WinXP; use strict; use warnings; use Config::Find::WinAny our @ISA = qw(Config::Find::WinAny); 1; __END__ =encoding latin1 =head1 NAME Config::Find::WinXP - WinXP idiosyncrasies for Config::Find =head1 SYNOPSIS # don't use Config::Find::WinXP directly use Config::Find; =head1 ABSTRACT Implements WinXP specific features for Config::Find =head1 DESCRIPTION Contains any idiosyncrasies found within WinXP, that do not apply to the standard Win32 base. =head1 SEE ALSO L, L, L =head1 AUTHOR Salvador FandiEo GarcEa, Esfandino@yahoo.comE =head1 CONTRIBUTORS Barbie, Ebarbie@missbarbell.co.ukE (some bug fixes and documentation) =head1 COPYRIGHT AND LICENSE Copyright 2003-2015 by Salvador FandiEo GarcEa (sfandino@yahoo.com) Copyright 2015 by Barbie (barbie@missbarbell.co.uk) This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut Config-Find-0.31/lib/Config/Find/Win7.pm0000755000175000017500000000201312531046302016526 0ustar salvasalvapackage Config::Find::Win7; use strict; use warnings; use Config::Find::WinAny our @ISA = qw(Config::Find::WinAny); 1; __END__ =encoding latin1 =head1 NAME Config::Find::Win7 - Win7 idiosyncrasies for Config::Find =head1 SYNOPSIS # don't use Config::Find::Win7 directly use Config::Find; =head1 ABSTRACT Implements Win7 specific features for Config::Find =head1 DESCRIPTION Contains any idiosyncrasies found within Win7, that do not apply to the standard Win32 base. =head1 SEE ALSO L, L, L =head1 AUTHOR Salvador FandiEo GarcEa, Esfandino@yahoo.comE =head1 CONTRIBUTORS Barbie, Ebarbie@missbarbell.co.ukE (some bug fixes and documentation) =head1 COPYRIGHT AND LICENSE Copyright 2003-2015 by Salvador FandiEo GarcEa (sfandino@yahoo.com) Copyright 2015 by Barbie (barbie@missbarbell.co.uk) This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut Config-Find-0.31/lib/Config/Find/WinME.pm0000755000175000017500000000202212531046272016667 0ustar salvasalvapackage Config::Find::WinME; use strict; use warnings; use Config::Find::WinAny our @ISA = qw(Config::Find::WinAny); 1; __END__ =encoding latin1 =head1 NAME Config::Find::WinME - WinME idiosyncrasies for Config::Find =head1 SYNOPSIS # don't use Config::Find::WinME directly use Config::Find; =head1 ABSTRACT Implements WinME specific features for Config::Find =head1 DESCRIPTION Contains any idiosyncrasies found within WinME, that do not apply to the standard Win32 base. =head1 SEE ALSO L, L, L =head1 AUTHOR Salvador FandiEo GarcEa, Esfandino@yahoo.comE =head1 CONTRIBUTORS Barbie, Ebarbie@missbarbell.co.ukE (some bug fixes and documentation) =head1 COPYRIGHT AND LICENSE Copyright 2003-2015 by Salvador FandiEo GarcEa (sfandino@yahoo.com) Copyright 2015 by Barbie (barbie@missbarbell.co.uk) This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut Config-Find-0.31/lib/Config/Find/WinCE.pm0000644000175000017500000000202212531046273016653 0ustar salvasalvapackage Config::Find::WinCE; use strict; use warnings; use Config::Find::WinAny our @ISA = qw(Config::Find::WinAny); 1; __END__ =encoding latin1 =head1 NAME Config::Find::WinCE - WinCE idiosyncrasies for Config::Find =head1 SYNOPSIS # don't use Config::Find::WinCE directly use Config::Find; =head1 ABSTRACT Implements WinCE specific features for Config::Find =head1 DESCRIPTION Contains any idiosyncrasies found within WinCE, that do not apply to the standard Win32 base. =head1 SEE ALSO L, L, L =head1 AUTHOR Salvador FandiEo GarcEa, Esfandino@yahoo.comE =head1 CONTRIBUTORS Barbie, Ebarbie@missbarbell.co.ukE (some bug fixes and documentation) =head1 COPYRIGHT AND LICENSE Copyright 2003-2015 by Salvador FandiEo GarcEa (sfandino@yahoo.com) Copyright 2015 by Barbie (barbie@missbarbell.co.uk) This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut Config-Find-0.31/lib/Config/Find/WinNT.pm0000755000175000017500000000202212531046270016705 0ustar salvasalvapackage Config::Find::WinNT; use strict; use warnings; use Config::Find::WinAny our @ISA = qw(Config::Find::WinAny); 1; __END__ =encoding latin1 =head1 NAME Config::Find::WinNT - WinNT idiosyncrasies for Config::Find =head1 SYNOPSIS # don't use Config::Find::WinNT directly use Config::Find; =head1 ABSTRACT Implements WinNT specific features for Config::Find =head1 DESCRIPTION Contains any idiosyncrasies found within WinNT, that do not apply to the standard Win32 base. =head1 SEE ALSO L, L, L =head1 AUTHOR Salvador FandiEo GarcEa, Esfandino@yahoo.comE =head1 CONTRIBUTORS Barbie, Ebarbie@missbarbell.co.ukE (some bug fixes and documentation) =head1 COPYRIGHT AND LICENSE Copyright 2003-2015 by Salvador FandiEo GarcEa (sfandino@yahoo.com) Copyright 2015 by Barbie (barbie@missbarbell.co.uk) This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut Config-Find-0.31/lib/Config/Find/Win2k3.pm0000644000175000017500000000202712531046303016762 0ustar salvasalvapackage Config::Find::Win2k3; use strict; use warnings; use Config::Find::WinAny our @ISA = qw(Config::Find::WinAny); 1; __END__ =encoding latin1 =head1 NAME Config::Find::Win2k - Win2k idiosyncrasies for Config::Find =head1 SYNOPSIS # don't use Config::Find::Win2k3 directly use Config::Find; =head1 ABSTRACT Implements Win2003 specific features for Config::Find =head1 DESCRIPTION Contains any idiosyncrasies found within Win2003, that do not apply to the standard Win32 base. =head1 SEE ALSO L, L, L =head1 AUTHOR Salvador FandiEo GarcEa, Esfandino@yahoo.comE =head1 CONTRIBUTORS Barbie, Ebarbie@missbarbell.co.ukE (some bug fixes and documentation) =head1 COPYRIGHT AND LICENSE Copyright 2003-2015 by Salvador FandiEo GarcEa (sfandino@yahoo.com) Copyright 2015 by Barbie (barbie@missbarbell.co.uk) This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut Config-Find-0.31/lib/Config/Find/Win98.pm0000755000175000017500000000202212531046276016632 0ustar salvasalvapackage Config::Find::Win98; use strict; use warnings; use Config::Find::WinAny our @ISA = qw(Config::Find::WinAny); 1; __END__ =encoding latin1 =head1 NAME Config::Find::Win98 - Win98 idiosyncrasies for Config::Find =head1 SYNOPSIS # don't use Config::Find::Win98 directly use Config::Find; =head1 ABSTRACT Implements Win98 specific features for Config::Find =head1 DESCRIPTION Contains any idiosyncrasies found within Win98, that do not apply to the standard Win32 base. =head1 SEE ALSO L, L, L =head1 AUTHOR Salvador FandiEo GarcEa, Esfandino@yahoo.comE =head1 CONTRIBUTORS Barbie, Ebarbie@missbarbell.co.ukE (some bug fixes and documentation) =head1 COPYRIGHT AND LICENSE Copyright 2003-2015 by Salvador FandiEo GarcEa (sfandino@yahoo.com) Copyright 2015 by Barbie (barbie@missbarbell.co.uk) This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut Config-Find-0.31/lib/Config/Find/WinAny.pm0000755000175000017500000001370412531046275017131 0ustar salvasalvapackage Config::Find::WinAny; use strict; use warnings; use Carp; use Config::Find::Any; use Win32 qw( CSIDL_LOCAL_APPDATA CSIDL_APPDATA CSIDL_DESKTOPDIRECTORY); our @ISA = qw(Config::Find::Any); sub app_dir { my ($class, $name)=@_; $name=$class->guess_script_name unless defined $name; my $ename = uc($name).'_HOME'; return $ENV{$ename} if (exists $ENV{$ename}); $class->guess_script_dir; } my $winlocalappdir=Win32::GetFolderPath(CSIDL_LOCAL_APPDATA); my $winappdir=Win32::GetFolderPath(CSIDL_APPDATA); my $windesktop=Win32::GetFolderPath(CSIDL_DESKTOPDIRECTORY); if (defined $windesktop and $windesktop ne '') { undef $winlocalappdir if (defined($winlocalappdir) and index($winlocalappdir, $windesktop) == 0); undef $winappdir if (defined($winappdir) and index($winappdir, $windesktop) == 0); } sub app_user_dir { my ($class, $name)=@_; return ( (defined $winlocalappdir) && ($winlocalappdir ne "") ? $winlocalappdir : (defined $winappdir) && ($winappdir ne "") ? $winappdir : File::Spec->catdir($class->app_dir($name), 'Users', $class->my_getlogin)); } sub system_temp { my $class=shift; return $ENV{TEMP} if defined $ENV{TEMP}; return $ENV{TMP} if defined $ENV{TMP}; return File::Spec->catfile($ENV{windir}, 'Temp') if defined $ENV{windir}; return 'C:\Temp'; } sub _var_dir { my ($class, $name, $more_name, $scope)=@_; if ($scope eq 'user') { File::Spec->catdir($class->app_user_dir($name), $name, 'Data', $more_name) } else { File::Spec->catdir($class->app_dir($name), 'Data', $more_name); } } sub _bin_dir { my ($class, $name, $more_name, $scope)=@_; if ($scope eq 'app') { $class->app_dir($name); } else { die "unimplemented option scope => $scope"; } } sub look_for_helper { my ($class, $dir, $helper)=@_; my @ext=('', ( defined $ENV{PATHEXT} ? (split /;/, $ENV{PATHEXT}) : qw(.COM .EXE .BAT .CMD))); for my $ext (@ext) { my $path=File::Spec->catfile($dir, $helper.$ext); -e $path and -x $path and return $path; } croak "helper '$helper' not found"; } sub look_for_file { my ($class, $name, $write, $global)=@_; my $fn; my $fnwe=$class->add_extension($name, 'cfg'); if ($write) { return File::Spec->catfile($class->app_dir($name), $fnwe) if ($global); # my $login=getlogin(); return File::Spec->catfile($class->app_user_dir($name), $fnwe ); } else { unless ($global) { $fn=File::Spec->catfile($class->app_user_dir, $fnwe ); return $fn if -f $fn; } $fn=File::Spec->catfile($class->app_dir($name), $fnwe); return $fn if -f $fn; } return; } sub look_for_dir_file { my ($class, $dir, $name, $write, $global)=@_; my $fn; my $fnwe=$class->add_extension($name, 'cfg'); if ($write) { return File::Spec->catfile($class->app_dir($dir), $dir, $fnwe) if ($global); # my $login=getlogin(); return File::Spec->catfile($class->app_user_dir($dir), $dir, $fnwe ); } else { unless ($global) { $fn=File::Spec->catfile($class->app_user_dir($name), $dir, $fnwe ); return $fn if -f $fn; } $fn=File::Spec->catfile($class->app_dir($name), $fnwe); return $fn if -f $fn; } return; } 1; __END__ =encoding latin1 =head1 NAME Config::Find::WinAny - Behaviours common to any Win32 OS for Config::Find =head1 SYNOPSIS # don't use Config::Find::WinAny directly use Config::Find; =head1 ABSTRACT Implements features common to all the Win32 OS's =head1 DESCRIPTION This module implements Config::Find for Win32 OS's. B Configuration file placement has changed on version 0.15 to be more Windows friendly (see note below). Order for config files searching is... (see note at the end for entries marked as 1b and 2b) 1 ${LOCAL_APPDATA}/$name.cfg [user] (1b /$path_to_script/Users/$user/$name.cfg [user]) 2 /$path_to_script/$name.cfg [global] unless when C<$ENV{${name}_HOME}> is defined. That changes the search paths to... (1b $ENV{${name}_HOME}/Users/$user/$name.cfg [user]) 2 $ENV{${name}_HOME}/$name.cfg [global] When the "several configuration files in one directory" approach is used, the order is something different... 1 ${LOCAL_APPDATA}/$dir/$name.cfg [user] (1b /$path_to_script/Users/$user/$dir/$name.cfg [user]) 2 /$path_to_script/$name.cfg [global] (2b /$path_to_script/$dir/$name.dfg [global]) (it is also affected by C<$ENV{${name}_HOME}> variable) Note: entries marked as 1b were the default behaviour for versions of Config::Find until 0.14. New behaviour is to put user application configuration data under ${LOCAL_APPDATA} as returned by C (if this call fails, the old approach is used). Also, global configuration files were stored under a new directory placed in the same directory as the script but this is unnecessary because windows apps already go in their own directory. It seems that, sometimes, ${LOCAL_APPDATA} points to the user desktop and placing configuration files there would be obviously wrong. As a work around, the module will ignore ${LOCAL_APPDATA} or ${APPDATA} if they point to any place below the desktop path. =head1 SEE ALSO L, L =head1 AUTHOR Salvador FandiEo GarcEa, Esfandino@yahoo.comE =head1 CONTRIBUTORS Barbie, Ebarbie@missbarbell.co.ukE (some bug fixes and documentation) =head1 COPYRIGHT AND LICENSE Copyright 2003-2015 by Salvador FandiEo GarcEa (sfandino@yahoo.com) Copyright 2015 by Barbie (barbie@missbarbell.co.uk) This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut Config-Find-0.31/lib/Config/Find.pm0000755000175000017500000001613712531050112015710 0ustar salvasalvapackage Config::Find; our $VERSION = '0.31'; use strict; use warnings; use Carp; # selects implementation module: our @ISA; BEGIN { if ($^O=~/Win32/) { require Win32; my $OS = uc Win32::GetOSName(); if ($OS=~/^WIN95/) { require Config::Find::Win95; @ISA=qw(Config::Find::Win95); } elsif ($OS=~/^WIN98/) { require Config::Find::Win98; @ISA=qw(Config::Find::Win98); } elsif ($OS=~/^WINME/) { require Config::Find::WinME; @ISA=qw(Config::Find::WinME); } elsif ($OS=~/^WINNT/) { require Config::Find::WinNT; @ISA=qw(Config::Find::WinNT); } elsif ($OS=~/^WIN2000/) { require Config::Find::Win2k; @ISA=qw(Config::Find::Win2k); } elsif ($OS=~/^WIN2003/) { require Config::Find::Win2k3; @ISA=qw(Config::Find::Win2k3); } elsif ($OS=~/^WINXP/) { require Config::Find::WinXP; @ISA=qw(Config::Find::WinXP); } elsif ($OS=~/^WINCE/) { require Config::Find::WinCE; @ISA=qw(Config::Find::WinCE); } elsif ($OS=~/^WIN7/) { require Config::Find::Win7; @ISA=qw(Config::Find::Win7); } else { # default to WinAny, and separate exceptions require Config::Find::WinAny; @ISA=qw(Config::Find::WinAny); #croak "Unknown MSWin32 OS '$OS'"; } } else { require Config::Find::Unix; @ISA=qw(Config::Find::Unix); } } sub find { my $class=shift; my ($write, $global, $fn, @names)=$class->parse_opts(@_); if (defined $fn) { return ($write or -f $fn) ? $fn : undef; } $class->_find($write, $global, @names); } sub open { my $class=shift; my ($write, $global, $fn, @names)=$class->parse_opts(@_); defined($fn) or $fn=$class->_find($write, $global, @names); $class->_open($write, $global, $fn); } sub install { my $class=shift; my $orig=shift; my ($write, $global, $fn, @names)=$class->parse_opts( mode => 'w', @_); defined($fn) or $fn=$class->_find($write, $global, @names); $class->_install($orig, $write, $global, $fn); } sub parse_opts { my ($class, %opts)=@_; my $fn=$opts{file}; my @names; if (exists $opts{name}) { @names=$opts{name}; } elsif (exists $opts{names}) { UNIVERSAL::isa($opts{names}, 'ARRAY') or croak "invalid argument for 'names', expecting an array ref"; @names=@{$opts{names}} } else { @names=$class->guess_script_name(); } my $write; if (exists $opts{mode}) { if ($opts{mode}=~/^r(ead)?$/i) { # yes, do nothing! } elsif ($opts{mode}=~/w(rite)?$/i) { $write=1; } else { croak "invalid option mode => '$opts{mode}'"; } } my $global; if (exists $opts{scope}) { if ($opts{scope}=~/^u(ser)?$/i) { # yes, do nothing! } elsif ($opts{scope}=~/g(lobal)?$/i) { $global=1; } else { croak "invalid option scope => '$opts{scope}'"; } } return ($write, $global, $fn, @names) } 1; __END__ =encoding latin1 =head1 NAME Config::Find - Find configuration files in the native OS fashion =head1 SYNOPSIS use Config::Find; my $filename=Config::Find->find; ... my $fn_foo=Config::Find->find( name => 'my_app/foo', mode => 'write', scope => 'user' ); my $fn_bar=Config::Find->find( names => [qw(my_app/bar appbar)] ); my $fh=Config::Find->open( name => 'foo', scope => 'global', mode => 'w' ) my $fn=Config::Find->install( 'original/config/file.conf', name => 'foo' ); my $fn=Config::Find->find( file => $opt_c, name => foo ); =head1 ABSTRACT Config::Find searches for configuration files using OS dependant heuristics. =head1 DESCRIPTION Every OS has different rules for configuration files placement, this module allows one to easily find and create your app configuration files following those rules. Config::Find references configuration files by the application name or by the application name and the configuration file name when the app uses several application files, i.e C, C, C, C. By default the $0 value is used to generate the configuration file name. To define it explicitly the keywords C or C have to be used: =over 4 =item name => C or C picks the first configuration file matching that name. =item names => [qw(foo bar foo/bar)] picks the first configuration file matching any of the names passed. =back Alternatively, the exact position for the file can be specified with the C keyword: =over 4 =item file => C explicit position of the configuration file. If undef is passed this entry is ignored and the search for the configuration file continues with the appropriate OS rules. This allows for: use Config::Find; use Getopt::Std; our $opt_c; getopts('c:'); my $fn=Config::Find->find(file => $opt_c) =back Methods in this package also accept the optional arguments C and C: =over 4 =item scope => C or C Configuration files can be private to the application user or global to the OS, i.e. in unix there is the global C and the user C<~/.profile>. =item mode => C or C In C mode already existent file names are returned, in C mode the file names point to where the configuration file has to be stored. =back =head2 METHODS All the methods in this package are class methods (you don't need an object to call them). =over 4 =item $fn=Config::Find-Efind(%opts) returns the name of the configuration file. =item $fh=Config::Find-Eopen(%opts) returns a open file handle for the configuration file. In write mode, the file and any nonexistent parent directories are created. =item $fn=Config::Find-Einstall($original, %opts) copies a configuration file to a convenient place. =back =head1 BUGS Some Win32 operating systems are not completely implemented and default to inferior modes, but hey, this is a work in progress!!! Contributions, bug reports, feedback and any kind of comments are welcome. =head1 SEE ALSO L, L for descriptions of the heuristics used to find the configuration files. L for information about adding support for a new OS. L give me the idea for this module. =head1 AUTHOR Salvador FandiEo GarcEa, Esfandino@yahoo.comE =head1 CONTRIBUTORS Barbie, Ebarbie@missbarbell.co.ukE (some bug fixes and documentation) =head1 COPYRIGHT AND LICENSE Copyright 2003-2015 by Salvador FandiEo GarcEa (sfandino@yahoo.com) Copyright 2015 by Barbie (barbie@missbarbell.co.uk) This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut Config-Find-0.31/t/0000755000175000017500000000000012531056144012762 5ustar salvasalvaConfig-Find-0.31/t/data/0000755000175000017500000000000012531056144013673 5ustar salvasalvaConfig-Find-0.31/t/data/.test10000644000175000017500000000000012530550445014724 0ustar salvasalvaConfig-Find-0.31/t/data/test3.cfg0000644000175000017500000000000012530551402015400 0ustar salvasalvaConfig-Find-0.31/t/data/test2.cfg0000644000175000017500000000000012530551402015377 0ustar salvasalvaConfig-Find-0.31/t/data/.test20000644000175000017500000000000012530550445014725 0ustar salvasalvaConfig-Find-0.31/t/data/test1.cfg0000644000175000017500000000000012530551402015376 0ustar salvasalvaConfig-Find-0.31/t/data/.test30000644000175000017500000000000012530550445014726 0ustar salvasalvaConfig-Find-0.31/t/94metatest.t0000755000175000017500000000173412530550445015164 0ustar salvasalva#!/usr/bin/perl -w use strict; use Test::More; # Skip if doing a regular install plan skip_all => "Author tests not required for installation" unless ( $ENV{AUTOMATED_TESTING} ); eval "use Test::CPAN::Meta"; plan skip_all => "Test::CPAN::Meta required for testing META.yml" if $@; plan 'no_plan'; my $meta = meta_spec_ok(undef,undef,@_); use Config::Find; my $version = $Config::Find::VERSION; is($meta->{version},$version, 'META.yml distribution version matches'); if($meta->{provides}) { for my $mod (keys %{$meta->{provides}}) { is($meta->{provides}{$mod}{version},$version, "META.yml entry [$mod] version matches"); next if($mod =~ /Unix|Win/); eval "require $mod"; my $VERSION = '$' . $mod . '::VERSION'; my $v = eval "$VERSION"; is($meta->{provides}{$mod}{version},$v, "META.yml entry [$mod] version matches module version"); isnt($meta->{provides}{$mod}{version},0); } } Config-Find-0.31/t/91podcover.t0000644000175000017500000000103312530550445015141 0ustar salvasalva#!/usr/bin/perl -w use strict; use Test::More; # Skip if doing a regular install plan skip_all => "Author tests not required for installation" unless ( $ENV{AUTOMATED_TESTING} ); eval "use Test::Pod::Coverage 0.08"; plan skip_all => "Test::Pod::Coverage 0.08 required for testing POD coverage" if $@; pod_coverage_ok('Config::Find', { also_private => [ qr/^parse_opts$/ ] } ); pod_coverage_ok('Config::Find::Any'); pod_coverage_ok('Config::Find::Where', { also_private => [ qr/^(create_dir_if|parse_opts)$/ ] } ); done_testing(); Config-Find-0.31/t/96metatest.t0000755000175000017500000000200712530550445015160 0ustar salvasalva#!/usr/bin/perl -w use strict; use Test::More; # Skip if doing a regular install plan skip_all => "Author tests not required for installation" unless ( $ENV{AUTOMATED_TESTING} ); eval "use Test::CPAN::Meta::JSON"; plan skip_all => "Test::CPAN::Meta::JSON required for testing META.json files" if $@; plan 'no_plan'; my $meta = meta_spec_ok(undef,undef,@_); use Config::Find; my $version = $Config::Find::VERSION; is($meta->{version},$version, 'META.json distribution version matches'); if($meta->{provides}) { for my $mod (keys %{$meta->{provides}}) { is($meta->{provides}{$mod}{version},$version, "META.json entry [$mod] version matches distribution version"); next if($mod =~ /Unix|Win/); eval "require $mod"; my $VERSION = '$' . $mod . '::VERSION'; my $v = eval "$VERSION"; is($meta->{provides}{$mod}{version},$v, "META.json entry [$mod] version matches module version"); isnt($meta->{provides}{$mod}{version},0); } } Config-Find-0.31/t/95changedate.t0000755000175000017500000000230312530550445015413 0ustar salvasalva#!/usr/bin/perl -w use strict; use Test::More; use IO::File; # Skip if doing a regular install plan skip_all => "Author tests not required for installation" unless ( $ENV{AUTOMATED_TESTING} ); my $fh = IO::File->new('Changes','r') or plan skip_all => "Cannot open Changes file"; plan 'no_plan'; use Config::Find; my $version = $Config::Find::VERSION; my $latest = 0; while(<$fh>) { next unless(m!^\d!); $latest = 1 if(m!^$version!); # 2012-08-26T01:02 or 2012-08-26T01:02:03 or 2012-08-26T01:02:03.04 or 2012-08-26T01:02+01:00 like($_, qr!^ \d[\d._]+\s+ # version ( \d{4}-\d{2}-\d{2} # 2012-08-26 - YYYY-MM-DD ( T\d{2}:\d{2} # T01:02 - Thh:mm ( :\d{2} # :02 - :ss ( \.\d+ # .2 - .ss (microseconds) )? )? ( (Z|[-+]\d+:\d+) # +01:00 - timezone )? )? ) \s*$!x,'... version has a date'); } is($latest,1,'... latest version not listed'); Config-Find-0.31/t/90podtest.t0000755000175000017500000000045312530550445015011 0ustar salvasalva#!/usr/bin/perl -w use strict; use Test::More; # Skip if doing a regular install plan skip_all => "Author tests not required for installation" unless ( $ENV{AUTOMATED_TESTING} ); eval "use Test::Pod 1.00"; plan skip_all => "Test::Pod 1.00 required for testing POD" if $@; all_pod_files_ok(); Config-Find-0.31/t/01load.t0000755000175000017500000000100712530550445014232 0ustar salvasalva# Before `make install' is performed this script should be runnable with # `make test'. After `make install' it should work as `perl 1.t' ######################### use Test::More tests => 3; my $OS = '-'; BEGIN { use_ok('Config::Find'); use_ok('Config::Find::Any'); use_ok('Config::Find::Where'); if ($^O=~/Win32/) { require Win32; $OS = uc Win32::GetOSName(); } }; diag( "Testing Config::Find $Config::Find::VERSION, Perl $], $^X, OS: $^O ($OS)" ); ######################### Config-Find-0.31/t/10find.t0000644000175000017500000000301712530551402014225 0ustar salvasalva#!/usr/bin/perl -w use strict; use Config::Find; use File::Path; use Test::More tests => 9; $ENV{HOME} = 't/data'; if ($^O eq 'MSWin32') { no warnings qw(redefine once); *Config::Find::WinAny::app_user_dir = sub { return 't/data'; } } my $test1_name = $^O eq 'MSWin32' ? 't\\data\\test1.cfg' : 't/data/.test1'; my $test2_name = $^O eq 'MSWin32' ? 't\\data\\test2.cfg' : 't/data/.test2'; my $test3_name = $^O eq 'MSWin32' ? 't\\data\\test3.cfg' : 't/data/.test3'; my $fn = Config::Find->find( name => 'test1' ); is($fn,$test1_name) or do { $fn = Config::Find->find( names => ['test1'], mode => 'write', scope => 'global' ); diag ("was searching for $fn"); }; $fn = Config::Find->find( names => ['test2','test1'] ); is($fn,$test2_name); eval { $fn = Config::Find->find( names => ['does','not','exist'] ) }; is($fn,undef); eval { $fn = Config::Find->find( names => 'string' ) }; like($@,qr/expecting an array ref/); eval { $fn = Config::Find->find( names => ['string'], mode => 'append' ) }; like($@,qr/invalid option mode/); eval { $fn = Config::Find->find( names => ['string'], scope => 'peri' ) }; like($@,qr/invalid option scope/); eval { $fn = Config::Find->find( names => ['test1','test2'], mode => 'read' ) }; is($fn,$test1_name); eval { $fn = Config::Find->find( names => ['test3'], mode => 'write' ) }; is($fn,$test3_name); mkdir('conf'); eval { $fn = Config::Find->find( names => ['test3'], mode => 'write', scope => 'global' ) }; like($fn,($^O eq 'MSWin32' ? qr!t\\test3\.cfg$! : qr!/conf/test3\.conf$!)); rmdir('conf'); Config-Find-0.31/README0000755000175000017500000000122512530551402013376 0ustar salvasalvaConfig-Find =========== Config::Find implements a set of heuristics to find the configuration files for your applications in an OS dependant and friendly manner. INSTALLATION To install this module type the following: perl Makefile.PL make make test make install DEPENDENCIES This module requires these other modules and libraries: File::HomeDir File::Which File::Spec Test::More COPYRIGHT AND LICENCE Copyright (C) 2003-2015 Salvador Fandiño García Copyright 2015 by Barbie (barbie@missbarbell.co.uk) This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. Config-Find-0.31/MANIFEST0000755000175000017500000000134112531056144013652 0ustar salvasalvaChanges lib/Config/Find.pm lib/Config/Find/Any.pm lib/Config/Find/Unix.pm lib/Config/Find/Where.pm lib/Config/Find/Win2k.pm lib/Config/Find/Win2k3.pm lib/Config/Find/Win7.pm lib/Config/Find/Win95.pm lib/Config/Find/Win98.pm lib/Config/Find/WinAny.pm lib/Config/Find/WinCE.pm lib/Config/Find/WinME.pm lib/Config/Find/WinNT.pm lib/Config/Find/WinXP.pm Makefile.PL MANIFEST README t/01load.t t/10find.t t/90podtest.t t/91podcover.t t/94metatest.t t/95changedate.t t/96metatest.t t/data/.test1 t/data/.test2 t/data/.test3 t/data/test1.cfg t/data/test2.cfg t/data/test3.cfg META.yml Module YAML meta-data (added by MakeMaker) META.json Module JSON meta-data (added by MakeMaker) Config-Find-0.31/Makefile.PL0000755000175000017500000000131712531043745014501 0ustar salvasalva#!/usr/bin/perl use strict; use warnings; use 5.006; use ExtUtils::MakeMaker; WriteMakefile( AUTHOR => 'Salvador Fandino ', NAME => 'Config::Find', VERSION_FROM => 'lib/Config/Find.pm', ABSTRACT => 'Find configuration files in the native OS fashion', PREREQ_PM => {# prereqs 'File::Which' => '0', 'File::Spec' => '0', 'File::HomeDir' => '0', # build/test prereqs 'Test::More' => '0.70', 'IO::File' => '0' } ); Config-Find-0.31/META.yml0000664000175000017500000000113312531056144013770 0ustar salvasalva--- abstract: 'Find configuration files in the native OS fashion' author: - 'Salvador Fandino ' build_requires: ExtUtils::MakeMaker: '0' configure_requires: ExtUtils::MakeMaker: '0' dynamic_config: 1 generated_by: 'ExtUtils::MakeMaker version 7.04, CPAN::Meta::Converter version 2.150001' license: unknown meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: Config-Find no_index: directory: - t - inc requires: File::HomeDir: '0' File::Spec: '0' File::Which: '0' IO::File: '0' Test::More: '0.70' version: '0.31' Config-Find-0.31/META.json0000664000175000017500000000201312531056144014136 0ustar salvasalva{ "abstract" : "Find configuration files in the native OS fashion", "author" : [ "Salvador Fandino " ], "dynamic_config" : 1, "generated_by" : "ExtUtils::MakeMaker version 7.04, CPAN::Meta::Converter version 2.150001", "license" : [ "unknown" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : "2" }, "name" : "Config-Find", "no_index" : { "directory" : [ "t", "inc" ] }, "prereqs" : { "build" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "configure" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "runtime" : { "requires" : { "File::HomeDir" : "0", "File::Spec" : "0", "File::Which" : "0", "IO::File" : "0", "Test::More" : "0.70" } } }, "release_status" : "stable", "version" : "0.31" }