| 1 | 2 | ▶ | use 5.10.0; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 2 | 2 | ▶ | use strict; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 3 | 2 | ▶ | use warnings; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 4 | |||||||||||||||
| 5 | package Dist::Zilla::Plugin::PodnameFromClassname; | ||||||||||||||
| 6 | |||||||||||||||
| 7 | # ABSTRACT: Insert PODNAME for Moops classes. | ||||||||||||||
| 8 | 2 | our $AUTHORITY = 'cpan:CSSON'; # AUTHORITY | |||||||||||||
| 9 | 2 | our $VERSION = '0.1100'; | |||||||||||||
| 10 | |||||||||||||||
| 11 | 2 | ▶ | use Moose; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 12 | 2 | ▶ | use namespace::autoclean; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 13 | 2 | with ('Dist::Zilla::Role::FileMunger', 'Dist::Zilla::Role::FileFinderUser' => { default_finders => [':InstallModules']}); | |||||||||||||
| 14 | |||||||||||||||
| 15 | 1 | ▶ | sub munge_files { | ||||||||||||
|
Subroutine
munge_files: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||
| 16 | 1 | my $self = shift; | |||||||||||||
| 17 | 1 | $self->munge_file($_) for @{ $self->found_files }; | |||||||||||||
| 18 | } | ||||||||||||||
| 19 | |||||||||||||||
| 20 | 1 | ▶ | sub munge_file { | ||||||||||||
|
Subroutine
munge_file: called CC=3 SCAR=12.2
Pod
undocumented
| |||||||||||||||
| 21 | 1 | my $self = shift; | |||||||||||||
| 22 | 1 | my $file = shift; | |||||||||||||
| 23 | 1 | my $content = $file->content; | |||||||||||||
| 24 | |||||||||||||||
| 25 | 1 | my $optional_ws = qr/[\t ]*/; | |||||||||||||
| 26 | |||||||||||||||
| 27 | 1 | ▶ | if($content !~ m{^$optional_ws# PODCLASSNAME:?$}ms) { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 28 | 0 | $self->log_debug(["Skipping %s, no # PODCLASSNAME directive found", $file->name]); | |||||||||||||
| 29 | 0 | return; | |||||||||||||
| 30 | } | ||||||||||||||
| 31 | elsif($content !~ m{^$optional_ws(?:class|library|namespace|role) +([a-zA-Z][a-zA-Z0-9_]*(?:::[a-zA-Z][a-zA-Z0-9_]*)*)}ms) { | ||||||||||||||
| 32 | 0 | $self->log_debug(["Skipping %s, none of the keywords found", $file->name]); | |||||||||||||
| 33 | 0 | return; | |||||||||||||
| 34 | } | ||||||||||||||
| 35 | 1 | my $classname = $1; | |||||||||||||
| 36 | |||||||||||||||
| 37 | 1 | $content =~ s{^($optional_ws)# PODCLASSNAME:?$}{$1# PODNAME: $classname}ms; | |||||||||||||
| 38 | |||||||||||||||
| 39 | 1 | $self->log(["Inserting podname for $classname"]); | |||||||||||||
| 40 | 1 | $file->content($content); | |||||||||||||
| 41 | |||||||||||||||
| 42 | } | ||||||||||||||
| 43 | |||||||||||||||
| 44 | 2 | __PACKAGE__->meta->make_immutable; | |||||||||||||
| 45 | |||||||||||||||
| 46 | 2 | 1; | |||||||||||||
| 47 | |||||||||||||||
| 48 | __END__ | ||||||||||||||