diff -pruN 0.02-1/BaseDir.pm 0.03-0ubuntu1/BaseDir.pm --- 0.02-1/BaseDir.pm 2003-09-04 20:17:45.000000000 +0100 +++ 0.03-0ubuntu1/BaseDir.pm 1970-01-01 01:00:00.000000000 +0100 @@ -1,156 +0,0 @@ -package File::BaseDir; - -use strict; -use Carp; -require File::Spec; -require Exporter; - -our @ISA = qw(Exporter); -our @EXPORT_OK = qw( - xdg_data_home xdg_data_dirs xdg_data_files - xdg_config_home xdg_config_dirs xdg_config_files - xdg_cache_home -); -our $VERSION = 0.02; - -my $rootdir = File::Spec->rootdir(); - -our $xdg_data_home = File::Spec->catdir($ENV{HOME}, qw/.local share/); -our @xdg_data_dirs = ( - File::Spec->catdir($rootdir, qw/usr local share/), - File::Spec->catdir($rootdir, qw/usr share/), -); - -our $xdg_config_home = File::Spec->catdir($ENV{HOME}, '.config'); -our @xdg_config_dirs = ( File::Spec->catdir($rootdir, qw/etc xdg/) ); - -our $xdg_cache_home = File::Spec->catdir($ENV{HOME}, '.cache'); - -sub new { bless \$VERSION, shift } # what else is there to bless ? - -sub xdg_data_home { $ENV{XDG_DATA_HOME} || $xdg_data_home } - -sub xdg_data_dirs { - ( $ENV{XDG_DATA_DIRS} - ? _adapt($ENV{XDG_DATA_DIRS}) - : @xdg_data_dirs - ) -} - -sub xdg_data_files { _find_files(\@_, xdg_data_home, xdg_data_dirs) } - -sub xdg_config_home {$ENV{XDG_CONFIG_HOME} || $xdg_config_home } - -sub xdg_config_dirs { - ( $ENV{XDG_CONFIG_DIRS} - ? _adapt($ENV{XDG_CONFIG_DIRS}) - : @xdg_config_dirs - ) -} - -sub xdg_config_files { _find_files(\@_, xdg_config_home, xdg_config_dirs) } - -sub xdg_cache_home { $ENV{XDG_CACHE_HOME} || $xdg_cache_home } - -sub _adapt { - map { File::Spec->catdir( split('/', $_) ) } - split ':', shift; -} - -sub _find_files { - my $file = shift; - return - grep { -f $_ && -r $_ } - map { File::Spec->catfile($_, @$file) } - @_; -} - -1; - -__END__ - -=head1 NAME - -File::BaseDir - use the freedesktop basedir spec - -=head1 SYNOPSIS - - use File::BaseDir qw/xdg_data_files/; - for ( xdg_data_files('mime/globs') ) { - # do something - } - -=head1 DESCRIPTION - -This module can be used to find directories and files as specified -by the XDG Base Directory Specification. It takes care of defaults -and uses L to make the output platform specific. - -This module forked from L. - -For this module the XDG basedir specification 0.6 was used. - -=head1 EXPORT - -None by default, but all methods can be exported on demand. - -=head1 METHODS - -=over 4 - -=item C - -Simple constructor to allow Object Oriented use of this module. - -=item C - -Returns either C<$ENV{XDG_DATA_HOME}> or it's default value. - -=item C - -Returns either C<$ENV{XDG_DATA_DIRS}> or it's default value. - -=item C - -Searches for C<$file> in all C and only returns -existing readable files. - -The file path can also be given as a list. - -=item C - -Returns either C<$ENV{XDG_CONFIG_HOME}> or it's default value. - -=item C - -Returns either C<$ENV{XDG_CONFIG_DIRS}> or it's default value. - -=item C - -Searches for C<$file> in all C and only returns -existing readable files. - -The file path can also be given as a list. - -=item C - -Returns either C<$ENV{XDG_CACHE_HOME}> or it's default value. - -=back - -=head1 BUGS - -Please mail the author if you encounter any bugs. - -=head1 AUTHOR - -Jaap Karssenberg || Pardus [Larus] Epardus@cpan.orgE - -Copyright (c) 2003 Jaap G Karssenberg. All rights reserved. -This program is free software; you can redistribute it and/or -modify it under the same terms as Perl itself. - -=head1 SEE ALSO - -L - diff -pruN 0.02-1/Build.PL 0.03-0ubuntu1/Build.PL --- 0.02-1/Build.PL 1970-01-01 01:00:00.000000000 +0100 +++ 0.03-0ubuntu1/Build.PL 2007-10-24 20:57:22.000000000 +0100 @@ -0,0 +1,24 @@ +#!/usr/bin/perl + +use Module::Build; + +my $build = Module::Build->new( + dist_name => 'File-BaseDir', + dist_version_from => 'lib/File/BaseDir.pm', + dist_author => 'Jaap Karssenberg ', + license => 'perl', + requires => { + 'Carp' => 0, + 'Exporter' => 0, + 'File::Spec' => 0, + }, + build_requires => { + 'Module::Build' => '0.24', + 'Test::More' => 0, + }, + create_makefile_pl => 'passthrough', + #dynamic_config => 1, +); + +$build->create_build_script; + diff -pruN 0.02-1/Changes 0.03-0ubuntu1/Changes --- 0.02-1/Changes 2003-09-04 20:16:52.000000000 +0100 +++ 0.03-0ubuntu1/Changes 2007-10-24 20:57:22.000000000 +0100 @@ -1,5 +1,15 @@ Revision history for Perl extension File::BaseDir. +0.03 Wed Oct 24 2007 + - Added lookup methods for files and dirs: + data_home, data_files, data_dirs, + config_home, config_files, config_dirs & cache_home; + suggested by Matisse Enzer + - Deprecated xdg_data_files and xdg_config_files; + suggested by Michael Schwern + - Added a bit of Win32 support + - Extended tests to full coverage + 0.02 Thu Sep 4 2003 - forgot to remove h2xs default "use 5.008" tag :( emergency release it is ... diff -pruN 0.02-1/debian/changelog 0.03-0ubuntu1/debian/changelog --- 0.02-1/debian/changelog 2007-11-28 01:12:43.000000000 +0000 +++ 0.03-0ubuntu1/debian/changelog 2007-11-28 01:11:31.000000000 +0000 @@ -1,3 +1,16 @@ +libfile-basedir-perl (0.03-0ubuntu1) hardy; urgency=low + + * New upstream release + * debian/control: + - Updated maintainer fields + - Added homepage field + - Upgraded standards version to 3.7.2 + - Added build-depend-indep libmodule-build-perl + * debian/compat: Upgraded to 5 + * Closes lp: #172244 + + -- Cody A.W. Somerville Tue, 27 Nov 2007 02:22:21 -0400 + libfile-basedir-perl (0.02-1) unstable; urgency=low * Initial release. diff -pruN 0.02-1/debian/compat 0.03-0ubuntu1/debian/compat --- 0.02-1/debian/compat 2007-11-28 01:12:43.000000000 +0000 +++ 0.03-0ubuntu1/debian/compat 2007-11-28 01:11:31.000000000 +0000 @@ -1 +1 @@ -4 +5 diff -pruN 0.02-1/debian/control 0.03-0ubuntu1/debian/control --- 0.02-1/debian/control 2007-11-28 01:12:43.000000000 +0000 +++ 0.03-0ubuntu1/debian/control 2007-11-28 01:11:31.000000000 +0000 @@ -1,10 +1,12 @@ Source: libfile-basedir-perl Section: perl Priority: optional -Maintainer: Florian Ragwitz +Maintainer: Cody A.W. Somerville +XSBC-Original-Maintainer: Florian Ragwitz Build-Depends: cdbs, debhelper (>= 4.1.0) -Build-Depends-Indep: perl -Standards-Version: 3.6.2 +Build-Depends-Indep: perl, libmodule-build-perl +Standards-Version: 3.7.2 +Homepage: http://search.cpan.org/~pardus/ Package: libfile-basedir-perl Architecture: all diff -pruN 0.02-1/lib/File/BaseDir.pm 0.03-0ubuntu1/lib/File/BaseDir.pm --- 0.02-1/lib/File/BaseDir.pm 1970-01-01 01:00:00.000000000 +0100 +++ 0.03-0ubuntu1/lib/File/BaseDir.pm 2007-10-24 20:57:22.000000000 +0100 @@ -0,0 +1,296 @@ +package File::BaseDir; + +use strict; +use Carp; +require File::Spec; +require Exporter; + +our $VERSION = 0.03; + +our @ISA = qw(Exporter); +our %EXPORT_TAGS = ( + vars => [ qw( + xdg_data_home xdg_data_dirs + xdg_config_home xdg_config_dirs + xdg_cache_home + ) ], + lookup => [ qw( + data_home data_dirs data_files + config_home config_dirs config_files + cache_home + ) ], +); +our @EXPORT_OK = ( + qw(xdg_data_files xdg_config_files), + map @$_, values %EXPORT_TAGS +); + +# Set root and home directories +my $rootdir = File::Spec->rootdir(); +if ($^O eq 'MSWin32') { + $rootdir = 'C:\\'; # File::Spec default depends on CWD + $ENV{HOME} ||= $ENV{USERPROFILE} || $ENV{HOMEDRIVE}.$ENV{HOMEPATH}; + # logic from File::HomeDir::Windows +} +my $home = $ENV{HOME}; +unless ($home) { + warn "WARNING: HOME is not set, using root: $rootdir\n"; + $home = $rootdir; +} + +# Set defaults +our $xdg_data_home = File::Spec->catdir($home, qw/.local share/); +our @xdg_data_dirs = ( + File::Spec->catdir($rootdir, qw/usr local share/), + File::Spec->catdir($rootdir, qw/usr share/), +); +our $xdg_config_home = File::Spec->catdir($home, '.config'); +our @xdg_config_dirs = ( File::Spec->catdir($rootdir, qw/etc xdg/) ); +our $xdg_cache_home = File::Spec->catdir($home, '.cache'); + +# OO method +sub new { bless \$VERSION, shift } # what else is there to bless ? + +# Variable methods +sub xdg_data_home { $ENV{XDG_DATA_HOME} || $xdg_data_home } + +sub xdg_data_dirs { + ( $ENV{XDG_DATA_DIRS} + ? _adapt($ENV{XDG_DATA_DIRS}) + : @xdg_data_dirs + ) +} + +sub xdg_config_home {$ENV{XDG_CONFIG_HOME} || $xdg_config_home } + +sub xdg_config_dirs { + ( $ENV{XDG_CONFIG_DIRS} + ? _adapt($ENV{XDG_CONFIG_DIRS}) + : @xdg_config_dirs + ) +} + +sub xdg_cache_home { $ENV{XDG_CACHE_HOME} || $xdg_cache_home } + +sub _adapt { + map { File::Spec->catdir( split('/', $_) ) } split /[:;]/, shift; + # ':' defined in the spec, but ';' is standard on win32 +} + +# Lookup methods +sub data_home { _catfile(xdg_data_home, @_) } + +sub data_dirs { _find_files(\&_dir, \@_, xdg_data_home, xdg_data_dirs) } + +sub data_files { _find_files(\&_file, \@_, xdg_data_home, xdg_data_dirs) } + +sub xdg_data_files { my @dirs = data_files(@_); return @dirs } + +sub config_home { _catfile(xdg_config_home, @_) } + +sub config_dirs { _find_files(\&_dir, \@_, xdg_config_home, xdg_config_dirs) } + +sub config_files { _find_files(\&_file, \@_, xdg_config_home, xdg_config_dirs) } + +sub xdg_config_files { my @dirs = config_files(@_); return @dirs } + +sub cache_home { _catfile(xdg_cache_home, @_) } + +sub _catfile { + my $dir = shift; + shift if ref $_[0] or $_[0] =~ /::/; # OO call + return File::Spec->catfile($dir, @_); +} + +sub _find_files { + my $type = shift; + my $file = shift; + shift @$file if ref $$file[0] or $$file[0] =~ /::/; # OO call + #warn "Looking for: @$file\n in: @_\n"; + if (wantarray) { + return grep { &$type( $_ ) && -r $_ } + map { File::Spec->catfile($_, @$file) } @_; + } + else { # prevent unnessecary stats by returning early + for (@_) { + my $path = File::Spec->catfile($_, @$file); + return $path if &$type($path) && -r $path; + } + } + return (); +} + +sub _dir { -d $_[0] } + +sub _file { -f $_[0] } + +1; + +__END__ + +=head1 NAME + +File::BaseDir - Use the Freedesktop.org base directory specification + +=head1 SYNOPSIS + + use File::BaseDir qw/xdg_data_files/; + for ( xdg_data_files('mime/globs') ) { + # do something + } + +=head1 DESCRIPTION + +This module can be used to find directories and files as specified +by the Freedesktop.org Base Directory Specification. This specifications +gives a mechanism to locate directories for configuration, application data +and cache data. It is suggested that desktop applications for e.g. the +Gnome, KDE or Xfce platforms follow this layout. However, the same layout can +just as well be used for non-GUI applications. + +This module forked from L. + +This module follows version 0.6 of BaseDir specification. + +=head1 EXPORT + +None by default, but all methods can be exported on demand. +Also the groups ":lookup" and ":vars" are defined. The ":vars" group +contains all routines with a "xdg_" prefix; the ":lookup" group +contains the routines to locate files and directories. + +=head1 METHODS + +=over 4 + +=item C + +Simple constructor to allow Object Oriented use of this module. + +=back + +=head2 Lookup + +The following methods are used to lookup files and folders in one of the +search paths. + +=over 4 + +=item C + +Takes a list of file path elements and returns a new path by appending +them to the data home directory. The new path does not need to exist. +Use this when writing user specific application data. + +Example: + + # data_home is: /home/USER/.local/share + $path = $bd->data_home('Foo', 'Bar', 'Baz'); + # returns: /home/USER/.local/share/Foo/Bar/Baz + +=item C + +Looks for directories specified by C<@PATH> in the data home and +other data directories. Returns (possibly empty) list of readable +directories. In scalar context only the first directory found is +returned. Use this to lookup application data. + +=item C + +Looks for files specified by C<@PATH> in the data home and other data +directories. Only returns files that are readable. In scalar context only +the first file found is returned. Use this to lookup application data. + +=item C + +Takes a list of path elements and appends them to the config home +directory returning a new path. The new path does not need to exist. +Use this when writing user specific configuration. + +=item C + +Looks for directories specified by C<@PATH> in the config home and +other config directories. Returns (possibly empty) list of readable +directories. In scalar context only the first directory found is +returned. Use this to lookup configuration. + +=item C + +Looks for files specified by C<@PATH> in the config home and other +config directories. Returns a (possibly empty) list of files that +are readable. In scalar context only the first file found is returned. +Use this to lookup configuration. + +=item C + +Takes a list of path elements and appends them to the cache home +directory returning a new path. The new path does not need to exist. + +=back + +=head2 Variables + +The following methods only returns the value of one of the XDG variables. + +=over 4 + +=item C + +Returns either C<$ENV{XDG_DATA_HOME}> or it's default value. +Default is F<$HOME/.local/share>. + +=item C + +Returns either C<$ENV{XDG_DATA_DIRS}> or it's default value as list. +Default is F, F. + +=item C + +Returns either C<$ENV{XDG_CONFIG_HOME}> or it's default value. +Default is F<$HOME/.config>. + +=item C + +Returns either C<$ENV{XDG_CONFIG_DIRS}> or it's default value as list. +Default is F. + +=item C + +Returns either C<$ENV{XDG_CACHE_HOME}> or it's default value. +Default is F<$HOME/.cache>. + +=back + +=head1 NON-UNIX PLATFORMS + +The use of L ensures that all paths are returned in the apropriate +form for the current platform. On Windows this module will try to set C<$HOME> +to a sensible value if it is not defined yet. On other platforms one can use +e.g. L to set $HOME before loading File::BaseDir. + +Please note that the specification is targeting Unix platforms only and +will only have limited relevance on other platforms. Any platform dependend +behavior in this module should be considerd an extension of the spec. + +=head1 BACKWARDS COMPATIBILITY + +The methods C and C are exported for +backwards compatibilty with version 0.02. They are identical to C +and C respectively but without the C behavior. + +=head1 BUGS + +Please mail the author if you encounter any bugs. + +=head1 AUTHOR + +Jaap Karssenberg || Pardus [Larus] Epardus@cpan.orgE + +Copyright (c) 2003, 2007 Jaap G Karssenberg. All rights reserved. +This program is free software; you can redistribute it and/or +modify it under the same terms as Perl itself. + +=head1 SEE ALSO + +L + diff -pruN 0.02-1/Makefile.PL 0.03-0ubuntu1/Makefile.PL --- 0.02-1/Makefile.PL 2003-09-04 20:15:15.000000000 +0100 +++ 0.03-0ubuntu1/Makefile.PL 2007-10-24 20:57:22.000000000 +0100 @@ -1,15 +1,31 @@ -use ExtUtils::MakeMaker; - -WriteMakefile( - 'NAME' => 'File::BaseDir', - 'VERSION_FROM' => 'BaseDir.pm', - 'PREREQ_PM' => { - 'Carp' => 0, - 'Exporter' => 0, - 'File::Spec' => 0, - }, - ($] >= 5.005 - ? (AUTHOR => 'Jaap Karssenberg ') - : () - ), -); +# Note: this file was auto-generated by Module::Build::Compat version 0.03 + + unless (eval "use Module::Build::Compat 0.02; 1" ) { + print "This module requires Module::Build to install itself.\n"; + + require ExtUtils::MakeMaker; + my $yn = ExtUtils::MakeMaker::prompt + (' Install Module::Build now from CPAN?', 'y'); + + unless ($yn =~ /^y/i) { + die " *** Cannot install without Module::Build. Exiting ...\n"; + } + + require Cwd; + require File::Spec; + require CPAN; + + # Save this 'cause CPAN will chdir all over the place. + my $cwd = Cwd::cwd(); + + CPAN::Shell->install('Module::Build::Compat'); + CPAN::Shell->expand("Module", "Module::Build::Compat")->uptodate + or die "Couldn't install Module::Build, giving up.\n"; + + chdir $cwd or die "Cannot chdir() back to $cwd: $!"; + } + eval "use Module::Build::Compat 0.02; 1" or die $@; + + Module::Build::Compat->run_build_pl(args => \@ARGV); + require Module::Build; + Module::Build::Compat->write_makefile(build_class => 'Module::Build'); diff -pruN 0.02-1/MANIFEST 0.03-0ubuntu1/MANIFEST --- 0.02-1/MANIFEST 2003-09-03 20:14:14.000000000 +0100 +++ 0.03-0ubuntu1/MANIFEST 2007-10-24 20:57:22.000000000 +0100 @@ -1,8 +1,13 @@ -configure -BaseDir.pm +Build.PL Changes +configure +lib/File/BaseDir.pm Makefile.PL -MANIFEST +MANIFEST This list of files +META.yml README -t/1.t -t/some_file +t/01_vars.t +t/02_lookup.t +t/03_OO.t +t/04_pod_ok.t +t/05_pod_cover.t diff -pruN 0.02-1/META.yml 0.03-0ubuntu1/META.yml --- 0.02-1/META.yml 1970-01-01 01:00:00.000000000 +0100 +++ 0.03-0ubuntu1/META.yml 2007-10-24 20:57:22.000000000 +0100 @@ -0,0 +1,24 @@ +--- +name: File-BaseDir +version: 0.03 +author: + - 'Jaap Karssenberg ' +abstract: Use the Freedesktop.org base directory specification +license: perl +resources: + license: http://dev.perl.org/licenses/ +requires: + Carp: 0 + Exporter: 0 + File::Spec: 0 +build_requires: + Module::Build: 0.24 + Test::More: 0 +provides: + File::BaseDir: + file: lib/File/BaseDir.pm + version: 0.03 +generated_by: Module::Build version 0.2806 +meta-spec: + url: http://module-build.sourceforge.net/META-spec-v1.2.html + version: 1.2 diff -pruN 0.02-1/README 0.03-0ubuntu1/README --- 0.02-1/README 2003-09-03 19:09:51.000000000 +0100 +++ 0.03-0ubuntu1/README 2007-10-24 20:57:22.000000000 +0100 @@ -1,17 +1,17 @@ -File-BaseDir version 0.1 -========================= +File-BaseDir +============ This module can be used to find directories and files as specified -by the XDG Base Directory Specification. +by the Freedekstop.org Base Directory Specification. INSTALLATION To install this module type the following: - perl Makefile.PL - make - make test - make install + perl Build.PL + ./Build + ./Build test + ./Build install DEPENDENCIES @@ -19,13 +19,14 @@ This module requires these other modules the CPAN if they are not allready installed on your system : + Module::Build Carp Exporter File::Spec COPYRIGHT AND LICENCE -Copyright (c) 2003 Jaap G Karssenberg. All rights reserved. +Copyright (c) 2003, 2007 Jaap G Karssenberg. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. diff -pruN 0.02-1/t/01_vars.t 0.03-0ubuntu1/t/01_vars.t --- 0.02-1/t/01_vars.t 1970-01-01 01:00:00.000000000 +0100 +++ 0.03-0ubuntu1/t/01_vars.t 2007-10-24 20:57:22.000000000 +0100 @@ -0,0 +1,45 @@ +use strict; +use Test::More tests => 12; + +use_ok('File::BaseDir', qw/:vars/); + +my $rootdir = ($^O eq 'MSWin32') ? 'c:\\' : File::Spec->rootdir(); +ok(length($ENV{HOME}), 'HOME defined'); + +$ENV{XDG_CONFIG_HOME} = ''; +ok( xdg_config_home() eq File::Spec->catdir($ENV{HOME}, qw/.config/), + 'xdg_config_home default'); +$ENV{XDG_CONFIG_HOME} = 'test123'; +ok( xdg_config_home() eq 'test123', 'xdg_data_home set'); + +$ENV{XDG_CONFIG_DIRS} = ''; +is_deeply( [xdg_config_dirs()], + [ File::Spec->catdir($rootdir, qw/etc xdg/) ], + 'xdg_config_dirs default'); +$ENV{XDG_CONFIG_DIRS} = './t:foo:bar'; +is_deeply( [xdg_config_dirs()], + [File::Spec->catdir('.', 't'), 'foo', 'bar'], + 'xdg_data_dirs set'); + +$ENV{XDG_DATA_HOME} = ''; +ok( xdg_data_home() eq File::Spec->catdir($ENV{HOME}, qw/.local share/), + 'xdg_data_home default'); +$ENV{XDG_DATA_HOME} = 'test123'; +ok( xdg_data_home() eq 'test123', 'xdg_data_home set'); + +$ENV{XDG_DATA_DIRS} = ''; +is_deeply( [xdg_data_dirs()], + [ File::Spec->catdir($rootdir, qw/usr local share/), + File::Spec->catdir($rootdir, qw/usr share/) ], + 'xdg_data_dirs default'); +$ENV{XDG_DATA_DIRS} = './t:foo:bar'; +is_deeply( [xdg_data_dirs()], + [File::Spec->catdir('.', 't'), 'foo', 'bar'], + 'xdg_data_dirs set'); + +$ENV{XDG_CACHE_HOME} = ''; +ok( xdg_cache_home() eq File::Spec->catdir($ENV{HOME}, qw/.cache/), + 'xdg_cache_home default'); +$ENV{XDG_CACHE_HOME} = 'test123'; +ok( xdg_cache_home() eq 'test123', 'xdg_cache_home set'); + diff -pruN 0.02-1/t/02_lookup.t 0.03-0ubuntu1/t/02_lookup.t --- 0.02-1/t/02_lookup.t 1970-01-01 01:00:00.000000000 +0100 +++ 0.03-0ubuntu1/t/02_lookup.t 2007-10-24 20:57:22.000000000 +0100 @@ -0,0 +1,68 @@ +use strict; +use Test::More tests => 17; +use File::Spec; + +use_ok('File::BaseDir', qw/:lookup xdg_data_files xdg_config_files/); + +# Initalize test data: + +# t/ +# `-- data/ $dir[1] +# |-- dir/ $dir[2] +# | `-- test $file[1] +# `-- test $file[0] + +my @dir = ('t', map File::Spec->catdir(@$_), + [qw/t data/], [qw/t data dir/] ); +my @file = (map File::Spec->catfile(@$_), + [qw/t data test/], [qw/t data dir test/] ); +mkdir $dir[1] or die $! unless -d $dir[1]; +mkdir $dir[2] or die $! unless -d $dir[2]; +open TEST, ">$file[0]" or die $!; +print TEST "test 1 2 3\n"; +close TEST; +eval { chmod 0644, $file[0] }; # reset previous run +open TEST, ">$file[1]" or die $!; +print TEST "test 1 2 3\n"; +close TEST; + +$ENV{XDG_CONFIG_HOME} = 'foo'; +$ENV{XDG_CONFIG_DIRS} = 'bar'; +$ENV{XDG_DATA_HOME} = '.'; +$ENV{XDG_DATA_DIRS} = join ':', @dir; + +is(data_home(qw/t data test/), $file[0], 'data_home'); +is(data_files(qw/data test/), $file[0], 'data_files'); +is_deeply([data_files(qw/test/)], \@file, 'data_files - list'); +is(data_dirs(qw/data dir/), $dir[2], 'data_dirs'); +is_deeply([data_dirs(qw/data dir/)], [$dir[2]], 'data_dirs - list'); + +ok(!data_files(qw/data dir/), 'data_files does not match dir'); +ok(!data_dirs(qw/data test/), 'data_dirs does not match file'); + +is_deeply([xdg_data_files(qw/test/)], \@file, + 'xdg_data_files - for backward compatibility'); + +$ENV{XDG_CONFIG_HOME} = '.'; +$ENV{XDG_CONFIG_DIRS} = join ':', @dir; +$ENV{XDG_DATA_HOME} = 'foo'; +$ENV{XDG_DATA_DIRS} = 'bar'; + +is(config_home(qw/t data test/), $file[0], 'config_home'); +is(config_files(qw/data test/), $file[0], 'config_files'); +is_deeply([config_files(qw/test/)], \@file, 'config_files - list'); +is(config_dirs(qw/data dir/), $dir[2], 'config_dirs'); +is_deeply([config_dirs(qw/data dir/)], [$dir[2]], 'config_dirs - list'); + +is_deeply([xdg_config_files(qw/test/)], \@file, + 'xdg_config_files - for backward compatibility'); + +SKIP: { + eval { chmod 0200, $file[0] }; # make non-readable + skip "chmod not supported", 1 if -r $file[0]; + is(config_files(qw/test/), $file[1], 'config_files checks for read'); +} + +$ENV{XDG_CACHE_HOME} = 't/data'; +ok(cache_home('test') eq $file[0], 'data_cache'); + diff -pruN 0.02-1/t/03_OO.t 0.03-0ubuntu1/t/03_OO.t --- 0.02-1/t/03_OO.t 1970-01-01 01:00:00.000000000 +0100 +++ 0.03-0ubuntu1/t/03_OO.t 2007-10-24 20:57:22.000000000 +0100 @@ -0,0 +1,26 @@ +use strict; +use Test::More tests => 6; +use File::BaseDir; + +my $rootdir = ($^O eq 'MSWin32') ? 'c:\\' : File::Spec->rootdir(); + +my $conf = File::BaseDir->new; + +is(ref($conf), 'File::BaseDir', 'OO constructor works'); + +$ENV{XDG_DATA_DIRS} = ''; +is_deeply( [$conf->xdg_data_dirs()], + [ File::Spec->catdir($rootdir, qw/usr local share/), + File::Spec->catdir($rootdir, qw/usr share/) ], + 'xdg_data_dirs default - OO'); + +$ENV{XDG_DATA_HOME} = 't'; +is($conf->data_dirs('data'), File::Spec->catdir(qw/t data/), + 'data_dirs - OO'); +is(File::BaseDir->data_dirs('data'), File::Spec->catdir(qw/t data/), + 'data_dirs - Module'); + +is($conf->data_home('data', 'test'), File::Spec->catfile(qw/t data test/), + 'data_home - OO'); +is(File::BaseDir->data_home('data', 'test'), File::Spec->catfile(qw/t data test/), + 'data_home - Module'); diff -pruN 0.02-1/t/04_pod_ok.t 0.03-0ubuntu1/t/04_pod_ok.t --- 0.02-1/t/04_pod_ok.t 1970-01-01 01:00:00.000000000 +0100 +++ 0.03-0ubuntu1/t/04_pod_ok.t 2007-10-24 20:57:22.000000000 +0100 @@ -0,0 +1,4 @@ +use Test::More; +eval "use Test::Pod 1.00"; +plan skip_all => "Test::Pod 1.00 required for testing POD" if $@; +all_pod_files_ok( Test::Pod::all_pod_files(qw/bin lib/) ); diff -pruN 0.02-1/t/05_pod_cover.t 0.03-0ubuntu1/t/05_pod_cover.t --- 0.02-1/t/05_pod_cover.t 1970-01-01 01:00:00.000000000 +0100 +++ 0.03-0ubuntu1/t/05_pod_cover.t 2007-10-24 20:57:22.000000000 +0100 @@ -0,0 +1,9 @@ +use Test::More; + +use File::BaseDir qw/xdg_data_dirs/; +$ENV{XDG_DATA_DIRS} = join ':', 'share', xdg_data_dirs; + +eval "use Test::Pod::Coverage 1.00"; +plan skip_all => "Test::Pod::Coverage 1.00 required for testing POD coverage" if $@; +all_pod_coverage_ok( + { also_private => [ qr/^_/, qr/^xdg_.*_files$/ ] } ); diff -pruN 0.02-1/t/1.t 0.03-0ubuntu1/t/1.t --- 0.02-1/t/1.t 2003-09-03 20:28:39.000000000 +0100 +++ 0.03-0ubuntu1/t/1.t 1970-01-01 01:00:00.000000000 +0100 @@ -1,15 +0,0 @@ -use Test::More tests => 5; - -use_ok('File::BaseDir', qw/xdg_data_home xdg_data_dirs xdg_data_files/); # 1 - -ok( ref(File::BaseDir->new) eq 'File::BaseDir', 'OO constructor works'); # 2 - -$ENV{XDG_DATA_HOME} = 'test123'; -ok( xdg_data_home() eq 'test123', 'xdg_data_home works'); # 3 - -$ENV{XDG_DATA_DIRS} = './t/'; -ok( -d ( xdg_data_dirs() )[0], 'xdg_data_dirs work'); # 4 - -my $file = ( xdg_data_files('some_file') )[0]; -ok( -e $file, 'xdg_data_files seems to work'); # 5 -