| 1 | package Dist::Zilla::PluginBundle::SHLOMIF; | ||||||||||||||||||
| 2 | 1 | $Dist::Zilla::PluginBundle::SHLOMIF::VERSION = '0.000011'; | |||||||||||||||||
| 3 | 1 | ▶ | use 5.014; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 4 | |||||||||||||||||||
| 5 | 1 | ▶ | use Moose; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 6 | # ABSTRACT: Dist::Zilla plugins for me | ||||||||||||||||||
| 7 | |||||||||||||||||||
| 8 | 1 | ▶ | use List::MoreUtils qw(any); | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 9 | |||||||||||||||||||
| 10 | 1 | ▶ | use Dist::Zilla; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 11 | 1 | with 'Dist::Zilla::Role::PluginBundle::Easy'; | |||||||||||||||||
| 12 | |||||||||||||||||||
| 13 | |||||||||||||||||||
| 14 | 1 | has dist => ( | |||||||||||||||||
| 15 | is => 'ro', | ||||||||||||||||||
| 16 | isa => 'Str', | ||||||||||||||||||
| 17 | required => 1, | ||||||||||||||||||
| 18 | ); | ||||||||||||||||||
| 19 | |||||||||||||||||||
| 20 | 1 | has authority => ( | |||||||||||||||||
| 21 | is => 'ro', | ||||||||||||||||||
| 22 | isa => 'Str', | ||||||||||||||||||
| 23 | default => 'cpan:SHLOMIF', | ||||||||||||||||||
| 24 | ); | ||||||||||||||||||
| 25 | |||||||||||||||||||
| 26 | 1 | has github_user => ( | |||||||||||||||||
| 27 | is => 'ro', | ||||||||||||||||||
| 28 | isa => 'Str', | ||||||||||||||||||
| 29 | default => 'shlomif', | ||||||||||||||||||
| 30 | ); | ||||||||||||||||||
| 31 | |||||||||||||||||||
| 32 | has github_name => ( | ||||||||||||||||||
| 33 | is => 'ro', | ||||||||||||||||||
| 34 | isa => 'Str', | ||||||||||||||||||
| 35 | lazy => 1, | ||||||||||||||||||
| 36 | 0 | ▶ | default => sub { lc shift->dist }, | ||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||
| 37 | 1 | ); | |||||||||||||||||
| 38 | |||||||||||||||||||
| 39 | 1 | has repository => ( | |||||||||||||||||
| 40 | is => 'ro', | ||||||||||||||||||
| 41 | isa => 'Str', | ||||||||||||||||||
| 42 | default => 'github', | ||||||||||||||||||
| 43 | ); | ||||||||||||||||||
| 44 | |||||||||||||||||||
| 45 | 1 | for my $attr (qw(repository_type repository_url repository_web)) { | |||||||||||||||||
| 46 | has $attr => ( | ||||||||||||||||||
| 47 | is => 'ro', | ||||||||||||||||||
| 48 | isa => 'Maybe[Str]', | ||||||||||||||||||
| 49 | lazy => 1, | ||||||||||||||||||
| 50 | 0 | ▶ | default => sub { | ||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||
| 51 | 0 | my $self = shift; | |||||||||||||||||
| 52 | 0 | my $data = $self->_repository_data; | |||||||||||||||||
| 53 | 0 | ▶ | return unless $data; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 54 | 0 | return $data->{$attr}; | |||||||||||||||||
| 55 | }, | ||||||||||||||||||
| 56 | 3 | ); | |||||||||||||||||
| 57 | } | ||||||||||||||||||
| 58 | |||||||||||||||||||
| 59 | 0 | ▶ | sub _repository_data { | ||||||||||||||||
|
Subroutine
_repository_data: not called CC=3 SCAR=24.8
| |||||||||||||||||||
| 60 | 0 | my $self = shift; | |||||||||||||||||
| 61 | |||||||||||||||||||
| 62 | 0 | my $host = $self->repository; | |||||||||||||||||
| 63 | 0 | ▶ | return unless defined $host; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 64 | |||||||||||||||||||
| 65 | die "Unknown repository host $host" | ||||||||||||||||||
| 66 | 0 | ▶ | unless exists $self->_repository_host_map->{$host}; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 67 | |||||||||||||||||||
| 68 | 0 | return $self->_repository_host_map->{$host}; | |||||||||||||||||
| 69 | } | ||||||||||||||||||
| 70 | |||||||||||||||||||
| 71 | has _repository_host_map => ( | ||||||||||||||||||
| 72 | is => 'ro', | ||||||||||||||||||
| 73 | isa => 'HashRef[HashRef[Str]]', | ||||||||||||||||||
| 74 | lazy => 1, | ||||||||||||||||||
| 75 | 0 | ▶ | default => sub { | ||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||
| 76 | 0 | my $self = shift; | |||||||||||||||||
| 77 | return { | ||||||||||||||||||
| 78 | 0 | 'github' => { | |||||||||||||||||
| 79 | repository_type => 'git', | ||||||||||||||||||
| 80 | repository_url => sprintf('git://github.com/%s/%s.git', $self->github_user, $self->github_name), | ||||||||||||||||||
| 81 | repository_web => sprintf('https://github.com/%s/%s', $self->github_user, $self->github_name), | ||||||||||||||||||
| 82 | }, | ||||||||||||||||||
| 83 | } | ||||||||||||||||||
| 84 | }, | ||||||||||||||||||
| 85 | 1 | ); | |||||||||||||||||
| 86 | |||||||||||||||||||
| 87 | has bugtracker => ( | ||||||||||||||||||
| 88 | is => 'ro', | ||||||||||||||||||
| 89 | isa => 'Str', | ||||||||||||||||||
| 90 | lazy => 1, | ||||||||||||||||||
| 91 | 0 | ▶ | default => sub { shift->repository eq 'github' ? 'github' : 'rt' }, | ||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||
| 92 | 1 | ); | |||||||||||||||||
| 93 | |||||||||||||||||||
| 94 | 1 | for my $attr (qw(bugtracker_web bugtracker_mailto)) { | |||||||||||||||||
| 95 | has $attr => ( | ||||||||||||||||||
| 96 | is => 'ro', | ||||||||||||||||||
| 97 | isa => 'Maybe[Str]', | ||||||||||||||||||
| 98 | lazy => 1, | ||||||||||||||||||
| 99 | 0 | ▶ | default => sub { | ||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||
| 100 | 0 | my $self = shift; | |||||||||||||||||
| 101 | 0 | my $data = $self->_bugtracker_data; | |||||||||||||||||
| 102 | 0 | ▶ | return unless $data; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 103 | 0 | return $data->{$attr}; | |||||||||||||||||
| 104 | }, | ||||||||||||||||||
| 105 | 2 | ); | |||||||||||||||||
| 106 | } | ||||||||||||||||||
| 107 | |||||||||||||||||||
| 108 | 0 | ▶ | sub _bugtracker_data { | ||||||||||||||||
|
Subroutine
_bugtracker_data: not called CC=3 SCAR=24.8
| |||||||||||||||||||
| 109 | 0 | my $self = shift; | |||||||||||||||||
| 110 | |||||||||||||||||||
| 111 | 0 | my $host = $self->bugtracker; | |||||||||||||||||
| 112 | 0 | ▶ | return unless defined $host; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 113 | |||||||||||||||||||
| 114 | die "Unknown bugtracker host $host" | ||||||||||||||||||
| 115 | 0 | ▶ | unless exists $self->_bugtracker_host_map->{$host}; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 116 | |||||||||||||||||||
| 117 | 0 | return $self->_bugtracker_host_map->{$host}; | |||||||||||||||||
| 118 | } | ||||||||||||||||||
| 119 | |||||||||||||||||||
| 120 | has _bugtracker_host_map => ( | ||||||||||||||||||
| 121 | is => 'ro', | ||||||||||||||||||
| 122 | isa => 'HashRef[HashRef[Str]]', | ||||||||||||||||||
| 123 | lazy => 1, | ||||||||||||||||||
| 124 | 0 | ▶ | default => sub { | ||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||
| 125 | 0 | my $self = shift; | |||||||||||||||||
| 126 | return { | ||||||||||||||||||
| 127 | 0 | 'github' => { | |||||||||||||||||
| 128 | bugtracker_web => sprintf('https://github.com/%s/%s/issues', $self->github_user, $self->github_name), | ||||||||||||||||||
| 129 | }, | ||||||||||||||||||
| 130 | 'rt' => { | ||||||||||||||||||
| 131 | bugtracker_web => sprintf('http://rt.cpan.org/Public/Dist/Display.html?Name=%s', $self->dist), | ||||||||||||||||||
| 132 | bugtracker_mailto => sprintf('bug-%s@rt.cpan.org', lc $self->dist), | ||||||||||||||||||
| 133 | }, | ||||||||||||||||||
| 134 | } | ||||||||||||||||||
| 135 | }, | ||||||||||||||||||
| 136 | 1 | ); | |||||||||||||||||
| 137 | |||||||||||||||||||
| 138 | has homepage => ( | ||||||||||||||||||
| 139 | is => 'ro', | ||||||||||||||||||
| 140 | isa => 'Str', | ||||||||||||||||||
| 141 | lazy => 1, | ||||||||||||||||||
| 142 | 0 | ▶ | default => sub { sprintf('http://metacpan.org/release/%s', shift->dist) }, | ||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||
| 143 | 1 | ); | |||||||||||||||||
| 144 | |||||||||||||||||||
| 145 | 1 | has awesome => ( | |||||||||||||||||
| 146 | is => 'ro', | ||||||||||||||||||
| 147 | isa => 'Str', | ||||||||||||||||||
| 148 | ); | ||||||||||||||||||
| 149 | |||||||||||||||||||
| 150 | 1 | has dynamic_config => ( | |||||||||||||||||
| 151 | is => 'ro', | ||||||||||||||||||
| 152 | isa => 'Str', | ||||||||||||||||||
| 153 | ); | ||||||||||||||||||
| 154 | |||||||||||||||||||
| 155 | has is_task => ( | ||||||||||||||||||
| 156 | is => 'ro', | ||||||||||||||||||
| 157 | isa => 'Bool', | ||||||||||||||||||
| 158 | lazy => 1, | ||||||||||||||||||
| 159 | 0 | ▶ | default => sub { shift->dist =~ /^Task-/ ? 1 : 0 }, | ||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||
| 160 | 1 | ); | |||||||||||||||||
| 161 | |||||||||||||||||||
| 162 | has is_test_dist => ( | ||||||||||||||||||
| 163 | is => 'ro', | ||||||||||||||||||
| 164 | isa => 'Bool', | ||||||||||||||||||
| 165 | lazy => 1, | ||||||||||||||||||
| 166 | 0 | ▶ | default => sub { | ||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||
| 167 | 0 | my $self = shift; | |||||||||||||||||
| 168 | 0 | ▶ | return 1 if $ENV{DZIL_FAKE_RELEASE}; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 169 | 0 | ▶ | return $self->dist =~ /^Foo-/ ? 1 : 0 | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 170 | }, | ||||||||||||||||||
| 171 | 1 | ); | |||||||||||||||||
| 172 | |||||||||||||||||||
| 173 | 1 | has done_testing => ( | |||||||||||||||||
| 174 | is => 'ro', | ||||||||||||||||||
| 175 | isa => 'Bool', | ||||||||||||||||||
| 176 | default => 1, | ||||||||||||||||||
| 177 | ); | ||||||||||||||||||
| 178 | |||||||||||||||||||
| 179 | has _plugins => ( | ||||||||||||||||||
| 180 | is => 'ro', | ||||||||||||||||||
| 181 | isa => 'ArrayRef[Str]', | ||||||||||||||||||
| 182 | lazy => 1, | ||||||||||||||||||
| 183 | 0 | ▶ | default => sub { | ||||||||||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
| |||||||||||||||||||
| 184 | 0 | my $self = shift; | |||||||||||||||||
| 185 | [ | ||||||||||||||||||
| 186 | 0 | ▶ | qw( | ||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||
| 187 | AutoPrereqs | ||||||||||||||||||
| 188 | ExecDir | ||||||||||||||||||
| 189 | GatherDir | ||||||||||||||||||
| 190 | License | ||||||||||||||||||
| 191 | ManifestSkip | ||||||||||||||||||
| 192 | MetaYAML | ||||||||||||||||||
| 193 | PruneCruft | ||||||||||||||||||
| 194 | Readme | ||||||||||||||||||
| 195 | RunExtraTests | ||||||||||||||||||
| 196 | ShareDir | ||||||||||||||||||
| 197 | ), | ||||||||||||||||||
| 198 | ($self->awesome ? $self->awesome : 'MakeMaker'), | ||||||||||||||||||
| 199 | qw( | ||||||||||||||||||
| 200 | CheckChangesHasContent | ||||||||||||||||||
| 201 | ConfirmRelease | ||||||||||||||||||
| 202 | Manifest | ||||||||||||||||||
| 203 | MetaConfig | ||||||||||||||||||
| 204 | MetaJSON | ||||||||||||||||||
| 205 | MetaProvides::Package | ||||||||||||||||||
| 206 | MetaResources | ||||||||||||||||||
| 207 | ModuleBuild | ||||||||||||||||||
| 208 | PkgVersion | ||||||||||||||||||
| 209 | PodCoverageTests | ||||||||||||||||||
| 210 | PodSyntaxTests | ||||||||||||||||||
| 211 | Test::Compile | ||||||||||||||||||
| 212 | Test::CPAN::Changes | ||||||||||||||||||
| 213 | Test::EOL | ||||||||||||||||||
| 214 | Test::NoTabs | ||||||||||||||||||
| 215 | Test::TrailingSpace | ||||||||||||||||||
| 216 | TestRelease | ||||||||||||||||||
| 217 | ), | ||||||||||||||||||
| 218 | ($self->is_task ? 'TaskWeaver' : 'PodWeaver'), | ||||||||||||||||||
| 219 | ($self->is_test_dist ? 'FakeRelease' : 'UploadToCPAN'), | ||||||||||||||||||
| 220 | ] | ||||||||||||||||||
| 221 | }, | ||||||||||||||||||
| 222 | 1 | ); | |||||||||||||||||
| 223 | |||||||||||||||||||
| 224 | has plugin_options => ( | ||||||||||||||||||
| 225 | is => 'ro', | ||||||||||||||||||
| 226 | isa => 'HashRef[HashRef[Str]]', | ||||||||||||||||||
| 227 | init_arg => undef, | ||||||||||||||||||
| 228 | lazy => 1, | ||||||||||||||||||
| 229 | 0 | ▶ | default => sub { | ||||||||||||||||
|
Subroutine
__ANON__: not called CC=8 SCAR=42.8
| |||||||||||||||||||
| 230 | 0 | my $self = shift; | |||||||||||||||||
| 231 | 0 | my %opts = ( | |||||||||||||||||
| 232 | 'Authority' => { authority => $self->authority }, | ||||||||||||||||||
| 233 | ); | ||||||||||||||||||
| 234 | |||||||||||||||||||
| 235 | 0 | for my $metaresource (qw(repository.type repository.url repository.web bugtracker.web bugtracker.mailto homepage)) { | |||||||||||||||||
| 236 | 0 | (my $method = $metaresource) =~ s/\./_/g; | |||||||||||||||||
| 237 | 0 | my $value = $self->$method; | |||||||||||||||||
| 238 | 0 | ▶ | if (!$value) { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 239 | 0 | ▶ | warn "*** resources.$metaresource is not configured! This needs to be fixed! ***" | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 240 | unless $metaresource eq 'bugtracker.mailto'; | ||||||||||||||||||
| 241 | 0 | next; | |||||||||||||||||
| 242 | } | ||||||||||||||||||
| 243 | 0 | $opts{MetaResources}{$metaresource} = $value; | |||||||||||||||||
| 244 | } | ||||||||||||||||||
| 245 | delete $opts{MetaResources}{'repository.type'} | ||||||||||||||||||
| 246 | 0 | ▶ | unless exists $opts{MetaResources}{'repository.url'}; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 247 | |||||||||||||||||||
| 248 | 0 | for my $option (keys %{ $self->payload }) { | |||||||||||||||||
| 249 | 0 | ▶ | next unless $option =~ /^([A-Z][^_]*)_(.+)$/; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 250 | 0 | my ($plugin, $plugin_option) = ($1, $2); | |||||||||||||||||
| 251 | 0 | ▶ | $opts{$plugin} ||= {}; | ||||||||||||||||
|
Condition0%0/2
$opts{$plugin} ||= {}
MC/DC0%0/1
$opts{$plugin} ||= {}
$opts{$plugin}
Truth table0%0/2
A
A= $opts{$plugin}
| |||||||||||||||||||
| 252 | 0 | $opts{$plugin}->{$plugin_option} = $self->payload->{$option}; | |||||||||||||||||
| 253 | } | ||||||||||||||||||
| 254 | |||||||||||||||||||
| 255 | 0 | return \%opts; | |||||||||||||||||
| 256 | }, | ||||||||||||||||||
| 257 | 1 | ); | |||||||||||||||||
| 258 | |||||||||||||||||||
| 259 | 0 | ▶ | around BUILDARGS => sub { | ||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||
| 260 | 0 | my $orig = shift; | |||||||||||||||||
| 261 | 0 | my $class = shift; | |||||||||||||||||
| 262 | 0 | my $args = $class->$orig(@_); | |||||||||||||||||
| 263 | 0 | return { %{ $args->{payload} }, %{ $args } }; | |||||||||||||||||
| 264 | 1 | }; | |||||||||||||||||
| 265 | |||||||||||||||||||
| 266 | 0 | ▶ | sub configure { | ||||||||||||||||
|
Subroutine
configure: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||
| 267 | 0 | my $self = shift; | |||||||||||||||||
| 268 | |||||||||||||||||||
| 269 | 0 | ▶ | $self->add_plugins( | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 270 | [ 'Prereqs' => 'TestMoreDoneTesting' => { | ||||||||||||||||||
| 271 | -phase => 'test', | ||||||||||||||||||
| 272 | -type => 'requires', | ||||||||||||||||||
| 273 | 'Test::More' => '0.88', | ||||||||||||||||||
| 274 | } ] | ||||||||||||||||||
| 275 | ) if $self->done_testing; | ||||||||||||||||||
| 276 | $self->add_plugins( | ||||||||||||||||||
| 277 | 0 | ▶ | map { [ $_ => ($self->plugin_options->{$_} || {}) ] } | ||||||||||||||||
|
Condition0%0/2
$self->plugin_options->{$_} || {}
MC/DC0%0/1
$self->plugin_options->{$_} || {}
$self->plugin_options->{$_}
Truth table0%0/2
A
A= $self->plugin_options->{$_}
| |||||||||||||||||||
| 278 | 0 | @{ $self->_plugins }, | |||||||||||||||||
| 279 | ); | ||||||||||||||||||
| 280 | } | ||||||||||||||||||
| 281 | |||||||||||||||||||
| 282 | |||||||||||||||||||
| 283 | 1 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||
| 284 | 1 | ▶ | no Moose; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 285 | |||||||||||||||||||
| 286 | 1 | 1; | |||||||||||||||||
| 287 | |||||||||||||||||||
| 288 | __END__ | ||||||||||||||||||