File-ShareDir-1.118/0000755000175000017500000000000013743750527012277 5ustar snosnoFile-ShareDir-1.118/lib/0000755000175000017500000000000013743750527013045 5ustar snosnoFile-ShareDir-1.118/lib/File/0000755000175000017500000000000013743750527013724 5ustar snosnoFile-ShareDir-1.118/lib/File/ShareDir.pm0000755000175000017500000004345313743745173016000 0ustar snosnopackage File::ShareDir; =pod =head1 NAME File::ShareDir - Locate per-dist and per-module shared files =begin html Travis CI Coverage Status Say Thanks =end html =head1 SYNOPSIS use File::ShareDir ':ALL'; # Where are distribution-level shared data files kept $dir = dist_dir('File-ShareDir'); # Where are module-level shared data files kept $dir = module_dir('File::ShareDir'); # Find a specific file in our dist/module shared dir $file = dist_file( 'File-ShareDir', 'file/name.txt'); $file = module_file('File::ShareDir', 'file/name.txt'); # Like module_file, but search up the inheritance tree $file = class_file( 'Foo::Bar', 'file/name.txt' ); =head1 DESCRIPTION The intent of L is to provide a companion to L and L, modules that take a process that is well-known by advanced Perl developers but gets a little tricky, and make it more available to the larger Perl community. Quite often you want or need your Perl module (CPAN or otherwise) to have access to a large amount of read-only data that is stored on the file-system at run-time. On a linux-like system, this would be in a place such as /usr/share, however Perl runs on a wide variety of different systems, and so the use of any one location is unreliable. Perl provides a little-known method for doing this, but almost nobody is aware that it exists. As a result, module authors often go through some very strange ways to make the data available to their code. The most common of these is to dump the data out to an enormous Perl data structure and save it into the module itself. The result are enormous multi-megabyte .pm files that chew up a lot of memory needlessly. Another method is to put the data "file" after the __DATA__ compiler tag and limit yourself to access as a filehandle. The problem to solve is really quite simple. 1. Write the data files to the system at install time. 2. Know where you put them at run-time. Perl's install system creates an "auto" directory for both every distribution and for every module file. These are used by a couple of different auto-loading systems to store code fragments generated at install time, and various other modules written by the Perl "ancient masters". But the same mechanism is available to any dist or module to store any sort of data. =head2 Using Data in your Module C forms one half of a two part solution. Once the files have been installed to the correct directory, you can use C to find your files again after the installation. For the installation half of the solution, see L and its C directive. Using L together with L allows one to rely on the files in appropriate C or C in development phase, too. =head1 FUNCTIONS C provides four functions for locating files and directories. For greater maintainability, none of these are exported by default and you are expected to name the ones you want at use-time, or provide the C<':ALL'> tag. All of the following are equivalent. # Load but don't import, and then call directly use File::ShareDir; $dir = File::ShareDir::dist_dir('My-Dist'); # Import a single function use File::ShareDir 'dist_dir'; dist_dir('My-Dist'); # Import all the functions use File::ShareDir ':ALL'; dist_dir('My-Dist'); All of the functions will check for you that the dir/file actually exists, and that you have read permissions, or they will throw an exception. =cut use 5.005; use strict; use warnings; use base ('Exporter'); use constant IS_MACOS => !!($^O eq 'MacOS'); use constant IS_WIN32 => !!($^O eq 'MSWin32'); use Carp (); use Exporter (); use File::Spec (); use Class::Inspector (); our %DIST_SHARE; our %MODULE_SHARE; our @CARP_NOT; our @EXPORT_OK = qw{ dist_dir dist_file module_dir module_file class_dir class_file }; our %EXPORT_TAGS = ( ALL => [@EXPORT_OK], ); our $VERSION = '1.118'; ##################################################################### # Interface Functions =pod =head2 dist_dir # Get a distribution's shared files directory my $dir = dist_dir('My-Distribution'); The C function takes a single parameter of the name of an installed (CPAN or otherwise) distribution, and locates the shared data directory created at install time for it. Returns the directory path as a string, or dies if it cannot be located or is not readable. =cut sub dist_dir { my $dist = _DIST(shift); my $dir; # Try the new version, then fall back to the legacy version $dir = _dist_dir_new($dist) || _dist_dir_old($dist); return $dir if defined $dir; # Ran out of options Carp::croak("Failed to find share dir for dist '$dist'"); } sub _dist_dir_new { my $dist = shift; return $DIST_SHARE{$dist} if exists $DIST_SHARE{$dist}; # Create the subpath my $path = File::Spec->catdir('auto', 'share', 'dist', $dist); # Find the full dir within @INC return _search_inc_path($path); } sub _dist_dir_old { my $dist = shift; # Create the subpath my $path = File::Spec->catdir('auto', split(/-/, $dist),); # Find the full dir within @INC return _search_inc_path($path); } =pod =head2 module_dir # Get a module's shared files directory my $dir = module_dir('My::Module'); The C function takes a single parameter of the name of an installed (CPAN or otherwise) module, and locates the shared data directory created at install time for it. In order to find the directory, the module B be loaded when calling this function. Returns the directory path as a string, or dies if it cannot be located or is not readable. =cut sub module_dir { my $module = _MODULE(shift); return $MODULE_SHARE{$module} if exists $MODULE_SHARE{$module}; # Try the new version first, then fall back to the legacy version return _module_dir_new($module) || _module_dir_old($module); } sub _module_dir_new { my $module = shift; # Create the subpath my $path = File::Spec->catdir('auto', 'share', 'module', _module_subdir($module),); # Find the full dir within @INC return _search_inc_path($path); } sub _module_dir_old { my $module = shift; my $short = Class::Inspector->filename($module); my $long = Class::Inspector->loaded_filename($module); $short =~ tr{/}{:} if IS_MACOS; $short =~ tr{\\} {/} if IS_WIN32; $long =~ tr{\\} {/} if IS_WIN32; substr($short, -3, 3, ''); $long =~ m/^(.*)\Q$short\E\.pm\z/s or Carp::croak("Failed to find base dir"); my $dir = File::Spec->catdir("$1", 'auto', $short); -d $dir or Carp::croak("Directory '$dir': No such directory"); -r $dir or Carp::croak("Directory '$dir': No read permission"); return $dir; } =pod =head2 dist_file # Find a file in our distribution shared dir my $dir = dist_file('My-Distribution', 'file/name.txt'); The C function takes two parameters of the distribution name and file name, locates the dist directory, and then finds the file within it, verifying that the file actually exists, and that it is readable. The filename should be a relative path in the format of your local filesystem. It will simply added to the directory using L's C method. Returns the file path as a string, or dies if the file or the dist's directory cannot be located, or the file is not readable. =cut sub dist_file { my $dist = _DIST(shift); my $file = _FILE(shift); # Try the new version first, in doubt hand off to the legacy version my $path = _dist_file_new($dist, $file) || _dist_file_old($dist, $file); $path or Carp::croak("Failed to find shared file '$file' for dist '$dist'"); -f $path or Carp::croak("File '$path': No such file"); -r $path or Carp::croak("File '$path': No read permission"); return $path; } sub _dist_file_new { my $dist = shift; my $file = shift; # If it exists, what should the path be my $dir = _dist_dir_new($dist); return undef unless defined $dir; my $path = File::Spec->catfile($dir, $file); # Does the file exist return undef unless -e $path; return $path; } sub _dist_file_old { my $dist = shift; my $file = shift; # If it exists, what should the path be my $dir = _dist_dir_old($dist); return undef unless defined $dir; my $path = File::Spec->catfile($dir, $file); # Does the file exist return undef unless -e $path; return $path; } =pod =head2 module_file # Find a file in our module shared dir my $dir = module_file('My::Module', 'file/name.txt'); The C function takes two parameters of the module name and file name. It locates the module directory, and then finds the file within it, verifying that the file actually exists, and that it is readable. In order to find the directory, the module B be loaded when calling this function. The filename should be a relative path in the format of your local filesystem. It will simply added to the directory using L's C method. Returns the file path as a string, or dies if the file or the dist's directory cannot be located, or the file is not readable. =cut sub module_file { my $module = _MODULE(shift); my $file = _FILE(shift); my $dir = module_dir($module); my $path = File::Spec->catfile($dir, $file); -e $path or Carp::croak("File '$path' does not exist in module dir"); -r $path or Carp::croak("File '$path': No read permission"); return $path; } =pod =head2 class_file # Find a file in our module shared dir, or in our parent class my $dir = class_file('My::Module', 'file/name.txt'); The C function takes two parameters of the module name and file name. It locates the module directory, and then finds the file within it, verifying that the file actually exists, and that it is readable. In order to find the directory, the module B be loaded when calling this function. The filename should be a relative path in the format of your local filesystem. It will simply added to the directory using L's C method. If the file is NOT found for that module, C will scan up the module's @ISA tree, looking for the file in all of the parent classes. This allows you to, in effect, "subclass" shared files. Returns the file path as a string, or dies if the file or the dist's directory cannot be located, or the file is not readable. =cut sub class_file { my $module = _MODULE(shift); my $file = _FILE(shift); # Get the super path ( not including UNIVERSAL ) # Rather than using Class::ISA, we'll use an inlined version # that implements the same basic algorithm. my @path = (); my @queue = ($module); my %seen = ($module => 1); while (my $cl = shift @queue) { push @path, $cl; no strict 'refs'; ## no critic (TestingAndDebugging::ProhibitNoStrict) unshift @queue, grep { !$seen{$_}++ } map { my $s = $_; $s =~ s/^::/main::/; $s =~ s/\'/::/g; $s } (@{"${cl}::ISA"}); } # Search up the path foreach my $class (@path) { my $dir = eval { module_dir($class); }; next if $@; my $path = File::Spec->catfile($dir, $file); -e $path or next; -r $path or Carp::croak("File '$file' cannot be read, no read permissions"); return $path; } Carp::croak("File '$file' does not exist in class or parent shared files"); } ## no critic (BuiltinFunctions::ProhibitStringyEval) if (eval "use List::MoreUtils 0.428; 1;") { List::MoreUtils->import("firstres"); } else { ## no critic (ErrorHandling::RequireCheckingReturnValueOfEval) eval <<'END_OF_BORROWED_CODE'; sub firstres (&@) { my $test = shift; foreach (@_) { my $testval = $test->(); $testval and return $testval; } return undef; } END_OF_BORROWED_CODE } ##################################################################### # Support Functions sub _search_inc_path { my $path = shift; # Find the full dir within @INC my $dir = firstres( sub { my $d; $d = File::Spec->catdir($_, $path) if defined _STRING($_); defined $d and -d $d ? $d : 0; }, @INC ) or return; Carp::croak("Found directory '$dir', but no read permissions") unless -r $dir; return $dir; } sub _module_subdir { my $module = shift; $module =~ s/::/-/g; return $module; } ## no critic (BuiltinFunctions::ProhibitStringyEval) if (eval "use Params::Util 1.07; 1;") { Params::Util->import("_CLASS", "_STRING"); } else { ## no critic (ErrorHandling::RequireCheckingReturnValueOfEval) eval <<'END_OF_BORROWED_CODE'; # Inlined from Params::Util pure perl version sub _CLASS ($) { return (defined $_[0] and !ref $_[0] and $_[0] =~ m/^[^\W\d]\w*(?:::\w+)*\z/s) ? $_[0] : undef; } sub _STRING ($) { (defined $_[0] and ! ref $_[0] and length($_[0])) ? $_[0] : undef; } END_OF_BORROWED_CODE } # Maintainer note: The following private functions are used by # File::ShareDir::PAR. (It has to or else it would have to copy&fork) # So if you significantly change or even remove them, please # notify the File::ShareDir::PAR maintainer(s). Thank you! # Matches a valid distribution name ### This is a total guess at this point sub _DIST ## no critic (Subroutines::RequireArgUnpacking) { defined _STRING($_[0]) and $_[0] =~ /^[a-z0-9+_-]+$/is and return $_[0]; Carp::croak("Not a valid distribution name"); } # A valid and loaded module name sub _MODULE { my $module = _CLASS(shift) or Carp::croak("Not a valid module name"); Class::Inspector->loaded($module) and return $module; Carp::croak("Module '$module' is not loaded"); } # A valid file name sub _FILE { my $file = shift; _STRING($file) or Carp::croak("Did not pass a file name"); File::Spec->file_name_is_absolute($file) and Carp::croak("Cannot use absolute file name '$file'"); return $file; } 1; =pod =head1 EXTENDING =head2 Overriding Directory Resolution C has two convenience hashes for people who have advanced usage requirements of C such as using uninstalled C directories during development. # # Dist-Name => /absolute/path/for/DistName/share/dir # %File::ShareDir::DIST_SHARE # # Module::Name => /absolute/path/for/Module/Name/share/dir # %File::ShareDir::MODULE_SHARE Setting these values any time before the corresponding calls dist_dir('Dist-Name') dist_file('Dist-Name','some/file'); module_dir('Module::Name'); module_file('Module::Name','some/file'); Will override the base directory for resolving those calls. An example of where this would be useful is in a test for a module that depends on files installed into a share directory, to enable the tests to use the development copy without needing to install them first. use File::ShareDir; use Cwd qw( getcwd ); use File::Spec::Functions qw( rel2abs catdir ); $File::ShareDir::MODULE_SHARE{'Foo::Module'} = rel2abs(catfile(getcwd,'share')); use Foo::Module; # internal calls in Foo::Module to module_file('Foo::Module','bar') now resolves to # the source trees share/ directory instead of something in @INC =head1 SUPPORT Bugs should always be submitted via the CPAN request tracker, see below. You can find documentation for this module with the perldoc command. perldoc File::ShareDir You can also look for information at: =over 4 =item * RT: CPAN's request tracker L =item * AnnoCPAN: Annotated CPAN documentation L =item * CPAN Ratings L =item * CPAN Search L =back =head2 Where can I go for other help? If you have a bug report, a patch or a suggestion, please open a new report ticket at CPAN (but please check previous reports first in case your issue has already been addressed). Report tickets should contain a detailed description of the bug or enhancement request and at least an easily verifiable way of reproducing the issue or fix. Patches are always welcome, too. =head2 Where can I go for help with a concrete version? Bugs and feature requests are accepted against the latest version only. To get patches for earlier versions, you need to get an agreement with a developer of your choice - who may or not report the issue and a suggested fix upstream (depends on the license you have chosen). =head2 Business support and maintenance For business support you can contact the maintainer via his CPAN email address. Please keep in mind that business support is neither available for free nor are you eligible to receive any support based on the license distributed with this package. =head1 AUTHOR Adam Kennedy Eadamk@cpan.orgE =head2 MAINTAINER Jens Rehsack Erehsack@cpan.orgE =head1 SEE ALSO L, L, L, L, L, L, L =head1 COPYRIGHT Copyright 2005 - 2011 Adam Kennedy, Copyright 2014 - 2018 Jens Rehsack. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of the license can be found in the LICENSE file included with this module. =cut File-ShareDir-1.118/META.yml0000664000175000017500000000175213743750527013557 0ustar snosno--- abstract: 'Locate per-dist and per-module shared files' author: - 'Adam Kennedy ' build_requires: ExtUtils::MakeMaker: '0' File::Path: '2.08' File::ShareDir::Install: '0.13' Test::More: '0.90' configure_requires: ExtUtils::MakeMaker: '0' File::ShareDir::Install: '0.13' dynamic_config: 1 generated_by: 'ExtUtils::MakeMaker version 7.46, CPAN::Meta::Converter version 2.150010' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: File-ShareDir no_index: directory: - t - inc recommends: List::MoreUtils: '0.428' Params::Util: '1.07' requires: Carp: '0' Class::Inspector: '1.12' File::Spec: '0.80' warnings: '0' resources: bugtracker: http://rt.cpan.org/Public/Dist/Display.html?Name=File-ShareDir homepage: https://metacpan.org/release/File-ShareDir repository: https://github.com/perl5-utils/File-ShareDir version: '1.118' x_serialization_backend: 'CPAN::Meta::YAML version 0.018' File-ShareDir-1.118/MANIFEST0000644000175000017500000000107313743750527013431 0ustar snosno.perltidyrc Changes foo/test_file.txt inc/inc_File-ShareDir-Install/File/ShareDir/Install.pm inc/latest.pm inc/latest/private.pm lib/File/ShareDir.pm LICENSE Makefile.PL MANIFEST This list of files MANIFEST.SKIP README.md share/sample.txt share/subdir/sample.txt t/00_prereqs.t t/01_compile.t t/02_main.t t/03_extensions.t t/04_fail.t t/05_class.t t/06_old.t t/lib/ShareDir/TestClass.pm testrules.yml META.yml Module YAML meta-data (added by MakeMaker) META.json Module JSON meta-data (added by MakeMaker) File-ShareDir-1.118/inc/0000755000175000017500000000000013743750527013050 5ustar snosnoFile-ShareDir-1.118/inc/latest.pm0000644000175000017500000000023613733356145014700 0ustar snosno# This stub created by inc::latest 0.500 package inc::latest; use strict; use vars '@ISA'; require inc::latest::private; @ISA = qw/inc::latest::private/; 1; File-ShareDir-1.118/inc/inc_File-ShareDir-Install/0000755000175000017500000000000013743750527017663 5ustar snosnoFile-ShareDir-1.118/inc/inc_File-ShareDir-Install/File/0000755000175000017500000000000013743750527020542 5ustar snosnoFile-ShareDir-1.118/inc/inc_File-ShareDir-Install/File/ShareDir/0000755000175000017500000000000013743750527022243 5ustar snosnoFile-ShareDir-1.118/inc/inc_File-ShareDir-Install/File/ShareDir/Install.pm0000644000175000017500000002567013733356145024216 0ustar snosnopackage File::ShareDir::Install; # git description: v0.12-6-g29a6ff7 # ABSTRACT: Install shared files use strict; use warnings; use Carp (); use File::Spec; use IO::Dir; our $VERSION = '0.13'; our @DIRS; our %ALREADY; require Exporter; our @ISA = qw( Exporter ); our @EXPORT = qw( install_share delete_share ); our @EXPORT_OK = qw( postamble install_share delete_share ); our $INCLUDE_DOTFILES = 0; our $INCLUDE_DOTDIRS = 0; ##################################################################### sub install_share { my $dir = @_ ? pop : 'share'; my $type = @_ ? shift : 'dist'; unless ( defined $type and ( $type =~ /^(module|dist)$/ ) ) { Carp::confess "Illegal or invalid share dir type '$type'"; } if( $type eq 'dist' and @_ ) { Carp::confess "Too many parameters to install_share"; } my $def = _mk_def( $type ); _add_module( $def, $_[0] ); _add_dir( $def, $dir ); } ##################################################################### sub delete_share { my $dir = @_ ? pop : ''; my $type = @_ ? shift : 'dist'; unless ( defined $type and ( $type =~ /^(module|dist)$/ ) ) { Carp::confess "Illegal or invalid share dir type '$type'"; } if( $type eq 'dist' and @_ ) { Carp::confess "Too many parameters to delete_share"; } my $def = _mk_def( "delete-$type" ); _add_module( $def, $_[0] ); _add_dir( $def, $dir ); } # # Build a task definition sub _mk_def { my( $type ) = @_; return { type=>$type, dotfiles => $INCLUDE_DOTFILES, dotdirs => $INCLUDE_DOTDIRS }; } # # Add the module to a task definition sub _add_module { my( $def, $class ) = @_; if( $def->{type} =~ /module$/ ) { my $module = _CLASS( $class ); unless ( defined $module ) { Carp::confess "Missing or invalid module name '$_[0]'"; } $def->{module} = $module; } } # # Add directories to a task definition # Save the definition sub _add_dir { my( $def, $dir ) = @_; $dir = [ $dir ] unless ref $dir; my $del = 0; $del = 1 if $def->{type} =~ /^delete-/; foreach my $d ( @$dir ) { unless ( $del or (defined $d and -d $d) ) { Carp::confess "Illegal or missing directory '$d'"; } if( not $del and $ALREADY{ $d }++ ) { Carp::confess "Directory '$d' is already being installed"; } push @DIRS, { %$def }; $DIRS[-1]{dir} = $d; } } ##################################################################### # Build the postamble section sub postamble { my $self = shift; my @ret; # = $self->SUPER::postamble( @_ ); foreach my $def ( @DIRS ) { push @ret, __postamble_share_dir( $self, $def ); } return join "\n", @ret; } ##################################################################### sub __postamble_share_dir { my( $self, $def ) = @_; my $dir = $def->{dir}; my( $idir ); if( $def->{type} eq 'delete-dist' ) { $idir = File::Spec->catdir( _dist_dir(), $dir ); } elsif( $def->{type} eq 'delete-module' ) { $idir = File::Spec->catdir( _module_dir( $def ), $dir ); } elsif ( $def->{type} eq 'dist' ) { $idir = _dist_dir(); } else { # delete-share and share $idir = _module_dir( $def ); } my @cmds; if( $def->{type} =~ /^delete-/ ) { @cmds = "\$(RM_RF) $idir"; } else { my $autodir = '$(INST_LIB)'; my $pm_to_blib = $self->oneliner(<split_command( $pm_to_blib, map { ($self->quote_literal($_) => $self->quote_literal($files->{$_})) } sort keys %$files ); } my $r = join '', map { "\t\$(NOECHO) $_\n" } @cmds; # use Data::Dumper; # die Dumper $files; # Set up the install return "config::\n$r"; } # Get the per-dist install directory. # We depend on the Makefile for most of the info sub _dist_dir { return File::Spec->catdir( '$(INST_LIB)', qw( auto share dist ), '$(DISTNAME)' ); } # Get the per-module install directory # We depend on the Makefile for most of the info sub _module_dir { my( $def ) = @_; my $module = $def->{module}; $module =~ s/::/-/g; return File::Spec->catdir( '$(INST_LIB)', qw( auto share module ), $module ); } sub _scan_share_dir { my( $files, $idir, $dir, $def ) = @_; my $dh = IO::Dir->new( $dir ) or die "Unable to read $dir: $!"; my $entry; while( defined( $entry = $dh->read ) ) { next if $entry =~ /(~|,v|#)$/; my $full = File::Spec->catfile( $dir, $entry ); if( -f $full ) { next if not $def->{dotfiles} and $entry =~ /^\./; $files->{ $full } = File::Spec->catfile( $idir, $entry ); } elsif( -d $full ) { if( $def->{dotdirs} ) { next if $entry eq '.' or $entry eq '..' or $entry =~ /^\.(svn|git|cvs)$/; } else { next if $entry =~ /^\./; } _scan_share_dir( $files, File::Spec->catdir( $idir, $entry ), $full, $def ); } } } ##################################################################### # Cloned from Params::Util::_CLASS sub _CLASS ($) { ( defined $_[0] and ! ref $_[0] and $_[0] =~ m/^[^\W\d]\w*(?:::\w+)*$/s ) ? $_[0] : undef; } 1; __END__ =pod =encoding UTF-8 =head1 NAME File::ShareDir::Install - Install shared files =head1 VERSION version 0.13 =head1 SYNOPSIS use ExtUtils::MakeMaker; use File::ShareDir::Install; install_share 'share'; install_share dist => 'dist-share'; install_share module => 'My::Module' => 'other-share'; WriteMakefile( ... ); # As you normally would package MY; use File::ShareDir::Install qw(postamble); =head1 DESCRIPTION File::ShareDir::Install allows you to install read-only data files from a distribution. It is a companion module to L, which allows you to locate these files after installation. It is a port of L to L with the improvement of only installing the files you want; C<.svn>, C<.git> and other source-control junk will be ignored. Please note that this module installs read-only data files; empty directories will be ignored. =head1 EXPORT =head2 install_share install_share $dir; install_share dist => $dir; install_share module => $module, $dir; Causes all the files in C<$dir> and its sub-directories to be installed into a per-dist or per-module share directory. Must be called before L. The first 2 forms are equivalent; the files are installed in a per-distribution directory. For example C. The name of that directory can be recovered with L. The last form installs files in a per-module directory. For example C. The name of that directory can be recovered with L. The parameter C<$dir> may be an array of directories. The files will be installed when you run C. However, the list of files to install is generated when Makefile.PL is run. Note that if you make multiple calls to C on different directories that contain the same filenames, the last of these calls takes precedence. In other words, if you do: install_share 'share1'; install_share 'share2'; And both C and C contain a file called C, the file C will be installed into your C. =head2 delete_share delete_share $list; delete_share dist => $list; delete_share module => $module, $list; Remove previously installed files or directories. Unlike L, the last parameter is a list of files or directories that were previously installed. These files and directories will be deleted when you run C. The parameter C<$list> may be an array of files or directories. Deletion happens in-order along with installation. This means that you may delete all previously installed files by putting the following at the top of your Makefile.PL. delete_share '.'; You can also selectively remove some files from installation. install_share 'some-dir'; if( ... ) { delete_share 'not-this-file.rc'; } =head2 postamble This function must be exported into the MY package. You will normally do this with the following. package MY; use File::ShareDir::Install qw( postamble ); If you need to overload postamble, use the following. package MY; use File::ShareDir::Install; sub postamble { my $self = shift; my @ret = File::ShareDir::Install::postamble( $self ); # ... add more things to @ret; return join "\n", @ret; } =head1 CONFIGURATION Two variables control the handling of dot-files and dot-directories. A dot-file has a filename that starts with a period (.). For example C<.htaccess>. A dot-directory is a directory that starts with a period (.). For example C<.config/>. Not all filesystems support the use of dot-files. =head2 $INCLUDE_DOTFILES If set to a true value, dot-files will be copied. Default is false. =head2 $INCLUDE_DOTDIRS If set to a true value, the files inside dot-directories will be copied. Known version control directories are still ignored. Default is false. =head2 Note These variables only influence subsequent calls to C. This allows you to control the behaviour for each directory. For example: $INCLUDE_DOTDIRS = 1; install_share 'share1'; $INCLUDE_DOTFILES = 1; $INCLUDE_DOTDIRS = 0; install_share 'share2'; The directory C will have files in its dot-directories installed, but not dot-files. The directory C will have files in its dot-files installed, but dot-directories will be ignored. =head1 SEE ALSO L, L. =head1 SUPPORT Bugs may be submitted through L (or L). =head1 AUTHOR Philip Gwyn =head1 CONTRIBUTORS =for stopwords Karen Etheridge Shoichi Kaji =over 4 =item * Karen Etheridge =item * Shoichi Kaji =back =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2009 by Philip Gwyn. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut File-ShareDir-1.118/inc/latest/0000755000175000017500000000000013743750527014344 5ustar snosnoFile-ShareDir-1.118/inc/latest/private.pm0000644000175000017500000000601613733356145016354 0ustar snosnouse strict; use warnings; package inc::latest::private; # ABSTRACT: private implementation for inc::latest our $VERSION = '0.500'; use File::Spec; use IO::File; # must ultimately "goto" the import routine of the module to be loaded # so that the calling package is correct when $mod->import() runs. sub import { my ( $package, $mod, @args ) = @_; my $file = $package->_mod2path($mod); if ( $INC{$file} ) { # Already loaded, but let _load_module handle import args goto \&_load_module; } # A bundled copy must be present my ( $bundled, $bundled_dir ) = $package->_search_bundled($file) or die "No bundled copy of $mod found"; my $from_inc = $package->_search_INC($file); unless ($from_inc) { # Only bundled is available unshift( @INC, $bundled_dir ); goto \&_load_module; } if ( _version($from_inc) >= _version($bundled) ) { # Ignore the bundled copy goto \&_load_module; } # Load the bundled copy unshift( @INC, $bundled_dir ); goto \&_load_module; } sub _version { require ExtUtils::MakeMaker; return ExtUtils::MM->parse_version(shift); } # use "goto" for import to preserve caller sub _load_module { my $package = shift; # remaining @_ is ready for goto my ( $mod, @args ) = @_; eval "require $mod; 1" or die $@; if ( my $import = $mod->can('import') ) { goto $import; } return 1; } sub _search_bundled { my ( $self, $file ) = @_; my $mypath = 'inc'; local *DH; # Maintain 5.005 compatibility opendir DH, $mypath or die "Can't open directory $mypath: $!"; while ( defined( my $e = readdir DH ) ) { next unless $e =~ /^inc_/; my $try = File::Spec->catfile( $mypath, $e, $file ); return ( $try, File::Spec->catdir( $mypath, $e ) ) if -e $try; } return; } # Look for the given path in @INC. sub _search_INC { # TODO: doesn't handle coderefs or arrayrefs or objects in @INC, but # it probably should my ( $self, $file ) = @_; foreach my $dir (@INC) { next if ref $dir; my $try = File::Spec->catfile( $dir, $file ); return $try if -e $try; } return; } # Translate a module name into a directory/file.pm to search for in @INC sub _mod2path { my ( $self, $mod ) = @_; my @parts = split /::/, $mod; $parts[-1] .= '.pm'; return $parts[0] if @parts == 1; return File::Spec->catfile(@parts); } 1; # vim: ts=4 sts=4 sw=4 tw=75 et: __END__ =pod =encoding UTF-8 =head1 NAME inc::latest::private - private implementation for inc::latest =head1 VERSION version 0.500 =head1 DESCRIPTION This module has the private methods used to find and load bundled modules. It should not be used directly. =head1 AUTHORS =over 4 =item * David Golden =item * Eric Wilhelm =back =head1 COPYRIGHT AND LICENSE This software is Copyright (c) 2009 by David Golden. This is free software, licensed under: The Apache License, Version 2.0, January 2004 =cut File-ShareDir-1.118/META.json0000664000175000017500000000471613743750527013732 0ustar snosno{ "abstract" : "Locate per-dist and per-module shared files", "author" : [ "Adam Kennedy " ], "dynamic_config" : 1, "generated_by" : "ExtUtils::MakeMaker version 7.46, CPAN::Meta::Converter version 2.150010", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : 2 }, "name" : "File-ShareDir", "no_index" : { "directory" : [ "t", "inc" ] }, "prereqs" : { "build" : { "requires" : { "ExtUtils::MakeMaker" : "0", "File::ShareDir::Install" : "0.13" } }, "configure" : { "recommends" : { "File::ShareDir::Install" : "0.08", "inc::latest" : "0.500" }, "requires" : { "ExtUtils::MakeMaker" : "0", "File::ShareDir::Install" : "0.13" } }, "develop" : { "requires" : { "File::ShareDir::Install" : "0.08", "Module::CPANTS::Analyse" : "0.96", "Test::CPAN::Changes" : "0", "Test::CheckManifest" : "0", "Test::Kwalitee" : "0", "Test::Perl::Critic" : "0", "Test::PerlTidy" : "0", "Test::Pod" : "0", "Test::Pod::Coverage" : "0", "Test::Pod::Spelling::CommonMistakes" : "0", "Test::Spelling" : "0", "inc::latest" : "0.500" } }, "runtime" : { "recommends" : { "List::MoreUtils" : "0.428", "Params::Util" : "1.07" }, "requires" : { "Carp" : "0", "Class::Inspector" : "1.12", "File::Spec" : "0.80", "warnings" : "0" } }, "test" : { "recommends" : { "CPAN::Meta" : "2.11044" }, "requires" : { "File::Path" : "2.08", "Test::More" : "0.90" } } }, "release_status" : "stable", "resources" : { "bugtracker" : { "mailto" : "file-sharedir@rt.cpan.org", "web" : "http://rt.cpan.org/Public/Dist/Display.html?Name=File-ShareDir" }, "homepage" : "https://metacpan.org/release/File-ShareDir", "repository" : { "type" : "git", "web" : "https://github.com/perl5-utils/File-ShareDir" } }, "version" : "1.118", "x_serialization_backend" : "JSON::PP version 4.05" } File-ShareDir-1.118/LICENSE0000644000175000017500000004367013733356034013310 0ustar snosnoThis software is copyright (c) 2005 - 2011 Adam Kennedy. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Terms of the Perl programming language system itself a) the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version, or b) the "Artistic License" --- The GNU General Public License, Version 1, February 1989 --- This software is copyright (c) 2005 - 2011 Adam Kennedy. This is free software, licensed under: The GNU General Public License, Version 1, February 1989 GNU GENERAL PUBLIC LICENSE Version 1, February 1989 Copyright (C) 1989 Free Software Foundation, Inc. 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The license agreements of most software companies try to keep users at the mercy of those companies. By contrast, our General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. The General Public License applies to the Free Software Foundation's software and to any other program whose authors commit to using it. You can use it for your programs, too. When we speak of free software, we are referring to freedom, not price. Specifically, the General Public License is designed to make sure that you have the freedom to give away or sell copies of free software, that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of a such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must tell them their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any work containing the Program or a portion of it, either verbatim or with modifications. Each licensee is addressed as "you". 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this General Public License and to the absence of any warranty; and give any other recipients of the Program a copy of this General Public License along with the Program. You may charge a fee for the physical act of transferring a copy. 2. You may modify your copy or copies of the Program or any portion of it, and copy and distribute such modifications under the terms of Paragraph 1 above, provided that you also do the following: a) cause the modified files to carry prominent notices stating that you changed the files and the date of any change; and b) cause the whole of any work that you distribute or publish, that in whole or in part contains the Program or any part thereof, either with or without modifications, to be licensed at no charge to all third parties under the terms of this General Public License (except that you may choose to grant warranty protection to some or all third parties, at your option). c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the simplest and most usual way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this General Public License. d) You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. Mere aggregation of another independent work with the Program (or its derivative) on a volume of a storage or distribution medium does not bring the other work under the scope of these terms. 3. You may copy and distribute the Program (or a portion or derivative of it, under Paragraph 2) in object code or executable form under the terms of Paragraphs 1 and 2 above provided that you also do one of the following: a) accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Paragraphs 1 and 2 above; or, b) accompany it with a written offer, valid for at least three years, to give any third party free (except for a nominal charge for the cost of distribution) a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Paragraphs 1 and 2 above; or, c) accompany it with the information you received as to where the corresponding source code may be obtained. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form alone.) Source code for a work means the preferred form of the work for making modifications to it. For an executable file, complete source code means all the source code for all modules it contains; but, as a special exception, it need not include source code for modules which are standard libraries that accompany the operating system on which the executable file runs, or for standard header files or definitions files that accompany that operating system. 4. You may not copy, modify, sublicense, distribute or transfer the Program except as expressly provided under this General Public License. Any attempt otherwise to copy, modify, sublicense, distribute or transfer the Program is void, and will automatically terminate your rights to use the Program under this License. However, parties who have received copies, or rights to use copies, from you under this General Public License will not have their licenses terminated so long as such parties remain in full compliance. 5. By copying, distributing or modifying the Program (or any work based on the Program) you indicate your acceptance of this license to do so, and all its terms and conditions. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. 7. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of the license which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the license, you may choose any version ever published by the Free Software Foundation. 8. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to humanity, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19xx name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (a program to direct compilers to make passes at assemblers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice That's all there is to it! --- The Artistic License 1.0 --- This software is copyright (c) 2005 - 2011 Adam Kennedy. This is free software, licensed under: The Artistic License 1.0 The Artistic License Preamble The intent of this document is to state the conditions under which a Package may be copied, such that the Copyright Holder maintains some semblance of artistic control over the development of the package, while giving the users of the package the right to use and distribute the Package in a more-or-less customary fashion, plus the right to make reasonable modifications. Definitions: - "Package" refers to the collection of files distributed by the Copyright Holder, and derivatives of that collection of files created through textual modification. - "Standard Version" refers to such a Package if it has not been modified, or has been modified in accordance with the wishes of the Copyright Holder. - "Copyright Holder" is whoever is named in the copyright or copyrights for the package. - "You" is you, if you're thinking about copying or distributing this Package. - "Reasonable copying fee" is whatever you can justify on the basis of media cost, duplication charges, time of people involved, and so on. (You will not be required to justify it to the Copyright Holder, but only to the computing community at large as a market that must bear the fee.) - "Freely Available" means that no fee is charged for the item itself, though there may be fees involved in handling the item. It also means that recipients of the item may redistribute it under the same conditions they received it. 1. You may make and give away verbatim copies of the source form of the Standard Version of this Package without restriction, provided that you duplicate all of the original copyright notices and associated disclaimers. 2. You may apply bug fixes, portability fixes and other modifications derived from the Public Domain or from the Copyright Holder. A Package modified in such a way shall still be considered the Standard Version. 3. You may otherwise modify your copy of this Package in any way, provided that you insert a prominent notice in each changed file stating how and when you changed that file, and provided that you do at least ONE of the following: a) place your modifications in the Public Domain or otherwise make them Freely Available, such as by posting said modifications to Usenet or an equivalent medium, or placing the modifications on a major archive site such as ftp.uu.net, or by allowing the Copyright Holder to include your modifications in the Standard Version of the Package. b) use the modified Package only within your corporation or organization. c) rename any non-standard executables so the names do not conflict with standard executables, which must also be provided, and provide a separate manual page for each non-standard executable that clearly documents how it differs from the Standard Version. d) make other distribution arrangements with the Copyright Holder. 4. You may distribute the programs of this Package in object code or executable form, provided that you do at least ONE of the following: a) distribute a Standard Version of the executables and library files, together with instructions (in the manual page or equivalent) on where to get the Standard Version. b) accompany the distribution with the machine-readable source of the Package with your modifications. c) accompany any non-standard executables with their corresponding Standard Version executables, giving the non-standard executables non-standard names, and clearly documenting the differences in manual pages (or equivalent), together with instructions on where to get the Standard Version. d) make other distribution arrangements with the Copyright Holder. 5. You may charge a reasonable copying fee for any distribution of this Package. You may charge any fee you choose for support of this Package. You may not charge a fee for this Package itself. However, you may distribute this Package in aggregate with other (possibly commercial) programs as part of a larger (possibly commercial) software distribution provided that you do not advertise this Package as a product of your own. 6. The scripts and library files supplied as input to or produced as output from the programs of this Package do not automatically fall under the copyright of this Package, but belong to whomever generated them, and may be sold commercially, and may be aggregated with this Package. 7. C or perl subroutines supplied by you and linked into this Package shall not be considered part of this Package. 8. The name of the Copyright Holder may not be used to endorse or promote products derived from this software without specific prior written permission. 9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. The End File-ShareDir-1.118/MANIFEST.SKIP0000644000175000017500000000054013733367073014173 0ustar snosno\B\.svn\b \B\.git\b \.gitignore$ \.[Bb][Aa][Kk]$ \.orig$ \.old$ \.tdy$ \.tmp$ \..*swp ^Makefile$ ^Build$ ^Build\.bat$ cover_db/ \.Inline/.* _Inline/.* \.bak$ \.tar$ \.tgz$ \.tar\.gz$ ^mess/ ^tmp/ ^testdata/ ^blib/ ^sandbox/ ^pm_to_blib$ ^cover_db/ nytprof*/ nytprof.out ^_build/.* ~$ .*\.planner .*\.lock \.travis\.yml ^File-ShareDir-.* \bxt ^MYMETA.* File-ShareDir-1.118/share/0000755000175000017500000000000013743750527013401 5ustar snosnoFile-ShareDir-1.118/share/sample.txt0000755000175000017500000000023713733356034015422 0ustar snosnoThis is a sample shared file. You should be able to locate it using the following use File::ShareDir (); module_file('File::ShareDir', 'sample.txt'); File-ShareDir-1.118/share/subdir/0000755000175000017500000000000013743750527014671 5ustar snosnoFile-ShareDir-1.118/share/subdir/sample.txt0000755000175000017500000000024613733356034016712 0ustar snosnoThis is a sample shared file. You should be able to locate it using the following use File::ShareDir (); module_file('File::ShareDir', 'subdir/sample.txt'); File-ShareDir-1.118/foo/0000755000175000017500000000000013743750527013062 5ustar snosnoFile-ShareDir-1.118/foo/test_file.txt0000644000175000017500000000002213733356034015565 0ustar snosnoAnother test file File-ShareDir-1.118/.perltidyrc0000644000175000017500000000017413733356034014455 0ustar snosno-b -bl -noll -pt=2 -bt=2 -sbt=2 -vt=0 -vtc=0 -dws -aws -nsfs -asc -bbt=0 -cab=0 -l=130 -ole=unix --noblanks-before-comments File-ShareDir-1.118/README.md0000644000175000017500000002630613733356034013557 0ustar snosno# NAME File::ShareDir - Locate per-dist and per-module shared files
Travis CI Coverage Status Say Thanks
# SYNOPSIS use File::ShareDir ':ALL'; # Where are distribution-level shared data files kept $dir = dist_dir('File-ShareDir'); # Where are module-level shared data files kept $dir = module_dir('File::ShareDir'); # Find a specific file in our dist/module shared dir $file = dist_file( 'File-ShareDir', 'file/name.txt'); $file = module_file('File::ShareDir', 'file/name.txt'); # Like module_file, but search up the inheritance tree $file = class_file( 'Foo::Bar', 'file/name.txt' ); # DESCRIPTION The intent of [File::ShareDir](https://metacpan.org/pod/File::ShareDir) is to provide a companion to [Class::Inspector](https://metacpan.org/pod/Class::Inspector) and [File::HomeDir](https://metacpan.org/pod/File::HomeDir), modules that take a process that is well-known by advanced Perl developers but gets a little tricky, and make it more available to the larger Perl community. Quite often you want or need your Perl module (CPAN or otherwise) to have access to a large amount of read-only data that is stored on the file-system at run-time. On a linux-like system, this would be in a place such as /usr/share, however Perl runs on a wide variety of different systems, and so the use of any one location is unreliable. Perl provides a little-known method for doing this, but almost nobody is aware that it exists. As a result, module authors often go through some very strange ways to make the data available to their code. The most common of these is to dump the data out to an enormous Perl data structure and save it into the module itself. The result are enormous multi-megabyte .pm files that chew up a lot of memory needlessly. Another method is to put the data "file" after the \_\_DATA\_\_ compiler tag and limit yourself to access as a filehandle. The problem to solve is really quite simple. 1. Write the data files to the system at install time. 2. Know where you put them at run-time. Perl's install system creates an "auto" directory for both every distribution and for every module file. These are used by a couple of different auto-loading systems to store code fragments generated at install time, and various other modules written by the Perl "ancient masters". But the same mechanism is available to any dist or module to store any sort of data. ## Using Data in your Module `File::ShareDir` forms one half of a two part solution. Once the files have been installed to the correct directory, you can use `File::ShareDir` to find your files again after the installation. For the installation half of the solution, see [File::ShareDir::Install](https://metacpan.org/pod/File::ShareDir::Install) and its `install_share` directive. Using [File::ShareDir::Install](https://metacpan.org/pod/File::ShareDir::Install) together with [File::ShareDir](https://metacpan.org/pod/File::ShareDir) allows one to rely on the files in appropriate `dist_dir()` or `module_dir()` in development phase, too. # FUNCTIONS `File::ShareDir` provides four functions for locating files and directories. For greater maintainability, none of these are exported by default and you are expected to name the ones you want at use-time, or provide the `':ALL'` tag. All of the following are equivalent. # Load but don't import, and then call directly use File::ShareDir; $dir = File::ShareDir::dist_dir('My-Dist'); # Import a single function use File::ShareDir 'dist_dir'; dist_dir('My-Dist'); # Import all the functions use File::ShareDir ':ALL'; dist_dir('My-Dist'); All of the functions will check for you that the dir/file actually exists, and that you have read permissions, or they will throw an exception. ## dist\_dir # Get a distribution's shared files directory my $dir = dist_dir('My-Distribution'); The `dist_dir` function takes a single parameter of the name of an installed (CPAN or otherwise) distribution, and locates the shared data directory created at install time for it. Returns the directory path as a string, or dies if it cannot be located or is not readable. ## module\_dir # Get a module's shared files directory my $dir = module_dir('My::Module'); The `module_dir` function takes a single parameter of the name of an installed (CPAN or otherwise) module, and locates the shared data directory created at install time for it. In order to find the directory, the module **must** be loaded when calling this function. Returns the directory path as a string, or dies if it cannot be located or is not readable. ## dist\_file # Find a file in our distribution shared dir my $dir = dist_file('My-Distribution', 'file/name.txt'); The `dist_file` function takes two parameters of the distribution name and file name, locates the dist directory, and then finds the file within it, verifying that the file actually exists, and that it is readable. The filename should be a relative path in the format of your local filesystem. It will simply added to the directory using [File::Spec](https://metacpan.org/pod/File::Spec)'s `catfile` method. Returns the file path as a string, or dies if the file or the dist's directory cannot be located, or the file is not readable. ## module\_file # Find a file in our module shared dir my $dir = module_file('My::Module', 'file/name.txt'); The `module_file` function takes two parameters of the module name and file name. It locates the module directory, and then finds the file within it, verifying that the file actually exists, and that it is readable. In order to find the directory, the module **must** be loaded when calling this function. The filename should be a relative path in the format of your local filesystem. It will simply added to the directory using [File::Spec](https://metacpan.org/pod/File::Spec)'s `catfile` method. Returns the file path as a string, or dies if the file or the dist's directory cannot be located, or the file is not readable. ## class\_file # Find a file in our module shared dir, or in our parent class my $dir = class_file('My::Module', 'file/name.txt'); The `module_file` function takes two parameters of the module name and file name. It locates the module directory, and then finds the file within it, verifying that the file actually exists, and that it is readable. In order to find the directory, the module **must** be loaded when calling this function. The filename should be a relative path in the format of your local filesystem. It will simply added to the directory using [File::Spec](https://metacpan.org/pod/File::Spec)'s `catfile` method. If the file is NOT found for that module, `class_file` will scan up the module's @ISA tree, looking for the file in all of the parent classes. This allows you to, in effect, "subclass" shared files. Returns the file path as a string, or dies if the file or the dist's directory cannot be located, or the file is not readable. # EXTENDING ## Overriding Directory Resolution `File::ShareDir` has two convenience hashes for people who have advanced usage requirements of `File::ShareDir` such as using uninstalled `share` directories during development. # # Dist-Name => /absolute/path/for/DistName/share/dir # %File::ShareDir::DIST_SHARE # # Module::Name => /absolute/path/for/Module/Name/share/dir # %File::ShareDir::MODULE_SHARE Setting these values any time before the corresponding calls dist_dir('Dist-Name') dist_file('Dist-Name','some/file'); module_dir('Module::Name'); module_file('Module::Name','some/file'); Will override the base directory for resolving those calls. An example of where this would be useful is in a test for a module that depends on files installed into a share directory, to enable the tests to use the development copy without needing to install them first. use File::ShareDir; use Cwd qw( getcwd ); use File::Spec::Functions qw( rel2abs catdir ); $File::ShareDir::MODULE_SHARE{'Foo::Module'} = rel2abs(catfile(getcwd,'share')); use Foo::Module; # interal calls in Foo::Module to module_file('Foo::Module','bar') now resolves to # the source trees share/ directory instead of something in @INC # SUPPORT Bugs should always be submitted via the CPAN request tracker, see below. You can find documentation for this module with the perldoc command. perldoc File::ShareDir You can also look for information at: - RT: CPAN's request tracker [http://rt.cpan.org/NoAuth/Bugs.html?Dist=File-ShareDir](http://rt.cpan.org/NoAuth/Bugs.html?Dist=File-ShareDir) - AnnoCPAN: Annotated CPAN documentation [http://annocpan.org/dist/File-ShareDir](http://annocpan.org/dist/File-ShareDir) - CPAN Ratings [http://cpanratings.perl.org/s/File-ShareDir](http://cpanratings.perl.org/s/File-ShareDir) - CPAN Search [http://search.cpan.org/dist/File-ShareDir/](http://search.cpan.org/dist/File-ShareDir/) ## Where can I go for other help? If you have a bug report, a patch or a suggestion, please open a new report ticket at CPAN (but please check previous reports first in case your issue has already been addressed). Report tickets should contain a detailed description of the bug or enhancement request and at least an easily verifiable way of reproducing the issue or fix. Patches are always welcome, too. ## Where can I go for help with a concrete version? Bugs and feature requests are accepted against the latest version only. To get patches for earlier versions, you need to get an agreement with a developer of your choice - who may or not report the issue and a suggested fix upstream (depends on the license you have chosen). ## Business support and maintenance For business support you can contact the maintainer via his CPAN email address. Please keep in mind that business support is neither available for free nor are you eligible to receive any support based on the license distributed with this package. # AUTHOR Adam Kennedy ## MAINTAINER Jens Rehsack # SEE ALSO [File::ShareDir::Install](https://metacpan.org/pod/File::ShareDir::Install), [File::ConfigDir](https://metacpan.org/pod/File::ConfigDir), [File::HomeDir](https://metacpan.org/pod/File::HomeDir), [Module::Install](https://metacpan.org/pod/Module::Install), [Module::Install::Share](https://metacpan.org/pod/Module::Install::Share), [File::ShareDir::PAR](https://metacpan.org/pod/File::ShareDir::PAR), [Dist::Zilla::Plugin::ShareDir](https://metacpan.org/pod/Dist::Zilla::Plugin::ShareDir) # COPYRIGHT Copyright 2005 - 2011 Adam Kennedy, Copyright 2014 - 2018 Jens Rehsack. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of the license can be found in the LICENSE file included with this module. File-ShareDir-1.118/t/0000755000175000017500000000000013743750527012542 5ustar snosnoFile-ShareDir-1.118/t/lib/0000755000175000017500000000000013743750527013310 5ustar snosnoFile-ShareDir-1.118/t/lib/ShareDir/0000755000175000017500000000000013743750527015011 5ustar snosnoFile-ShareDir-1.118/t/lib/ShareDir/TestClass.pm0000644000175000017500000000014713743745173017257 0ustar snosnopackage ShareDir::TestClass; use strict; use parent ("File::ShareDir"); our $VERSION = "1.118"; 1; File-ShareDir-1.118/t/00_prereqs.t0000644000175000017500000000657313733370763014721 0ustar snosno#!perl use strict; use warnings; use Test::More; # Prereqs-testing for File::ShareDir BEGIN { if (!eval { require CPAN::Meta; 1 }) { plan skip_all => "Need CPAN::Meta for this test"; } } my $meta = CPAN::Meta->load_file(-d "xt" ? "MYMETA.json" : "META.json"); my $prereqs = $meta->effective_prereqs; my %dups; my %report; my %len = ( module => length("module"), want => length("wanted"), have => length("missing") ); foreach my $phase (qw/configure build runtime test/, (-d "xt" ? "develop" : ())) { foreach my $severity (qw/requires recommends suggests/) { my $reqs = $prereqs->requirements_for($phase, $severity); my @modules = sort $reqs->required_modules; @modules or next; $len{module} < length(" $phase / $severity ") and $len{module} = length(" $phase / $severity "); for my $module (@modules) { my $want = $reqs->{requirements}->{$module}->{minimum}->{original}; defined $dups{$module} and $dups{$module} >= $want and next; $len{module} < length($module) and $len{module} = length($module); $dups{$module} = $want; $len{want} < length($want) and $len{want} = length($want); local $TODO = $severity eq "requires" ? undef : $severity; if (eval { require_ok($module) unless $module eq 'perl'; 1 }) { my $version = $module eq 'perl' ? $] : $module->VERSION; my $status; if (defined $version) { $len{have} < length($version) and $len{have} = length($version); my $ok = ok($reqs->accepts_module($module, $version), "$module matches required $version"); $status = $ok ? "ok" : "not ok"; } else { $status = "not ok"; $version = "n/a"; } $report{$phase}{$severity}{$module} = { want => $want, have => $version, status => $status }; } else { $report{$phase}{$severity}{$module} = { want => $want, have => "undef", status => "missing" }; } } } } diag sprintf("Requirements for %s version %s", $meta->name, $meta->version); my $fmt_str = " %$len{module}s | %$len{have}s | %$len{want}s | %s"; my $sep_str = "-%$len{module}s-+-%$len{have}s-+-%$len{want}s-+---------"; diag(sprintf($fmt_str, qw(module version wanted status))); foreach my $phase (qw/configure build runtime test/, (-d "xt" ? "develop" : ())) { foreach my $severity (qw/requires recommends suggests/) { scalar keys %{$report{$phase}{$severity}} or next; my $cap = " $phase / $severity "; $cap .= "-" x ($len{module} - length($cap)); diag(sprintf($sep_str, $cap, "-" x $len{have}, "-" x $len{want})); foreach my $module (sort keys %{$report{$phase}{$severity}}) { my ($have, $want, $status) = @{$report{$phase}{$severity}{$module}}{qw(have want status)}; diag(sprintf($fmt_str, $module, $have, $want, $status)); } } } diag(sprintf($sep_str, "-" x $len{module}, "-" x $len{have}, "-" x $len{want})); done_testing; File-ShareDir-1.118/t/01_compile.t0000755000175000017500000000045113733356034014654 0ustar snosno#!/usr/bin/perl # Compile-testing for File::ShareDir use strict; BEGIN { $| = 1; $^W = 1; } use Test::More; ok($] > 5.005, 'Perl version is 5.005 or newer'); use_ok('File::ShareDir'); diag("Testing File::ShareDir $File::ShareDir::VERSION, Perl $], $^X, UID: $<"); done_testing(); File-ShareDir-1.118/t/03_extensions.t0000644000175000017500000000150213733356034015420 0ustar snosnouse strict; use warnings; use Test::More; # ABSTRACT: Test for overriding paths use File::ShareDir qw( dist_dir dist_file module_dir module_file ); use Cwd qw( getcwd ); my $FAKE_DIST = 'Fake-Sample-Dist'; my $FAKE_MODULE = 'Fake::Sample::Module'; { package Fake::Sample::Module; $INC{'Fake/Sample/Module.pm'} = 1; } $File::ShareDir::DIST_SHARE{$FAKE_DIST} = getcwd; $File::ShareDir::MODULE_SHARE{$FAKE_MODULE} = getcwd; is(dist_dir($FAKE_DIST), getcwd, "Fake distribution resolves to forced value"); ok(-f dist_file($FAKE_DIST, 't/03_extensions.t'), "Fake distribution resolves to forced value with a file"); is(module_dir($FAKE_MODULE), getcwd, "Fake module resolves to forced value"); ok(-f module_file($FAKE_MODULE, 't/03_extensions.t'), "Fake module resolves to forced value with a file"); done_testing; File-ShareDir-1.118/t/02_main.t0000755000175000017500000000476013733356034014160 0ustar snosno#!/usr/bin/perl # Compile-testing for File::ShareDir use strict; BEGIN { $| = 1; $^W = 1; } use Test::More; use File::ShareDir; # Print the contents of @INC #diag("\@INC = qw{"); #foreach ( @INC ) { # diag(" $_"); #} #diag(" }"); ##################################################################### # Loading and Importing # Don't import by default ok(!defined &dist_dir, 'dist_dir not imported by default'); ok(!defined &module_dir, 'module_dir not imported by default'); ok(!defined &dist_file, 'dist_file not imported by default'); ok(!defined &module_file, 'module_file not imported by default'); ok(!defined &class_file, 'class_file not imported by default'); use_ok('File::ShareDir', ':ALL'); # Import as needed ok(defined &dist_dir, 'dist_dir imported'); ok(defined &module_dir, 'module_dir imported'); ok(defined &dist_file, 'dist_file imported'); ok(defined &module_file, 'module_file imported'); ok(defined &class_file, 'class_file imported'); # Allow all named functions use_ok('File::ShareDir', 'module_dir', 'module_file', 'dist_dir', 'dist_file', 'class_file',); ##################################################################### # Support Methods is(File::ShareDir::_MODULE('File::ShareDir'), 'File::ShareDir', '_MODULE returns correct for known loaded module',); is(File::ShareDir::_DIST('File-ShareDir'), 'File-ShareDir', '_DIST returns correct for known good dist',); ##################################################################### # Module Tests my $module_dir = module_dir('File::ShareDir'); ok($module_dir, 'Can find our own module dir'); ok(-d $module_dir, '... and is a dir'); ok(-r $module_dir, '... and have read permissions'); my $module_file = module_file('File::ShareDir', 'test_file.txt'); ok(-f $module_file, 'module_file ok'); ##################################################################### # Distribution Tests my $dist_dir = dist_dir('File-ShareDir'); ok($dist_dir, 'Can find our own dist dir'); ok(-d $dist_dir, '... and is a dir'); ok(-r $dist_dir, '... and have read permissions'); my $dist_file = dist_file('File-ShareDir', 'sample.txt'); ok($dist_file, 'Can find our sample module file'); ok(-f $dist_file, '... and is a file'); ok(-r $dist_file, '... and have read permissions'); # Make sure the directory in dist_dir, matches the one from dist_file # Bug found in Module::Install 0.54, fixed in 0.55 is(File::Spec->catfile($dist_dir, 'sample.txt'), $dist_file, 'dist_dir and dist_file find the same directory',); done_testing; File-ShareDir-1.118/t/05_class.t0000644000175000017500000000125413733356034014334 0ustar snosno#!perl use strict; use warnings; use Cwd ('abs_path'); use File::Basename ('dirname'); use File::Spec (); use Test::More; ##################################################################### # Class Tests { my @TEST_INC = @INC; local @INC = (File::Spec->catdir(abs_path(dirname($0)), "lib"), @TEST_INC); use_ok("ShareDir::TestClass"); } my $class_file = File::ShareDir->can("class_file")->('ShareDir::TestClass', 'test_file.txt'); ok(-f $class_file, 'class_file ok'); my $module_file = File::ShareDir->can("module_file")->('File::ShareDir', 'test_file.txt'); is($class_file, $module_file, 'class_file matches module_file for subclass'); done_testing; File-ShareDir-1.118/t/06_old.t0000644000175000017500000000327113733370126014005 0ustar snosno#!perl use strict; use warnings; use Cwd ('abs_path'); use File::Basename ('dirname'); use File::Path ('make_path', 'remove_tree'); use File::Spec (); use Test::More; my $testlib = File::Spec->catdir(abs_path(dirname($0)), "lib"); unshift @INC, $testlib; my $testautolib = File::Spec->catdir($testlib, "auto"); my $testsharedirold = File::Spec->catdir($testautolib, qw(ShareDir TestClass)); END { remove_tree($testautolib); } use_ok('File::ShareDir', 'module_dir', 'module_file', 'dist_dir', 'dist_file', 'class_file'); use_ok("ShareDir::TestClass"); is(File::ShareDir::_MODULE('ShareDir::TestClass'), 'ShareDir::TestClass', '_MODULE returns correct for known loaded module',); is(File::ShareDir::_DIST('ShareDir-TestClass'), 'ShareDir-TestClass', '_DIST returns correct for known good dist',); remove_tree($testautolib); make_path($testsharedirold, {mode => 0700}); SKIP: { open(my $fh, ">", File::Spec->catfile($testsharedirold, qw(sample.txt))) or skip "Can't write to [$testsharedirold]: $!", 9; close($fh); my $module_dir = module_dir('ShareDir::TestClass'); ok($module_dir, 'Can find our own module dir'); ok(-d $module_dir, '... and is a dir'); ok(-r $module_dir, '... and have read permissions'); my $dist_dir = dist_dir('ShareDir-TestClass'); ok($dist_dir, 'Can find our own dist dir'); ok(-d $dist_dir, '... and is a dir'); ok(-r $dist_dir, '... and have read permissions'); my $dist_file = dist_file('ShareDir-TestClass', 'sample.txt'); ok($dist_file, 'Can find our sample module file'); ok(-f $dist_file, '... and is a file'); ok(-r $dist_file, '... and have read permissions'); } done_testing; File-ShareDir-1.118/t/04_fail.t0000644000175000017500000001275513733370132014144 0ustar snosno#!perl use strict; use warnings; use Cwd ('abs_path'); use File::Basename ('dirname'); use File::Path ('make_path', 'remove_tree'); use File::Spec (); use POSIX; use Test::More; sub dies { local $Test::Builder::Level = $Test::Builder::Level + 1; my $code = shift; my $pattern = shift; my $message = shift || 'Code dies as expected'; my $rv = eval { &$code() }; my $err = $@; like($err, $pattern, $message); } use File::ShareDir ':ALL'; my $testlib = File::Spec->catdir(abs_path(dirname($0)), "lib"); unshift @INC, $testlib; use_ok("ShareDir::TestClass"); my $fh; my $testautolib = File::Spec->catdir($testlib, "auto"); my $testsharedirold = File::Spec->catdir($testautolib, qw(ShareDir TestClass)); END { remove_tree($testautolib); } remove_tree($testautolib); make_path($testautolib, {mode => 0700}); sysopen($fh, File::Spec->catfile($testautolib, qw(noread.txt)), O_RDWR | O_CREAT, 0100) or diag("$!"); close($fh); my $NO_PERMISSION_CHECK = -r File::Spec->catfile($testautolib, qw(noread.txt)); dies(sub { File::ShareDir::_DIST("ShareDir::TestClass") }, qr/Not a valid distribution name/, "Not a valid distribution name"); dies( sub { File::ShareDir::_FILE(File::Spec->catfile($testsharedirold, "file.txt")); }, qr/Cannot use absolute file name/, "Cannot use absolute file name" ); dies(sub { module_dir() }, qr/Not a valid module name/, 'No params to module_dir dies'); dies(sub { module_dir('') }, qr/Not a valid module name/, 'Null param to module_dir dies'); dies( sub { module_dir('File::ShareDir::Bad') }, qr/Module 'File::ShareDir::Bad' is not loaded/, 'Getting module dir for known non-existent module dies', ); # test from RT#125582 dies( sub { dist_file('File-ShareDir', 'file/name.txt'); }, qr,Failed to find shared file 'file/name.txt' for dist 'File-ShareDir',, "Getting non-existent file dies" ); remove_tree($testautolib); dies(sub { my $dist_dir = dist_dir('ShareDir-TestClass'); }, qr/Failed to find share dir for dist/, "No module directory"); dies(sub { my $module_dir = module_dir('ShareDir::TestClass'); }, qr/No such directory/, "Old module directory but file"); make_path(dirname($testsharedirold), {mode => 0700}); make_path($testsharedirold, {mode => 0100}); SKIP: { skip("Root always has read permissions", 1) if $NO_PERMISSION_CHECK; dies( sub { my $module_dir = module_dir('ShareDir::TestClass'); }, qr/No read permission/, "New module directory without read permission" ); } my $testsharedirnew = File::Spec->catdir($testautolib, qw(share dist ShareDir-TestClass)); make_path(dirname($testsharedirnew), {mode => 0700}); make_path($testsharedirnew, {mode => 0100}); SKIP: { skip("Root always has read permissions", 1) if $NO_PERMISSION_CHECK; dies( sub { my $dist_dir = dist_dir('ShareDir-TestClass'); }, qr/but no read permissions/, "New module directory without read permission" ); } remove_tree($testautolib); open($fh, ">", $testsharedirold); close($fh); dies(sub { my $module_dir = module_dir('ShareDir::TestClass'); }, qr/No such directory/, "Old module directory but file"); dies(sub { my $dist_dir = dist_dir('ShareDir-TestClass'); }, qr/Failed to find share dir for dist/, "Old dist directory but file"); dies( sub { my $dist_file = dist_file('ShareDir-TestClass', 'noread.txt'); }, qr/Failed to find shared file/, "Old dist directory but file" ); remove_tree($testautolib); make_path($testsharedirold, {mode => 0700}); sysopen($fh, File::Spec->catfile($testsharedirold, qw(noread.txt)), O_RDWR | O_CREAT, 0200) or diag("$!"); print $fh "Moep\n"; close($fh); SKIP: { skip("Root always has read permissions", 3) if $NO_PERMISSION_CHECK; dies(sub { my $dist_file = dist_file('ShareDir-TestClass', 'noread.txt'); }, qr/No read permission/, "Unreadable dist_file"); dies( sub { my $module_file = module_file('ShareDir::TestClass', 'noread.txt'); }, qr/No read permission/, "Unreadable module_file" ); dies( sub { my $class_file = class_file('ShareDir::TestClass', 'noread.txt'); }, qr/cannot be read, no read permissions/, "Unreadable class_file" ); } dies( sub { my $module_file = module_file('ShareDir::TestClass', 'noehere.txt'); }, qr/does not exist in module dir/, "Unavailable module_file" ); dies( sub { my $class_file = class_file('ShareDir::TestClass', 'noehere.txt'); }, qr/does not exist in class or parent shared files/, "Unavailable class_file" ); make_path(File::Spec->catdir($testsharedirold, "weird.dir"), {mode => 0700}); dies(sub { my $dist_file = dist_file('ShareDir-TestClass', 'weird.dir'); }, qr/No such file/, "Dir instead of file"); eval <new(), @TEST_INC); my $dist_dir = dist_dir('ShareDir-TestClass'); ok($dist_dir, "Found dist_dir even with weird \@INC"); } dies( sub { File::ShareDir::_DIST(Module::WithOut::File->new()) }, qr/Not a valid distribution name/, "Object instead of distribution" ); dies(sub { File::ShareDir::_FILE(Module::WithOut::File->new()) }, qr/Did not pass a file name/, "Did not pass a file name"); done_testing; File-ShareDir-1.118/testrules.yml0000644000175000017500000000011113733370220015030 0ustar snosnoseq: - seq: - t/04_fail.t - t/06_old.t - par: ** File-ShareDir-1.118/Changes0000644000175000017500000001067313743745637013607 0ustar snosnoRevision history for Perl extension File-ShareDir 1.118 2020-10-21 - Releasing 1.117_001 without further changes 1.117_001 2020-09-25 - fix failing test of dependencies after in 1.116 (from 1.112), thanks to Dirk Stöcker for reporting via RT#127376 and Mohammad S Anwar (@manwar) for providing the fix via Github PR#14 - Fix RT#133368 (PR#15): Fix running tests in parallel submitted by Kent Fredric (KENTNL) and fix provided by Tom Hukins (@tomhukins) - Fix RT#125907: spelling error in manpage - thanks to Lucas Kanashiro for reporting and Graham Knop (@haarg) for kicking me by submitting PR#17 1.116 2018-06-24 - fix fail-test which incorrectly read without permission ==> introduce new CI test proving this (Thanks to Ville Skyttä ) - spelling fixes (Thanks to Ville Skyttä ) - fix author tests when run without recommended dependencies (reported by Mohammed Anwar & Wesley Schwengle) - add a test proving and reporting dependencies 1.114 2018-06-21 - be more expressive regarding to prerequisites - improve detection for situations where no permission test can be done - fix edge case for 5.8 1.112 2018-06-18 - Fix tests that fail when running as root (RT#125602, thanks Wesley Schwengle ) - Fix tests fail on MSWin32 for similar reason as the root failures from RT#125602 - clarify support rules - improve POD 1.110 2018-06-16 - remove unused/incomplete _dist_packfile - increase test coverage - refactor _search_inc_path - add badges to POD 1.108 2018-06-15 - Fix RT#125582: Undefined subroutine &File::ShareDir::croak called reported by yseto and Andreas Koenig (via RT#125575) - Improve tests a little (a higher test coverage would be great) - Update README.md 1.106 2018-06-10 - Add support for overriding the resolved path for a given Module or Dist (Thanks to Kent Fredric ) - Fix RT#84914: _dist_file_new lacks return check (Thanks to Alex Peters ) -- fixes RT#40158, too. - Fix RT#60431: common @INC traversal code Phillip Moore requested for easier overriding in controlled environments an extraction of @INC traversal in one subroutine. The provided patch has been applied with minor modifications, thanks Phillip! - Fix RT#63548: State explicit how developers can use File::ShareDir even in development phase out-of-the-box - Fix RT#18042: Windows style path errors (Thanks to Barbie ) - Improve infrastructure of distribution (toolchain, perltidy, perlcritic, Devel::Cover, ...) - deploy with most recent File::ShareDir::Install (v0.12-6-g29a6ff7 aka 0.13) 1.104 2017-06-29 - Fix RT#120833: Fails tests when no "." in @INC reported by Kent Fredric . - avoid tracking bundled prereqs - use inc::latest tooling from List::MoreUtils... - bundle reasonable LICENSE file and README.md 1.102 2014-05-12 - Fix RT#95572 "necessary test files not copied into blib" Thanks to Graham Knop for fixing and Zefram for reporting - Explicitly require warnings as runtime prerequisite Thanks to Graham Knop for reporting 1.101 2014-05-10 - Reformat Changes according to CPAN::Changes::Spec - Switch to EU::MM - fix RT#95401 (Thanks, Dolmen) - Taking Maintainership (Jens Rehsack, thanks to David Golden) 1.03 2010-02-01 - Upgraded to Module::Install 1.00 1.02 2010-05-18 - Upgraded to Module::Install 0.95 - Removed Params::Util dep (MIYAGAWA) 1.01 2009-11-24 - Updating Module::Install to 0.91 - Fix typo in documentation (Thanks, ribasushi) 1.00 2009-07-17 - Everything appears ok, release prod 0.99_01 2009-07-10 - Updating tests a little - Adding the class_file function - Allow *_file to find any kind of path, not just files (hdp) - Localising $@ during evals - Implementing the new sharedir model 0.05 2006-09-04 - Upgrading to Module::Install 0.64 0.04 2006-05-09 - Made module_dir work properly under MSWin32 (ishigaki) 0.03 2006-12-27 - Upgraded to Module::Install 0.55 - Added an additional test case for a bug(sort of) in 0.54 0.02 2005-12-11 - Made dist_file work properly with Module::Install::Share 0.01 2005-12-10 - First implementation File-ShareDir-1.118/Makefile.PL0000644000175000017500000001265713733356034014256 0ustar snosno#!perl use strict; use warnings; use 5.008_001; use ExtUtils::MakeMaker; BEGIN { unless (grep { $_ eq "." } @INC) { use lib "."; } } use inc::latest 'File::ShareDir::Install'; File::ShareDir::Install->import('0.03', 'install_share'); if (inc::latest->can("write")) { inc::latest->write("inc"); for my $mod (inc::latest->loaded_modules) { inc::latest->bundle_module($mod, "inc"); } } install_share 'share'; # Full version install_share module => 'File::ShareDir' => 'foo'; my %RUN_DEPS = ( 'warnings' => 0, 'Carp' => 0, 'Class::Inspector' => '1.12', 'File::Spec' => '0.80', ); my %BUILD_DEPS = ( 'ExtUtils::MakeMaker' => 0, 'File::ShareDir::Install' => '0.13' ); my %BUNDLE_CONFIGURE_DEPS = ( 'inc::latest' => '0.500', 'File::ShareDir::Install' => '0.08', ); my %TEST_DEPS = ( 'Test::More' => '0.90', 'File::Path' => '2.08', ); WriteMakefile1( MIN_PERL_VERSION => '5.008001', META_ADD => { 'meta-spec' => {version => 2}, resources => { homepage => 'https://metacpan.org/release/File-ShareDir', repository => { url => 'git@github.com:perl5-utils/File-ShareDir.git', web => 'https://github.com/perl5-utils/File-ShareDir', type => 'git', }, bugtracker => { web => 'http://rt.cpan.org/Public/Dist/Display.html?Name=File-ShareDir', mailto => 'file-sharedir@rt.cpan.org', }, }, prereqs => { develop => { requires => { 'Test::CPAN::Changes' => 0, 'Test::CheckManifest' => 0, 'Module::CPANTS::Analyse' => '0.96', 'Test::Kwalitee' => 0, 'Test::Perl::Critic' => 0, 'Test::PerlTidy' => 0, 'Test::Pod' => 0, 'Test::Pod::Coverage' => 0, 'Test::Pod::Spelling::CommonMistakes' => 0, 'Test::Spelling' => 0, %BUNDLE_CONFIGURE_DEPS, }, }, configure => { requires => {%BUILD_DEPS}, recommends => {%BUNDLE_CONFIGURE_DEPS} }, build => {requires => {%BUILD_DEPS}}, test => { requires => {%TEST_DEPS}, recommends => {'CPAN::Meta' => 2.110440} }, runtime => { requires => {%RUN_DEPS}, recommends => { 'Params::Util' => '1.07', 'List::MoreUtils' => '0.428' }, }, }, }, NAME => 'File::ShareDir', VERSION_FROM => 'lib/File/ShareDir.pm', ABSTRACT_FROM => 'lib/File/ShareDir.pm', LICENSE => 'perl', AUTHOR => q{Adam Kennedy }, PREREQ_PM => \%RUN_DEPS, BUILD_REQUIRES => \%BUILD_DEPS, TEST_REQUIRES => \%TEST_DEPS, (-d "xt" ? (realclean => {FILES => "inc/latest* inc/inc_* t/xs"}) : ()), test => {TESTS => 't/*.t xt/*.t'}, ); sub WriteMakefile1 { # originally written by Alexandr Ciornii, version 0.21. Added by eumm-upgrade. my %params = @_; my $eumm_version = $ExtUtils::MakeMaker::VERSION; $eumm_version = eval $eumm_version; die "EXTRA_META is deprecated" if (exists($params{EXTRA_META})); die "License not specified" if (!exists($params{LICENSE})); if ($params{TEST_REQUIRES} and ($eumm_version < 6.6303)) { if ($params{BUILD_REQUIRES}) { $params{BUILD_REQUIRES} = {%{$params{BUILD_REQUIRES}}, %{$params{TEST_REQUIRES}}}; } else { $params{BUILD_REQUIRES} = delete $params{TEST_REQUIRES}; } } if ($params{BUILD_REQUIRES} and ($eumm_version < 6.5503)) { #EUMM 6.5502 has problems with BUILD_REQUIRES $params{PREREQ_PM} = {%{$params{PREREQ_PM} || {}}, %{$params{BUILD_REQUIRES}}}; delete $params{BUILD_REQUIRES}; } delete $params{CONFIGURE_REQUIRES} if ($eumm_version < 6.52); delete $params{MIN_PERL_VERSION} if ($eumm_version < 6.48); delete $params{META_MERGE} if ($eumm_version < 6.46); delete $params{META_ADD}{prereqs} if ($eumm_version < 6.58); delete $params{META_ADD}{'meta-spec'} if ($eumm_version < 6.58); delete $params{META_ADD} if ($eumm_version < 6.46); delete $params{LICENSE} if ($eumm_version < 6.31); delete $params{AUTHOR} if ($] < 5.005); delete $params{ABSTRACT_FROM} if ($] < 5.005); delete $params{BINARY_LOCATION} if ($] < 5.005); # more or less taken from Moose' Makefile.PL if ($params{CONFLICTS}) { my $ok = CheckConflicts(%params); exit(0) if ($params{PREREQ_FATAL} and not $ok); my $cpan_smoker = grep { $_ =~ m/(?:CR_SMOKER|CPAN_REPORTER|AUTOMATED_TESTING)/ } keys %ENV; unless ($cpan_smoker || $ENV{PERL_MM_USE_DEFAULT}) { sleep 4 unless ($ok); } delete $params{CONFLICTS}; } WriteMakefile(%params); } package MY; use File::ShareDir::Install qw(postamble); 1;