File-ShareDir-Install-0.05/000075500000000000000000000000001222430454600154205ustar00rootroot00000000000000File-ShareDir-Install-0.05/Changes000064400000000000000000000007001222430454600167100ustar00rootroot00000000000000Revision history for Perl extension File::ShareDir::Install. 0.05 Sep 3 2013 - Tweak doco and fix typos Thank you dsteinbrunner@pobox.com 0.04 Aug 25 2011 - Tweak for better error reports 0.03 Sep 9 2009 - Drop PERL_MM_OPT in test so that it passes with local::lib Thank you Peter Makholm 0.02 Jul 2 - Renamed to File::ShareDir::Install - Tweak the doco 0.01 Jul 1 - Initial release to the CPAN File-ShareDir-Install-0.05/MANIFEST000064400000000000000000000005461222430454600165560ustar00rootroot00000000000000Changes Makefile.PL MANIFEST README lib/File/ShareDir/Install.pm t/module/again t/module/deeper/bonk t/module/bonk t/share/honk t/00_compile.t t/01_pod.t t/02_pod_coverage.t t/10_makefile.t META.yml Module YAML meta-data (added by MakeMaker) META.json Module JSON meta-data (added by MakeMaker) File-ShareDir-Install-0.05/META.json000064400000000000000000000016541222430454600170470ustar00rootroot00000000000000{ "abstract" : "Install shared files", "author" : [ "Philip Gwyn " ], "dynamic_config" : 1, "generated_by" : "ExtUtils::MakeMaker version 6.62, CPAN::Meta::Converter version 2.112150", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : "2" }, "name" : "File-ShareDir-Install", "no_index" : { "directory" : [ "t", "inc" ] }, "prereqs" : { "build" : { "requires" : { "ExtUtils::MakeMaker" : 0 } }, "configure" : { "requires" : { "ExtUtils::MakeMaker" : 0 } }, "runtime" : { "requires" : { "ExtUtils::MakeMaker" : "6.11", "File::Spec" : 0, "IO::Dir" : 0 } } }, "release_status" : "stable", "version" : "0.05" } File-ShareDir-Install-0.05/META.yml000064400000000000000000000010201222430454600166620ustar00rootroot00000000000000--- abstract: 'Install shared files' author: - 'Philip Gwyn ' build_requires: ExtUtils::MakeMaker: 0 configure_requires: ExtUtils::MakeMaker: 0 dynamic_config: 1 generated_by: 'ExtUtils::MakeMaker version 6.62, CPAN::Meta::Converter version 2.112150' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 name: File-ShareDir-Install no_index: directory: - t - inc requires: ExtUtils::MakeMaker: 6.11 File::Spec: 0 IO::Dir: 0 version: 0.05 File-ShareDir-Install-0.05/Makefile.PL000064400000000000000000000015201222430454600173700ustar00rootroot00000000000000use 5.008; use ExtUtils::MakeMaker; # See lib/ExtUtils/MakeMaker.pm for details of how to influence # the contents of the Makefile that is written. WriteMakefile( NAME => 'File::ShareDir::Install', VERSION_FROM => 'lib/File/ShareDir/Install.pm', # finds $VERSION LICENSE => 'perl', dist=>{COMPRESS=>'gzip -9f', EXT=>'gz'}, PREREQ_PM => { # Module::Install::Share requires this also... # (known-bad on RHEL 3, with 5.8.0) 'ExtUtils::MakeMaker' => '6.11', 'IO::Dir' => 0, 'File::Spec' => 0, }, ($] >= 5.005 ? ## Add these new keywords supported since 5.005 (ABSTRACT_FROM => 'lib/File/ShareDir/Install.pm', # retrieve abstract from module AUTHOR => 'Philip Gwyn ') : ()), ); File-ShareDir-Install-0.05/README000064400000000000000000000012161222430454600163000ustar00rootroot00000000000000File-ShareDir-Install version 0.01 ================================== 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. INSTALLATION To install this module type the following: perl Makefile.PL make make test make install COPYRIGHT AND LICENCE Copyright (C) 2009-2011 by Philip Gwyn This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available. File-ShareDir-Install-0.05/lib/000075500000000000000000000000001222430454600161665ustar00rootroot00000000000000File-ShareDir-Install-0.05/lib/File/000075500000000000000000000000001222430454600170455ustar00rootroot00000000000000File-ShareDir-Install-0.05/lib/File/ShareDir/000075500000000000000000000000001222430454600205465ustar00rootroot00000000000000File-ShareDir-Install-0.05/lib/File/ShareDir/Install.pm000064400000000000000000000131451222430454600225160ustar00rootroot00000000000000package File::ShareDir::Install; use 5.008; use strict; use warnings; use Carp; use File::Spec; use IO::Dir; our $VERSION = '0.05'; our @DIRS; our %TYPES; require Exporter; our @ISA = qw( Exporter ); our @EXPORT = qw( install_share ); our @EXPORT_OK = qw( postamble install_share ); ##################################################################### sub install_share { my $dir = @_ ? pop : 'share'; my $type = @_ ? shift : 'dist'; unless ( defined $type and $type eq 'module' or $type eq 'dist' ) { confess "Illegal or invalid share dir type '$type'"; } unless ( defined $dir and -d $dir ) { confess "Illegal or missing directory '$dir'"; } if( $type eq 'dist' and @_ ) { confess "Too many parameters to share_dir"; } push @DIRS, $dir; $TYPES{$dir} = [ $type ]; if( $type eq 'module' ) { my $module = _CLASS( $_[0] ); unless ( defined $module ) { confess "Missing or invalid module name '$_[0]'"; } push @{ $TYPES{$dir} }, $module; } } ##################################################################### sub postamble { my $self = shift; my @ret; # = $self->SUPER::postamble( @_ ); foreach my $dir ( @DIRS ) { push @ret, __postamble_share_dir( $self, $dir, @{ $TYPES{ $dir } } ); } return join "\n", @ret; } ##################################################################### sub __postamble_share_dir { my( $self, $dir, $type, $mod ) = @_; my( $idir ); if ( $type eq 'dist' ) { $idir = File::Spec->catdir( '$(INST_LIB)', qw( auto share dist ), '$(DISTNAME)' ); } else { my $module = $mod; $module =~ s/::/-/g; $idir = File::Spec->catdir( '$(INST_LIB)', qw( auto share module ), $module ); } my $files = {}; _scan_share_dir( $files, $idir, $dir ); my $autodir = '$(INST_LIB)'; my $pm_to_blib = $self->oneliner(<split_command( $pm_to_blib, %$files ); my $r = join '', map { "\t\$(NOECHO) $_\n" } @cmds; # use Data::Dumper; # die Dumper $files; # Set up the install return "config::\n$r"; } sub _scan_share_dir { my( $files, $idir, $dir ) = @_; my $dh = IO::Dir->new( $dir ) or die "Unable to read $dir: $!"; my $entry; while( defined( $entry = $dh->read ) ) { next if $entry =~ /^\./ or $entry =~ /(~|,v)$/; my $full = File::Spec->catfile( $dir, $entry ); if( -f $full ) { $files->{ $full } = File::Spec->catfile( $idir, $entry ); } elsif( -d $full ) { _scan_share_dir( $files, File::Spec->catdir( $idir, $entry ), $full ); } } } ##################################################################### # Cloned from Params::Util::_CLASS sub _CLASS ($) { ( defined $_[0] and ! ref $_[0] and $_[0] =~ m/^[^\W\d]\w*(?:::\w+)*$/s ) ? $_[0] : undef; } 1; __END__ =head1 NAME File::ShareDir::Install - Install shared files =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 normaly 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> and other source-control junk 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 will be installed when you run C. To locate the files after installation so they can be used inside your module, see L. my $dir = File::ShareDir::module_dir( $module ); 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 fill called C, the file C will be installed into your C. =head2 postamble Exported into the MY package. Only documented here if you need to write your own postamble. 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 SEE ALSO L, L. =head1 AUTHOR Philip Gwyn, Egwyn-AT-cpan.orgE =head1 COPYRIGHT AND LICENSE Copyright (C) 2009-2011 by Philip Gwyn This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available. =cut File-ShareDir-Install-0.05/t/000075500000000000000000000000001222430454600156635ustar00rootroot00000000000000File-ShareDir-Install-0.05/t/00_compile.t000064400000000000000000000001651222430454600200010ustar00rootroot00000000000000#!/usr/bin/perl use strict; use warnings; use Test::More tests => 1; BEGIN { use_ok('File::ShareDir::Install') }; File-ShareDir-Install-0.05/t/01_pod.t000064400000000000000000000002561222430454600171350ustar00rootroot00000000000000#!/usr/bin/perl use strict; use warnings; 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(); File-ShareDir-Install-0.05/t/02_pod_coverage.t000064400000000000000000000007431222430454600210120ustar00rootroot00000000000000#!/usr/bin/perl use strict; use warnings; use Test::More; eval "use Test::Pod::Coverage 1.00"; plan skip_all => "Test::Pod::Coverage 1.00 required for testing POD coverage" if $@; plan tests => 1; pod_coverage_ok( "File::ShareDir::Install", { also_private => [ # qr/^(OH|SE)_.+$/, # qr/^(handler_for|instantiate|set_objectre)$/ ], }, "File::ShareDir::Install, ignoring private functions", ); File-ShareDir-Install-0.05/t/10_makefile.t000064400000000000000000000055311222430454600201310ustar00rootroot00000000000000#!/usr/bin/perl use strict; use warnings; use Config; use File::Path qw( rmtree ); use Test::More ( tests => 15 ); use ExtUtils::MakeMaker; my $FILE = 'test-Makefile'; rmtree( [ qw( tlib troot ) ], 0, 0 ); END { $FILE and -f $FILE and unlink $FILE; rmtree( [ qw( tlib troot ) ], 0, 0 ); } use File::ShareDir::Install; install_share 't/share'; install_share module => 'My::Test' => 't/module'; delete $ENV{PERL_MM_OPT}; # local::lib + PREFIX below will FAIL # XXX maybe we should just remove INSTALL_BASE=[^ ]+ from PERL_MM_OPT? WriteMakefile( NAME => 'File::ShareDir::Install', VERSION_FROM => 'lib/File/ShareDir/Install.pm', INST_LIB => 'tlib/lib', PREFIX => 'troot', MAKEFILE => $FILE, PREREQ_PM => {}, ($] >= 5.005 ? (ABSTRACT_FROM => 'lib/File/ShareDir/Install.pm', AUTHOR => 'Philip Gwyn ') : ()), ); sub slurp { local @ARGV = @_; local $/; local $.; <>; }; ##### ok( -f $FILE, "Created $FILE" ); my $content = slurp $FILE; ok( $content =~ m(t.share.honk.+share.dist...DISTNAME..honk), "Shared by dist" ); ok( $content =~ m(t.module.bonk.+share.module.My-Test.bonk), "Shared by module" ); ok( $content =~ m(t.module.again.+share.module.My-Test.again), "Shared by module again" ); ok( $content =~ m(t.module.deeper.bonk.+share.module.My-Test.deeper.bonk), "Shared by module in subdirectory" ); ##### mysystem( $Config{make}, '-f', $FILE ); my $TOP = "tlib/lib/auto/share"; ok( -f "$TOP/dist/File-ShareDir-Install/honk", "Copied to blib for dist" ); ok( -f "$TOP/module/My-Test/bonk", "Copied to blib for module" ); ok( -f "$TOP/module/My-Test/again", "Copied to blib for module again" ); ok( -f "$TOP/module/My-Test/deeper/bonk", "Copied to blib for module, in subdir" ); my $c = slurp "$TOP/module/My-Test/bonk"; is( $c, "bonk\n", "Same names" ); $c = slurp "$TOP/module/My-Test/deeper/bonk"; is( $c, "deeper\n", " ... not mixed up" ); ##### mysystem( $Config{make}, '-f', $FILE, 'install' ); unless( $content =~ m(INSTALLSITELIB = (.+)) ) { SKIP: { skip "Can't find INSTALLSITELIB in test-Makefile", 4; } } else { $TOP = "$1/auto/share"; $TOP =~ s/\$\(SITEPREFIX\)/troot/; ok( -f "$TOP/dist/File-ShareDir-Install/honk", "Copied to blib for dist" ); ok( -f "$TOP/module/My-Test/bonk", "Copied to blib for module" ); ok( -f "$TOP/module/My-Test/again", "Copied to blib for module again" ); ok( -f "$TOP/module/My-Test/deeper/bonk", "Copied to blib for module, in subdir" ); } ##################################### sub mysystem { my $cmd = join ' ', @_; my $ret = qx($cmd 2>&1); return unless $?; die "Error running $cmd: ?=$? ret=$ret"; } ########################################################################### package MY; use File::ShareDir::Install qw(postamble); File-ShareDir-Install-0.05/t/module/000075500000000000000000000000001222430454600171505ustar00rootroot00000000000000File-ShareDir-Install-0.05/t/module/again000064400000000000000000000000061222430454600201460ustar00rootroot00000000000000again File-ShareDir-Install-0.05/t/module/bonk000064400000000000000000000000051222430454600200170ustar00rootroot00000000000000bonk File-ShareDir-Install-0.05/t/module/deeper/000075500000000000000000000000001222430454600204145ustar00rootroot00000000000000File-ShareDir-Install-0.05/t/module/deeper/bonk000064400000000000000000000000071222430454600212650ustar00rootroot00000000000000deeper File-ShareDir-Install-0.05/t/share/000075500000000000000000000000001222430454600167655ustar00rootroot00000000000000File-ShareDir-Install-0.05/t/share/honk000064400000000000000000000000001222430454600176350ustar00rootroot00000000000000