Permalink
Browse files

Using in-memory open() as commited in 0.05 didn't work. I don't know …

…why, there's a TODO test for this attached

We now use temporary files instead. This is wasteful but I can't find
another way to do this which does the right thing, Pod::Simple's own
`output_string' method keeps giving me text in the incorrect encoding.
  • Loading branch information...
1 parent baf2791 commit 57b3579d3599d8cd48a2f76d63ad7c43fad57019 @avar committed Mar 11, 2010
Showing with 449 additions and 1 deletion.
  1. +5 −0 Changes
  2. +2 −0 dist.ini
  3. +13 −1 lib/Dist/Zilla/Plugin/ReadmeFromPod.pm
  4. +429 −0 t/gist-329018.t
View
@@ -1,5 +1,10 @@
Revision history for Dist-Zilla-Plugin-ReadmeFromPod
+0.06 2010.03.11
+ Using in-memory filehandles as commited in 0.05 doesn't work
+ for some unknown reason. There's a TODO test for this
+ t/gist-329018.t now taken from http://gist.github.com/329018
+
0.05 2010.03.11
Using IO::Scalar instead of Perl's built-in open() to open
in-memory filehandles breaks in-memory Pod::Text processing of
View
@@ -12,6 +12,8 @@ remove = BumpVersion
[Prereq]
Dist::Zilla = 1.007
Pod::Text = 3.13
+IO::Handle = 0
+File::Temp = 0
[PodWeaver]
@@ -4,6 +4,8 @@ package Dist::Zilla::Plugin::ReadmeFromPod;
use Moose;
use Moose::Autobox;
+use IO::Handle;
+use File::Temp qw< tempdir tempfile >;
#with 'Dist::Zilla::Role::FileGatherer';
with 'Dist::Zilla::Role::InstallTool'; # after PodWeaver
@@ -25,7 +27,8 @@ sub setup_installer {
require Dist::Zilla::File::InMemory;
- open(my $out_fh, ">", \my $content);
+ my $dir = tempdir( CLEANUP => 1 );
+ my ($out_fh, $filename) = tempfile( DIR => $dir );
my $mmcontent = $self->zilla->main_module->content;
@@ -34,6 +37,15 @@ sub setup_installer {
$parser->output_fh( $out_fh );
$parser->parse_string_document( $mmcontent );
+ $out_fh->sync();
+ close $out_fh;
+
+ # Do *not* convert this to something that doesn't use open() for
+ # cleverness, that breaks UTF-8 pod files.
+ open(my $fh, "<", $filename) or die "Can't open file '$filename'";
+ my $content = do { local $/; <$fh> };
+ close $fh;
+
my $file = $self->zilla->files->grep( sub { $_->name =~ m{README\z} } )->head;
if ( $file ) {
$file->content( $content );
Oops, something went wrong.

0 comments on commit 57b3579

Please sign in to comment.