| 1 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 2 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 3 | ▶ | use feature 'switch'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 3 | ▶ | use utf8; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | package Dist::Zilla::PluginBundle::Author::RTHOMPSON; | ||||||||||||||||||||||||||||
| 7 | # ABSTRACT: RTHOMPSON's Dist::Zilla Configuration | ||||||||||||||||||||||||||||
| 8 | 3 | $Dist::Zilla::PluginBundle::Author::RTHOMPSON::VERSION = '0.163250'; # TRIAL | |||||||||||||||||||||||||||
| 9 | 3 | ▶ | use Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 3 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 3 | with 'Dist::Zilla::Role::PluginBundle::Easy'; | |||||||||||||||||||||||||||
| 12 | 3 | with 'Dist::Zilla::Role::PluginBundle::Config::Slicer'; | |||||||||||||||||||||||||||
| 13 | 3 | with 'Dist::Zilla::Role::PluginBundle::PluginRemover'; | |||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 6 | ▶ | sub mvp_multivalue_args { qw( copy_file move_file allow_dirty ) } | ||||||||||||||||||||||||||
|
Subroutine
mvp_multivalue_args: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | # Returns true for strings of 'true', 'yes', or positive numbers, | ||||||||||||||||||||||||||||
| 18 | # false otherwise. | ||||||||||||||||||||||||||||
| 19 | 12 | ▶ | sub _parse_bool { | ||||||||||||||||||||||||||
|
Subroutine
_parse_bool: called CC=4 SCAR=14.9
| |||||||||||||||||||||||||||||
| 20 | 12 | ▶ | $_ ||= ''; | ||||||||||||||||||||||||||
|
Condition50%1/2
$_ ||= ""
MC/DC0%0/1
$_ ||= ""
$_
Truth table50%1/2
A
A= $_
| |||||||||||||||||||||||||||||
| 21 | 12 | ▶ | return 1 if $_[0] =~ m{^(true|yes|1)$}xsmi; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 22 | 2 | ▶ | return if $_[0] =~ m{^(false|no|0)$}xsmi; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 23 | 0 | die "Invalid boolean value $_[0]. Valid values are true/yes/1 or false/no/0"; | |||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 6 | ▶ | sub configure { | ||||||||||||||||||||||||||
|
Subroutine
configure: called CC=22 SCAR=32.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 27 | 6 | my $self = shift; | |||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | 6 | my $defaults = { | |||||||||||||||||||||||||||
| 30 | # AutoVersion by default | ||||||||||||||||||||||||||||
| 31 | version => 'auto', | ||||||||||||||||||||||||||||
| 32 | # Assume that the module is experimental unless told | ||||||||||||||||||||||||||||
| 33 | # otherwise. | ||||||||||||||||||||||||||||
| 34 | version_major => 0, | ||||||||||||||||||||||||||||
| 35 | # Assume that synopsis is perl code and should compile | ||||||||||||||||||||||||||||
| 36 | # cleanly. | ||||||||||||||||||||||||||||
| 37 | synopsis_is_perl_code => 1, | ||||||||||||||||||||||||||||
| 38 | # Realease to CPAN for real | ||||||||||||||||||||||||||||
| 39 | release => 'real', | ||||||||||||||||||||||||||||
| 40 | # Archive releases | ||||||||||||||||||||||||||||
| 41 | archive => 1, | ||||||||||||||||||||||||||||
| 42 | archive_directory => 'releases', | ||||||||||||||||||||||||||||
| 43 | # version control system = git | ||||||||||||||||||||||||||||
| 44 | vcs => 'git', | ||||||||||||||||||||||||||||
| 45 | git_remote => 'origin', | ||||||||||||||||||||||||||||
| 46 | git_branch => 'master', | ||||||||||||||||||||||||||||
| 47 | allow_dirty => [ 'dist.ini', 'README.pod', 'Changes' ], | ||||||||||||||||||||||||||||
| 48 | }; | ||||||||||||||||||||||||||||
| 49 | 6 | my %args = (%$defaults, %{$self->payload}); | |||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | # Add appropriate version plugin, if any | ||||||||||||||||||||||||||||
| 52 | 6 | ▶ | if (lc($args{version}) eq 'auto') { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 53 | $self->add_plugins( | ||||||||||||||||||||||||||||
| 54 | 3 | [ 'AutoVersion' => { major => $args{version_major} } ] | |||||||||||||||||||||||||||
| 55 | ); | ||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||
| 57 | 12 | elsif (grep { lc($args{version}) eq $_ } (qw(disable none false), q())) { | |||||||||||||||||||||||||||
| 58 | 2 | delete $args{version}; | |||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||
| 60 | else { | ||||||||||||||||||||||||||||
| 61 | $self->add_plugins( | ||||||||||||||||||||||||||||
| 62 | 1 | [ 'StaticVersion' => { version => $args{version} } ] | |||||||||||||||||||||||||||
| 63 | ); | ||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | # Copy/move files from build dir. The "copy_file" and "move_file" | ||||||||||||||||||||||||||||
| 67 | # arguments get passed to CopyFilesFromBuild as "copy" and "move" | ||||||||||||||||||||||||||||
| 68 | # respectively. | ||||||||||||||||||||||||||||
| 69 | 6 | my %cffb_opt_hash = (); | |||||||||||||||||||||||||||
| 70 | 6 | for my $opt ("copy", "move") { | |||||||||||||||||||||||||||
| 71 | 12 | ▶ | if ($args{"${opt}_file"} and @{$args{"${opt}_file"}}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$args{"${opt}_file"} and @{$args{"${opt}_file"};}
MC/DC50%1/2
$args{"${opt}_file"} and @{$args{"${opt}_file"};}
$args{"${opt}_file"}
@{$args{"${opt}_file"};}
Truth table66%2/3
A and B
A= $args{"${opt}_file"}B= @{$args{"${opt}_file"};}
| |||||||||||||||||||||||||||||
| 72 | 2 | $cffb_opt_hash{$opt} = $args{"${opt}_file"}; | |||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||
| 75 | 6 | ▶ | if (keys %cffb_opt_hash) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 76 | 1 | $self->add_plugins([ 'CopyFilesFromBuild' => \%cffb_opt_hash ]); | |||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | # Decide whether to test SYNOPSIS for syntax. | ||||||||||||||||||||||||||||
| 80 | 6 | ▶ | if (_parse_bool($args{synopsis_is_perl_code})) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 81 | 5 | $self->add_plugins('Test::Synopsis'); | |||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | # Choose release plugin | ||||||||||||||||||||||||||||
| 85 | 6 | for ($args{release}) { | |||||||||||||||||||||||||||
| 86 | 6 | ▶ | if (lc eq 'real') { | ||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||
| 87 | 0 | $self->add_plugins('UploadToCPAN') | |||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||
| 89 | elsif (lc eq 'fake') { | ||||||||||||||||||||||||||||
| 90 | 6 | $self->add_plugins('FakeRelease') | |||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||
| 92 | elsif (lc eq 'none') { | ||||||||||||||||||||||||||||
| 93 | # No release plugin | ||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||
| 95 | elsif ($_) { | ||||||||||||||||||||||||||||
| 96 | 0 | $self->add_plugins("$_") | |||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||
| 98 | else { | ||||||||||||||||||||||||||||
| 99 | # Empty string is the same as 'none' | ||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | # Choose whether and where to archive releases | ||||||||||||||||||||||||||||
| 104 | 6 | ▶ | if (_parse_bool($args{archive})) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 105 | $self->add_plugins( | ||||||||||||||||||||||||||||
| 106 | ['ArchiveRelease' => { | ||||||||||||||||||||||||||||
| 107 | directory => $args{archive_directory}, | ||||||||||||||||||||||||||||
| 108 | 5 | } ] | |||||||||||||||||||||||||||
| 109 | ); | ||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | # All the invariant plugins | ||||||||||||||||||||||||||||
| 113 | $self->add_plugins( | ||||||||||||||||||||||||||||
| 114 | # @Basic | ||||||||||||||||||||||||||||
| 115 | 6 | 'GatherDir', | |||||||||||||||||||||||||||
| 116 | 'PruneCruft', | ||||||||||||||||||||||||||||
| 117 | 'ManifestSkip', | ||||||||||||||||||||||||||||
| 118 | 'MetaYAML', | ||||||||||||||||||||||||||||
| 119 | 'MetaJSON', | ||||||||||||||||||||||||||||
| 120 | 'License', | ||||||||||||||||||||||||||||
| 121 | 'ExecDir', | ||||||||||||||||||||||||||||
| 122 | 'ShareDir', | ||||||||||||||||||||||||||||
| 123 | 'MakeMaker', | ||||||||||||||||||||||||||||
| 124 | 'Manifest', | ||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||
| 126 | # Add provides section to META.yml | ||||||||||||||||||||||||||||
| 127 | 'MetaProvides::Package', | ||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||
| 129 | # Don't include the corpus directory, it's just for files that | ||||||||||||||||||||||||||||
| 130 | # tests will run on | ||||||||||||||||||||||||||||
| 131 | [ 'MetaNoIndex' => { dir => 'corpus' } ], | ||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||
| 133 | # Mods | ||||||||||||||||||||||||||||
| 134 | 'PkgVersion', | ||||||||||||||||||||||||||||
| 135 | # TODO: Only add PodWeaver if weaver.ini exists | ||||||||||||||||||||||||||||
| 136 | 'PodWeaver', | ||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||
| 138 | # Generated Docs | ||||||||||||||||||||||||||||
| 139 | 'InstallGuide', | ||||||||||||||||||||||||||||
| 140 | ['ReadmeAnyFromPod', 'ReadmeTextInBuild'], | ||||||||||||||||||||||||||||
| 141 | # This one gets copied out of the build dir by default, and | ||||||||||||||||||||||||||||
| 142 | # does not become part of the dist. | ||||||||||||||||||||||||||||
| 143 | ['ReadmeAnyFromPod', 'ReadmePodInRoot ' => { | ||||||||||||||||||||||||||||
| 144 | phase => 'release', | ||||||||||||||||||||||||||||
| 145 | }], | ||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||
| 147 | # Tests | ||||||||||||||||||||||||||||
| 148 | 'Test::Perl::Critic', | ||||||||||||||||||||||||||||
| 149 | 'PodCoverageTests', | ||||||||||||||||||||||||||||
| 150 | 'PodSyntaxTests', | ||||||||||||||||||||||||||||
| 151 | 'HasVersionTests', | ||||||||||||||||||||||||||||
| 152 | 'Test::Portability', | ||||||||||||||||||||||||||||
| 153 | 'Test::UnusedVars', | ||||||||||||||||||||||||||||
| 154 | ['Test::Compile' => { | ||||||||||||||||||||||||||||
| 155 | # The test files don't seem to compile in the context of | ||||||||||||||||||||||||||||
| 156 | # this test. But it's ok, because if they really have | ||||||||||||||||||||||||||||
| 157 | # problems, they'll fail to compile when they run. | ||||||||||||||||||||||||||||
| 158 | skip => 'Test$', | ||||||||||||||||||||||||||||
| 159 | }], | ||||||||||||||||||||||||||||
| 160 | 'Test::Kwalitee', | ||||||||||||||||||||||||||||
| 161 | 'ExtraTests', | ||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||
| 163 | # Prerequisite checks | ||||||||||||||||||||||||||||
| 164 | 'ReportVersions', | ||||||||||||||||||||||||||||
| 165 | 'MinimumPerl', | ||||||||||||||||||||||||||||
| 166 | 'AutoPrereqs', | ||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||
| 168 | # Release checks | ||||||||||||||||||||||||||||
| 169 | 'CheckChangesHasContent', | ||||||||||||||||||||||||||||
| 170 | 'CheckPrereqsIndexed', | ||||||||||||||||||||||||||||
| 171 | 'CheckVersionIncrement', | ||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||
| 173 | # Release | ||||||||||||||||||||||||||||
| 174 | 'NextRelease', | ||||||||||||||||||||||||||||
| 175 | 'TestRelease', | ||||||||||||||||||||||||||||
| 176 | ); | ||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||
| 178 | # Choose version control. This must be after 'NextRelease' so that | ||||||||||||||||||||||||||||
| 179 | # the Changes file is updated before committing. | ||||||||||||||||||||||||||||
| 180 | 6 | for ($args{vcs}) { | |||||||||||||||||||||||||||
| 181 | 6 | ▶ | if (lc eq 'none') { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 182 | # No-op | ||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||
| 184 | elsif (lc eq 'git') { | ||||||||||||||||||||||||||||
| 185 | $self->add_plugins( | ||||||||||||||||||||||||||||
| 186 | ['Git::Check' => { | ||||||||||||||||||||||||||||
| 187 | allow_dirty => $args{allow_dirty}, | ||||||||||||||||||||||||||||
| 188 | } ], | ||||||||||||||||||||||||||||
| 189 | [ 'Git::Commit' => { | ||||||||||||||||||||||||||||
| 190 | allow_dirty => $args{allow_dirty}, | ||||||||||||||||||||||||||||
| 191 | 6 | } ], | |||||||||||||||||||||||||||
| 192 | 'Git::Tag', | ||||||||||||||||||||||||||||
| 193 | # This can't hurt. It's a no-op if github is not involved. | ||||||||||||||||||||||||||||
| 194 | 'GithubMeta', | ||||||||||||||||||||||||||||
| 195 | ); | ||||||||||||||||||||||||||||
| 196 | 6 | ▶ | if ($args{git_remote}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 197 | 6 | ▶ | if (! $args{no_check_remote} && $args{git_branch}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not $args{"no_check_remote"} and $args{"git_branch"}
MC/DC50%1/2
not $args{"no_check_remote"} and $args{"git_branch"}
not $args{"no_check_remote"}
$args{"git_branch"}
Truth table66%2/3
not(A) and B
A= not $args{"no_check_remote"}B= $args{"git_branch"}
| |||||||||||||||||||||||||||||
| 198 | $self->add_plugins( | ||||||||||||||||||||||||||||
| 199 | ['Git::Remote::Check' => { | ||||||||||||||||||||||||||||
| 200 | remote_name => $args{git_remote}, | ||||||||||||||||||||||||||||
| 201 | branch => $args{git_branch}, | ||||||||||||||||||||||||||||
| 202 | remote_branch => $args{git_remote_branch} || $args{git_branch}, | ||||||||||||||||||||||||||||
| 203 | 5 | ▶ | } ], | ||||||||||||||||||||||||||
|
Condition33%1/3
$args{'git_remote_branch'} || $args{'git_branch'}
MC/DC0%0/2
$args{'git_remote_branch'} || $args{'git_branch'}
$args{'git_remote_branch'}
$args{'git_branch'}
Truth table33%1/3
A || B
A= $args{'git_remote_branch'}B= $args{'git_branch'}
| |||||||||||||||||||||||||||||
| 204 | ); | ||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||
| 206 | 6 | ▶ | if (! $args{no_push}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 207 | $self->add_plugins( | ||||||||||||||||||||||||||||
| 208 | ['Git::Push' => { | ||||||||||||||||||||||||||||
| 209 | push_to => $args{git_remote}, | ||||||||||||||||||||||||||||
| 210 | 5 | } ], | |||||||||||||||||||||||||||
| 211 | ); | ||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||
| 213 | } | ||||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||
| 215 | else { | ||||||||||||||||||||||||||||
| 216 | 0 | croak "Unknown vcs: $_\nTry setting vcs = 'none' and setting it up yourself."; | |||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||
| 220 | # This is added last so that the user is only asked for | ||||||||||||||||||||||||||||
| 221 | # confimation if *all* other pre-release checkpoints have been | ||||||||||||||||||||||||||||
| 222 | # passed. | ||||||||||||||||||||||||||||
| 223 | $self->add_plugins( | ||||||||||||||||||||||||||||
| 224 | 6 | 'ConfirmRelease', | |||||||||||||||||||||||||||
| 225 | ); | ||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||
| 228 | 3 | 1; # Magic true value required at end of module | |||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||
| 230 | __END__ | ||||||||||||||||||||||||||||