Skip Menu |

This queue is for tickets about the Dist-Zilla-Plugin-ReadmeFromPod CPAN distribution.

Report information
The Basics
Id: 75272
Status: resolved
Priority: 0/
Queue: Dist-Zilla-Plugin-ReadmeFromPod

People
Owner: Nobody in particular
Requestors: rjbs [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: (no value)



Subject: allow non-main_module file
Instead of always scanning main_module, there should be a filename argument that just defaults to main_module. -- rjbs
From: mitakaa [...] gmail.com
As we discussed on IRC that should do it. Also it follows the recommendtion on ticket #75272 and uses FileGatherer. Also this patch makes the module to explode if a README file already exists. This behaviour could always be skipped by saying something like: [GatherDir] exclude_filename = README On Fri Feb 24 08:05:14 2012, RJBS wrote: Show quoted text
> Instead of always scanning main_module, there should be a filename > argument that just defaults > to main_module.
Subject: zilla-readmefrompod.patch
diff --git a/lib/Dist/Zilla/Plugin/ReadmeFromPod.pm b/lib/Dist/Zilla/Plugin/ReadmeFromPod.pm index c957368..2dbba24 100644 --- a/lib/Dist/Zilla/Plugin/ReadmeFromPod.pm +++ b/lib/Dist/Zilla/Plugin/ReadmeFromPod.pm @@ -5,39 +5,47 @@ use Moose::Autobox; use IO::Handle; use Encode qw( encode ); -with 'Dist::Zilla::Role::InstallTool'; +with 'Dist::Zilla::Role::FileGatherer'; + +has filename => ( + is => 'ro', + isa => 'Str', + lazy => 1, + builder => '_build_filename', +); + +sub _build_filename { + my $self = shift; + $self->zilla->main_module->name; +} -sub setup_installer { +sub gather_files { my ($self, $arg) = @_; - require Dist::Zilla::File::InMemory; - - my $mmcontent = $self->zilla->main_module->content; - - require Pod::Text; - my $parser = Pod::Text->new(); - $parser->output_string( \my $input_content ); - $parser->parse_string_document( $mmcontent ); + require Dist::Zilla::File::FromCode; - my $content; - if( defined $parser->{encoding} ){ - $content = encode( $parser->{encoding} , $input_content ); - } else { - $content = $input_content; - } - - my $file = $self->zilla->files->grep( sub { $_->name =~ m{README\z} } )->head; - - if ( $file ) { - $file->content( $content ); - $self->zilla->log("Override README from [ReadmeFromPod]"); - } else { - $file = Dist::Zilla::File::InMemory->new({ - content => $content, - name => 'README', - }); - $self->add_file($file); - } + my $file = Dist::Zilla::File::FromCode->new({ + code => sub { + my $mmcontent + = $self->zilla->files->grep(sub { $_->name eq $self->filename })->head->content; + + require Pod::Text; + my $parser = Pod::Text->new(); + $parser->output_string( \my $input_content ); + $parser->parse_string_document( $mmcontent ); + + my $content; + if( defined $parser->{encoding} ){ + $content = encode( $parser->{encoding} , $input_content ); + } else { + $content = $input_content; + } + + return $content; + }, + name => 'README', + }); + $self->add_file($file); return; }
patches applied. and new version is on the way CPAN. Thanks