| 1 | package Dist::Dzpl::Parser; | ||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use Dist::Zilla; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 7 | 2 | ▶ | use Dist::Zilla::Chrome::Term; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use Dist::Zilla::Util; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 9 | 2 | ▶ | use Class::MOP; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 10 | 2 | ▶ | use Moose::Autobox; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||
| 12 | 1 | ▶ | sub parse { | ||||||||||||||||||||||||||||
|
Subroutine
parse: called CC=11 SCAR=27.2
Pod
undocumented
| |||||||||||||||||||||||||||||||
| 13 | 1 | my $self = shift; | |||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||
| 15 | 1 | my ( %zilla, @prerequisite ); | |||||||||||||||||||||||||||||
| 16 | 1 | ▶ | while( @_ ) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 17 | 5 | local $_ = shift; | |||||||||||||||||||||||||||||
| 18 | 5 | ▶ | if ( m/\A(?:authors?|by)\z/ ) { $self->_parse_author( \%zilla, shift ) } | ||||||||||||||||||||||||||||
|
Branch: 6 branches
| |||||||||||||||||||||||||||||||
| 19 | 1 | elsif ( m/\Acopyright\z/) { $self->_parse_copyright( \%zilla => shift ) } | |||||||||||||||||||||||||||||
| 20 | 1 | elsif ( m/\Alicense\z/) { $self->_parse_license( \%zilla => shift ) } | |||||||||||||||||||||||||||||
| 21 | 0 | elsif ( m/\Arequire\z/) { $self->_parse_prerequisite( \@prerequisite => require => shift ) } | |||||||||||||||||||||||||||||
| 22 | 0 | elsif ( m/\Arecommend\z/) { $self->_parse_prerequisite( \@prerequisite => recommend => shift ) } | |||||||||||||||||||||||||||||
| 23 | 0 | elsif ( m/\Aprefer\z/) { $self->_parse_prerequisite( \@prerequisite => prefer => shift ) } | |||||||||||||||||||||||||||||
| 24 | 2 | else { $zilla{$_} = shift } | |||||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||
| 27 | 1 | ▶ | $zilla{ chrome } ||= Dist::Zilla::Chrome::Term->new; | ||||||||||||||||||||||||||||
|
Condition33%1/3
$zilla{"chrome"} ||= "Dist::Zilla::Chrome::Term"->new
MC/DC0%0/2
$zilla{"chrome"} ||= "Dist::Zilla::Chrome::Term"->new
$zilla{"chrome"}
"Dist::Zilla::Chrome::Term"->new
Truth table33%1/3
A ||= B
A= $zilla{"chrome"}B= "Dist::Zilla::Chrome::Term"->new
| |||||||||||||||||||||||||||||||
| 28 | 1 | ▶ | $zilla{ root } ||= '.'; | ||||||||||||||||||||||||||||
|
Condition50%1/2
$zilla{"root"} ||= "."
MC/DC0%0/1
$zilla{"root"} ||= "."
$zilla{"root"}
Truth table50%1/2
A
A= $zilla{"root"}
| |||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||
| 30 | 1 | my $zilla = Dist::Zilla->new( %zilla ); | |||||||||||||||||||||||||||||
| 31 | 1 | for my $prerequisite (@prerequisite) { | |||||||||||||||||||||||||||||
| 32 | 0 | my ( $phase, $type, $manifest ) = @$prerequisite{qw/ phase type manifest /}; | |||||||||||||||||||||||||||||
| 33 | 0 | $phase = lc $phase; | |||||||||||||||||||||||||||||
| 34 | 0 | $type = "${type}s"; | |||||||||||||||||||||||||||||
| 35 | 0 | $zilla->register_prereqs( { phase => $phase, type => $type }, @$manifest ); | |||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||
| 38 | 1 | return $zilla; | |||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||
| 41 | 6 | ▶ | sub _parse_prerequisite { | ||||||||||||||||||||||||||||
|
Subroutine
_parse_prerequisite: called CC=11 SCAR=24.4
| |||||||||||||||||||||||||||||||
| 42 | 6 | my $self = shift; | |||||||||||||||||||||||||||||
| 43 | 6 | my $stash = shift; | |||||||||||||||||||||||||||||
| 44 | 6 | my $importance = shift; | |||||||||||||||||||||||||||||
| 45 | 6 | my $input = shift; | |||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||
| 47 | 6 | ▶ | die "Missing input" unless defined $input && length $input; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $input and length $input
MC/DC0%0/2
defined $input and length $input
defined $input
length $input
Truth table33%1/3
A and B
A= defined $inputB= length $input
| |||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||
| 49 | 6 | my @stash; | |||||||||||||||||||||||||||||
| 50 | 6 | my $manifest = []; | |||||||||||||||||||||||||||||
| 51 | 6 | push @stash, { phase => 'runtime', type => $importance, manifest => $manifest }; | |||||||||||||||||||||||||||||
| 52 | 6 | for my $line ( split m/\n/, $input ) { | |||||||||||||||||||||||||||||
| 53 | 21 | s/^\s*//, s/\s*$// for $line; | |||||||||||||||||||||||||||||
| 54 | 21 | ▶ | next if $line =~ m/^#/ || $line !~ m/\S/; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$line =~ /^#/ or not $line =~ /\S/
MC/DC50%1/2
$line =~ /^#/ or not $line =~ /\S/
$line =~ /^#/
not $line =~ /\S/
Truth table66%2/3
A or not(B)
A= $line =~ /^#/B= not $line =~ /\S/
| |||||||||||||||||||||||||||||||
| 55 | 18 | ▶ | if ( | ||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$line =~ /\A\@([\w\-]+):\z/ or $line =~ /\A\[([\w\-]+)\]\z/
MC/DC50%1/2
$line =~ /\A\@([\w\-]+):\z/ or $line =~ /\A\[([\w\-]+)\]\z/
$line =~ /\A\@([\w\-]+):\z/
$line =~ /\A\[([\w\-]+)\]\z/
Truth table66%2/3
A or B
A= $line =~ /\A\@([\w\-]+):\z/B= $line =~ /\A\[([\w\-]+)\]\z/
| |||||||||||||||||||||||||||||||
| 56 | $line =~ m/\A\@([\w\-]+):\z/ || # @Test: | ||||||||||||||||||||||||||||||
| 57 | $line =~ m/\A\[([\w\-]+)\]\z/ # [Test] | ||||||||||||||||||||||||||||||
| 58 | ) { | ||||||||||||||||||||||||||||||
| 59 | 9 | push @stash, { phase => lc $1, type => $importance, manifest => ( $manifest = [] ) }; | |||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||
| 61 | else { | ||||||||||||||||||||||||||||||
| 62 | 9 | my ( $package, $version ) = split m/\s+/, $line, 2; | |||||||||||||||||||||||||||||
| 63 | 9 | ▶ | $package = $line unless defined $package; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 64 | 9 | ▶ | $version ||= 0; | ||||||||||||||||||||||||||||
|
Condition100%2/2
$version ||= 0
MC/DC100%1/1
$version ||= 0
$version
Truth table100%2/2
A
A= $version
| |||||||||||||||||||||||||||||||
| 65 | 9 | push @$manifest, ( $package => $version ); | |||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||
| 69 | 6 | push @$stash, grep { @{ $_->{manifest} } > 0 } @stash; | |||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||
| 72 | 2 | ▶ | sub _parse_author { | ||||||||||||||||||||||||||||
|
Subroutine
_parse_author: called CC=5 SCAR=16.2
| |||||||||||||||||||||||||||||||
| 73 | 2 | my $self = shift; | |||||||||||||||||||||||||||||
| 74 | 2 | my $zilla = shift; | |||||||||||||||||||||||||||||
| 75 | 2 | my $input = shift; | |||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||
| 77 | 2 | my @author; | |||||||||||||||||||||||||||||
| 78 | 2 | ▶ | if ( ref $input eq 'ARRAY' ) { | ||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||
| 79 | 0 | @author = @$input; | |||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||
| 81 | elsif ( $input =~ m/\n/ ) { | ||||||||||||||||||||||||||||||
| 82 | 1 | for my $line ( split m/\n/, $input ) { | |||||||||||||||||||||||||||||
| 83 | 4 | local $_ = $line; | |||||||||||||||||||||||||||||
| 84 | 4 | ▶ | next unless m/\S/; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 85 | 2 | $line =~ s/^\s*//, s/\s*$//; | |||||||||||||||||||||||||||||
| 86 | 2 | push @author, $line; | |||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||
| 89 | else { | ||||||||||||||||||||||||||||||
| 90 | 1 | @author = ($input); | |||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||
| 93 | 2 | $zilla->{authors} = \@author; | |||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||
| 96 | 4 | ▶ | sub _parse_copyright { | ||||||||||||||||||||||||||||
|
Subroutine
_parse_copyright: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||
| 97 | 4 | my $self = shift; | |||||||||||||||||||||||||||||
| 98 | 4 | my $zilla = shift; | |||||||||||||||||||||||||||||
| 99 | 4 | my $input = shift; | |||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||
| 101 | 4 | ▶ | if ( $input =~ m/\A\s*(\d{4})\s+(.+?)\s*\z/ ) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 102 | 2 | $zilla->{copyright_year} = $1; | |||||||||||||||||||||||||||||
| 103 | 2 | $zilla->{copyright_holder} = $2; | |||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||
| 105 | else { | ||||||||||||||||||||||||||||||
| 106 | 2 | $zilla->{copyright_holder} = $input; | |||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||
| 110 | 4 | ▶ | sub _parse_license { | ||||||||||||||||||||||||||||
|
Subroutine
_parse_license: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||
| 111 | 4 | my $self = shift; | |||||||||||||||||||||||||||||
| 112 | 4 | my $zilla = shift; | |||||||||||||||||||||||||||||
| 113 | 4 | my $input = shift; | |||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||
| 115 | 4 | my $license = $input; | |||||||||||||||||||||||||||||
| 116 | 4 | ▶ | if ( $license =~ m/\APerl[\-_]?5/ ) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 117 | 4 | $license = 'Perl_5'; | |||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||
| 120 | 4 | $zilla->{license} = $license; | |||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||
| 124 | 2 | 1; | |||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||