[Bps-public-commit] r9286 - in IPC-Run-SafeHandles: . lib lib/IPC t
clkao at bestpractical.com
clkao at bestpractical.com
Fri Oct 12 12:33:27 EDT 2007
Author: clkao
Date: Fri Oct 12 12:33:26 2007
New Revision: 9286
Added:
IPC-Run-SafeHandles/.cvsignore
IPC-Run-SafeHandles/Changes
IPC-Run-SafeHandles/MANIFEST
IPC-Run-SafeHandles/Makefile.PL
IPC-Run-SafeHandles/README
IPC-Run-SafeHandles/lib/
IPC-Run-SafeHandles/lib/IPC/
IPC-Run-SafeHandles/lib/IPC/Run/
IPC-Run-SafeHandles/lib/IPC/Run/SafeHandles.pm
IPC-Run-SafeHandles/t/
IPC-Run-SafeHandles/t/00-load.t
IPC-Run-SafeHandles/t/boilerplate.t
IPC-Run-SafeHandles/t/pod-coverage.t
IPC-Run-SafeHandles/t/pod.t
Log:
first cut of IPC::Run::SafeHandles.
Added: IPC-Run-SafeHandles/.cvsignore
==============================================================================
--- (empty file)
+++ IPC-Run-SafeHandles/.cvsignore Fri Oct 12 12:33:26 2007
@@ -0,0 +1,10 @@
+blib*
+Makefile
+Makefile.old
+Build
+_build*
+pm_to_blib*
+*.tar.gz
+.lwpcookies
+IPC-Run-SafeHandles-*
+cover_db
Added: IPC-Run-SafeHandles/Changes
==============================================================================
--- (empty file)
+++ IPC-Run-SafeHandles/Changes Fri Oct 12 12:33:26 2007
@@ -0,0 +1,5 @@
+Revision history for IPC-Run-SafeHandles
+
+0.01 Oct 13, 2007
+ Initial CPAN release.
+
Added: IPC-Run-SafeHandles/MANIFEST
==============================================================================
--- (empty file)
+++ IPC-Run-SafeHandles/MANIFEST Fri Oct 12 12:33:26 2007
@@ -0,0 +1,10 @@
+Changes
+MANIFEST
+META.yml # Will be created by "make dist"
+Makefile.PL
+README
+lib/IPC/Run/SafeHandles.pm
+t/00-load.t
+t/boilerplate.t
+t/pod-coverage.t
+t/pod.t
Added: IPC-Run-SafeHandles/Makefile.PL
==============================================================================
--- (empty file)
+++ IPC-Run-SafeHandles/Makefile.PL Fri Oct 12 12:33:26 2007
@@ -0,0 +1,16 @@
+use strict;
+use warnings;
+use ExtUtils::MakeMaker;
+
+WriteMakefile(
+ NAME => 'IPC::Run::SafeHandles',
+ AUTHOR => 'Chia-liang Kao <clkao at bestpractical.com>',
+ VERSION_FROM => 'lib/IPC/Run/SafeHandles.pm',
+ ABSTRACT_FROM => 'lib/IPC/Run/SafeHandles.pm',
+ PL_FILES => {},
+ PREREQ_PM => {
+ 'Test::More' => 0,
+ },
+ dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
+ clean => { FILES => 'IPC-Run-SafeHandles-*' },
+);
Added: IPC-Run-SafeHandles/README
==============================================================================
--- (empty file)
+++ IPC-Run-SafeHandles/README Fri Oct 12 12:33:26 2007
@@ -0,0 +1,54 @@
+NAME
+ IPC::Run::SafeHandles - Use IPC::Run and IPC::Run3 safely
+
+SYNOPSIS
+ use IPC::Run::SafeHandles;
+
+DESCRIPTION
+ IPC::Run and IPC::Run3 are both very upset when you try to use them
+ under environments where you have STDOUT and/or STDERR tied to something
+ else, such as under fastcgi.
+
+ The module adds safe-guarding code when you call IPC::Run or IPC::Run3
+ under such environment to make sure it always works.
+
+ If you intend to release your code to work under normal envionrment as
+ well as under fastcgi, simply use this module *after* the "IPC" modules
+ are loaded in your code.
+
+AUTHOR
+ Chia-liang Kao, "<clkao at bestpractical.com>"
+
+BUGS
+ Please report any bugs or feature requests to "bug-ipc-run-safehandles
+ at rt.cpan.org", or through the web interface at
+ <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=IPC-Run-SafeHandles>. I
+ will be notified, and then you'll automatically be notified of progress
+ on your bug as I make changes.
+
+SUPPORT
+ You can find documentation for this module with the perldoc command.
+
+ perldoc IPC::Run::SafeHandles
+
+ You can also look for information at:
+
+ * AnnoCPAN: Annotated CPAN documentation
+ <http://annocpan.org/dist/IPC-Run-SafeHandles>
+
+ * CPAN Ratings
+ <http://cpanratings.perl.org/d/IPC-Run-SafeHandles>
+
+ * RT: CPAN's request tracker
+ <http://rt.cpan.org/NoAuth/Bugs.html?Dist=IPC-Run-SafeHandles>
+
+ * Search CPAN
+ <http://search.cpan.org/dist/IPC-Run-SafeHandles>
+
+ACKNOWLEDGEMENTS
+COPYRIGHT & LICENSE
+ Copyright 2007 Chia-liang Kao, all rights reserved.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the same terms as Perl itself.
+
Added: IPC-Run-SafeHandles/lib/IPC/Run/SafeHandles.pm
==============================================================================
--- (empty file)
+++ IPC-Run-SafeHandles/lib/IPC/Run/SafeHandles.pm Fri Oct 12 12:33:26 2007
@@ -0,0 +1,135 @@
+package IPC::Run::SafeHandles;
+
+use warnings;
+use strict;
+use IO::Handle ();
+
+=head1 NAME
+
+IPC::Run::SafeHandles - Use IPC::Run and IPC::Run3 safely
+
+=cut
+
+our $VERSION = '0.01';
+
+=head1 SYNOPSIS
+
+ use IPC::Run::SafeHandles;
+
+=head1 DESCRIPTION
+
+L<IPC::Run> and L<IPC::Run3> are both very upset when you try to use
+them under environments where you have STDOUT and/or STDERR tied to
+something else, such as under fastcgi.
+
+The module adds safe-guarding code when you call L<IPC::Run> or
+L<IPC::Run3> under such environment to make sure it always works.
+
+If you intend to release your code to work under normal envionrment
+as well as under fastcgi, simply use this module I<after> the C<IPC>
+modules are loaded in your code.
+
+=cut
+
+my $wrapper_context = [];
+
+sub import {
+ _wrap_it('IPC::Run::run') if $INC{'IPC/Run.pm'};
+ _wrap_it('IPC::Run3::run3') if $INC{'IPC/Run3.pm'};
+
+ unless (@$wrapper_context) {
+ Carp::carp "Use of IPC::Run::SafeHandles wihtout using IPC::Run or IPC::Run3 first";
+ }
+}
+
+sub _wrap_it {
+ no strict 'refs';
+ my $typeglob = shift;
+ my $original = *$typeglob{CODE};
+ my $unwrap = 0;
+
+ my $wrapper = sub {
+
+ goto &$original unless $ENV{FCGI_ROLE};
+
+ my $stdout = IO::Handle->new;
+ $stdout->fdopen( 1, 'w' );
+ local *STDOUT = $stdout;
+
+ my $stderr = IO::Handle->new;
+ $stderr->fdopen( 2, 'w' );
+ local *STDERR = $stderr;
+ goto &$original;
+ };
+ no warnings 'redefine';
+ *{$typeglob} = $wrapper;
+ push @$wrapper_context,
+ bless(sub { no warnings 'redefine';
+ *{$typeglob} = $original }, __PACKAGE__);
+}
+
+=head2 unimport
+
+When unimport, the original L<IPC::Run> and/or L<IPC::Run3> functions
+are restored.
+
+=cut
+
+sub unimport {
+ $wrapper_context = [];
+}
+
+sub DESTROY { $_[0]->() }
+
+=head1 AUTHOR
+
+Chia-liang Kao, C<< <clkao at bestpractical.com> >>
+
+=head1 BUGS
+
+Please report any bugs or feature requests to
+C<bug-ipc-run-safehandles at rt.cpan.org>, or through the web interface at
+L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=IPC-Run-SafeHandles>.
+I will be notified, and then you'll automatically be notified of progress on
+your bug as I make changes.
+
+=head1 SUPPORT
+
+You can find documentation for this module with the perldoc command.
+
+ perldoc IPC::Run::SafeHandles
+
+You can also look for information at:
+
+=over 4
+
+=item * AnnoCPAN: Annotated CPAN documentation
+
+L<http://annocpan.org/dist/IPC-Run-SafeHandles>
+
+=item * CPAN Ratings
+
+L<http://cpanratings.perl.org/d/IPC-Run-SafeHandles>
+
+=item * RT: CPAN's request tracker
+
+L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=IPC-Run-SafeHandles>
+
+=item * Search CPAN
+
+L<http://search.cpan.org/dist/IPC-Run-SafeHandles>
+
+=back
+
+=head1 ACKNOWLEDGEMENTS
+
+=head1 COPYRIGHT & LICENSE
+
+Copyright 2007 Chia-liang Kao, all rights reserved.
+
+This program is free software; you can redistribute it and/or modify it
+under the same terms as Perl itself.
+
+=cut
+
+1; # End of IPC::Run::SafeHandles
Added: IPC-Run-SafeHandles/t/00-load.t
==============================================================================
--- (empty file)
+++ IPC-Run-SafeHandles/t/00-load.t Fri Oct 12 12:33:26 2007
@@ -0,0 +1,9 @@
+#!perl -T
+
+use Test::More tests => 1;
+
+BEGIN {
+ use_ok( 'IPC::Run::SafeHandles' );
+}
+
+diag( "Testing IPC::Run::SafeHandles $IPC::Run::SafeHandles::VERSION, Perl $], $^X" );
Added: IPC-Run-SafeHandles/t/boilerplate.t
==============================================================================
--- (empty file)
+++ IPC-Run-SafeHandles/t/boilerplate.t Fri Oct 12 12:33:26 2007
@@ -0,0 +1,48 @@
+#!perl -T
+
+use strict;
+use warnings;
+use Test::More tests => 3;
+
+sub not_in_file_ok {
+ my ($filename, %regex) = @_;
+ open my $fh, "<", $filename
+ or die "couldn't open $filename for reading: $!";
+
+ my %violated;
+
+ while (my $line = <$fh>) {
+ while (my ($desc, $regex) = each %regex) {
+ if ($line =~ $regex) {
+ push @{$violated{$desc}||=[]}, $.;
+ }
+ }
+ }
+
+ if (%violated) {
+ fail("$filename contains boilerplate text");
+ diag "$_ appears on lines @{$violated{$_}}" for keys %violated;
+ } else {
+ pass("$filename contains no boilerplate text");
+ }
+}
+
+not_in_file_ok(README =>
+ "The README is used..." => qr/The README is used/,
+ "'version information here'" => qr/to provide version information/,
+);
+
+not_in_file_ok(Changes =>
+ "placeholder date/time" => qr(Date/time)
+);
+
+sub module_boilerplate_ok {
+ my ($module) = @_;
+ not_in_file_ok($module =>
+ 'the great new $MODULENAME' => qr/ - The great new /,
+ 'boilerplate description' => qr/Quick summary of what the module/,
+ 'stub function definition' => qr/function[12]/,
+ );
+}
+
+module_boilerplate_ok('lib/IPC/Run/SafeHandles.pm');
Added: IPC-Run-SafeHandles/t/pod-coverage.t
==============================================================================
--- (empty file)
+++ IPC-Run-SafeHandles/t/pod-coverage.t Fri Oct 12 12:33:26 2007
@@ -0,0 +1,6 @@
+#!perl -T
+
+use Test::More;
+eval "use Test::Pod::Coverage 1.04";
+plan skip_all => "Test::Pod::Coverage 1.04 required for testing POD coverage" if $@;
+all_pod_coverage_ok();
Added: IPC-Run-SafeHandles/t/pod.t
==============================================================================
--- (empty file)
+++ IPC-Run-SafeHandles/t/pod.t Fri Oct 12 12:33:26 2007
@@ -0,0 +1,6 @@
+#!perl -T
+
+use Test::More;
+eval "use Test::Pod 1.14";
+plan skip_all => "Test::Pod 1.14 required for testing POD" if $@;
+all_pod_files_ok();
More information about the Bps-public-commit
mailing list