blib/lib/Dist/Zilla/Plugin/PodnameFromClassname.pm

filter: Statementstmt 88.5% 31 / 35 Branchbran 50.0% 2 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 7 / 7 Podpod 0.0% 0 / 2 totaltotal 83.3% 40 / 48 CC 4 SCAR 6.5
CC
4
Cov
85%
munge_file
3.4
munge_files
2.0
BEGIN
1.0
CRAP 1.9
↑ Summary
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
BranchTrueFalseTotal
if (not $content =~ /^$optional_ws# PODCLASSNAME:?$/ms) { } 0 1 1
elsif (not $content =~ /^$optional_ws(?:class|library|namespace|role) +([a-zA-Z][a-zA-Z0-9_]*(?:::[a-zA-Z][a-zA-Z0-9_]*)*)/ms) { } 0 1 1
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__
↑ Summary