| 1 | 8 | ▶ | use 5.006; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 2 | 8 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 8 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | package Dist::Zilla::Plugin::MetaData::BuiltWith; | ||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 8 | our $VERSION = '1.004005'; | |||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | # ABSTRACT: Report what versions of things your distribution was built against | ||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 8 | our $AUTHORITY = 'cpan:KENTNL'; # AUTHORITY | |||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 8 | ▶ | use Carp qw( carp croak ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | 8 | ▶ | use Config qw(); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | 8 | ▶ | use Moose 2.0; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | 8 | ▶ | use Moose qw( with has around ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 17 | 8 | ▶ | use MooseX::Types::Moose qw( ArrayRef Bool Str ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 18 | 8 | ▶ | use Module::Runtime qw( is_module_name ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 19 | 8 | ▶ | use Devel::CheckBin qw( can_run ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 20 | 8 | ▶ | use Path::Tiny qw( path ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 21 | 8 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 22 | 8 | with 'Dist::Zilla::Role::FileGatherer'; | |||||||||||||||||||||||||||
| 23 | 8 | with 'Dist::Zilla::Role::FileMunger'; | |||||||||||||||||||||||||||
| 24 | 8 | with 'Dist::Zilla::Role::MetaProvider'; | |||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 6 | ▶ | sub mvp_multivalue_args { return qw( exclude include ) } | ||||||||||||||||||||||||||
|
Subroutine
mvp_multivalue_args: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | has _exclude => ( | ||||||||||||||||||||||||||||
| 44 | init_arg => 'exclude', | ||||||||||||||||||||||||||||
| 45 | is => 'ro', | ||||||||||||||||||||||||||||
| 46 | isa => ArrayRef, | ||||||||||||||||||||||||||||
| 47 | 5 | ▶ | default => sub { [] }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 48 | 8 | traits => [qw( Array )], | |||||||||||||||||||||||||||
| 49 | handles => { exclude => 'elements', }, | ||||||||||||||||||||||||||||
| 50 | ); | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | has _include => ( | ||||||||||||||||||||||||||||
| 62 | init_arg => 'include', | ||||||||||||||||||||||||||||
| 63 | is => 'ro', | ||||||||||||||||||||||||||||
| 64 | isa => ArrayRef, | ||||||||||||||||||||||||||||
| 65 | 4 | ▶ | default => sub { [] }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 66 | 8 | traits => [qw( Array )], | |||||||||||||||||||||||||||
| 67 | handles => { include => 'elements', }, | ||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | ); | ||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | 8 | has show_config => ( is => 'ro', isa => 'Bool', default => 0 ); | |||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | 8 | has show_uname => ( is => 'ro', isa => Bool, default => 0 ); | |||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | 8 | has uname_call => ( is => 'ro', isa => Str, default => 'uname' ); | |||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||
| 109 | 8 | has uname_args => ( is => 'ro', isa => Str, default => '-a' ); | |||||||||||||||||||||||||||
| 110 | 8 | has _uname_args => ( | |||||||||||||||||||||||||||
| 111 | init_arg => undef, | ||||||||||||||||||||||||||||
| 112 | is => 'ro', | ||||||||||||||||||||||||||||
| 113 | isa => ArrayRef, | ||||||||||||||||||||||||||||
| 114 | lazy_build => 1, | ||||||||||||||||||||||||||||
| 115 | traits => [qw( Array )], | ||||||||||||||||||||||||||||
| 116 | handles => { _all_uname_args => 'elements', }, | ||||||||||||||||||||||||||||
| 117 | ); | ||||||||||||||||||||||||||||
| 118 | 8 | has _stash_key => ( is => 'ro', isa => Str, default => 'x_BuiltWith' ); | |||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||
| 146 | 8 | has 'use_external_file' => ( | |||||||||||||||||||||||||||
| 147 | is => 'ro', | ||||||||||||||||||||||||||||
| 148 | lazy_build => 1, | ||||||||||||||||||||||||||||
| 149 | ); | ||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||
| 167 | 8 | has 'external_file_name' => ( | |||||||||||||||||||||||||||
| 168 | is => 'ro', | ||||||||||||||||||||||||||||
| 169 | isa => Str, | ||||||||||||||||||||||||||||
| 170 | lazy_build => 1, | ||||||||||||||||||||||||||||
| 171 | ); | ||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||
| 173 | 0 | ▶ | around dump_config => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||
| 174 | 0 | my ( $orig, $self, @args ) = @_; | |||||||||||||||||||||||||||
| 175 | 0 | my $config = $self->$orig(@args); | |||||||||||||||||||||||||||
| 176 | 0 | my $payload = $config->{ +__PACKAGE__ } = {}; | |||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||
| 178 | 0 | $payload->{show_uname} = $self->show_uname; | |||||||||||||||||||||||||||
| 179 | 0 | $payload->{_stash_key} = $self->_stash_key; | |||||||||||||||||||||||||||
| 180 | 0 | $payload->{show_config} = $self->show_config; | |||||||||||||||||||||||||||
| 181 | 0 | $payload->{use_external_file} = $self->use_external_file; | |||||||||||||||||||||||||||
| 182 | 0 | $payload->{external_file_name} = $self->external_file_name; | |||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||
| 184 | 0 | ▶ | if ( $self->show_uname ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 185 | 0 | $payload->{'uname'} = { | |||||||||||||||||||||||||||
| 186 | uname_call => $self->uname_call, | ||||||||||||||||||||||||||||
| 187 | uname_args => $self->_uname_args, | ||||||||||||||||||||||||||||
| 188 | }; | ||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||
| 191 | 0 | ▶ | if ( $self->exclude ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 192 | 0 | $payload->{exclude} = [ $self->exclude ]; | |||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||
| 194 | 0 | ▶ | if ( $self->include ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 195 | 0 | $payload->{include} = [ $self->include ]; | |||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||
| 198 | ## no critic (RequireInterpolationOfMetachars) | ||||||||||||||||||||||||||||
| 199 | # Self report when inherited. | ||||||||||||||||||||||||||||
| 200 | 0 | ▶ | $payload->{ q[$] . __PACKAGE__ . '::VERSION' } = $VERSION unless __PACKAGE__ eq ref $self; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 201 | 0 | ▶ | $payload->{q[$Module::Metadata::VERSION]} = $Module::Metadata::VERSION if $INC{'Module/Metadata.pm'}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 202 | 0 | return $config; | |||||||||||||||||||||||||||
| 203 | 8 | }; | |||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||
| 205 | 8 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||
| 206 | 8 | ▶ | no Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||
| 208 | 6 | ▶ | sub _config { | ||||||||||||||||||||||||||
|
Subroutine
_config: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||
| 209 | 6 | my $self = shift; | |||||||||||||||||||||||||||
| 210 | 6 | ▶ | return () unless $self->show_config; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 211 | 1 | my @interesting = qw( git_describe git_commit_id git_commit_date myarchname gccversion osname osver ); | |||||||||||||||||||||||||||
| 212 | 1 | my $interested = {}; | |||||||||||||||||||||||||||
| 213 | 1 | for my $key (@interesting) { | |||||||||||||||||||||||||||
| 214 | ## no critic (ProhibitPackageVars) | ||||||||||||||||||||||||||||
| 215 | 7 | ▶ | if ( defined $Config::Config{$key} and $Config::Config{$key} ne q{} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $Config::Config{$key} and $Config::Config{$key} ne ""
MC/DC100%2/2
defined $Config::Config{$key} and $Config::Config{$key} ne ""
defined $Config::Config{$key}
$Config::Config{$key} ne ""
Truth table100%3/3
A and B
A= defined $Config::Config{$key}B= $Config::Config{$key} ne ""
| |||||||||||||||||||||||||||||
| 216 | 3 | $interested->{$key} = $Config::Config{$key}; | |||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||
| 219 | 1 | return ( 'perl-config', $interested ); | |||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||
| 222 | 6 | ▶ | sub _uname { | ||||||||||||||||||||||||||
|
Subroutine
_uname: called CC=6 SCAR=19.2
| |||||||||||||||||||||||||||||
| 223 | 6 | my $self = shift; | |||||||||||||||||||||||||||
| 224 | 6 | ▶ | return () unless $self->show_uname; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 225 | { | ||||||||||||||||||||||||||||
| 226 | 1 | my $str; | |||||||||||||||||||||||||||
| 227 | 1 | ▶ | if ( not can_run( $self->uname_call ) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 228 | 0 | $self->log( q[can't invoke ] . $self->uname_call . q[ on this device] ); | |||||||||||||||||||||||||||
| 229 | 0 | return (); | |||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||
| 231 | 1 | ▶ | last unless open my $fh, q{-|}, $self->uname_call, $self->_all_uname_args; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 232 | 1 | ▶ | while ( my $line = <$fh> ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 233 | 1 | chomp $line; | |||||||||||||||||||||||||||
| 234 | 1 | $str .= $line; | |||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||
| 236 | 1 | ▶ | last unless close $fh; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 237 | 1 | return ( 'uname', $str ); | |||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||||||||
| 240 | ## no critic ( ProhibitPunctuationVars ) | ||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||
| 242 | 0 | $self->log(q{WARNING: `uname` invocation failed, omit from metadata}); | |||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||
| 244 | 0 | return (); | |||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||
| 248 | 1 | ▶ | sub _build__uname_args { | ||||||||||||||||||||||||||
|
Subroutine
_build__uname_args: called CC=2 SCAR=7.6
| |||||||||||||||||||||||||||||
| 249 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 250 | ## no critic ( RequireDotMatchAnything RequireExtendedFormatting RequireLineBoundaryMatching ) | ||||||||||||||||||||||||||||
| 251 | 1 | ▶ | return [ grep { defined $_ && $_ ne q{} } split /\s+/, $self->uname_args ]; | ||||||||||||||||||||||||||
|
Condition33%1/3
defined $_ && $_ ne ''
MC/DC0%0/2
defined $_ && $_ ne ''
defined $_
$_ ne ''
Truth table33%1/3
A && B
A= defined $_B= $_ ne ''
| |||||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||
| 254 | 6 | ▶ | sub _build_use_external_file { | ||||||||||||||||||||||||||
|
Subroutine
_build_use_external_file: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 255 | 6 | return; | |||||||||||||||||||||||||||
| 256 | } | ||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||
| 258 | 0 | ▶ | sub _build_external_file_name { | ||||||||||||||||||||||||||
|
Subroutine
_build_external_file_name: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 259 | 0 | return 'misc/built_with.json'; | |||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||
| 266 | 6 | ▶ | sub metadata { | ||||||||||||||||||||||||||
|
Subroutine
metadata: called CC=3 SCAR=13.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 267 | 6 | my ($self) = @_; | |||||||||||||||||||||||||||
| 268 | 6 | ▶ | return {} unless 'only' eq ( $self->use_external_file || q[] ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$self->use_external_file || ''
MC/DC0%0/1
$self->use_external_file || ''
$self->use_external_file
Truth table50%1/2
A
A= $self->use_external_file
| |||||||||||||||||||||||||||||
| 269 | 0 | return { $self->_stash_key, { external_file => $self->external_file_name }, }; | |||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||
| 272 | 6 | ▶ | sub _get_prereq_modnames { | ||||||||||||||||||||||||||
|
Subroutine
_get_prereq_modnames: called CC=7 SCAR=19.7
| |||||||||||||||||||||||||||||
| 273 | 6 | my ($self) = @_; | |||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||
| 275 | 6 | my $modnames = {}; | |||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||
| 277 | 6 | my $prereqs = $self->zilla->prereqs->as_string_hash; | |||||||||||||||||||||||||||
| 278 | ## use critic | ||||||||||||||||||||||||||||
| 279 | 6 | ▶ | if ( not %{$prereqs} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 280 | 0 | $self->log(q{WARNING: No prereqs were found, probably a bug}); | |||||||||||||||||||||||||||
| 281 | 0 | return []; | |||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||
| 283 | 6 | $self->log_debug( [ '%s phases defined: %s ', scalar keys %{$prereqs}, ( join q{,}, keys %{$prereqs} ) ] ); | |||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||
| 285 | 6 | for my $phase_name ( keys %{$prereqs} ) { | |||||||||||||||||||||||||||
| 286 | 6 | my $phase_data = $prereqs->{$phase_name}; | |||||||||||||||||||||||||||
| 287 | 6 | ▶ | next unless defined $phase_data; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 288 | 6 | my $phase_deps = {}; | |||||||||||||||||||||||||||
| 289 | 6 | for my $type ( keys %{$phase_data} ) { | |||||||||||||||||||||||||||
| 290 | 6 | my $type_data = $phase_data->{$type}; | |||||||||||||||||||||||||||
| 291 | 6 | ▶ | next unless defined $type_data; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 292 | 6 | for my $module ( keys %{$type_data} ) { | |||||||||||||||||||||||||||
| 293 | 12 | $phase_deps->{$module} = 1; | |||||||||||||||||||||||||||
| 294 | } | ||||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||
| 296 | 6 | $self->log_debug( [ 'Prereqs for %s: %s', $phase_name, join q{,}, keys %{$phase_deps} ] ); | |||||||||||||||||||||||||||
| 297 | 6 | $modnames = { %{$modnames}, %{$phase_deps} }; | |||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||
| 299 | } | ||||||||||||||||||||||||||||
| 300 | 6 | return [ sort keys %{$modnames} ]; | |||||||||||||||||||||||||||
| 301 | } | ||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||
| 303 | 1426 | ▶ | sub _detect_installed { | ||||||||||||||||||||||||||
|
Subroutine
_detect_installed: called CC=11 SCAR=24.2
| |||||||||||||||||||||||||||||
| 304 | 1426 | my ( undef, $module ) = @_; | |||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||
| 306 | 1426 | ▶ | croak('Cannot determine a version if module=undef') if not defined $module; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||
| 308 | 1426 | ▶ | return [ undef, undef ] if 'perl' eq $module; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||
| 310 | 1425 | ▶ | return [ undef, 'not a valid module name' ] if not is_module_name($module); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||
| 312 | 1425 | my @pmname = split qr/::|'/, $module; ## no critic (RegularExpressions) | |||||||||||||||||||||||||||
| 313 | 1425 | $pmname[-1] .= '.pm'; | |||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||
| 315 | 1425 | my $path; | |||||||||||||||||||||||||||
| 316 | 1425 | for my $incdir (@INC) { | |||||||||||||||||||||||||||
| 317 | 9866 | ▶ | next if ref $incdir; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 318 | 9866 | my $fullpath = path( $incdir, @pmname ); | |||||||||||||||||||||||||||
| 319 | 9866 | ▶ | next unless -e $fullpath; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 320 | 572 | ▶ | next if -d $fullpath; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 321 | 572 | $path = $fullpath; | |||||||||||||||||||||||||||
| 322 | 572 | last; | |||||||||||||||||||||||||||
| 323 | } | ||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||
| 325 | 1425 | ▶ | return [ undef, 'module was not found in INC' ] if not defined $path; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||
| 327 | 572 | require Module::Metadata; | |||||||||||||||||||||||||||
| 328 | 572 | my $mm = Module::Metadata->new_from_file( $path, collect_pod => 0 ); | |||||||||||||||||||||||||||
| 329 | 572 | ▶ | return [ undef, 'Module::MetaData could not parse ' . $path ] if not defined $mm; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||
| 331 | 572 | my $v = $mm->version($module); | |||||||||||||||||||||||||||
| 332 | 572 | ▶ | return [ undef, 'Module::MetaData could not parse a version from ' . $path ] if not $v; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||
| 334 | 531 | return [ $v, undef ]; | |||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||
| 336 | } | ||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||
| 347 | 6 | ▶ | sub _metadata { | ||||||||||||||||||||||||||
|
Subroutine
_metadata: called CC=9 SCAR=22.1
| |||||||||||||||||||||||||||||
| 348 | 6 | my ($self) = @_; | |||||||||||||||||||||||||||
| 349 | 6 | $self->log_debug(q{Metadata called}); | |||||||||||||||||||||||||||
| 350 | 6 | my $report = $self->_get_prereq_modnames(); | |||||||||||||||||||||||||||
| 351 | 6 | $self->log_debug( 'Found mods: ' . scalar @{$report} ); | |||||||||||||||||||||||||||
| 352 | 6 | my %modtable; | |||||||||||||||||||||||||||
| 353 | my %failures; | ||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||
| 355 | 6 | for my $module ( @{$report}, $self->include ) { | |||||||||||||||||||||||||||
| 356 | 14 | my $result = $self->_detect_installed($module); | |||||||||||||||||||||||||||
| 357 | 14 | ▶ | $modtable{$module} = $result->[0] if defined $result->[0]; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 358 | 14 | ▶ | $failures{$module} = $result->[1] if defined $result->[1]; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 359 | } | ||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||
| 361 | 6 | for my $badmodule ( $self->exclude ) { | |||||||||||||||||||||||||||
| 362 | 2 | ▶ | delete $modtable{$badmodule} if exists $modtable{$badmodule}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 363 | 2 | ▶ | delete $failures{$badmodule} if exists $failures{$badmodule}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 364 | } | ||||||||||||||||||||||||||||
| 365 | ## no critic ( Variables::ProhibitPunctuationVars ) | ||||||||||||||||||||||||||||
| 366 | 6 | my $perlver; | |||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||
| 368 | 6 | ▶ | if ( $] < 5.010000 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 369 | 0 | $perlver = { %{ version->parse( version->parse($])->normal ) } }; | |||||||||||||||||||||||||||
| 370 | } | ||||||||||||||||||||||||||||
| 371 | else { | ||||||||||||||||||||||||||||
| 372 | 6 | $perlver = { %{$^V} }; | |||||||||||||||||||||||||||
| 373 | } | ||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||
| 375 | 6 | my $result = { | |||||||||||||||||||||||||||
| 376 | modules => \%modtable, | ||||||||||||||||||||||||||||
| 377 | perl => $perlver, | ||||||||||||||||||||||||||||
| 378 | platform => $^O, | ||||||||||||||||||||||||||||
| 379 | $self->_uname(), | ||||||||||||||||||||||||||||
| 380 | $self->_config(), | ||||||||||||||||||||||||||||
| 381 | }; | ||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||
| 383 | 6 | ▶ | $result->{failures} = \%failures if keys %failures; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||
| 385 | 6 | return $result; | |||||||||||||||||||||||||||
| 386 | } | ||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||
| 392 | 6 | ▶ | sub gather_files { | ||||||||||||||||||||||||||
|
Subroutine
gather_files: called CC=6 SCAR=34.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 393 | 6 | my ($self) = @_; | |||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||
| 395 | 6 | ▶ | return unless $self->use_external_file; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||
| 397 | 0 | ▶ | my $type = | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 398 | $self->external_file_name =~ /[.]json\z/msix ? 'JSON' | ||||||||||||||||||||||||||||
| 399 | : $self->external_file_name =~ /[.]ya?ml\z/msix ? 'YAML' | ||||||||||||||||||||||||||||
| 400 | : croak 'Cant guess file type for ' . $self->external_file_name; | ||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||
| 402 | 0 | my $code; | |||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||
| 404 | 0 | ▶ | if ( 'JSON' eq $type ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 405 | 0 | require JSON::MaybeXS; | |||||||||||||||||||||||||||
| 406 | 0 | require Dist::Zilla::File::FromCode; | |||||||||||||||||||||||||||
| 407 | 0 | my $json = JSON::MaybeXS->new; | |||||||||||||||||||||||||||
| 408 | 0 | $json->pretty(1); | |||||||||||||||||||||||||||
| 409 | 0 | $json->canonical(1); | |||||||||||||||||||||||||||
| 410 | 0 | $json->convert_blessed(1); | |||||||||||||||||||||||||||
| 411 | 0 | $json->allow_blessed(1); | |||||||||||||||||||||||||||
| 412 | 0 | ▶ | $code = sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 413 | 0 | ▶ | local *UNIVERSAL::TO_JSON = sub { "$_[0]" }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 414 | 0 | return $json->encode( $self->_metadata ); | |||||||||||||||||||||||||||
| 415 | 0 | }; | |||||||||||||||||||||||||||
| 416 | } | ||||||||||||||||||||||||||||
| 417 | 0 | ▶ | if ( 'YAML' eq $type ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 418 | 0 | require YAML::Tiny; | |||||||||||||||||||||||||||
| 419 | 0 | ▶ | $code = sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 420 | 0 | return YAML::Tiny::Dump( $self->_metadata ); | |||||||||||||||||||||||||||
| 421 | 0 | }; | |||||||||||||||||||||||||||
| 422 | } | ||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||
| 424 | $self->add_file( | ||||||||||||||||||||||||||||
| 425 | 0 | Dist::Zilla::File::FromCode->new( | |||||||||||||||||||||||||||
| 426 | name => $self->external_file_name, | ||||||||||||||||||||||||||||
| 427 | code => $code, | ||||||||||||||||||||||||||||
| 428 | code_return_type => 'text', | ||||||||||||||||||||||||||||
| 429 | ), | ||||||||||||||||||||||||||||
| 430 | ); | ||||||||||||||||||||||||||||
| 431 | 0 | return; | |||||||||||||||||||||||||||
| 432 | } | ||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||
| 434 | 6 | ▶ | sub munge_files { | ||||||||||||||||||||||||||
|
Subroutine
munge_files: called CC=7 SCAR=19.6
Pod
documented
| |||||||||||||||||||||||||||||
| 435 | 6 | my ($self) = @_; | |||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||
| 437 | 6 | my $munged = {}; | |||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||
| 439 | 6 | ▶ | return if 'only' eq ( $self->use_external_file || q[] ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$self->use_external_file || ''
MC/DC0%0/1
$self->use_external_file || ''
$self->use_external_file
Truth table50%1/2
A
A= $self->use_external_file
| |||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||
| 441 | 6 | for my $file ( @{ $self->zilla->files } ) { | |||||||||||||||||||||||||||
| 442 | 7 | ▶ | if ( 'META.json' eq $file->name ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 443 | 5 | require JSON::MaybeXS; | |||||||||||||||||||||||||||
| 444 | 5 | require CPAN::Meta::Converter; | |||||||||||||||||||||||||||
| 445 | 5 | my $json = JSON::MaybeXS->new->pretty->canonical(1); | |||||||||||||||||||||||||||
| 446 | 5 | my $old = $file->code; | |||||||||||||||||||||||||||
| 447 | $file->code( | ||||||||||||||||||||||||||||
| 448 | 5 | ▶ | sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 449 | 5 | my $content = $json->decode( $old->() ); | |||||||||||||||||||||||||||
| 450 | 5 | $content->{ $self->_stash_key } = $self->_metadata; | |||||||||||||||||||||||||||
| 451 | 5 | my $normal = CPAN::Meta::Converter->new($content)->convert( version => $content->{'meta-spec'}->{version} ); | |||||||||||||||||||||||||||
| 452 | 5 | return $json->encode($normal); | |||||||||||||||||||||||||||
| 453 | }, | ||||||||||||||||||||||||||||
| 454 | 5 | ); | |||||||||||||||||||||||||||
| 455 | 5 | $munged->{'META.json'} = 1; | |||||||||||||||||||||||||||
| 456 | 5 | next; | |||||||||||||||||||||||||||
| 457 | } | ||||||||||||||||||||||||||||
| 458 | 2 | ▶ | if ( 'META.yml' eq $file->name ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 459 | 1 | require YAML::Tiny; | |||||||||||||||||||||||||||
| 460 | 1 | require CPAN::Meta::Converter; | |||||||||||||||||||||||||||
| 461 | 1 | my $old = $file->code; | |||||||||||||||||||||||||||
| 462 | $file->code( | ||||||||||||||||||||||||||||
| 463 | 1 | ▶ | sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 464 | 1 | my $content = YAML::Tiny::Load( $old->() ); | |||||||||||||||||||||||||||
| 465 | 1 | $content->{ $self->_stash_key } = $self->_metadata; | |||||||||||||||||||||||||||
| 466 | 1 | my $normal = CPAN::Meta::Converter->new($content)->convert( version => $content->{'meta-spec'}->{version} ); | |||||||||||||||||||||||||||
| 467 | 1 | return YAML::Tiny::Dump($normal); | |||||||||||||||||||||||||||
| 468 | }, | ||||||||||||||||||||||||||||
| 469 | 1 | ); | |||||||||||||||||||||||||||
| 470 | 1 | $munged->{'META.yml'} = 1; | |||||||||||||||||||||||||||
| 471 | 1 | next; | |||||||||||||||||||||||||||
| 472 | } | ||||||||||||||||||||||||||||
| 473 | } | ||||||||||||||||||||||||||||
| 474 | 6 | ▶ | if ( not keys %{$munged} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 475 | 0 | my $message = <<'EOF'; | |||||||||||||||||||||||||||
| 476 | No META.* files to munge. | ||||||||||||||||||||||||||||
| 477 | BuiltWith cannot operate without one in tree prior to it | ||||||||||||||||||||||||||||
| 478 | EOF | ||||||||||||||||||||||||||||
| 479 | 0 | $self->log_fatal($message); | |||||||||||||||||||||||||||
| 480 | } | ||||||||||||||||||||||||||||
| 481 | 6 | return; | |||||||||||||||||||||||||||
| 482 | } | ||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||
| 484 | 8 | 1; | |||||||||||||||||||||||||||
| 485 | |||||||||||||||||||||||||||||
| 486 | __END__ | ||||||||||||||||||||||||||||