Dist-Zilla-Plugin-AbstractFromPOD

 view release on metacpan or  search on metacpan

lib/Dist/Zilla/Plugin/AbstractFromPOD.pm  view on Meta::CPAN

package Dist::Zilla::Plugin::AbstractFromPOD;

use 5.008;
use version; our $VERSION = qv( sprintf '0.3.%d', q$Rev: 1 $ =~ /\d+/gmx );

use Moose;
use English                 qw( -no_match_vars );
use File::Spec::Functions   qw( catfile );

with 'Dist::Zilla::Role::BeforeBuild';

sub before_build {
   my $self  = shift;
   my $name  = $self->zilla->name;
   my $class = $name; $class =~ s{ [\-] }{::}gmx;
   my $file  = $self->zilla->_main_module_override
            || catfile( 'lib', split m{ [\-] }mx, "${name}.pm" );

                     $file or die 'No main module specified';
                  -f $file or die "Path ${file} does not exist or not a file";
   open my $fh, '<', $file or die "File ${file} cannot open: ${OS_ERROR}";

   my $content    = do { local $RS; <$fh> }; $fh->close;
   my ($abstract) = $content
      =~ m{ =head1 \s+ Name \s* [\n] \s* $class \s* [\-] \s* ([^\n]+) }imsx;

   $abstract or die "File ${file} contains no abstract";
   $self->zilla->abstract( $abstract );
   return;
}

__PACKAGE__->meta->make_immutable;

no Moose;

1;

__END__

=pod

=encoding utf8

=begin html

<a href="http://badge.fury.io/pl/Dist-Zilla-Plugin-AbstractFromPOD"><img src="https://badge.fury.io/pl/Dist-Zilla-Plugin-AbstractFromPOD.svg" alt="CPAN Badge"></a>
<a href="http://cpants.cpanauthors.org/dist/Dist-Zilla-Plugin-AbstractFromPOD"><img src="http://cpants.cpanauthors.org/dist/Dist-Zilla-Plugin-AbstractFromPOD.png" alt="Kwalitee Badge"></a>

=end html

=head1 Name

Dist::Zilla::Plugin::AbstractFromPOD - Case insensitive head1 POD matching for the Name attribute

=head1 Synopsis

   # In dist.ini
   [AbstractFromPOD]

=head1 Version

This documents version v0.3.$Rev: 1 $ of L<Dist::Zilla::Plugin::AbstractFromPOD>

=head1 Description

Case insensitive head1 POD matching for the Name attribute

L<Dist::Zilla> should do this by default but unfortunately it's pattern
matching is case sensitive so this instead

=head1 Configuration and Environment

Defines no attributes

=head1 Subroutines/Methods

=head2 before_build



( run in 0.810 second using v1.01-cache-2.11-cpan-71847e10f99 )