| 1 | 5 | ▶ | use strict; use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 2 | package Module::Manifest::Skip; | ||||||||||||||||||||||||||||||||||||||||||
| 3 | 5 | our $VERSION = '0.24'; | |||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||
| 5 | 5 | ▶ | use Moo; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | 5 | has text => ( | |||||||||||||||||||||||||||||||||||||||||
| 8 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 9 | builder => 'text__', | ||||||||||||||||||||||||||||||||||||||||||
| 10 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 11 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||
| 13 | has old_text => ( | ||||||||||||||||||||||||||||||||||||||||||
| 14 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 15 | 1 | ▶ | default => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 17 | 1 | return $self->read_file('MANIFEST.SKIP', 1); | |||||||||||||||||||||||||||||||||||||||||
| 18 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 19 | 5 | ); | |||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||
| 21 | 6 | ▶ | sub import { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
import: called CC=4 SCAR=22.9
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | 6 | my ($package, $command) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 23 | 6 | ▶ | if ($command and $command eq 'create') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$command and $command eq "create"
MC/DC0%0/2
$command and $command eq "create"
$command
$command eq "create"
Truth table33%1/3
A and B
A= $commandB= $command eq "create"
| |||||||||||||||||||||||||||||||||||||||||||
| 24 | 0 | my $text = $package->new->text; | |||||||||||||||||||||||||||||||||||||||||
| 25 | 0 | ▶ | open MS, '>', 'MANIFEST.SKIP' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 26 | or die "Can't open MANIFEST.SKIP for output:\n$!"; | ||||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | print MS $text; | |||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | close MS; | |||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | exit; | |||||||||||||||||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | ▶ | sub add { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | ▶ | my $addition = shift or return; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | chomp $addition; | |||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | ▶ | if (not $self->{add_occurred}++) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | $self->{text} =~ s/\n+\z/\n\n/; | |||||||||||||||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | $self->{text} .= $addition . "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | ▶ | sub remove { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
remove: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | ▶ | my $exclude = shift or return; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | $self->{text} =~ s/^(\Q$exclude\E)$/# $1/mg; | |||||||||||||||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||
| 49 | 1 | ▶ | sub text__ { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
text__: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 50 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 51 | 1 | my $old = $self->old_text; | |||||||||||||||||||||||||||||||||||||||||
| 52 | 1 | ▶ | my $text = ($old =~ /\A(\S.*?\n\n)/s) ? $1 : ''; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 53 | 1 | chomp $text; | |||||||||||||||||||||||||||||||||||||||||
| 54 | 1 | $text .= $self->skip_template; | |||||||||||||||||||||||||||||||||||||||||
| 55 | 1 | local $self->{text} = $text; | |||||||||||||||||||||||||||||||||||||||||
| 56 | 1 | $self->reduce; | |||||||||||||||||||||||||||||||||||||||||
| 57 | 1 | return $self->{text}; | |||||||||||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||
| 60 | 1 | ▶ | sub reduce { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
reduce: called CC=2 SCAR=7.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 61 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 62 | 1 | ▶ | while ($self->{text} =~ s/^- (.*)$/* $1/m) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | $self->remove($1); | |||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||
| 65 | 1 | $self->{text} =~ s/^\* /- /mg; | |||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||
| 68 | 1 | ▶ | sub skip_template { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
skip_template: called CC=8 SCAR=36.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 69 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 70 | 1 | ▶ | my $path = $INC{'Module/Manifest/Skip.pm'} or die; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 71 | 1 | ▶ | if (-e 'lib/Module/Manifest/Skip.pm') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 72 | 1 | return $self->read_file('share/MANIFEST.SKIP'); | |||||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||||
| 74 | ▶ | elsif ($path =~ s!(\S.*?)[\\/]?\blib\b.*!$1! and -e "$path/share") { | |||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$path =~ s[(\S.*?)[\\/]?\blib\b.*][$1] and -e "$path/share"
MC/DC0%0/2
$path =~ s[(\S.*?)[\\/]?\blib\b.*][$1] and -e "$path/share"
$path =~ s[(\S.*?)[\\/]?\blib\b.*][$1]
-e "$path/share"
Truth table0%0/3
A and B
A= $path =~ s[(\S.*?)[\\/]?\blib\b.*][$1]B= -e "$path/share"
| |||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | return $self->read_file("$path/share/MANIFEST.SKIP"); | |||||||||||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||||||||||
| 77 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | require File::ShareDir; | |||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | require File::Spec; | |||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | my $dir = File::ShareDir::dist_dir('Module-Manifest-Skip'); | |||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | my $file = File::Spec->catfile($dir, 'MANIFEST.SKIP'); | |||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | ▶ | die "Can't find MANIFEST.SKIP share file for Module::Manifest::Skip" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$dir and -f $file and -r $file
$dir and -f $file
MC/DC0%0/3
$dir and -f $file and -r $file
$dir
-f $file
-r $file
Truth table0%0/4
A and B and C
A= $dirB= -f $fileC= -r $file
| |||||||||||||||||||||||||||||||||||||||||||
| 83 | unless $dir and -f $file and -r $file; | ||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | return $self->read_file($file); | |||||||||||||||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||
| 88 | 10 | ▶ | sub read_file { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
read_file: called CC=4 SCAR=14.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 89 | 10 | my ($self, $file, $ignore) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 90 | 10 | ▶ | open FILE, $file or | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition60%3/5
open FILE, $file or $ignore and return ""
$ignore and return ""
MC/DC0%0/2
open FILE, $file or $ignore and return ""
open FILE, $file
$ignore
Truth table66%2/3
A or B
A= open FILE, $fileB= $ignore
| |||||||||||||||||||||||||||||||||||||||||||
| 91 | $ignore and return '' or | ||||||||||||||||||||||||||||||||||||||||||
| 92 | die "Can't open '$file' for input:\n$!"; | ||||||||||||||||||||||||||||||||||||||||||
| 93 | 9 | my $text = do { local $/; <FILE> }; | |||||||||||||||||||||||||||||||||||||||||
| 94 | 9 | close FILE; | |||||||||||||||||||||||||||||||||||||||||
| 95 | 9 | $text =~ s/\r//g; | |||||||||||||||||||||||||||||||||||||||||
| 96 | 9 | return $text; | |||||||||||||||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||
| 99 | 5 | 1; | |||||||||||||||||||||||||||||||||||||||||