| 1 | 1 | ▶ | use 5.008; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 2 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | package Dist::Zilla::Plugin::Pod2Readme; | ||||||||||
| 6 | # ABSTRACT: Generate README from Pod, as simply as possible | ||||||||||
| 7 | |||||||||||
| 8 | 1 | our $VERSION = '0.004'; | |||||||||
| 9 | |||||||||||
| 10 | 1 | ▶ | use Dist::Zilla 5 (); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | |||||||||||
| 12 | 1 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | 1 | with 'Dist::Zilla::Role::FileGatherer'; | |||||||||
| 14 | |||||||||||
| 15 | #pod =attr filename | ||||||||||
| 16 | #pod | ||||||||||
| 17 | #pod Name for the generated README. Defaults to 'README'. | ||||||||||
| 18 | #pod | ||||||||||
| 19 | #pod =cut | ||||||||||
| 20 | |||||||||||
| 21 | 1 | has filename => ( | |||||||||
| 22 | is => 'ro', | ||||||||||
| 23 | isa => 'Str', | ||||||||||
| 24 | default => 'README' | ||||||||||
| 25 | ); | ||||||||||
| 26 | |||||||||||
| 27 | #pod =attr source_filename | ||||||||||
| 28 | #pod | ||||||||||
| 29 | #pod The file from which to extract POD for the content of the README. Defaults to | ||||||||||
| 30 | #pod the main module of the distribution. | ||||||||||
| 31 | #pod | ||||||||||
| 32 | #pod =cut | ||||||||||
| 33 | |||||||||||
| 34 | has source_filename => ( | ||||||||||
| 35 | is => 'ro', | ||||||||||
| 36 | isa => 'Str', | ||||||||||
| 37 | lazy => 1, | ||||||||||
| 38 | 1 | ▶ | default => sub { $_[0]->zilla->main_module->name } | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 39 | 1 | ); | |||||||||
| 40 | |||||||||||
| 41 | 2 | ▶ | sub gather_files { | ||||||||
|
Subroutine
gather_files: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 42 | 2 | my $self = shift; | |||||||||
| 43 | |||||||||||
| 44 | 2 | require Dist::Zilla::File::FromCode; | |||||||||
| 45 | 2 | require Pod::Text; | |||||||||
| 46 | 2 | require List::Util; | |||||||||
| 47 | |||||||||||
| 48 | $self->add_file( | ||||||||||
| 49 | Dist::Zilla::File::FromCode->new( | ||||||||||
| 50 | { | ||||||||||
| 51 | name => $self->filename, | ||||||||||
| 52 | 2 | ▶ | code => sub { | ||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||
| 53 | 2 | my $parser = Pod::Text->new(); | |||||||||
| 54 | 2 | $parser->output_string( \( my $text ) ); | |||||||||
| 55 | 2 | my $filename = $self->source_filename; | |||||||||
| 56 | 2 | ▶ | my $source = List::Util::first { $_->name eq $filename } @{ $self->zilla->files }; | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 57 | 2 | ▶ | $self->log_fatal("File $filename not found to extract readme") | ||||||||
|
Branch: 1 branch
| |||||||||||
| 58 | unless defined $source; | ||||||||||
| 59 | 2 | my $pod = $source->content; | |||||||||
| 60 | 2 | $parser->parse_string_document($pod); | |||||||||
| 61 | 2 | return $text; | |||||||||
| 62 | }, | ||||||||||
| 63 | } | ||||||||||
| 64 | ) | ||||||||||
| 65 | 2 | ); | |||||||||
| 66 | |||||||||||
| 67 | 2 | return; | |||||||||
| 68 | } | ||||||||||
| 69 | |||||||||||
| 70 | 1 | 1; | |||||||||
| 71 | |||||||||||
| 72 | |||||||||||
| 73 | # vim: ts=4 sts=4 sw=4 et tw=75: | ||||||||||
| 74 | |||||||||||
| 75 | __END__ | ||||||||||